Helpers

class Helpers.NFSpectrum(cont_type, disc_type)[source]

Stores and plots nonlinear Fourier spectra.

The following attributes can be set/read by the user:

xi : np.array(float)
Nonlinear frequency grid (a vector).
cont : np.array(complex)
Vector specficying the continuous spectrum at the nonlinear frequencies in xi. Has to be of the type specified during construction.
bound_states : np.array(complex)
Vector containing the bound states (eigenvalues).
normconsts : np.array(complex)
Vector specifying the residues (b/a’) or norming constants (b) for each of the bound states.
xi_plot_range : np.array(float)
Vector of length two with xi_plot_range[0]<xi_plot_range[1]. Speficies the xi range shown when the continuous spectrum is plotted using show(). The default is an empty vector [], in which case no range are set.
bound_state_plot_range : np.array(float)
Vector of length four of the form [re_min, re_max, im_min, im_max]. Speficies the range of real/imaginary parts for the bound states when the bound states are plotted using show(). The default is an empty vector [], in which case no ranges are set.
__init__(cont_type, disc_type)[source]

Constructor. Initializes all attributes mentioned above except cont_type and disc_type to empty values.

Parameters:
  • cont_type (str) – See the cont_type property.
  • disc_type (str) – See the disc_type property.
__weakref__

list of weak references to the object (if defined)

cont_type

Type of the continuous spectrum stored in this object (read-only, set during construction).

Returns:
  • “none” (str) – if no continuous spectrum is stored.
  • ”b/a” (str) – if the continuous spectrum is a reflection coefficient.
  • ”b” (str) – if the continuous spectrum is a b-coefficient.
disc_type

Type of the discrete spectrum stored in this object (read-only, set during construction).

Returns:
  • “none” (str) – if no discrete spectrum is stored.
  • ”b/a’” (str) – if the discrete spectrum contains eigenvalues and residues.
  • ”b” (str) – if the discrete spectrum contains eigenvalues and norming constants.
show(new_fig=False, title=None, legend=None)[source]

Plots the nonlinear Fourier spectrum stored in this object. This routine can be called repeatedly, in which several plots are shown in the same figure.

Parameters:
  • new_fig (bool) – If True, a new figute is created by the routine.
  • title (str) – Title of the plot.
  • legend (array(str)) – Array of legend entries. If None, no legend is added.
Returns:

Figure object, only if new_fig==True.

Return type:

matplotlib.figure object

show_contspec_angle(ax, legend=None)[source]

Plots the angle (phase) of the continous spectrum.

Parameters:
  • ax (matplotlib.axes object) – Axes used for plotting.
  • legend (array(str)) – Array of legend entries. If None, no legend is added.
show_contspec_mag(ax, legend=None)[source]

Plots the magnitude of the continous spectrum.

Parameters:
  • ax (matplotlib.axes object) – Axes used for plotting.
  • legend (array(str)) – Array of legend entries. If None, no legend is added.
show_discspec(ax, legend=None)[source]

Plots the bound states of the discrete spectrum.

Parameters:
  • ax (matplotlib.axes object) – Axes used for plotting.
  • legend (array(str)) – Array of legend entries. If None, no legend is added.