sinusoid_stf

signals.sinusoid_stf(amplitude, angular_frequency, phase=0.0)

Create an Stf representing a sinusoidal oscillation.

Parameters

  • amplitude (float or complex or Tensor) – The amplitude of the oscillation, AA. It must either be a scalar or contain a single element.
  • angular_frequency (float or Tensor) – The angular frequency of the oscillation, ω\omega. It must either be a scalar or contain a single element.
  • phase (float or Tensor , optional) – The phase of the oscillation, ϕ\phi. If passed, it must either be a scalar or contain a single element. Defaults to 0.

Returns

The sampleable sinusoid.

Return type

Stf

SEE ALSO

Graph.signals.hann_series_stf : Create an Stf representing a sum of Hann window functions.

boulderopal.signals.sinusoid : Create a Signal object representing a sinusoidal oscillation.

Graph.signals.sinusoid_pwc : Corresponding operation with Pwc output.

Graph.sin : Calculate the element-wise sine of an object.

Notes

The sinusoid is defined as

Sinusoid(t)=Asin(ωt+ϕ). \mathop{\mathrm{Sinusoid}}(t) = A \sin \left( \omega t + \phi \right) .

Examples

Define an STF oscillation.

>>> oscillation = graph.signals.sinusoid_stf(
...     amplitude=2.0, angular_frequency=3.0, phase=np.pi/4
... )
>>> graph.discretize_stf(
...     oscillation, duration=10, segment_count=5, name="oscillation"
... )
<Pwc: name="oscillation", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="oscillation")
>>> result["output"]["oscillation"]
{'durations': array([2., 2., 2., 2., 2.]),
'values': array([-1.20048699, -0.70570922, -0.15471507,  0.4086036 ,  0.93937314]),
'time_dimension': 0}

Define a sinusoid with optimizable parameters.

>>> amplitude = graph.optimizable_scalar(
...     lower_bound=0, upper_bound=4e3, name="amplitude"
... )
>>> angular_frequency = graph.optimizable_scalar(
...     lower_bound=5e6, upper_bound=20e6, name="angular_frequency"
... )
>>> phase = graph.optimization_variable(
...     count=1,
...     lower_bound=0,
...     upper_bound=2*np.pi,
...     is_lower_unbounded=True,
...     is_upper_unbounded=True,
...     name="phase",
... )
>>> graph.signals.sinusoid_stf(
...     amplitude=amplitude, angular_frequency=angular_frequency, phase=phase
... )
<Stf: operation_name="multiply", value_shape=(), batch_shape=()>

Was this useful?