# hann_series_pwc

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

hann_series_pwc(duration, segment_count, coefficients, *, name=None)

Create a Pwc representing a sum of Hann window functions.

The piecewise-constant function is sampled from Hann functions that start and end at zero.

Parameters:
• duration (float) – The duration of the signal, $$T$$.

• segment_count (int) – The number of segments in the PWC.

• coefficients (np.ndarray or Tensor) – The coefficients for the different Hann window functions, $$c_n$$. It must be a 1D array or Tensor and it can’t contain more than segment_count elements.

• name (str, optional) – The name of the node.

Returns:

The sampled Hann window functions series.

Return type:

Pwc

signals.cosine_pulse_pwc()

Create a Pwc representing a cosine pulse.

signals.sinusoid_pwc()

Create a Pwc representing a sinusoidal oscillation.

signals.hann_series()

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

signals.hann_series_stf()

Corresponding operation with Stf output.

Notes

The series is defined as

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

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

Examples

Define a simple Hann series.

>>> graph.signals.hann_series_pwc(
...     duration=5.0,
...     segment_count=50,
...     coefficients=np.array([0.5, 1, 0.25]),
...     name="hann_series",
... )
<Pwc: name="hann_series", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["hann_series"]
... )
>>> result.output["hann_series"]
[
{'value': 0.0067, 'duration': 0.1},
{'value': 0.0590, 'duration': 0.1},
...
{'value': 0.0590, 'duration': 0.1},
{'value': 0.0067, 'duration': 0.1},
]


Define a 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_pwc(
...     duration=2.0e-6,
...     segment_count=128,
...     coefficients=coefficients,
...     name="hann_series",
... )
<Pwc: name="hann_series", operation_name="pwc_signal", value_shape=(), batch_shape=()>