square_pulse_pwc

signals.square_pulse_pwc(duration, segment_count, amplitude, start_time=0, end_time=None, segmentation=SegmentationType.UNIFORM, *, name=None)

Create a Pwc representing a square pulse.

The entire signal lasts from time 0 to the given duration with the square pulse being applied from the start time to the end time.

Parameters

  • duration (float) – The duration of the signal.
  • segment_count (int) – The number of segments in the PWC. Only used if the segmentation type is “UNIFORM” .
  • amplitude (float or complex or Tensor) – The amplitude of the square pulse, AA. It must either be a scalar or contain a single element.
  • start_time (float , optional) – The start time of the square pulse, tstartt_\mathrm{start}. Defaults to 0.
  • end_time (float or None , optional) – The end time of the square pulse, tendt_\mathrm{end}. Must be greater than the start time. Defaults to the value of the given duration.
  • segmentation (SegmentationType) – The type of segmentation for the pulse. With a “MINIMAL” segmentation, the returned Pwc has between one and three segments, depending on the start time, end time, and duration 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 square pulse.

Return type

Pwc

SEE ALSO

Graph.signals.cosine_pulse_pwc : Create a Pwc representing a cosine pulse.

Graph.signals.gaussian_pulse_pwc : Create a Pwc representing a Gaussian pulse.

Graph.signals.sech_pulse_pwc : Create a Pwc representing a hyperbolic secant pulse.

boulderopal.signals.square_pulse : Create a Signal object representing a square pulse.

Notes

The square pulse is defined as

Square(t)=Aθ(ttstart)θ(tendt), \mathop{\mathrm{Square}}(t) = A \theta(t-t_\mathrm{start}) \theta(t_\mathrm{end}-t) ,

where θ(t)\theta(t) is the Heaviside step function.

Examples

Define a square pulse with an optimizable amplitude.

>>> amplitude = graph.optimizable_scalar(
...     lower_bound=0, upper_bound=2.*np.pi, name="amplitude"
... )
>>> graph.signals.square_pulse_pwc(
...     duration=4.0, amplitude=amplitude, segment_count=100, name="square"
... )
<Pwc: name="square", operation_name="pwc_signal", value_shape=(), batch_shape=()>

Define a square PWC pulse.

>>> graph.signals.square_pulse_pwc(
...     duration=4.0,
...     segment_count=5,
...     amplitude=2.5,
...     start_time=1.0,
...     end_time=3.0,
...     name="square",
... )
<Pwc: name="square", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="square")
>>> result["output"]["square"]
{
    'durations': array([0.8, 0.8, 0.8, 0.8, 0.8]),
    'values': array([0. , 2.5, 2.5, 2.5, 0. ]),
    'time_dimension': 0
}

Define a square PWC pulse with a minimal segmentation.

>>> graph.signals.square_pulse_pwc(
...     duration=4.0,
...     segment_count=None,
...     amplitude=2.5,
...     start_time=1.0,
...     end_time=3.0,
...     segmentation="MINIMAL",
...     name="square",
... )
<Pwc: name="square", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="square")
>>> result["output"]["square"]
{
    'durations': array([1., 2., 1.]),
    'values': array([0. , 2.5, 0. ]),
    'time_dimension': 0
}

Was this useful?