Function Reference

Classes

Mode()

Stores properties of a single mode, and has methods for plotting mode. See Mode class for details.

Solution()

Stores a complete fibre solution, including modes and plot of modes, with various methods for coupling in beams and propagating along the fibre. See Solution class for details.

Mode Finding and Handling

lpmodes.find_modes(core_radius, n_core, n_cladding, wavelength)

Finds all LP modes for a step index fibre by finding solutions to the equation:

besselj(l, u) / (u * besselj(l - 1, u))

= besselk(l, w) / (w * besselk(l - 1, w))

where w = sqrt(v^2-u^2) and

v = (2*pi*core_radius/wavelength)*sqrt(core_n^2-cladding_n^2)

Arguments:
core_radiusfloat

radius of the core in microns

n_corefloat

core refractive index

n_claddingfloat

cladding refractive index

wavelengthfloat

wavelength of light in microns

Returns:

Mode : instance of Mode class

lpmodes.power_in_core(mode, grid_size=100, max_plot_radius=None)

Calculates fraction of mode power that lies within core radius. The results will be more accurate if a larger grid_size is used. The max_plot_radius should be significantly larger than the core radius (e.g. 1.5 times as large).

Arguments:
modeinstance of Mode

as created by find_modes

Keyword Arguments:
grid_sizeint

size of plot in pixels (square). Defaults to 100

max_plot_radiusfloat, optional

radial distance at edge of plot, microns. Defaults to 1.5 times the core radius.

Returns:

float : fraction of power in core

lpmodes.find_mode(modes, l, m)

In a list of modes (instances of Mode) returns the mode with the specified l and m values.

Arguments:
modeslist of instances of Mode class

modes as returned by find_modes

lint

azimuthal mode number

mint

radial mode number

Returns:
Modeinstance of Mode class, mode with required l and m

(or None if not present)

lpmodes.find_mode_idx(modes, l, m)

In a list of modes (instances of Mode) find the index of the mode with the specififed l and m values.

Arguments:
modeslist of Mode

modes as returned by find_modes

lint

azimuthal mode number

mint

radial mode number

Rerturns:
idxint

index of required mode (or None if not present)

lpmodes.num_rotated_modes(modes)

Returns number of modes when rotations are counted as separate modes.

Arguments:
modeslist

list of instances of Mode as returned by find_modes

Returns:

int : number of modes

Fibre Properties

lpmodes.est_num_modes(core_radius, n_core, n_cladding, wavelength)

Estimates number of modes supported by a fibre using V number. Includes polarisation modes, so divide by 2 to get close to number of modes that will be found by find_modes (also need to include rotations for modes with m > 1).

Arguments:
core_radiusfloat

radius of the core in microns

n_corefloat

core refractive index

n_claddingfloat

cladding refractive index

wavelengthfloat

wavelength of light in microns

Returns:

int : estimated number of modes

lpmodes.fibre_na(n_core, n_cladding)

Returns NA of fibre with specified core and cladding refractive index

Arguments:
n_corefloat

core refractive index

n_claddingfloat

cladding refractive index

Returns:

float : numerical aperture

lpmodes.acceptance_angle(n_core, n_cladding)

Returns acceptance angle in degrees of fibre with spcecified core and cladding refractive index.

Arguments:
n_corefloat

core refractive index

n_claddingfloat

cladding refractive index

Returns:

float : angle in degrees

Mode and Field Plotting

lpmodes.plot_modes_amplitude(modes, grid_size, max_plot_radius)

Returns ‘plots’ of modes in a list of modes as numpy arrays. Both the cosine and sine versions are returned, as two separate 3D numpy arrays.

Arguments:
modeslist of instances of Mode

list of modes, as returned by find_modes

grid_sizeint

size of plot in pixels (square)

max_plot_radiusfloat

radial distance at edge of plot, microns

Returns:
np.array3D array, plots of sine versions of modes,

ordered (mode, x, y)

np.array3D array, plots of sine versions of modes,

ordered (mode, x, y)

lpmodes.plot_modes_intensity(modes, grid_size, max_plot_radius)

Returns ‘plots’ of intensity of modes in a list of modes as numpy arrays. Both the cosine and sine versions are returned, as two separate 3D numpy arrays.

Arguments:
modeslist of instances of Mode class

list of modes, as returned by find_modes

grid_sizeint

size of plot in pixels (square)

max_plot_radiusfloat

radial distance at edge of plot, microns

Returns:
np.array3D float, plots of intensity of modes, orderd (mode, x, y).

Cosine version

np.array3D float, plots of intensity of modes, orderd (mode, x, y).

Sine version

lpmodes.plot_field(mode_cos, mode_sin, mode_cos_coupling, mode_sin_coupling)

Computes the combined optical field from cosine and sine mode components and their respective couplings.

Arguments:
mode_cosnp.array

3D array of plot of cos components of modes (mode, x, y)

