# hann_series_stf

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/signals/hann_series_stf

```python
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*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.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](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Stf.md#boulderopal.graph.Stf)

### SEE ALSO
[`boulderopal.signals.hann_series`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/signals/hann_series.md#boulderopal.signals.hann_series)
: Create a Signal object representing a sum of Hann window functions.

[`Graph.signals.hann_series_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/signals/hann_series_pwc.md#boulderopal.graph.signals.hann_series_pwc)
: Corresponding operation with Pwc output.

[`Graph.signals.sinusoid_stf`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/signals/sinusoid_stf.md#boulderopal.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.

```pycon
>>> 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.

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