# hann_series_stf

The Boulder Opal Toolkits are currently in beta phase of development. Breaking changes may be introduced.

hann_series_stf(coefficients, end_time, start_time=0.0)

Create an Stf representing a sum of Hann window functions.

Parameters:
• coefficients (np.ndarray or Tensor) – The coefficients for the different Hann window functions, $$c_n$$. It must be a 1D array or Tensor.

• end_time (float) – The time at which the Hann series ends, $$t_\mathrm{end}$$.

• start_time (float, optional) – The time at which the Hann series starts, $$t_\mathrm{start}$$. Defaults to 0.

Returns:

The sampleable Hann window functions series.

Return type:

Stf

signals.hann_series()

Function to create a Signal object representing a sum of Hann window functions.

signals.hann_series_pwc()

Corresponding operation with Pwc output.

signals.sinusoid_stf()

Create an Stf representing a sinusoidal oscillation.

Notes

The series is defined as

$\mathop{\mathrm{Hann}}(t) = \sum_{n=1}^N c_n \sin^2 \left( \frac{\pi n (t - t_\mathrm{start})}{t_\mathrm{end} - t_\mathrm{start}} \right) ,$

where $$N$$ is the number of coefficients.

Note that the function values outside the $$(t_\mathrm{start}, t_\mathrm{end})$$ range will not be zero.

Examples

Define a simple sampleable Hann series.

>>> hann = graph.signals.hann_series_stf(coefficients=np.array([0.5, 1, 0.25]), end_time=1.0)
>>> hann
<Stf: operation_name="stf_sum", value_shape=(), batch_shape=()>
>>> graph.sample_stf(stf=hann, sample_times=np.linspace(0, 1, 7), name="hann_samples")
<Tensor: name="hann_samples", operation_name="hann_samples", shape=(7,)>
>>> graph.discretize_stf(hann, duration=1, segment_count=100, name="discretized_hann")
<Pwc: name="discretized_hann", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["hann_samples", "discretized_hann"]
... )
>>> result.output["hann_samples"]["value"]
array([0.000e+00, 1.125e+00, 1.125e+00, 7.500e-01, 1.125e+00, 1.125e+00, 5.159e-14])


Define a sampleable Hann series with optimizable coefficients.

>>> coefficients = graph.optimization_variable(
...     count=8, lower_bound=-3.5e6, upper_bound=3.5e6, name="coefficients"
... )
>>> graph.signals.hann_series_stf(coefficients=coefficients, end_time=2.0e-6)
<Stf: operation_name="stf_sum", value_shape=(), batch_shape=()>