Data types

Use this module to define the data types used in the library.

>>> from opticomlib.typing import binary_sequence, electrical_signal, optical_signal, eye, gv

Classes

global_variables()

Global Variables (gv)

binary_sequence(data)

Binary Sequence

electrical_signal(signal[, noise, dtype])

Electrical Signal

optical_signal(signal[, noise, n_pol, dtype])

Optical Signal

eye(**kwargs)

Eye Diagram Parameters.

class opticomlib.typing.global_variables[source]

Global Variables (gv)

This object is used to store global variables that are used in the simulation. The global variables are used mainly to define the sampling frequency, the slot rate, the number of samples per slot and the optical wavelength or frequency.

Note

A slot is taken as the smallest time unit representing a binary value of the signal. For example, in PPM a bit is not the same as a slot. However, in OOK a bit and a slot are the same.

This class don’t need to be instantiated. It is already instantiated as gv. For update or add a variable use the __call__() method (i.e gv(**kargs)).

Attributes

sps

Number of samples per slot, 16 by default.

R

Slot rate in Hz, 1e9 by default.

fs

Sampling frequency in Samples/s, R*sps=16e9 by default.

dt

Time step in seconds, 1/fs=62.5e-12 by default.

wavelength

Optical communication central wavelength in meters, 1550e-9 by default.

f0

Optical communication central frequency in Hz, c/wavelength=193.4e12 by default.

N

Number of slots to simulate (None by default), if provided, it will set the instance's N attribute and calculate t, dw, and w.

t

Time array in seconds, None by default.

dw

Frequency step in Hz, None by default.

w

Frequency array in Hz, None by default.

Methods

__call__([sps, R, fs, wavelength, N])

Configures the instance with the provided parameters.

__str__()

Returns a formatted string with the global variables of the instance.

print()

Prints the global variables of the instance in a formatted manner.

Examples

>>> gv(R=10e9, sps=8, N=100).print()
------------------------
*** Global Variables ***
------------------------
    sps :   8
    R   :   1.00e+10
    fs  :   8.00e+10
    λ0  :   1.55e-06
    f0  :   1.93e+14
    N   :   100
    dt  :   1.25e-11
    dw  :   6.28e+08
    t   :   [0.e+00 1.e-11 3.e-11 ... 1.e-08 1.e-08 1.e-08]
    w   :   [-3.e+11 -3.e+11 -3.e+11 ...  2.e+11  3.e+11  3.e+11]

Also can be define new variables trough **kwargs. If at least two of this arguments (sps, fs and R) are not provided a warning will be raised and the default values will be used.

>>> gv(alpha=0.5, beta=0.3).print()
UserWarning: `sps`, `R` and `fs` will be set to default values (16 samples per slot, 1.00e+09 Hz, 1.60e+10 Samples/s)
warnings.warn(msg)

------------------------------
***    Global Variables    ***
------------------------------
        sps :  16
        R   :  1.00e+09
        fs  :  1.60e+10
        λ0  :  1.55e-06
        f0  :  1.93e+14

Custom
------
        alpha : 0.5
        beta : 0.3
sps

Number of samples per slot, 16 by default.

R

Slot rate in Hz, 1e9 by default.

fs

Sampling frequency in Samples/s, R*sps=16e9 by default.

dt

Time step in seconds, 1/fs=62.5e-12 by default.

wavelength

Optical communication central wavelength in meters, 1550e-9 by default.

f0

Optical communication central frequency in Hz, c/wavelength=193.4e12 by default.

N

Number of slots to simulate (None by default), if provided, it will set the instance’s N attribute and calculate t, dw, and w.

t

Time array in seconds, None by default.

dw

Frequency step in Hz, None by default.

w

Frequency array in Hz, None by default.

__call__(sps: int = None, R: float = None, fs: float = None, wavelength: float = 1.55e-06, N: int = None, **kargs) Any[source]

Configures the instance with the provided parameters.

