cosine_pulse_pwc
signals.cosine_pulse_pwc(duration, segment_count, amplitude, drag=None, start_time=0.0, end_time=None, flat_duration=None, segmentation=SegmentationType.UNIFORM, *, name=None)
Create a Pwc representing a cosine pulse.
Parameters
- duration (float) – The duration of the signal, T.
- segment_count (int) – The number of segments in the PWC. Must be at least six.
- amplitude (float or complex or Tensor) – The amplitude of the pulse, A. It must either be a scalar or contain a single element.
- drag (float or Tensor or None , optional) – The DRAG parameter, β. If passed, it must either be a scalar or contain a single element. Defaults to no DRAG correction.
- start_time (float , optional) – The time at which the cosine pulse starts, tstart. Defaults to 0.
- end_time (float or None , optional) – The time at which the cosine pulse ends, tend. Defaults to the given duration T.
- flat_duration (float or None , optional) – The amount of time to remain constant after the peak of the cosine, tflat. If passed, it must be positive and less than the difference between end_time and start_time. Defaults to None, in which case no constant part is added to the cosine pulse.
- segmentation (
SegmentationType
) – The type of segmentation for the signal. With a “MINIMAL” segmentation, most of the segments are placed in the non-constant parts of the signal. Defaults to “UNIFORM”, in which case the segments are uniformly distributed along the signal’s duration. - name (str or None , optional) – The name of the node.
Returns
The sampled cosine pulse. If no flat duration is passed then the pulse is evenly sampled between 0 and T. If one is passed, the flat part of the pulse is described by one or two segments (depending on the value of segment_count), and the rest of the pulse is sampled with the remaining segments.
Return type
SEE ALSO
boulderopal.signals.cosine_pulse
: Create a Signal object representing a cosine pulse.
Graph.signals.gaussian_pulse_pwc
: Create a Pwc representing a Gaussian pulse.
Graph.signals.hann_series_pwc
: Create a Pwc representing a sum of Hann window functions.
Graph.signals.sech_pulse_pwc
: Create a Pwc representing a hyperbolic secant pulse.
Graph.signals.sinusoid_pwc
: Create a Pwc representing a sinusoidal oscillation.
Graph.signals.square_pulse_pwc
: Create a Pwc representing a square pulse.
Graph.cos
: Calculate the element-wise cosine of an object.
Notes
The cosine pulse is defined as
Cos(t)=⎩⎨⎧02A[1+cos(ωt−τ−)+iωβsin(ωt−τ−)]A2A[1+cos(ωt−τ+)+iωβsin(ωt−τ+)]0ift<tstartiftstart≤t<τ−ifτ−≤t≤τ+ifτ+<t≤tendift>tend,where ω=2π/(tend−tstart−tflat), τ∓ are the start/end times of the flat segment, with τ∓=(tstart+tend∓tflat)/2.
If the flat duration is zero (the default setting), this reduces to
Cos(t)=2A[1+cos(ωt−τ)+iωβsin(ωt−τ)]θ(t−tstart)θ(tend−t),where now ω=2π/(tend−tstart), τ=(tstart+tend)/2 and θ(t) is the Heaviside step function.
Examples
Define a cosine PWC pulse.
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0, segment_count=100, amplitude=1.0, name="cos_pulse"
... )
<Pwc: name="cos_pulse", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="cos_pulse")
>>> result["output"]["cos_pulse"]
{
'durations': array([0.03, 0.03, ..., 0.03, 0.03]),
'values': array([2.46719817e-04, 2.21901770e-03, ..., 2.21901770e-03, 2.46719817e-04]),
'time_dimension': 0
}
Define a flat-top cosine PWC pulse with a DRAG correction.
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0,
... segment_count=100,
... amplitude=1.0,
... drag=0.1,
... start_time=1.0,
... end_time=2.0,
... flat_duration=0.3,
... segmentation="MINIMAL",
... name="cos_flat",
... )
<Pwc: name="cos_flat", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="cos_flat")
>>> result["output"]["cos_flat"]
{
'durations': array([1. , 0.00729167, ..., 0.00729167, 1. ]),
'values': array([0.00000000e+00+0.j , 2.67706262e-04-0.01468429j, ...,
2.67706262e-04+0.01468429j, 0.00000000e+00+0.j ]),
'time_dimension': 0
}
Define a cosine pulse with optimizable parameters.
>>> amplitude = graph.optimizable_scalar(
... lower_bound=0, upper_bound=2.*np.pi, name="amplitude"
... )
>>> drag = graph.optimizable_scalar(
... lower_bound=0, upper_bound=1., name="drag"
... )
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0,
... segment_count=100,
... amplitude=amplitude,
... drag=drag,
... name="cos_pulse",
... )
<Pwc: name="cos_pulse", operation_name="pwc_signal", value_shape=(), batch_shape=()>