mode_sinlist of np.array

3D array of plot of sin components of modes (mode, x, y)

mode_cos_couplingnp.array

1D Array of coupling coefficients for the cos components of the modes.

mode_sin_couplingnp.array

1D Array of coupling coefficients for the sine components of the modes.

Returns:
np.arrayThe combined optical field as a 2D complex numpy

array (x,y)

lpmodes.vis_all_modes(modes, intensity=False, rotated=False)

Displays matplotlib plot of all modes in a single figure, arranged by l and m.

Arguments:
modeslist of instances of Mode

as created by find_modes

Optional Keyword Arguments:
intensityboolean

If True, intensity of mode will be plotted, otherwise default is to plot complex amplitude

rotatedboolean

If True, the sine version will be plotted, otherwise default it to plot cosine

Returns:

fig : handle to figure

lpmodes.ampcol()

Generates a colour map that is useful for plotting amplitude maps. The colour map runs from red to blue, with white in the middle.

Returns:

LinearSegmentedColormap : colormap

Coupling and Propagation

lpmodes.couple_beam(field, modes, modes_cos, modes_sin)

Determines power from complex field that will be coupled into each mode.

Arguments:
field: np.array

2D complex array representing E-field to be coupled

modes_cosnp.array

plot of cosine version of mode

modes_sinnp.array

plot of sine version of mode

Returns:

np.array : 1D array, amplitude in each cosine version np.array : 1D array, amplitude in each sine version np.array : 1D array, power in each mode

lpmodes.propagate_through_fibre(modes, mode_cos, mode_sin, mode_coupling_cos, mode_coupling_sin, distance, rotations=False)

Propagates the given modes through a fibre over a specified distance, optionally applying mode rotations.

Arguments:
modeslist

A list of mode objects, where each mode has a beta attribute.

mode_cosnp.array

The cosine components of the mode fields.

mode_sinnp.array

The sine components of the mode fields.

mode_coupling_cos: np.array

The initial amplitude coupling into the cosine version of each mode.

mode_coupling_sin: np.array

The initial amplitude coupling into the sine version of each mode.

distancefloat

The distance over which the modes are propagated.

Keyword Arguments:
rotationsbool, optional

If True, random power redistributions between cosine and sine components are applied during propagation. Defaults to False.

Returns:
tuple(np.array, np.array, np.array, np.array)
  • end_field (np.array): The field at the end of the fibre after propagation.

  • end_intensity (np.array): The intensity at the end of the fibre after propagation.

  • end_mode_coupling_cos (np.array): The final amplitude coupling into the cosine version of each mode.

  • end_mode_coupling_sin (np.array): The final amplitude coupling into the sine version of each mode.

lpmodes.mode_coupling_plot(modes, mode_coupling_cos, mode_coupling_sin)

Generates a 2D numpy array to show amplitude in each mode. Array is organied by l and m.

Arguments:
modeslist of instances of Mode

as created by find_modes

mode_coupling_cosnp.array

1D numpy array giving amplitude in the cosine component of each mode

mode_coupling_sinnp.array

1D numpy array giving amplitude in the sine component of each mode

Returns:
mode_couplingnp.array

2D array (l,m) with ampitude in each mode

Field Simulations

lpmodes.tilted_field(grid_size, field_size, wavelength, tilt)

Generates a (square) complex field with a tilt.

Arguments:
grid_sizeint

number of pixels in each direction

field_sizefloat

real size of field in microns

wavelengthfloat

wavelength of light in microns

tiltfloat

tilt of field in radians

Returns:

np.array : 2D complex array containing field

lpmodes.gaussian_field(grid_size, field_size, center, sigma)

Generates a (square) complex Gaussian field.

Arguments:
grid_sizeint

number of pixels in each direction

field_sizefloat

real size of field in microns

centertuple of floats

(x, y) coordinates of the Gaussian center in microns

sigmafloat

standard deviation of the Gaussian in microns

Returns:

np.array : 2D complex array containing field

Import and Export

lpmodes.modes_to_csv(modes, filename, header=True)

Exports the properties of a list of modes to a CSV file. Columns are “u”, “w”, “l”, “m”, “beta”, “n_eff”, “core_radius”, “wavelength”, “n_core”, “n_cladding”

Arguments:
modeslist

A list of instances of Mode class, as returned by find_modes

filenamestr

The path to the CSV file to which the mode data will be written.

Keyword Arguments:
headerbool, optional

If True, writes a header row in the CSV file. Defaults to True.

lpmodes.modes_from_csv(filename, header=True)

Loads the properties of modes from a CSV file and returns a list of mode objects.

Arguments:
filenamestr

The path to the CSV file from which the mode data will be read.

Keyword Arguments:
headerbool, optional

If True, skips the header row in the CSV file. Defaults to True.

Returns:
listA list of instances of Mode class, each corresponding to

a row in the CSV file.