# tanh_ramp

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/signals/tanh_ramp

```python
boulderopal.signals.tanh_ramp(duration, end_value, start_value=None, ramp_duration=None, center_time=None)
```

Create a Signal object representing a hyperbolic tangent ramp.

### Parameters
* **duration** (*float*) – The duration of the signal, $T$.
* **end_value** (*float* *or* *complex*) – The asymptotic value of the ramp towards $t \to +\infty$, $a_+$.
* **start_value** (*float* *or* *complex* *or* *None* *,* *optional*) – The asymptotic value of the ramp towards $t \to -\infty$, $a_-$.
  Defaults to minus end_value.
* **ramp_duration** (*float* *or* *None* *,* *optional*) – The characteristic time for the hyperbolic tangent ramp, $t_\mathrm{ramp}$.
  Defaults to $T/6$.
* **center_time** (*float* *or* *None* *,* *optional*) – The time at which the ramp has its greatest slope, $t_0$.
  Defaults to $T/2$.
### Returns
The hyperbolic tangent ramp.
### Return type
[Signal](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/signals/Signal.md#boulderopal.signals.Signal)

### SEE ALSO
[`boulderopal.signals.linear_ramp`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/signals/linear_ramp.md#boulderopal.signals.linear_ramp)
: Create a Signal object representing a linear ramp.

[`Graph.signals.tanh_ramp_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/signals/tanh_ramp_pwc.md#boulderopal.graph.signals.tanh_ramp_pwc)
: Graph operation to create a Pwc representing a hyperbolic tangent ramp.

[`Graph.signals.tanh_ramp_stf`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/signals/tanh_ramp_stf.md#boulderopal.graph.signals.tanh_ramp_stf)
: Graph operation to create a Stf representing a hyperbolic tangent ramp.

## Notes

The hyperbolic tangent ramp is defined as

$$
\mathop{\mathrm{Tanh}}(t)
= \frac{a_+ + a_-}{2}
    + \frac{a_+ - a_-}{2} \tanh\left( \frac{t - t_0}{t_\mathrm{ramp}} \right) ,
$$

where the function’s asymptotic values $a_\pm$ are defined by:

$$
a_\pm := \lim_{t\to\pm\infty} \mathop{\mathrm{Tanh}}(t) ,
$$

and $t_0$ is related to $t_\mathrm{ramp}$ by:

$$
\left.\frac{{\mathrm d}\mathop{\mathrm{Tanh}}(t)}{{\mathrm d}t}\right|_{t=t_0}
    = \frac{ (a_+ - a_-)}{2 t_\mathrm{ramp}} .
$$

Note that if $t_0$ is close to the edges of the ramp,
for example $t_0 \lesssim 2 t_\mathrm{ramp}$,
then the first and last values of the outputted array will differ from the
expected asymptotic values.

With the default values of start_value ($a_-$),
ramp_duration ($t_\mathrm{ramp}$), and center_time ($t_0$),
the ramp expression simplifies to

$$
\mathop{\mathrm{Tanh}}(t) = A \tanh\left( \frac{t - T/2}{T/6} \right),
$$

where $A = a_+$ is the end value (the start value is then $-A$).
This defines a symmetric ramp (around $(T/2, 0)$)
between $-0.995 A$ (at $t=0$) and $0.995 A$ (at $t=T$).

## Examples

Define a tanh ramp.

```pycon
>>> signal = bo.signals.tanh_ramp(
...     duration=4, end_value=2, start_value=1, ramp_duration=0.4, center_time=2.
... )
>>> signal.export_with_time_step(time_step=0.4)
array([1.00012339, 1.00091105, 1.00669285, 1.04742587, 1.26894142,
   1.73105858, 1.95257413, 1.99330715, 1.99908895, 1.99987661])
```
