Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions source/getting-started/user-guide/injection/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ Per the :code:`help` output, the :code:`inj` sub-commands are:
- :code:`chirp <name> <set|add|sub> <gain> <freqMin> <freqMax> <period>` - Inject chirp
- :code:`triangle <name> <set|add|sub> <valueMin> <valueMax> <period>` - Inject triangle
- :code:`square <name> <set|add|sub> <valueMin> <valueMax> <period>` - Inject square
- :code:`ramp <name> <set|add|sub> <valueMin> <valueMax> <period>` - Inject ramp

Start by typing :code:`inj list` to see all registered injection points.

Expand Down Expand Up @@ -583,7 +584,69 @@ The duty cycle is 50%.

The :code:`period` parameter is in seconds.

~~~~~~~~~~~~~~~~~~~~~~
Ramp Injection
~~~~~~~~~~~~~~~~~~~~~~

Example :code:`ramp` injection where the :code:`valueMin = 0.3`, :code:`valueMax = 0.8`, and :code:`period = 0.5`:

.. plot::
:context: close-figs
:class: align-plot-left

import matplotlib.pyplot as plt
import numpy as np

t_step = 1e-3
tt = np.arange(0, 1, t_step)
yy = np.zeros_like(tt)

period = 0.5
minValue = 0.3
maxValue = 0.8

my_slope = (maxValue-minValue) / (period)

t_local = 0
for idx,t in enumerate(tt):
yy[idx] = my_slope * (t_local % period) + minValue

t_local += t_step
if (t_local > period):
t_local = 0

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5,3))
ax.plot(tt, yy)

ax.set_ylim(0, 1)

ax.set_xlabel("Time (sec)")
ax.set_ylabel("Injected Signal")

anno_lw = 2

# Add annotations
ax.plot([0, 1], [maxValue, maxValue], color='black', linewidth=anno_lw, linestyle='dashed')
ax.text(0, minValue + 0.06, "valueMin", bbox=dict(facecolor='white', alpha=0.8))
ax.plot([0, 1], [minValue, minValue], color='black', linewidth=anno_lw, linestyle='dashed')
ax.text(0, maxValue + 0.06, "valueMax", bbox=dict(facecolor='white', alpha=0.8))

# Add period label
ax.plot([0, period], [0.1, 0.1], color='black', linewidth=anno_lw)
ax.plot([0, 0], [0.1-0.02, 0.1+0.02], color='black', linewidth=anno_lw)
ax.plot([period, period], [0.1-0.02, 0.1+0.02], color='black', linewidth=anno_lw)
ax.text(period/2, 0.1 + 0.06, "period", ha="center", bbox=dict(facecolor='white', alpha=0.8))

fig.tight_layout()

fig.show()

**Syntax:** :code:`inj ramp <name> <set|add|sub> <valueMin> <valueMax> <period>`

Injects a sawtooth wave ranging from the min value to the max value, over the period.
The waveform starts at the min value.

The :code:`period` parameter is in seconds.


.. raw:: html
Expand Down