quackseq.functions#
A module that contains functions that can be used in various modules. This used to be part of the nqrduck-spectrometer module.
Classes
A custom function. |
|
|
A function that can be used as a pulse parameter. |
The Gaussian function. |
|
The rectangular function. |
|
The sinc function. |
- class quackseq.functions.CustomFunction#
A custom function.
- class quackseq.functions.Function(expr)#
A function that can be used as a pulse parameter.
This class is the base class for all functions that can be used as pulse parameters. Functions can be used for pulse shapes, for example.
- Parameters:
expr (str | sympy.Expr) – The expression of the function.
- name#
The name of the function.
- Type:
str
- parameters#
The parameters of the function.
- Type:
list
- expr#
The sympy expression of the function.
- Type:
sympy.Expr
- resolution#
The resolution of the function in seconds.
- Type:
float
- start_x#
The x value where the evalution of the function starts.
- Type:
float
- end_x#
The x value where the evalution of the function ends.
- Type:
float
- class Parameter(name: str, symbol: str, value: float)#
A parameter of a function.
This can be for example the standard deviation of a Gaussian function.
- Parameters:
name (str) – The name of the parameter.
symbol (str) – The symbol of the parameter.
value (float) – The value of the parameter.
- name#
The name of the parameter.
- Type:
str
- symbol#
The symbol of the parameter.
- Type:
str
- value#
The value of the parameter.
- Type:
float
- default#
The default value of the parameter.
- Type:
float
- classmethod from_json(data)#
Creates a parameter from a json representation.
- Parameters:
data (dict) – The json representation of the parameter.
- Returns:
The parameter.
- Return type:
- set_value(value: float) None#
Sets the value of the parameter.
- Parameters:
value (float) – The new value of the parameter.
- to_json() dict#
Returns a json representation of the parameter.
- Returns:
The json representation of the parameter.
- Return type:
dict
- add_parameter(parameter: Parameter) None#
Adds a parameter to the function.
Args: parameter (Function.Parameter): The parameter to add.
- property end_x#
The x value where the evalution of the function ends.
- evaluate(pulse_length: float, resolution: float = None) ndarray#
Evaluates the function for the given pulse length.
- Parameters:
pulse_length (float) – The pulse length in seconds.
resolution (float, optional) – The resolution of the function in seconds. Defaults to None.
- Returns:
The evaluated function.
- Return type:
np.ndarray
- property expr#
The sympy expression of the function.
- classmethod from_json(data: dict) Function#
Creates a function from a json representation.
- Parameters:
data (dict) – The json representation of the function.
- Returns:
The function.
- Return type:
- get_pulse_amplitude(pulse_length: float, resolution: float = None) array#
Returns the pulse amplitude in the time domain.
- Parameters:
pulse_length (Float) – The pulse length in seconds.
resolution (float, optional) – The resolution of the function in seconds. Defaults to None.
- Returns:
The pulse amplitude.
- Return type:
np.array
- get_tdx(pulse_length: float) ndarray#
Returns the time domain points and the evaluated function for the given pulse length.
- Parameters:
pulse_length (float) – The pulse length in seconds.
- Returns:
The time domain points.
- Return type:
np.ndarray
- get_time_points(pulse_length: float) ndarray#
Returns the time domain points for the function with the given pulse length.
- Parameters:
pulse_length (float) – The pulse length in seconds.
- Returns:
The time domain points.
- Return type:
np.ndarray
- property resolution#
The resolution of the function in seconds.
- property start_x#
The x value where the evalution of the function starts.
- to_json() dict#
Returns a json representation of the function.
- Returns:
The json representation of the function.
- Return type:
dict
- class quackseq.functions.GaussianFunction#
The Gaussian function.
The Gaussian function is defined as exp(-0.5 * ((x - mu) / sigma)**2). The parameters are the mean and the standard deviation.
- class quackseq.functions.RectFunction#
The rectangular function.
- class quackseq.functions.SincFunction#
The sinc function.
The sinc function is defined as sin(x * l) / (x * l). The parameter is the scale factor l.