komm.RectangularPulse
Rectangular pulse. It is a pulse with waveform given by $$ p(t) = \begin{cases} 1, & 0 \leq t < w, \\ 0, & \text{otherwise}, \end{cases} $$ where $w$ is the relative width of the pulse, which must satisfy $0 < w \leq 1$.
The waveform of the rectangular pulse is depicted below for $w = 1$, and for $w = 0.5$.
Notes
- For $w = 1$ it is also called the NRZ pulse.
- For $w = 0.5$ it is also called the halfway RZ pulse.
Attributes:
-
width
(float
) –The relative width $w$ of the pulse. Must satisfy $0 < w \leq 1$. The default value is
1.0
.
waveform()
The waveform $p(t)$ of the pulse.
For the rectangular pulse, it is given by $$ p(t) = \rect\left(\frac{t - w/2}{w}\right). $$
Examples:
>>> pulse = komm.RectangularPulse(width=1.0) # NRZ pulse
>>> pulse.waveform(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )
array([0., 0., 0., 0., 1., 1., 1., 1., 0.])
>>> pulse = komm.RectangularPulse(width=0.5) # Halfway RZ pulse
>>> pulse.waveform(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )
array([0., 0., 0., 0., 1., 1., 0., 0., 0.])
spectrum()
The spectrum $\hat{p}(f)$ of the pulse.
For the rectangular pulse, it is given by $$ \hat{p}(f) = w \sinc(w f) \mathrm{e}^{-\mathrm{j} 2 \pi (w/2) f}. $$
Examples:
>>> pulse = komm.RectangularPulse(width=1.0) # NRZ pulse
>>> np.abs(pulse.spectrum(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )).round(3)
array([0. , 0.3 , 0.637, 0.9 , 1. , 0.9 , 0.637, 0.3 , 0. ])
>>> pulse = komm.RectangularPulse(width=0.5) # Halfway RZ pulse
>>> np.abs(pulse.spectrum(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )).round(3)
array([0.318, 0.392, 0.45 , 0.487, 0.5 , 0.487, 0.45 , 0.392, 0.318])
autocorrelation()
The autocorrelation function $R(\tau)$ of the pulse.
For the rectangular pulse, it is given by $$ R(\tau) = w \tri\left(\frac{\tau}{w}\right). $$
Examples:
>>> pulse = komm.RectangularPulse(width=1.0) # NRZ pulse
>>> pulse.autocorrelation(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )
array([0. , 0.25, 0.5 , 0.75, 1. , 0.75, 0.5 , 0.25, 0. ])
>>> pulse = komm.RectangularPulse(width=0.5) # Halfway RZ pulse
>>> pulse.autocorrelation(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... )
array([0. , 0. , 0. , 0.25, 0.5 , 0.25, 0. , 0. , 0. ])
energy_density_spectrum()
The energy density spectrum $S(f)$ of the pulse.
For the rectangular pulse, it is given by $$ S(f) = w^2 \sinc^2(w f). $$
Examples:
>>> pulse = komm.RectangularPulse(width=1.0) # NRZ pulse
>>> pulse.energy_density_spectrum(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... ).round(3)
array([0. , 0.09 , 0.405, 0.811, 1. , 0.811, 0.405, 0.09 , 0. ])
>>> pulse = komm.RectangularPulse(width=0.5) # Halfway RZ pulse
>>> pulse.energy_density_spectrum(
... [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0],
... ).round(3)
array([0.101, 0.154, 0.203, 0.237, 0.25 , 0.237, 0.203, 0.154, 0.101])