tanh_ramp_pwc
signals.tanh_ramp_pwc(duration, segment_count, end_value, start_value=None, ramp_duration=None, center_time=None, *, name=None)
Create a Pwc representing a hyperbolic tangent ramp.
Parameters
- duration (float) – The duration of the signal,
- segment_count (int) – The number of segments in the PWC.
- end_value (float or complex or Tensor) – The asymptotic value of the ramp towards ,
- start_value (float or complex or Tensor or None , optional) – The asymptotic value of the ramp towards ,
- ramp_duration (float or Tensor or None , optional) – The characteristic time for the hyperbolic tangent ramp, . If passed, it must either be a scalar or contain a single element. Defaults to
- center_time (float or Tensor or None , optional) – The time at which the ramp has its greatest slope, . If passed, it must either be a scalar or contain a single element. Defaults to
- name (str or None , optional) – The name of the node.
Returns
The sampled hyperbolic tangent ramp.
Return type
SEE ALSO
Graph.signals.linear_ramp_pwc
: Create a Pwc representing a linear ramp.
boulderopal.signals.tanh_ramp
: Create a Signal object representing a hyperbolic tangent ramp.
Graph.signals.tanh_ramp_stf
: Corresponding operation with Stf output.
Graph.tanh
: Calculate the element-wise hyperbolic tangent of an object.
Notes
The hyperbolic tangent ramp is defined as
where the function’s asymptotic values
and is related to
Note that if is close to the edges of the PWC, for example
With the default values of start_value (), ramp_duration (), and center_time (
where is the end value (the start value is then ). This defines a symmetric ramp (around ) between (at ) and (at
Examples
Define a simple tanh PWC ramp.
>>> graph.signals.tanh_ramp_pwc(
... duration=5.0, segment_count=50, end_value=1, name="tanh_ramp"
... )
<Pwc: name="tanh_ramp", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="tanh_ramp")
>>> result["output"]["tanh_ramp"]
{
'durations': array([0.1, 0.1, ..., 0.1, 0.1]),
'values': array([-0.99442601, -0.99291942, ..., 0.99291942, 0.99442601]),
'time_dimension': 0
}
Define a flat-top pulse from two hyperbolic tangent ramps.
>>> ramp = graph.signals.tanh_ramp_pwc(
... duration=3,
... segment_count=60,
... end_value=1,
... ramp_duration=0.25,
... center_time=0.5,
... )
>>> flat_top_pulse = 0.5 * (ramp + graph.time_reverse_pwc(ramp))
>>> flat_top_pulse.name="flat_top_pulse"
>>> result = bo.execute_graph(graph=graph, output_node_names="flat_top_pulse")
>>> result["output"]["flat_top_pulse"]
{
'durations': array([0.05, 0.05, ..., 0.05, 0.05]),
'values': array([0.02188127, 0.03229546, ..., 0.03229546, 0.02188127]),
'time_dimension': 0
}
Define a hyperbolic tangent ramp with optimizable parameters.
>>> end_value = graph.optimizable_scalar(
... lower_bound=0, upper_bound=3e6, name="end_value"
... )
>>> ramp_duration = graph.optimizable_scalar(
... lower_bound=0.1e-6, upper_bound=0.3e-6, name="ramp_duration"
... )
>>> center_time = graph.optimizable_scalar(
... lower_bound=0.25e-6, upper_bound=0.75e-6, name="center_time"
... )
>>> graph.signals.tanh_ramp_pwc(
... duration=1e-6,
... segment_count=32,
... end_value=end_value,
... start_value=0.0,
... ramp_duration=ramp_duration,
... center_time=center_time,
... name="tanh_ramp",
... )
<Pwc: name="tanh_ramp", operation_name="discretize_stf", value_shape=(), batch_shape=()>