Helper functions

load_spectrum(file_name: str)

Loads a spectrum file with two columns of floats as numpy array. The first column is wavelength in nanometers; the second column is some spectroscopic property (mostly cross section) in SI units.

load_two_column_file(file_name: str)

Loads a file with two columns of floats as a numpy array.

wl_bw_to_freq_bw(wl_bw: float, center_wl: float)

Transforms a spectral bandwidth in wavelength centered at wavelength center_wl into a spectral bandwidth in frequency.

Parameters
  • wl_bw (float or numpy array of floats) – Wavelength bandwidth

  • center_wl (float or numpy array of floats) – Central wavelength of the spectrum

Returns

Frequency bandwidth

Return type

float or numpy array

freq_bw_to_wl_bw(freq_bw: float, center_wl: float)

Transforms a spectral bandwidth in frequency centered at wavelength center_wl into a spectral bandwidth in wavelength.

Parameters
  • freq_bw (float or numpy array of floats) – Wavelength bandwidth

  • center_wl (float or numpy array of floats) – Central wavelength of the spectrum

Returns

Frequency bandwidth

Return type

float or numpy array

wl_to_freq(wl: float)

Transforms (vacuum) wavelength to frequency.

freq_to_wl(f: float)

Transforms frequency to (vacuum) wavelength.

wl_to_omega(wl: float)

Transforms (vacuum) wavelength to angular frequency.

beta2_to_d(beta2: float, wl: float)

Dispersion parameter

decibel_to_exp(x: float)

Transforms a logarithmic quantity from dB/m to 1/m.

exp_to_decibel(x: float)

Transforms a logarithmic quantity from 1/m to dB/m.

to_db(x: float)

Transforms a quantity to decibels.

to_dbm(power: float)

Transforms a input_power in Watts to dBm.

fundamental_mode_mfd_marcuse(wl: float, r: float, na: float)

Calculates the mode field diameter of the fundamental mode with vacuum wavelength freq using Marcuse’s equation.

Parameters
  • wl (float) – Wavelength of the mode

  • r (float) – Core radius

  • na (float) – Core numerical aperture

Returns

Mode field diameter of the fundamental mode

Return type

float

fundamental_mode_mfd_petermann_2(wl: float, r: float, na: float)

Calculates the mode field diameter of the fundamental mode with vacuum wavelength freq using the Petermann II equation.

Parameters
  • wl (float) – Wavelength of the mode

  • r (float) – Core radius

  • na (float) – Core numerical aperture

Returns

Mode field diameter of the fundamental mode

Return type

float

fundamental_mode_radius_petermann_2(wl: float, r: float, na: float)

Calculates the fundamental mode radius with vacuum wavelength freq using the Petermann II equation.

Parameters
  • wl (float) – Wavelength of the mode

  • r (float) – Core radius

  • na (float) – Core numerical aperture

Returns

Mode field radius of the fundamental mode

Return type

float

fiber_v_parameter(wl: float, r: float, na: float)

Calculates the V-parameter or normalized frequency of a fiber mode with vacuum wavelength freq.

Parameters
  • wl (float) – Wavelength of the mode

  • r (float) – Core radius

  • na (float) – Core numerical aperture

Returns

V-parameter of the mode

Return type

float

zeta_from_fiber_parameters(core_radius: float, upper_state_lifetime: float, ion_number_density: float)

Calculates the Giles mode’s saturation parameter zeta.

Parameters
  • core_radius (float) – Core radius of the fiber

  • upper_state_lifetime (float) – Lifetime of the excited state

  • ion_number_density (float) – Number density of the dopant ions (1/m^3)

Returns

Saturation parameter zeta

Return type

float

gaussian_peak_power(average_power: float, f_rep: float, fwhm_duration: float)

Calculates the peak input_power of a Gaussian pulse.

Parameters
  • average_power (float) – Average input_power of the pulse signal

  • f_rep (float) – Repetition rate of the pulsed signal

  • fwhm_duration (float) – FWHM duration of the Gaussian pulses

Returns

Peak input_power of the pulses

Return type

float

resample_array(arr, N: int)

Changes the width of an array to N columns by using linear interpolation to each row.

Parameters
  • arr (2D numpy array) – Array to be resized

  • N (int) – Number of columns in the resized array

Returns

The resized array with N colums.

Return type

2D numpy array

linspace_2d(start_vec, end_vec, length: int)

Creates a numpy array with given start and end vectors as first and last columns and a total number of columns specified by “length”. The middle columns are linearly interpolated.

Parameters
  • start_vec (1D numpy array) – First column of the generated array

  • end_vec (1D numpy array) – Last column of the generated array

  • length – Total number of columns in the generated array

Returns

Array interpolated between the start and end vectors

Return type

2D numpy array

expspace_2d(start_vec, end_vec, length: int)

Creates a numpy array with given start and end vectors as first and last columns and a total number of columns specified by “length”. The middle columns are calculated by assuming exponential increase (or decrease).

Parameters
  • start_vec (1D numpy array) – First column of the generated array

  • end_vec (1D numpy array) – Last column of the generated array

  • length – Total number of columns in the generated array

Returns

Array interpolated between the start and end vectors

Return type

2D numpy array

check_signal_reprate(f_rep: float)

Emits a warning if the repetition rate of the signal is too low to be accurately modelled due to pulse-to-pulse gain variations.

Parameters

f_rep (float) – Repetition frequency

dynamic_time_coordinates(max_time_steps: int, z_nodes: int, fiber_length: float, dt='auto')

Returns the time coordinates used in the simulation. Useful for setting time-varying input powers.

Parameters
  • max_time_steps – Number of time steps in the simulation

  • fiber (Subclass of FiberBase) – The fiber used in the simulation

  • z_nodes (int) – Number of spatial nodes used in the simulation.

  • dt (float) – Time step size. The ‘auto’ option uses realistic time step calculated from the Courant condition based on the speed of light in glass and the spatial step size. Larger (and physically unrealistic) time steps can be used to drastically speed up the convergence of steady state simulations.

Returns

Time coordinate array

Return type

numpy float array

averaged_value_of_finite_bandwidth_spectrum(center_frequency: float, frequency_bandwidth: float, spectrum_func)

Function used to calculate the average gain or absorption cross section of a finite bandwidth channel.

to_deg(x)

Radians to degrees

Parameters

x – Angle in radians

Returns

Angle in degrees