sinusoid_stf
The Boulder Opal Toolkits are currently in beta phase of development. Breaking changes may be introduced.
- 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, \(A\). 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:
See also
signals.hann_series_stf()
Create an Stf representing a sum of Hann window functions.
signals.sinusoid()
Function to create a Signal object representing a sinusoidal oscillation.
signals.sinusoid_pwc()
Corresponding operation with Pwc output.
sin()
Calculate the element-wise sine of an object.
Notes
The sinusoid is defined as
\[\mathop{\mathrm{Sinusoid}}(t) = A \sin \left( \omega t + \phi \right) .\]Examples
Define an STF oscillation.
>>> oscillation = graph.signals.sinusoid_stf( ... amplitude=1.0, angular_frequency=np.pi, phase=np.pi/2.0 ... ) >>> oscillation <Stf: operation_name="multiply", value_shape=(), batch_shape=()> >>> graph.sample_stf(stf=oscillation, sample_times=np.linspace(0, 1, 5), name="oscillation") <Tensor: name="oscillation", operation_name="sample_stf", shape=(5,)> >>> graph.discretize_stf( ... oscillation, duration=10, segment_count=100, name="discretized_oscillation" ... ) <Pwc: name="discretized_oscillation", operation_name="discretize_stf", value_shape=(), batch_shape=()> >>> result = qctrl.functions.calculate_graph( ... graph=graph, output_node_names=["oscillation", "discretized_oscillation"] ... ) >>> result.output["oscillation"]["value"] array([ 1.000e+00, 7.071e-01, 1.225e-16, -7.071e-01, -1.000e+00])
Define a sinusoid with optimizable parameters.
>>> amplitude = graph.optimization_variable( ... count=1, lower_bound=0, upper_bound=4e3, name="amplitude" ... ) >>> angular_frequency = graph.optimization_variable( ... count=1, 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=()>