sinusoid_pwc
signals.sinusoid_pwc(duration, segment_count, amplitude, angular_frequency, phase=0.0, *, name=None)
Create a Pwc representing a sinusoidal oscillation.
Parameters
- duration (float) – The duration of the signal, .
- segment_count (int) – The number of segments in the PWC.
- amplitude (float or complex or Tensor) – The amplitude of the oscillation, . It must either be a scalar or contain a single element.
- angular_frequency (float or Tensor) – The angular frequency of the oscillation, . It must either be a scalar or contain a single element.
- phase (float or Tensor , optional) – The phase of the oscillation, . If passed, it must either be a scalar or contain a single element. Defaults to 0.
- name (str or None , optional) – The name of the node.
Returns
The sampled sinusoid.
Return type
SEE ALSO
Graph.signals.cosine_pulse_pwc
: Create a Pwc representing a cosine pulse.
Graph.signals.hann_series_pwc
: Create a Pwc representing a sum of Hann window functions.
boulderopal.signals.sinusoid
: Create a Signal object representing a sinusoidal oscillation.
Graph.signals.sinusoid_stf
: Corresponding operation with Stf output.
Graph.sin
: Calculate the element-wise sine of an object.
Notes
The sinusoid is defined as
Examples
Define a PWC oscillation.
>>> graph.signals.sinusoid_pwc(
... duration=5.0,
... segment_count=100,
... amplitude=1.0,
... angular_frequency=np.pi,
... phase=np.pi/2.0,
... 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([0.05, 0.05, ..., 0.05, 0.05]),
'values': array([ 0.99691733, 0.97236992, ..., -0.97236992, -0.99691733]),
'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_pwc(
... duration=3e-6,
... segment_count=100,
... amplitude=amplitude,
... angular_frequency=angular_frequency,
... phase=phase,
... name="oscillation"
... )
<Pwc: name="oscillation", operation_name="discretize_stf", value_shape=(), batch_shape=()>