Parameters:
  • sps (int, optional) – Samples per slot. If provided, it will set the instance’s sps attribute.

  • R (float, optional) – Rate in Hz. If provided, it will set the instance’s R attribute.

  • fs (float, optional) – Sampling frequency in Samples/s. If provided, it will set the instance’s fs attribute.

  • wavelength (float, optional) – Wavelength in meters. Default is 1550e-9.

  • N (int, optional) – Number of samples. If provided, it will set the instance’s N attribute and calculate t, dw, and w.

  • **kargs (dict) – Additional attributes to set on the instance.

Returns:

The instance itself.

Return type:

self

Notes

If sps is provided and either R or fs is provided, it will calculate the missing one. If R is provided and fs is provided, it will calculate sps. If only fs is provided, it will calculate sps using the instance’s R attribute. If none of sps, R, or fs is provided, it will use the instance’s default values.

__str__()[source]

Returns a formatted string with the global variables of the instance.

print()[source]

Prints the global variables of the instance in a formatted manner.

Prints the global variables including sps, R, fs, wavelength, f0, N, dt, dw, t, and w. If there are other attributes defined, they will be printed under the “Custom” section.

Notes

The variables are printed with a precision of 2 in scientific notation, except for sps and N which are integers.

class opticomlib.typing.binary_sequence(data: str | Iterable)[source]

Binary Sequence

This class provides methods and attributes to work with binary sequences. The binary sequence can be provided as a string, list, tuple, or numpy array.

Attributes

data

The binary sequence data, a 1D numpy array of boolean values.

execution_time

The execution time of the last operation performed on the binary sequence.

Methods

__init__(data)

Initialize the binary sequence object.

__str__([title])

Return a formatted string with the binary sequence data, length, size in bytes and time if available.

__repr__()

Return repr(self).

print([msg])

Print object parameters.

__len__()

Get number of slots of the binary sequence.

__getitem__(slice)

Get a slice of the binary sequence (self[slice]).

__eq__(other)

Compare two binary sequences using == operator.

__add__(other)

Concatenate two binary sequences, adding to the end (+).

__radd__(other)

Concatenate two binary sequences, adding to the beginning (+).

__invert__()

Invert the binary sequence using the ~ operator.

len()

Get number of slots of the binary sequence.

ones()

Return the number of ones in the binary sequence.

zeros()

Return the number of zeros in the binary sequence.

type()

Return de object type.

sizeof()

Get memory size of object in bytes.

__init__(data: str | Iterable)[source]

Initialize the binary sequence object.

Parameters:

data (str, 1D array_like or scalar) – The binary sequence data.

data

The binary sequence data, a 1D numpy array of boolean values.

execution_time

The execution time of the last operation performed on the binary sequence.

__str__(title: str = None)[source]

Return a formatted string with the binary sequence data, length, size in bytes and time if available.

print(msg: str = None)[source]

Print object parameters.

Parameters:

msg (str, opcional) – top message to show

Returns:

The same object.

Return type:

binary_sequence

__len__()[source]

Get number of slots of the binary sequence. len(self)

__getitem__(slice: int | slice)[source]

Get a slice of the binary sequence (self[slice]).

Parameters:

slice (int or slice) – The slice to get.

Returns:

The value of the slot if slice is an integer, or a new binary sequence object with the result of the slice.

Return type:

int or binary_sequence

__eq__(other)[source]

Compare two binary sequences using == operator.

Parameters:

other (str or binary_sequence or Array_Like) – The binary sequence to compare.

Returns:

A boolean array with the result of the comparison. True if the elements are equal, False otherwise.

Return type:

np.ndarray of bool

__add__(other)[source]

Concatenate two binary sequences, adding to the end (+).

Parameters:

other (str or binary_sequence or Array_Like) – The binary sequence to concatenate.

Returns:

A new binary sequence object with the result of the concatenation.

Return type:

binary_sequence

Raises:
  • ValueError – If the sequence to concatenate it’s not in an apropiate format.

  • TypeError – If the binary sequence to concatenate is not of type str, binary_sequence or Array_Like.

See also

__radd__

Concatenates two binary sequence, adding at the beginning (+).

