FlatTopGaussianFilter#

class FlatTopGaussianFilter(envelopes, t_final)[source]#

Bases: Signal

A shape filter that forces the pulse to smoothly start and end at zero. This filter multiplies the input pulse with a flat-top Gaussian pulse.

Note

Use filters before the generators. Otherwise, automatic differentiation does not work in the current setup.

This is similar to PWCGenerator.multiply_flat_top = True.

__init__(envelopes, t_final)[source]#
Parameters:

Methods

__init__(envelopes, t_final)

get_envelopes()

Return envelopes from the FlatTopGaussianFilter.

get_gradient(times)

Compute the gradient of the _evaluate method.

get_parameters()

Return all parameters of this class that can be optimized.

get_time_and_parameter_gradient(times)

Compute the double derivative with respect to parameter and time.

get_time_gradient(times)

Compute a signal envelope's time derivative.

get_value(times)

Calculate the value of the object.

get_value_and_gradient(times)

Calculate the value and the gradient of the object.

set_all_optimizable_parameters(all_params)

Set all optimizable parameters in the optimization.

set_optimizable_parameters(params)

Set specified parameters to be optimized.

Attributes

all_optimizable_parameters

Get the optimizable parameters.

name

Get the name of the parameter.

optimizable_parameters

Get the optimizable parameters.

property all_optimizable_parameters: list[Quantity]#

Get the optimizable parameters.

Returns:

The list of all the optimizable parameters considered in the optimization.

get_envelopes()[source]#

Return envelopes from the FlatTopGaussianFilter.

get_gradient(times)[source]#

Compute the gradient of the _evaluate method.

Note

This uses Automatic differentiation as a fallback. The _evaluate method should be a pure function (should take the optimizable parameters as function arguments and doesn’t depend on global variables). Refer to https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html for functionally pure functions. To implement analytical gradients / other methods for gradient computation overwrite this method in the inherited class.

Parameters:

times (Array) – Array of times.

Returns:

The gradient array of the _evaluate method.

Return type:

Array

get_parameters()[source]#

Return all parameters of this class that can be optimized.

Raises:

NotImplementedError – Subclasses derived from this class must implement this method.

get_time_and_parameter_gradient(times)[source]#

Compute the double derivative with respect to parameter and time.

This function computes

\[\frac{\partial^2 \Omega}{\partial t \partial \alpha}\]

for a pulse \(\Omega(t)\) and parameter \(\alpha\).

Parameters:

times (Array) – Array of times.

Returns:

An array of the signal’s time derivative.

Return type:

Array

get_time_gradient(times)[source]#

Compute a signal envelope’s time derivative.

Parameters:

times (Array) – Array of times.

Returns:

An array of the signal’s time derivative.

Return type:

Array

get_value(times)[source]#

Calculate the value of the object.

Parameters:

times (Array) – Array of times.

Returns:

The value of the object. If it returns an Array then the value is calculated at the n_times and the dimension should be (n_times, (dimensions_of_object)). If the object is a scalar (1x1 Array) the dimension is just n_times. If it returns a Float for instance it means that the object depends on the whole array of times. This is for instance the case of fidelities that are a function of an array of times.

Return type:

Array

get_value_and_gradient(times)[source]#

Calculate the value and the gradient of the object.

Note

The default implementation here gathers the value and the gradient separately. For cases where the value can be obtained during the gradient calculation, this method is overwritten for efficiency.

Returns:

The value and the gradient of the object.

Return type:

tuple

property name: str | None#

Get the name of the parameter.

Returns:

Name of the parameter.

property optimizable_parameters: list[Quantity]#

Get the optimizable parameters.

Returns:

The list of optimizable parameters associated with the object.

set_all_optimizable_parameters(all_params)[source]#

Set all optimizable parameters in the optimization.

Parameters:

all_params (list[Quantity]) – List of optimizable parameters to be set.

set_optimizable_parameters(params)[source]#

Set specified parameters to be optimized.

Also add the indices to _grad_arg_nums to compute the gradients.

Parameters:

params (list[Quantity]) – Input list of parameters to be set.