pyMMF.IndexProfile.initFromArray#

IndexProfile.initFromArray(n_array)[source]#

Initializes the index profile from a numpy array. Use this function to define a custom index profile.

Parameters:
n_arraynp.ndarray

2d array containing the index values. Each value correspond to a pixel with coordinates given by (self.X, self.Y) in the cartesian coordinate system, or (self.R, self.TH) in the polar coordinate system.

Returns:
None
Parameters:

n_array (ndarray)

Return type:

None

Examples

Square fiber index profile:

import numpy as np
import pyMMF
n1 = 1.45
n2 = 1.44
npoints = 64
core_size = 10
areaSize = 20
profile = pyMMF.IndexProfile(npoints=npoints, areaSize=areaSize)
index_array = n2*np.ones((npoints,npoints))
mask_core = (np.abs(profile.X) < core_size/2) & (np.abs(profile.Y) < core_size/2)
index_array[mask_core] = n1
profile.initFromArray(index_array)