hann_series_stf

signals.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

See also

boulderopal.signals.hann_series

Create a Signal object representing a sum of Hann window functions.

Graph.signals.hann_series_pwc

Corresponding operation with Pwc output.

Graph.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
... )
>>> graph.discretize_stf(hann, duration=1, segment_count=5, name="hann")
<Pwc: name="hann", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="hann")
>>> result["output"]["hann"]
{'durations': array([0.2, 0.2, 0.2, 0.2, 0.2]),
'values': array([0.5568644 , 1.25563559, 0.75      , 1.25563569, 0.55686415]),
'time_dimension': 0}

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=()>