__radd__(other)[source]

Concatenate two binary sequences, adding to the beginning (+).

Parameters:

other (str or binary_sequence or Array_Like) – The binary sequence to concatenate.

Returns:

A new binary sequence object with the result of the concatenation.

Return type:

binary_sequence

Raises:
  • ValueError – If the sequence to concatenate it’s not in an apropiate format.

  • TypeError – If the binary sequence to concatenate is not of type str, binary_sequence or Array_Like.

See also

__add__

Concatenates two binary sequence, adding at the end.

__invert__()[source]

Invert the binary sequence using the ~ operator.

Implement a bitwise not ~ operation on the binary sequence. Example: ~binary_sequence([1,0,1,0]) returns binary_sequence([0,1,0,1]).

Returns:

A new binary sequence object with the result of the inversion.

Return type:

binary_sequence

len()[source]

Get number of slots of the binary sequence.

Returns:

The number of slots of the binary sequence.

Return type:

int

ones()[source]

Return the number of ones in the binary sequence.

Returns:

The number of ones in the binary sequence.

Return type:

int

zeros()[source]

Return the number of zeros in the binary sequence.

Returns:

The number of zeros in the binary sequence.

Return type:

int

type()[source]

Return de object type.

Returns:

The object type binary_sequence.

Return type:

type

sizeof()[source]

Get memory size of object in bytes.

class opticomlib.typing.electrical_signal(signal: str | Iterable, noise: str | Iterable = None, dtype: dtype = None)[source]

Electrical Signal

