Helper functions

load_spectrum(file_name)

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)

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

wl_bw_to_freq_bw(wl_bw, center_wl)

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

Parameters:
  • wl_bw – 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)

Transforms (vacuum) wavelength to frequency.

freq_to_wl(f)

Transforms frequency to (vacuum) wavelength.

decibel_to_exp(x)

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

exp_to_decibel(x)

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

to_db(x)

Transforms a quantity to decibels.

to_dbm(power)

Transforms a power in Watts to dBm.

fundamental_mode_mfd_marcuse(wl, r, na)

Calculates the mode field diameter of the fundamental mode with vacuum wavelength wl 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, r, na)

Calculates the mode field diameter of the fundamental mode with vacuum wavelength wl 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, r, na)

Calculates the fundamental mode radius with vacuum wavelength wl 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, r, na)

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

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, upper_state_lifetime, ion_number_density)

Calculates the Giles modes 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, f_rep, fwhm_duration)

Calculates the peak power of a Gaussian pulse.

Parameters:
  • average_power (float) – Average 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 power of the pulses

Return type:

float

resample_array(arr, N)

Changes the width of an array to N columns by using linear interpolation to each row. :param arr: Array to be resized :type arr: 2D numpy array :param N: Number of columns in the resized array :type N: int :returns: The resized array with N colums. :rtype: 2D numpy array

linspace_2d(start_vec, end_vec, length)

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)

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)

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, z_nodes, fiber_length, 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, frequency_bandwidth, spectrum_func)

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