This class provides methods and attributes to work with electrical signals. It has overloaded operators necessary to properly interpret the +, -, * and /` operations as any numpy array.

Attributes

signal

The signal values, a 1D numpy array of complex values.

noise

The noise values, a 1D numpy array of complex values.

execution_time

The execution time of the last operation performed on the electrical signal.

Methods

__init__(signal[, noise, dtype])

Initialize the electrical signal object.

__call__(domain[, shift])

Return a new object with Fast Fourier Transform (FFT) of signal and noise of input object.

print([msg])

Prints object parameters.

len()

Get number of samples of the electrical signal.

type()

Return de object type (electrical_signal).

sizeof()

Get memory size of object in bytes.

fs()

Get sampling frequency of the electrical signal.

sps()

Get samples per slot of the electrical signal.

dt()

Get time step of the electrical signal.

t()

Get time array for the electrical signal.

w([shift])

Return angular frequency for spectrum representation.

abs([by])

Get absolute value of signal, noise or signal+noise.

power([by])

Get power of the electrical signal.

phase()

Get phase of the signal + noise.

apply(function, *args, **kargs)

Apply a function to signal and noise.

copy([n])

Return a copy of the object.

plot([fmt, n, xlabel, ylabel, style, grid, hold])

Plot real part of electrical signal.

psd([fmt, n, xlabel, ylabel, yscale, style, ...])

Plot Power Spectral Density (PSD) of the electrical signal.

grid(**kwargs)

Add grid to the plot.

legend(*args, **kwargs)

Add a legend to the plot.

show()

Show plots.

__init__(signal: str | Iterable, noise: str | Iterable = None, dtype: dtype = None) None[source]

Initialize the electrical signal object.

Parameters:
  • signal (str or 1D array_like or scalar) – The signal values.

  • noise (str or 1D array_like or scalar, optional) – The noise values. Defaults to None.

Notes

The signal and noise can be provided as a string, in which case it will be converted to a numpy.array using the str2array() function. For example:

>>> electrical_signal('1 2 3,4,5')  # separate values by space or comma indistinctly
electrical_signal(signal=[1.+0.j 2.+0.j 3.+0.j 4.+0.j 5.+0.j],
                  noise=[0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j])
>>> electrical_signal('1+2j, 3+4j, 5+6j') # complex values
signal

The signal values, a 1D numpy array of complex values.

noise

The noise values, a 1D numpy array of complex values.

execution_time

The execution time of the last operation performed on the electrical signal.

__str__(title: str = None)[source]

Return a formatted string with the electrical_signal data, length, size in bytes and time if available.

print(msg: str = None)[source]

Prints object parameters.

Parameters:

msg (str, opcional) – top message to show

Returns:

self – The same object.

Return type:

electrical_signal

__add__(other)[source]

Add two electrical signals (+ operator). Same that __radd__.

Parameters:

other (electrical_signal or Array_Like or Number) – The signal to add.

Returns:

A new electrical signal object with the result of the addition.

Return type:

electrical_signal

__sub__(other)[source]

Substract two electrical signals (- operator).

Parameters:

other (electrical_signal or Array_Like or Number) – The signal to substract.

Returns:

A new electrical signal object with the result of the substraction.

Return type:

electrical_signal

__mul__(other)[source]

Multiply two electrical signals (* operator). Same that __rmul__.

Parameters:

other (electrical_signal or Array_Like or Number) – The signal to multiply.

Returns:

A new electrical signal object with the result of the multiplication.

Return type:

electrical_signal

__getitem__(slice: int | slice)[source]

Slice the signal.

Parameters:

slice (int or slice) – Index or slice to get.

Returns:

out – A new object with the result of the slicing.

Return type:

optical_signal

__call__(domain: Literal['t', 'w', 'f'], shift: bool = False)[source]

Return a new object with Fast Fourier Transform (FFT) of signal and noise of input object.

Parameters:
  • domain ({'t', 'w', 'f'}) – Domain to transform. ‘t’ for time domain (ifft is applied), ‘w’ and ‘f’ for frequency domain (fft is applied).

  • shift (bool, optional) – If True, apply the np.fft.fftshift() or np.fft.ifftshift functions as appropriate.

Returns:

new_obj – A new electrical signal object with the result of the transformation.

Return type:

electrical_signal or optical_signal

Raises:

TypeError – If domain is not one of the following values (‘t’, ‘w’, ‘f’).

__gt__(other)[source]

Compare the signal+noise with a threshold (> operator).

Parameters:

other (array_like or float) – The threshold to compare with. If other is an array, the comparison is element-wise.

Returns:

out – A new binary sequence object with the result of the comparison.

Return type:

binary_sequence

Raises:
  • ValueError – If the arrays must have the same length.

  • TypeError – If other is not of type electrical_signal, list, tuple, numpy.array, int or float.

__lt__(other)[source]

Compare the signal+noise with a threshold (< operator).

Parameters:

other (array_like or float) – The threshold to compare with. If other is an array, the comparison is element-wise.

Returns:

out – A new binary sequence object with the result of the comparison.

Return type:

binary_sequence

Raises:
  • ValueError – If the arrays must have the same length.

  • TypeError – If other is not of type electrical_signal, list, tuple, numpy.array, int or float.

len()[source]

Get number of samples of the electrical signal.

Returns:

The number of samples of the electrical signal.

Return type:

int

type()[source]

Return de object type (electrical_signal).

Returns:

The object type (electrical_signal).

Return type:

type

sizeof()[source]

Get memory size of object in bytes.

Returns:

The memory size of the object in bytes.

Return type:

int

fs()[source]

Get sampling frequency of the electrical signal.

Returns:

The sampling frequency of the electrical signal (gv.fs).

Return type:

float

sps()[source]

Get samples per slot of the electrical signal.

Returns:

The samples per slot of the electrical signal (gv.sps).

Return type:

int

dt()[source]

Get time step of the electrical signal.

Returns:

The time step of the electrical signal (gv.dt).

Return type:

float

t()[source]

Get time array for the electrical signal.

Returns:

The time array for the electrical signal.

Return type:

np.ndarray

w(shift: bool = False)[source]

Return angular frequency for spectrum representation.

Parameters:

shift (bool, optional) – If True, apply fftshift().

Returns:

The angular frequency array for signals simulation.

Return type:

np.ndarray

power(by: Literal['signal', 'noise', 'all'] = 'all')[source]

Get power of the electrical signal.

Parameters:

by (str, optional) – Defines from which attribute to obtain the power. If ‘all’, power of signal+noise is determined.

Returns:

The power of the electrical signal.

Return type:

float

phase()[source]

Get phase of the signal + noise.

Returns:

The phase of the electrical signal.

Return type:

np.ndarray

apply(function, *args, **kargs)[source]

Apply a function to signal and noise.

Parameters:
  • function (callable) – The function to apply.

  • *args (iterable) – Variable length argument list to pass to the function.

  • **kargs (dict) – Arbitrary keyword arguments to pass to the function.

Returns:

out – A new electrical signal object with the result of the function applied to the signal and noise.

Return type:

electrical_signal

copy(n: int = None)[source]

Return a copy of the object.

Parameters:

n (int, optional) – Index to truncate original object. If None, the whole object is copied.

Returns:

cp – A copy of the object.

Return type:

electrical_signal

abs(by: Literal['signal', 'noise', 'all'] = 'all')[source]

Get absolute value of signal, noise or signal+noise.

Parameters:

by (str, optional) – Defines from which attribute to obtain the absolute value. If ‘all’, absolute value of signal+noise is determined.

Returns:

out – The absolute value of the object.

Return type:

np.ndarray, (1D or 2D, float)

plot(fmt: str = '-', n: int = None, xlabel: str = None, ylabel: str = None, style: Literal['dark', 'light'] = 'dark', grid: bool = False, hold: bool = True, **kwargs: dict)[source]

Plot real part of electrical signal.

Parameters:
  • fmt (str) – Format style of line. Example ‘b-.’, Defaults to ‘-‘.

  • n (int, optional) – Number of samples to plot. Defaults to the length of the signal.

  • xlabel (str, optional) – X-axis label. Defaults to ‘Time [ns]’.

  • ylabel (str, optional) – Y-axis label. Defaults to ‘Amplitude [V]’.

  • style (str, optional) – Style of plot. Defaults to ‘dark’.

  • grid (bool, optional) – If show grid. Defaults to False.

  • hold (bool, optional) – If hold the current plot. Defaults to True.

  • **kwargs (dict) – Aditional keyword arguments compatible with matplotlib.pyplot.plot().

Returns:

self – The same object.

Return type:

electrical_signal

psd(fmt: str = '-', n: int = None, xlabel: str = None, ylabel: str = None, yscale: Literal['linear', 'dbm'] = 'dbm', style: Literal['dark', 'light'] = 'dark', grid: bool = True, hold: bool = True, **kwargs: dict)[source]

Plot Power Spectral Density (PSD) of the electrical signal.

Parameters:
  • fmt (str) – Format style of line. Example ‘b-.’. Defaults to ‘-‘.

  • n (int, optional) – Number of samples to plot. Defaults to the length of the signal.

  • xlabel (str, optional) – X-axis label. Defaults to ‘Frequency [GHz]’.

  • ylabel (str, optional) – Y-axis label. Defaults to ‘Power [dBm]’ if yscale='dbm' or ‘Power [W]’ if yscale='linear'.

  • yscale (str, {‘linear’, ‘dbm’}, optional) – Kind of Y-axis plot. Defaults to ‘dbm’.

  • style (str, {‘dark’, ‘light’}, optional) – Style of plot. Defaults to ‘dark’.

  • grid (bool, optional) – If show grid. Defaults to True.

  • hold (bool, optional) – If hold the current plot. Defaults to True.

  • **kwargs (dict) – Aditional matplotlib arguments.

Returns:

self – The same object.

Return type:

electrical_signal

grid(**kwargs)[source]

Add grid to the plot.

Parameters:

**kwargs (dict) – Arbitrary keyword arguments to pass to the function.

Returns:

self – The same object.

Return type:

electrical_signal

legend(*args, **kwargs)[source]

Add a legend to the plot.

Parameters:
  • *args (iterable) – Variable length argument list to pass to the function.

  • **kwargs (dict) – Arbitrary keyword arguments to pass to the function.

Returns:

self – The same object.

Return type:

electrical_signal

show()[source]

Show plots.

Returns:

self – The same object.

Return type:

electrical_signal

class opticomlib.typing.optical_signal(signal: str | Iterable, noise: str | Iterable = None, n_pol: Literal[1, 2] = None, dtype: dtype = None)[source]

Optical Signal

Bases: electrical_signal

This class provides methods and attributes to work with optical signals.

Attributes

signal

The signal values, a 1D numpy array of complex values.

noise

The noise values, a 1D numpy array of complex values.

execution_time

The execution time of the last operation performed on the electrical signal.

Methods

__init__(signal[, noise, n_pol, dtype])

Initialize the optical signal object.

__call__(domain[, shift])

Return a new object with Fast Fourier Transform (FFT) of signal and noise of input object.

print([msg])

Prints object parameters.

len()

Get number of samples of the electrical signal.

type()

Return de object type (electrical_signal).

sizeof()

Get memory size of object in bytes.

fs()

Get sampling frequency of the electrical signal.

sps()

Get samples per slot of the electrical signal.

dt()

Get time step of the electrical signal.

t()

Get time array for the electrical signal.

w([shift])

Return angular frequency for spectrum representation.

power([by])

Get power of the electrical signal.

phase()

Get phase of the signal + noise.

apply(function, *args, **kargs)

Apply a function to signal and noise.

copy([n])

Return a copy of the object.

abs([by])

Get absolute value of signal, noise or signal+noise.

plot([fmt, mode, n, xlabel, ylabel, style, ...])

Plot intensity of optical signal for selected polarization mode.

psd([fmt, mode, n, xlabel, ylabel, yscale, ...])

Plot Power Spectral Density (PSD) of the electrical signal.

grid(**kwargs)

Add grid to the plot.

legend(*args, **kwargs)

Add a legend to the plot.

show()

Show plots.

__init__(signal: str | Iterable, noise: str | Iterable = None, n_pol: Literal[1, 2] = None, dtype: dtype = None)[source]

Initialize the optical signal object.

Parameters:
  • signal (str or array_like (1D, 2D) or scalar) – The signal values.

  • noise (str or array_like (1D, 2D) or scalar, optional) – The noise values, default is None.

  • n_pol (int, optional) – Number of polarizations. Defaults to 1.

__getitem__(slice: int | slice)[source]

Slice the optical signal.

Parameters:

slice (int or slice) – Index or slice to get the new optical signal.

Returns:

out – A new optical signal object with the result of the slicing.

Return type:

optical_signal

plot(fmt: str | list = '-', mode: Literal['x', 'y', 'both', 'abs'] = 'abs', n=None, xlabel: str = None, ylabel: str = None, style: Literal['dark', 'light'] = 'dark', grid: bool = False, hold: bool = True, **kwargs)[source]

Plot intensity of optical signal for selected polarization mode.

Parameters:
  • fmt (str, optional) – Format style of line. Example ‘b-.’. Default is ‘-‘.

  • mode (str) –

    Polarization mode to show. Default is ‘abs’.

    • 'x' plot polarization x.

    • 'y' plot polarization y.

    • 'both' plot both polarizations x and y in the same figure

    • 'abs' plot intensity sum of both polarizations I(x) + I(y).

  • n (int, optional) – Number of samples to plot. Default is the length of the signal.

  • xlabel (str, optional) – X-axis label. Default is ‘Time [ns]’.

  • ylabel (str, optional) – Y-axis label. Default is ‘Power [mW]’.

  • style (str, optional) –

    Style of plot. Default is ‘dark’.

    • 'dark' use dark background.

    • 'light' use light background.

  • grid (bool, optional) – If show grid. Default is False.

  • hold (bool, optional) – If hold the current figure. Default is True.

  • **kwargs (dict) – Aditional matplotlib arguments.

Returns:

self – The same object.

Return type:

optical_signal

psd(fmt: str | list = '-', mode: Literal['x', 'y', 'both'] = 'x', n: int = None, xlabel: str = None, ylabel: str = None, yscale: Literal['linear', 'dbm'] = 'dbm', style: Literal['dark', 'light'] = 'dark', grid: bool = True, hold: bool = True, **kwargs: dict)[source]

Plot Power Spectral Density (PSD) of the electrical signal.

Parameters:
  • fmt (str) – Format style of line. Example ‘b-.’. Default is ‘-‘.

  • mode (str) –

    Polarization mode to show. Default is ‘x’.

    • 'x' plot polarization x.

    • 'y' plot polarization y.

    • 'both' plot both polarizations x and y in the same figure.

  • n (int, optional) – Number of samples to plot. Default is the length of the signal.

  • xlabel (str, optional) – X-axis label. Default is ‘Frequency [GHz]’.

  • ylabel (str, optional) – Y-axis label.

  • yscale (str, optional) –

    Kind of Y-axis plot. Default is ‘dbm’.

    • 'linear' plot linear scale.

    • 'dbm' plot dBm scale.

  • style (str, optional) –

    Style of plot. Default is ‘dark’.

    • 'dark' use dark background.

    • 'light' use light background.

  • grid (bool, optional) – If show grid. Default is True.

  • hold (bool, optional) – If hold the current figure. Default is True.

  • **kwargs (dict) – Aditional matplotlib arguments.

Returns:

self – The same object.

Return type:

optical_signal

class opticomlib.typing.eye(**kwargs: dict)[source]

Eye Diagram Parameters.

This object contains the parameters of an eye diagram and methods to plot it.

Methods

__init__(**kwargs)

Initialize the eye diagram object.

__str__([title])

Return a formatted string with the eye diagram data.

print([msg])

Print object parameters.

plot([medias_, legend_, style, cmap, title, ...])

Plot eye diagram.

show()

Show plot

t

The time values resampled. Shape (Nx1).

Type:

np.ndarray

y

The signal values resampled. Shape (Nx1).

Type:

np.ndarray

dt

Time between samples.

Type:

float

sps

Samples per slot.

Type:

int

t_left

Cross time of left edge.

Type:

float

t_right

Cross time of right edge.

Type:

float

t_opt

Optimal time decision.

Type:

float

t_dist

Time between slots.

Type:

float

t_span0

t_opt - t_dist*5%.

Type:

float

t_span1

t_opt + t_dist*5%.

Type:

float

y_top

Samples of signal above threshold and within t_span0 and t_apan1.

Type:

np.ndarray

y_bot

Samples of signal below threshold and within t_span0 and t_apan1.

Type:

np.ndarray

mu0

Mean of y_bot.

Type:

float

mu1

Mean of y_top.

Type:

float

s0

Standard deviation of y_bot.

Type:

float

s1

Standard deviation of y_top.

Type:

float

er

Extinction ratio.

Type:

float

eye_h

Eye height.

Type:

float

__init__(**kwargs: dict)[source]

Initialize the eye diagram object.

Parameters:

**kwargs (dict, optional) – Dictionary with the eye diagram parameters.

__str__(title: str = None)[source]

Return a formatted string with the eye diagram data.

print(msg: str = None)[source]

Print object parameters.

Parameters:

msg (str, optional) – Top message to show.

Returns:

self – Same object

Return type:

eye

plot(medias_: bool = True, legend_: bool = True, style: Literal['dark', 'light'] = 'dark', cmap: Literal['viridis', 'plasma', 'inferno', 'cividis', 'magma', 'winter'] = 'winter', title: str = '', savefig: str = None)[source]

Plot eye diagram.

Parameters:
  • style (str, optional) – Plot style. ‘dark’ or ‘light’.

  • means (bool, optional) – If True, plot mean values.

  • legend (bool, optional) – If True, show legend.

  • cmap (str, optional) – Colormap to plot.

  • title (str, optional) – Title of plot.

  • savefig (str, optional) – Name of the file to save the plot. If None, the plot is not saved. Input just the name of the file without extension (extension is .png by default).

Returns:

self – Same object

Return type:

eye

show()[source]

Show plot

Returns:

self – The same object.

Return type:

eye