4.1. py_pol package

4.1.1. Submodules

4.1.2. py_pol.drawings module

functions for drawing

py_pol.drawings.draw_ellipse(E, N_angles=91, filename='', figsize=(6, 6), limit='', draw_arrow=True, depol_central=False, depol_contour=False, depol_prob=False, subplots=None, N_prob=256, contour_levels=(0.9, ), cmap='hot')[source]

Draws polarization ellipse of Jones vector.

Parameters:
  • E (Jones_vector or Stokes) – Light object.
  • N_angles (int) – Number of angles to plot the ellipses. Default: 91.
  • limit (float) – limit for drawing. If empty, it is obtained from ampltiudes.
  • filename (str) – name of filename to save the figure.
  • figsize (tuple) – A tuple of length 2 containing the figure size. Default: (8,8).
  • draw_arrow (bool) – If True, draws an arrow containing the turning sense of the polarization. Does not work with linear polarization vectors. Default: True.
  • depol_central (bool) – If True, draws a central circle containing the unpolarized field amplitude. Default: False.
  • depol_contour (bool) – If True, draws a line enveloping the polarization ellipse in ordeer to plot the depolarization. Default: False.
  • depol_dist (bool) – If True, plots the probability distribution of the electric field. Default: False.
  • subplots (string, tuple or None) – If AS_SHAPE, divides the figure in several subplots as the shape of the py_pol object. If INDIVIDUAL, each vector is represented in its own subaxis, trying to use a square grid. If tuple, divides the figure in that same number of subplots. If None, all ellipses are plot in the same axes. Default: None.
  • N_prob (int) – Number of points in each dimension for probability distributions. Default: 256.
  • prob (flota, np.ndarray, tuple or list) – Contains the contour levels (normalized to 1). Default: 0.9.
  • cmap (str or color object) – Default colormap for probability distributions. Default: hot.
Returns:

handle to figure. ax (list of handles): handles to axes.

Return type:

fig (handle)

py_pol.drawings.draw_empty_sphere(ax, angle_view, axis_equal=True)[source]

Fucntion that plots an empty Poincare sphere.

py_pol.drawings.draw_poincare(S, normalize=True, remove_depol=False, kind='scatter', color_scatter='r', color_line='r', angle_view=[0.5, -1], figsize=(6, 6), filename='', subplots=None, axis_equal=True)[source]

Function to draw the poincare sphere. It admits Stokes or a list with Stokes, or None

Parameters:
  • stokes_points (Stokes, list, None) – list of Stokes points.
  • angle_view (float, float) – Elevation and azimuth for viewing.
  • is_normalized (bool) – normalize intensity to 1.
  • kind (str) – ‘line’, ‘scatter’ or ‘both’.
  • color (str) – color of line or scatter.
  • label (str) – labels for drawing.
  • filename (str) – name of filename to save the figure.
  • axis_equal (bool) – If True, the axis_equal method is used. Default: True.
py_pol.drawings.draw_stokes_points(ax, S, I_min=None, I_max=None, D_min=None, D_max=None, normalize=True, remove_depol=False, kind='scatter', color_scatter='Intensity', color_line='r')[source]

Function to draw Stokes vectors on the poincare sphere.

Parameters:
  • S (Stokes) – Stokes object.
  • normalize (bool) – If True, normalize the Stokes vectors to have intensity 1. Default: True.
  • I_min (float) – Minimum intensity among all subplots.
  • I_max (float) – Amximum intensity among all subplots.
  • D_min (float) – Minimum polarization degree among all subplots.
  • D_max (float) – Amximum polarization degree among all subplots.
  • remove_depol (bool) – If True, plot the polarized part of the Stokes vector. Default: False.
  • kind (str) – Plot type: LINE, SCATTER or BOTH. Default: SCATTER.
  • color_scatter (str) – There are three options. INTENSITY sets the color of the points intensity dependent. DEGREE sets the color to match the polarization degree. Another posibility is to use valid color strings such as ‘r’. Default: INTENSITY.
  • color_line (str) – Only valid color strings such as ‘r’. Default: ‘r’.

Returns:

4.1.3. py_pol.jones_matrix module

class py_pol.jones_matrix.Analysis_Jones_Matrix(Jones_matrix)[source]

Bases: object

Class for Jones matrix analysis.

Parameters:
  • self.parent (Jones_matrix) – Parent object.
  • self.dict_params (dict) – dictionary with parameters
decompose_pure(decomposition='RP', all_info=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False, transmissions='all', angles='all')[source]

Polar decomposition of a pure Mueller matrix in a retarder and a diattenuator.

References

“Homogeneous and inhomogeneous Jones matrices”, S.Y. Lu and R.A. Chipman, J. Opt. Soc. Am. A/Vol. 11, No. 2 pp. 766 (1994)

Parameters:
  • decomposition (string) – string with the order of the elements: retarder (R) or diattenuator/polarizer (D or P).
  • all_info (bool) – If True, the method returns the information regarding each condition separately. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
Returns:

Jones matrix object of the retarder. Jd (Jones_matrix): Jones matrix object of the diattenuator. dict_param (dictionary): Dictionary with the 9 parameters (7 independent) of both the retarder and the diattenuator (only if all_info = True).

Return type:

Jr (Jones_matrix)

diattenuator(transmissions='all', angles='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Analyzes the properties of the optical objects as a diattenuator.

Parameters:
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Dictionary of parameters.

Return type:

dict_param (dictionary)

get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Jones Matrix.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.

TODO

Returns:Dictionary with parameters of Jones Matrix.
Return type:(dict)
polarizer(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Analyzes the properties of the optical objects as a polarizer. In Jones formalism, this is the same as analyzing the element as a diattenuator.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Dictionary of parameters.

Return type:

dict_param (dictionary)

retarder(angles='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Analyzes the properties of the optical objects as a retarder.

Parameters:
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Dictionary of parameters.

Return type:

dict_param (dictionary)

class py_pol.jones_matrix.Checks_Jones_Matrix(Jones_matrix)[source]

Bases: object

Class for Jones matrix checks.

Parameters:
  • self.parent (Jones_matrix) – Parent object.
  • self.dict_params (dict) – dictionary with parameters
get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Jones Matrix.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
Returns:

Dictionary with parameters of Jones Matrix.

Return type:

(dict)

is_conjugate_symmetric(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if the object matrix is conjugate symmetric (i.e. $$J = J^{dagger}$$).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_diattenuator(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if matrix is an homogeneous diattenuator. The condition is that the Jones matrix must be hermitian ($$J^{dagger}=J$$).

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 123.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_homogeneous(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if matrix is homogeneous (the two eigenstates are orthogonal) or not.

References

“Homogeneous and inhomogeneous Jones matrices”, S.Y. Lu and R.A. Chipman, J. Opt. Soc. Am. A/Vol. 11, No. 2 pp. 766 (1994)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_physical(all_info=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Verifies that is a Jones matrix is physically realizable. Take into account that amplifiers are not included in this category.

References

  1. Martinez-Herrero, P.M. Mejias, G.Piquero “Characterization of partially polarized light fields” Springer series in Optical sciences (2009) ISBN 978-3-642-01326-3, page 3, eqs. 1.4a and 1.4b.
Parameters:
  • all_info (bool) – If True, the method returns the information regarding each condition separately. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_polarizer(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if matrix is an homogeneous polarizer. In Jones formalism, there is no difference between homogeneous diattenuators and polarizers.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_retarder(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if matrix is an homogeneous retarder. The condition is that the Jones matrix must be unitary ($$J^{dagger}=J^{-1}$$).

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 123.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_symmetric(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if the object matrix is symmetric (i.e. $$J = J^T$$).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

class py_pol.jones_matrix.Jones_matrix(name='J')[source]

Bases: object

Class for Jones matrices.

Parameters:
  • M (np.ndarray) – 2x2xN array containing all the Jones matrices.
  • name (string) – Name of the object for print purposes.
  • shape (tuple or list) – Shape desired for the outputs.
  • size (int) – Number of stored Jones matrices.
  • ndim (int) – Number of dimensions for representation purposes.
  • no_rotation (bool) – If True, rotation method do not act upon the object. Useful for objects that shouldn’t be rotated as mirrors.
  • _type (string) – Type of the object (‘Jones_matrix’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
self.parameters

parameters of the Jones matrices.

Type:class
self.checks

checks of the Jones matrices.

Type:class
self.analysis

analysis of the Jones matrices.

Type:class
add_global_phase(global_phase=0, keep=False, length=1, shape_like=None, shape=None)[source]

Function that adds a phase to the Jones matrix.

Parameters:
  • global_phase (float or np.ndarray) – Phase to be added to the Jones matrix. Default: 0.
  • keep (bool) – if True, self is not updated. Default: False.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Recalculated Jones matrix.

Return type:

(Jones_matrix)

clear()[source]

Removes data and name from Jones matrix.

Returns:Result.
Return type:(Jones_matrix)
copy(N=1)[source]

Creates a copy of the object.

Parameters:N (int) – Number of copies. Default: 1.
Returns:Result.
Return type:(Jones_matrix)
diattenuator_azimuth_ellipticity(p1=1, p2=0, Tmax=None, Tmin=None, azimuth=0, ellipticity=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the general diattenuator with orthogonal eigenstates from the characteristic angles of the main eigenstate.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 137.

Parameters:
  • p1 (float or numpy.ndarray) – [0, 1] Square root of the higher transmission for one eigenstate. Default: 1.
  • p2 (float or numpy.ndarray) – [0, 1] Square root of the lower transmission for the other eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • azimuth (float) – [0, pi]: Azimuth. Default: 0.
  • ellipticity (float) – [-pi/4, pi/]: Ellipticity angle. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

diattenuator_charac_angles(p1=1, p2=0, Tmax=None, Tmin=None, alpha=0, delay=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general homogenous diattenuator with orthogonal eigenstates from the characteristic angles of the main eigenstate.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 137.

Parameters:
  • p1 (float or numpy.ndarray) – Electric field transmission coefficient of the transmission eigenstate. Default: 1.
  • p2 (float or numpy.ndarray) – [0, 1] Square root of the lower transmission for the other eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • alpha (float or numpy.ndarray) – [0, pi/2]: tan(alpha) is the ratio between field amplitudes of X and Y components. Default: 0.
  • delay (float or numpy.ndarray) – [0, 2*pi]: phase difference between X and Y field components. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

diattenuator_linear(p1=1, p2=0, Tmax=None, Tmin=None, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a real polarizer with perpendicular axes:

\[J\left( heta=0\]
ight)=left[egin{array}{cc}
p_{1} & 00 & p_{2} end{array}

ight]’.

Parameters:
p1 (float or numpy.ndarray): Electric field transmission coefficient of the transmission eigenstate. Default: 1. p2 (float or numpy.ndarray): Electric field transmission coefficient of the extinction eigenstate. Default: 0. Tmax (float or numpy.ndarray): Maximum transmission. If not None, overrides p1. Default: None. Tmax (float or numpy.ndarray): Minimum transmission. If not None, overrides p1. Default: None. azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Jones_matrix): Created object.
diattenuator_perfect(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a perfect diattenuator (polarizer).

Parameters:
  • azimuth (float or numpy.ndarray) – rotation angle of the high transmission polarizer axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

diattenuator_retarder_azimuth_ellipticity(p1=1, p2=1, Tmax=None, Tmin=None, R=0, azimuth=0, ellipticity=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general homogenous diattenuator retarder from the azimuth and ellipticity of the fast eigenstate.

Parameters:
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • azimuth (float or numpy.ndarray) – rotation angle of the high transmission polarizer axis. Default: 0.
  • ellipticity (float) – [-pi/4, pi/]: Ellipticity angle. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

diattenuator_retarder_charac_angles(p1=1, p2=1, Tmax=None, Tmin=None, R=0, alpha=0, delay=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general homogenous diattenuator retarder from the characteristic angles of the fast eigenstate.

Parameters:
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • alpha (float or numpy.ndarray) – [0, pi/2]: tan(alpha) is the ratio between field amplitudes of X and Y components. Default: 0.
  • delay (float or numpy.ndarray) – [0, 2*pi]: phase difference between X and Y field components. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

diattenuator_retarder_linear(p1=1, p2=1, Tmax=None, Tmin=None, R=0, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]
Creates a linear diattenuator retarder with the same

axes for diattenuation and retardance. At 0 degrees, the matrix is of the form:

\[J\left( heta=0\]
ight)=left[egin{array}{cc}
p_{1} & 00 & p_{2}e^{i R} end{array}

ight]’.

Parameters:
p1 (float or numpy.ndarray): Field transmission of the fast axis. Default: 1. p2 (float or numpy.ndarray): Electric field transmission coefficient of the extinction eigenstate. Default: 0. Tmax (float or numpy.ndarray): Maximum transmission. If not None, overrides p1. Default: None. Tmax (float or numpy.ndarray): Minimum transmission. If not None, overrides p1. Default: None. R (float or numpy.ndarray): Retardance. Default: 0. azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Jones_matrix): Created object.
filter_amplifier(D=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Jones matrix of neutral filters or amplifiers.

Parameters:
  • D (float or numpy.ndarray) – Attenuation (gain if > 1). Default: 1.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

flip(axis=None, keep=False, change_name=True)[source]

Flips the elements stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the flip is performed. If None, the object is flipped as flattened. Default: None.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

from_Mueller(M, length=1, shape_like=None, shape=None)[source]

Converts a pure Mueller matrix into Jones matrix object. Elements of Mueller object which are not pure are converted into NaN values. The values are found inverting the equation:

\[M(J)=\left[egin{array}{cccc} 1 & 0 & 0 & 1\ 1 & 0 & 0 & -1\ 0 & 1 & 1 & 0\ 0 & i & -i & 0 \end{array}\]

ight]left(Jotimes J^{*} ight)left[egin{array}{cccc}

1 & 0 & 0 & 11 & 0 & 0 & -10 & 1 & 1 & 00 & i & -i & 0 end{array}

ight]^{-1}

References:
Handbook of Optics vol 2. 22.36 (52-54)
Parameters:
M (Mueller): Mueller object. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (float or numpy.ndarray): Use the shape of this array. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Jones_matrix): Created object.
from_components(components, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Jones matrix object form the arrays of electric field components.

Parameters:
  • components (tuple or list) – A 4 element tuple containing the 4 components of the Jones matrices (J00, J01, J10, J11).
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones matrix. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

from_list(l, shape_like=None, shape=None)[source]

Create a Jones_matrix object from a list of size 2x2 arrays.

Parameters:
  • l (list) – list of matrices.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

from_matrix(M, global_phase=0, length=1, shape_like=None, shape=None)[source]

Create a Jones_matrix object from an external array.

Parameters:
  • M (numpy.ndarray) – New matrix. At least two dimensions must be of size 2.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones matrix. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

general_eigenstates(E1, E2=None, p1=1, p2=1, Tmax=None, Tmin=None, R=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general optical element from its eigenstates.

Parameters:
  • E1 (Jones_vector) – First eigenstate.
  • E2 (Jones_vector) – Second eigenstate. If None, E2 is taken as the perpendicular state to E1, so the optical object is homogenous.
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

get_list(out_number=True)[source]

Returns a list of 2x2 Jones matrices.

Parameters:out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
Returns:(numpy.ndarray or list)
half_waveplate(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones matrix of an ideal half-waveplate \(\lambda/2\).

Parameters:
  • azimuth (float or numpy.ndarray) – rotation angle of the fast state axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

hermitian(keep=False, global_phase=0, length=1, shape_like=None, shape=None, change_name=True)[source]

Calculates the hermitian conjugate matrix of the Mueller matrix.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

inverse(keep=False, global_phase=0, length=1, shape_like=None, shape=None, change_name=True)[source]

Calculates the inverse matrix of the Jones matrix.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

mirror(ref=1, ref_field=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones matrix of a mirror.

Parameters:
  • ref (float or numpy.ndarray) – Intensity reflectivity of the mirror. Default: 1.
  • ref_field (float or numpy.ndarray) – Electric field reflectivity coefficient. If not None, it overrides REF. Default: None.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

prod(axis=None, keep=False, change_name=True)[source]

Calculates the product of Jones matrices stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the product is performed. If None, all matrices are multiplied.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

quarter_waveplate(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones matrix of an ideal quarter-waveplate \(\lambda/4\)..

Parameters:
  • azimuth (float or numpy.ndarray) – rotation angle of the fast state axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

reciprocal(keep=False, global_phase=0, length=1, shape_like=None, shape=None, change_name=True)[source]

Calculates the recirpocal of the optical element, so the light tranverses it in the opposite direction. It is calculated as:

\[J^{r}=\left[egin{array}{cc} 1 & 0\ 0 & -1 \end{array}\]
ight]J^{T}left[egin{array}{cc}
1 & 00 & -1 end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 106.
Parameters:
keep (bool): If True, the original element is not updated. Default: False. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. change_name (bool): If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:
(Jones_matrix): Result.
remove_global_phase(keep=False, length=1, shape_like=None, shape=None)[source]

Function that transforms the Jones vector removing the global phase, so J00 is real and positive.

Parameters:
  • keep (bool) – If True, self is not updated. Default: False.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Simplified Jones matrix.

Return type:

(Jones_matrix)

retarder_azimuth_ellipticity(R=1.5707963267948966, azimuth=0, ellipticity=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Function that calculates the most general homogeneous diattenuator from the characteristic angles of the fast eigenstate.

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 125.

Parameters:
  • R (float) – [0, pi] Retardance (delay between components). Default: 90 degrees.
  • azimuth (float) – [0, pi]: Azimuth. Default: 0.
  • ellipticity (float) – [-pi/4, pi/4]: Ellipticity. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

retarder_charac_angles(R=1.5707963267948966, alpha=0, delay=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Function that calculates the most general homogeneous diattenuator from the characteristic angles of the fast eigenstate.

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 125.

Parameters:
  • R (float) – [0, pi] Retardance (delay between components). Default: 90 degrees.
  • alpha (float) – [0, pi/2]: tan(alpha) is the ratio between amplitudes of the eigenstates in Jones formalism. Default: 0.
  • delay (float) – [0, 2*pi]: phase difference between both components of the eigenstates in Jones formalism. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

retarder_linear(R=1.5707963267948966, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a linear retarder.

Parameters:
  • R (float) – [0, pi] Retardance (delay between components). Default: 90 degrees.
  • azimuth (float or numpy.ndarray) – rotation angle of the fast state axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

retarder_material(ne=1, no=1, d=1.0, wavelength=0.6328, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates aretarder using the physical properties of an anisotropic material.

\[\phi = 2 \pi (n_e-n_o) d / \lambda.\]
Parameters:
  • ne (float or numpy.ndarray) – extraordinary index. Default: 1.
  • n0 (float or numpy.ndarray) – ordinary index. Default: 1.
  • d (float or numpy.ndarray) – thickness of the sheet in microns. Default: 1 um.
  • wavelength (float or numpy.ndarray) – wavelength of the illumination. Default: 0.6328 um.
  • azimuth (float or numpy.ndarray) – rotation angle of the fast state axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

rotate(angle=0, keep=False, change_name=True)[source]

Rotates a jones_matrix a certain angle:

M_rotated = R(-angle) * self.M * R(angle)

Parameters:
  • angle (float) – Rotation angle in radians.
  • keep (bool) – If True, the original element is not updated. Default: False.
  • change_name (bool) – If True and angle is of size 1, changes the object name adding @ XX deg, being XX the total rotation angle. Default: True.
Returns:

Rotated Jones matrix.

Return type:

(Jones_matrix)

set_global_phase(global_phase=0, keep=False, length=1, shape_like=None, shape=None)[source]

Function that sets the phase of the Jones matrix.

Parameters:
  • global_phase (float or np.ndarray) – Phase to be added to the Jones matrix. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Recalculated Jones matrix.

Return type:

(Jones_matrix)

shape_like(obj)[source]

Takes the shape of an object to use in the future.

Parameter:
obj (py_pol object or nd.array): Object to take the shape.
Returns:Result.
Return type:(Jones_matrix)
stretch(length, keep=False, shape=None, shape_like=None)[source]

Function that stretches a Jones matrix to have a higher number of equal elements.

Parameters:
  • length (int) – Number of elements.
  • keep (bool) – If True, self is not updated. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

sum(axis=None, keep=False, change_name=True)[source]

Calculates the sum of Jones matrices stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the summatory is performed. If None, all matrices are summed.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

transpose(keep=False, global_phase=0, length=1, shape_like=None, shape=None, change_name=True)[source]

Calculates the transposed matrices of the Jones matrices.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

update()[source]

Internal function. Updates self.parameters with values of self.

vacuum(global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the matrix for vacuum i.e., an optically neutral element.

Parameters:
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones matrix. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

class py_pol.jones_matrix.Parameters_Jones_Matrix(Jones_matrix)[source]

Bases: object

Class for Jones Matrix Parameters.

Parameters:
  • self.parent (Jones_matrix) – Parent object.
  • self.dict_params (dict) – dictionary with parameters
components(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Extracts the matrix components of the Jones matrix.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

array of the 0, 0 element of the matrix. J01 (numpy.ndarray): array of the 0, 1 element of the matrix. J10 (numpy.ndarray): array of the 1, 0 element of the matrix. J11 (numpy.ndarray): array of the 1, 1 element of the matrix.

Return type:

J00 (numpy.ndarray)

det(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the determinants of the Jones matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray, float or complex)

diattenuation(remove_nan=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculation of the diattenuation of a Jones Matrix.

References

“Homogeneous and inhomogeneous Jones matrices”, S.Y. Lu and R.A. Chipman, J. Opt. Soc. Am. A/Vol. 11, No. 2 pp. 766 (1994)

Parameters:
  • remove_nan (bool) – If True, np.nan values are substitued by 0. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Diattenuation.

Return type:

D (numpy.ndarray or float)

eig(as_objects=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenvalues and eigenstates of the Jones object.

Parameters:
  • as_objects (bool) – If True, the eigenvectors are extracted as py_pol objects. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

First eigenvalue. v2 (numpy.ndarray or float): Second eigenvalue. e1 (numpy.ndarray or Jones_vector): First eigenstate. e2 (numpy.ndarray or Jones_vector): Second eigenstate.

Return type:

v1 (numpy.ndarray or float)

TODO: Maybe give values and states together as a matrix

eigenstates(shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenstates of the Jones object. Very similar to eigenvectors, but the output are Jones_vector objects.

Parameters:
  • out_Jones (bool) – If True, the output eigenstates are Jones_vector objects. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

First eigenstate. e2 (Jones_vector): Second eigenstate.

Return type:

e1 (Jones_vector)

eigenvalues(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenvalues and eigenstates of the Jones object.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

First eigenvalue. v2 (numpy.ndarray or float): Second eigenvalue.

Return type:

v1 (numpy.ndarray or float)

eigenvectors(shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenstates of the Jones object.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

2xN first eigenvectors matrix. e2 (numpy.ndarray): 2xN second eigenvectors matrix.

Return type:

e1 (numpy.ndarray)

get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Jones Matrix.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
Returns:

Dictionary with parameters of Jones Matrix.

Return type:

(dict)

global_phase(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the phase of J00 (which is the reference for global phase in py_pol model).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Global phase.

Return type:

(numpy.ndarray) [0, 2*pi]

inhomogeneity(method='val', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the inhomogeneity parameter.

References

Method EIG: J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 119. Method VAL: “Homogeneous and inhomogeneous Jones matrices”, S.Y. Lu and R.A. Chipman, J. Opt. Soc. Am. A/Vol. 11, No. 2 pp. 766 (1994)

Parameters:
  • method (string) – Method used for the calculation of the inhomogeneity parameter: EIG uses the eigenstates and VAL uses determinant, norm and trace.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Inhomogeneity parameter.

Return type:

eta (numpy.ndarray or float)

matrix(shape=None, shape_like=None)[source]

Returns the numpy array of Jones matrices.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

(numpy.ndarray) 2x2xN numpy array.

mean_transmission(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculate the mean intensity transmitance of an optical element.

References

Handbook of Optics vol 2. 22.32 (eq.38)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result

Return type:

(numpy.ndarray) [0, 1]

norm(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the Frobenius norm of the Jones matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray, float or complex)

polarizance(remove_nan=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculation of the polarizance of the Jones matrices. In Jones formalism, this is the same as diattenuation.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Polarizance.

Return type:

P (numpy.ndarray or float)

retardance(remove_nan=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculation of the retardance (delay between eigenstates) of a Jones optical element.

References

“Homogeneous and inhomogeneous Jones matrices”, Shih-Yau Lu and Russell A. Chipman, J. Opt. Soc. Am. A/Vol. 11, No. 2 pp. 766 (1994)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Retardance.

Return type:

R (numpy.ndarray or float)

trace(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the trace of the Jones matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray, float or complex)

transmissions(kind='Intensity', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculate the maximum and minimum transmitance of an optical element.

References

Handbook of Optics vol 2. 22.32 (eq.38)

Parameters:
  • kind (str) – There are three options, FIELD, INTENSITY or ALL.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Maximum intensity transmission. T_min (numpy.ndarray): Minimum intensity transmission. p1 (numpy.ndarray): Maximum field transmission. p2 (numpy.ndarray): Minimum field transmission.

Return type:

T_max (numpy.ndarray)

py_pol.jones_matrix.create_Jones_matrices(name='J', N=1, out_object=True)[source]

Function that creates several Jones_matrix objects at he same time from a list of names or a number.

Parameters:
  • M (np.ndarray) – 2xN array containing all the Jones matrices.
  • name (string) – Name of the object for print purposes.
  • shape (tuple or list) – Shape desired for the outputs.
  • size (int) – Number of stores Jones matrices.
  • ndim (int) – Number of dimensions for representation purposes.
  • _type (string) – Type of the object (‘Jones_matrix’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
self.parameters

Class containing the measurable parameters of the Jones matrices.

Type:class
self.checks

Class containing the methods that check something about the Jones matrices.

Type:class
py_pol.jones_matrix.set_printoptions(N_list=None, list_spaces=None)[source]

Function that modifies the global print options parameters.

Parameters:
  • N_print_list (int) – Number of matrices that will be printed as a list if the shape of the object is 1D.
  • print_list_spaces (int) – Number ofspaces between matrices if they are printed as a list.

4.1.4. py_pol.jones_vector module

We present a class for polarization using Jones framework:

Class fields
  • M: 2xN array containing all the Jones vectors.
  • name: Name of the object for print purposes.
  • shape: Shape desired for the outputs.
  • size: Number of stores Jones vectors.
  • _type: Type of the object (‘Jones_vector’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
  • parameters: Object of class Parameters_Jones_vector.
  • checks: Object of class Checks_Jones_vector.
Generation methods
  • from_components: Creates a Jones_vector object directly from the electric field components $E_x$ and $E_y$.
  • from_matrix: Creates a Jones_vector object directly from a 2 x shape numpy array.
  • from_list: Creates a Jones_vector object directly from a list of 2 or 2x1 numpy arrays.
  • from_distribution: Creates a Jones vector from the temporal evolution of the electric field components.
  • from_Stokes: Creates a Jones vector from a Stokes object. Take into account that only pure (totally polarized) Stokes vectors must be transformed to Jones vectors, and thet even for them, the global phase might be unknown.
  • linear_light: Creates a state of linear polarization with the desired angle.
  • circular_light: Creates a state of circular polarization.
  • eliptical_light: Creates a state of eliptical polarization.
  • general_azimuth_ellipticity: Creates a Jones vector from the azimuth, ellipticity and amplitude parameters.
  • general_charac_angles: Creates a Jones vector from the characteristic angles and amplitude parameters.
Manipulation methods
  • clear: Removes data and name form Jones vector.
  • copy: Creates a copy of the Jones_vector object.
  • stretch: Stretches a Jones vector of size 1.
  • shape_like: Takes the shape of another object to use as its own.
  • simplify: Simplifies the Jones vector in several ways.
  • rotate: Rotates the Jones vector.
  • sum: Calculates the summatory of the Jones vectors in the object.
  • flip: Flips the object along some dimensions.
  • reciprocal: Calculates the Jones vector that propagates backwards.
  • orthogonal: Calculates the orthogonal Jones vector.
  • normalize: Normalize the electric field to be normalized in electric field amplitude or intensity.
  • rotate_to_azimuth: Rotates the Jones vector to have a certain azimuth.
  • remove_global_phase: Calculates the global phase of the electric field (respect to the X component) and removes it.
  • add_global_phase: Adds a global phase to the Jones vector.
  • set_global_phase: Sets the global phase of the Jones vector.
  • add_delay: Adds a phase to the Y component of the electric field of the Jones vector.
  • draw_ellipse: Draws the polarization ellipse of the Jones vector.
Parameters subclass methods
  • matrix: Gets a numpy array with all the vectors.
  • components: Calculates the electric field components of the Jones vector.
  • amplitudes: Calculates the electric field amplitudes of the Jones vector.
  • intensity: Calculates the intensity of the Jones vector.
  • irradiance: Calculates the irradiance of the Jones vector.
  • alpha: Calculates the ratio between electric field amplitudes ($E_x$/$E_y$).
  • delay / delta: Calculates the delay (phase shift) between Ex and Ey components of the electric field.
  • charac_angles: Calculates both alpha and delay, the characteristic angles of the Jones vector.
  • azimuth: Calculates azimuth, that is, the orientation angle of the major axis.
  • ellipticity_angle: Calculates the ellipticity angle.
  • azimuth_ellipticity: Calculates both azimuth and ellipticity angles.
  • ellipse_axes: Calculates the length of major and minor axis (a,b).
  • ellipticity_param: Calculates the ellipticity parameter, b/a.
  • eccentricity: Calculates the eccentricity, the complementary of the ellipticity parameter.
  • global_phase: Calculates the global phase of the Jones vector (respect to the X component of the electric field).
  • degree_linear_polarization: Calculates the degree of linear polarization of the Jones vector.
  • degree_circular_polarization: Calculates the degree of circular polarization of the Jones vector.
  • norm: Calculates the norm of the Jones vector.
  • get_all: Returns a dictionary with all the parameters of Jones vector.
Checks subclass methods
  • is_linear: Checks if the Jones vector is lienarly polarized.
  • is_circular: Checks if the Jones vector is circularly polarized.
  • is_right_handed: Checks if the Jones vector rotation direction is right handed.
  • is_left_handed: Checks if the Jones vector rotation direction is left handed.
  • get_all: Returns a dictionary with all the checks of Jones vector.
Auxiliar functions
  • create_Jones_vectors: Function to create several Jones_vector objects at once.
class py_pol.jones_vector.Checks_Jones_Vector(Jones_vector)[source]

Bases: object

Class for Jones vector checks.

Parameters:jones_vector (Jones_vector) – Parent object.
self.parent

Parent object.

Type:Jones_vector
get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the checks of Jones vector.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
Returns:

Dictionary with parameters of Jones vector.

Return type:

(dict)

is_circular(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Jones vector is circularly polarized.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_left_handed(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Jones polarization rotation direction is left-handed.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_linear(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Jones vector is linearly polarized.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_right_handed(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Jones polarization rotation direction is right-handed.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

class py_pol.jones_vector.Jones_vector(name='E')[source]

Bases: object

Class for Jones vectors.

Parameters:
  • M (np.ndarray) – 2xN array containing all the Jones vectors.
  • name (string) – Name of the object for print purposes.
  • shape (tuple or list) – Shape desired for the outputs.
  • size (int) – Number of stores Jones vectors.
  • ndim (int) – Number of dimensions for representation purposes.
  • _type (string) – Type of the object (‘Jones_vector’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
self.parameters

Class containing the measurable parameters of the Jones vectors.

Type:class
self.checks

Class containing the methods that check something about the Jones vectors.

Type:class
add_delay(delay=0, keep=False)[source]

Function that adds a phase to the Y component of the electric field of the Jones vector.

Parameters:
  • delay (float or np.ndarray) – Phase to be added to the Y component of the Jones vector. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

add_global_phase(phase=0, keep=False)[source]

Function that adds a phase to the Jones vector.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Jones vector. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

circular_light(kind='d', amplitude=None, intensity=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones vector for polarizer circular light

Parameters:
  • kind (str) – ‘d’,’r’ - right, dextro. ‘l’, ‘i’ - left, levo.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

clear()[source]

Removes data and name form Jones vector.

copy(N=1)[source]

Creates a copy of the object.

Parameters:N (int) – Number of copies. Default: 1.
Returns:Copied Jones vector object.
Return type:(Jones_vector or list)
draw_ellipse(*args, **kwargs)[source]

Draws polarization ellipse of Jones vector.

Parameters:
  • N_angles (int) – Number of angles to plot the ellipses. Default: 91.
  • filename (str) – name of filename to save the figure.
  • figsize (tuple) – A tuple of length 2 containing the figure size.
  • limit (float) – limit for drawing. If empty it is obtained from amplitudes.
  • draw_arrow (bool) – If True, draws an arrow containing the turning sense of the polarization. Does not work with linear polarization vectors. Default: True.
  • subplots (string, tuple or None) – If AS_SHAPE, divides the figure in several subplots as the shape of the py_pol object. If INDIVIDUAL, each vector is represented in its own subaxis, trying to use a square grid. If tuple, divides the figure in that same number of subplots. If None, all ellipses are plot in the same axes. Default: None.
Returns:

handle to axis. fig (handle): handle to figure.

Return type:

ax (handle)

elliptical_light(a=1, b=1, kind='r', azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones vector of the most general light calculated from the polarization ellipse parameters.

Parameters:
  • a (numpy.array or float) – Array of electric amplitude of x axis. Default: 1.
  • b (numpy.array or float) – Array of electric amplitude of y axis. Default: 1.
  • kind (str) – ‘d’,’r’ - right, dextro. ‘l’, ‘i’ - left, levo.
  • azimuth (numpy.array or float) – Angle of the a axis respect to the x axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

flip(axis=None, keep=False, change_name=True)[source]

Flips the elements stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the flip is performed. If None, the object is flipped as flattened. Default: None.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_vector)

from_Stokes(S, shape_like=None, shape=None, verbose=False)[source]

Create a Jones vector from a Stokes vector. This operation is only meaningful for pure (totally polarized) Stokes vectors. For the rest of them, only the polarized part is transformed, and a warning is printed.

Parameters:
  • S (Stokes) – Stokes vector object.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
Returns:

Created object.

Return type:

(Jones_vector)

from_components(Ex, Ey=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Jones vector object form the arrays of electric field components.

Parameters:
  • Ex (numpy.array, float or 2x1 tuple/list) – Electric field amplitude along x axis. This variable can also be a 2x1 tuple or list containing both Ex and Ey.
  • Ey (numpy.array or float) – Electric field amplitude along x axis.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

from_distribution(Ex, Ey, ind_d=-1, method='direct', N_periods=1, shape_like=None, shape=None)[source]

Determine Jones vector from a temporal or spatial electric field distribution [(Ex(t), Ey(t)].

Parameters:
  • Ex (numpy.ndarray or float) – X component of the electric field
  • Ey (numpy.ndarray or float) – Y component of the electric field
  • ind_d (int) – Index of the spatial or temporal dimension. Default: -1.
  • method (string) – Method for calculating the field amplitude and delay: DIRECT or FIT. Default: direct.
  • N_periods (float) – Number of periods in the representation data. It is used by the fit algorithm (real case only) for calculating the frequency. If the value is not exact, convergency may decrease. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

from_list(l, shape_like=None, shape=None)[source]

Create a Jones_vector object from a list of size 2 or 2x1 arrays.

Parameters:
  • l (list) – list of vectors.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

from_matrix(M, shape_like=None, shape=None)[source]

Create a Jones vector from an external matrix.

Parameters:
  • M (numpy.ndarray or float) – New matrix.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

general_azimuth_ellipticity(azimuth=0, ellipticity=0, amplitude=None, intensity=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones vector from azimuth, ellipticity angle and amplitude parameters.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 137.

Parameters:
  • azimuth (numpy.array or float) – [0, pi]: Azimuth. Default: 0.
  • ellipticity (numpy.array or float) – [-pi/4, pi/4]: Ellipticity angle. Default: 0.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

general_charac_angles(alpha=0, delay=0, amplitude=None, intensity=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones vector from characteristic angles and amplitude parameters.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 137.

Parameters:
  • alpha (numpy.ndarray or float) – Ratio between amplitude of components Ex/Ey of electric field. Default:0
  • delay (numpy.ndarray or float) – Phase delay between Ex and Ey components of the electric field. Default: 0.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

get_list(out_number=True)[source]

Returns a list of 2x1 Jones vectors.

Parameters:out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
Returns:Created object.
Return type:(numpy.ndarray or list)
linear_light(amplitude=None, azimuth=0, intensity=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Jones vector for polarizer linear light.

Parameters:
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • azimuth (numpy.array or float) – Array of azimuths. Default: 0.
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones vector. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

normalize(kind='amplitude', keep=False)[source]

Function that normalizes the Jones vectors in amplitude or intensity.

Parameters:
  • kind (string) – Field amplitude or intensity. Default: AMPLITUDE.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Normalized Jones vector.

Return type:

(Jones_vector)

orthogonal(keep=False, change_name=True)[source]

Calculates the orthogonal of the Jones vector.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 125.

Parameters:
  • keep (bool) – If True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Reciprocal Jones matrix.

Return type:

(Jones_vector)

reciprocal(keep=False, change_name=True)[source]

Calculates the recirpocal of the Jones vector, so the light is propagated in the opposite direction. It is calculated as Ey = -Ey.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp TODO.

Parameters:
  • keep (bool) – If True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Reciprocal Jones matrix.

Return type:

(Jones_vector)

remove_global_phase(keep=False)[source]

Function that transforms the Jones vector removing the global phase, so the first component of the elcric field is real and positive.

Parameters:keep (bool) – If True, self is not updated. Default: False.
Returns:Recalculated Jones vector.
Return type:(Jones_vector)
rotate(angle=0, keep=False, change_name=True)[source]

Rotates a jones vector a certain angle.

M_rotated = rotation_matrix_Jones(-angle) * self.M

Parameters:
  • angle (float) – Rotation angle in radians.
  • keep (bool) – If True, the original element is not updated. Default: False.
  • change_name (bool) – If True and angle is of size 1, changes the object name adding @ XX deg, being XX the total rotation angle. Default: True.
Returns:

Rotated object.

Return type:

(Jones_vector)

rotate_to_azimuth(azimuth=0, keep=False)[source]

Function that rotates the Jones vector to have a certain azimuth.

Parameters:
  • azimuth (string or np.ndarray) – Azimuth of the Jones vector. ‘X’, ‘Y’, ‘-X’ and ‘-Y’ are the same as 0, 90, 180 and 270 degrees respectively. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Normalized Jones vector.

Return type:

(Jones_vector)

set_global_phase(phase=0, keep=False)[source]

Function that sets the phase of the Jones vector.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Jones vector. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

shape_like(obj)[source]

Takes the shape of an object to use in the future.

Parameter:
obj (py_pol object or nd.array): Object to take the shape.
stretch(length=1, keep=False)[source]

Function that stretches a Jones vector to have a higher number of equal elements.

Parameters:
  • length (int) – Number of elements. Default: 1.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

sum(axis=None, keep=False, change_name=True)[source]

Calculates the sum of Jones vectors stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the summatory is performed. If None, all matrices are summed.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_vector)

update()[source]

Internal function. Checks that the .M dimensions are correct.

class py_pol.jones_vector.Parameters_Jones_Vector(Jones_vector)[source]

Bases: object

Class for Jones vector parameters.

Parameters:jones_vector (Jones_vector) – Jones Vector
self.M
Type:Jones_vector
alpha(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the angle ratio between amplitude of components Ex/Ey of electric field.

References

  1. Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.3-35
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the electric field amplitude in x axis. E0y (numpy.ndarray or float): Array of the electric field amplitude in y axis.

Return type:

E0x (numpy.ndarray or float)

amplitudes(give_Ez=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the x and y field amplitudes of the Jones vector.

Parameters:
  • give_Ez (bool) – If True, it returns the z component of the electric field (all values will be 0). Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of electric field amplitude along x axis. E0y (numpy.ndarray or float): Array of electric field amplitude along y axis. E0z (numpy.array, optional): Array of electric field amplitude along z axis.

Return type:

E0x (numpy.ndarray or float)

azimuth(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates azimuth, that is, the orientation of the major axis.

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 137.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

[0, pi]: Array of azimuth angles.

Return type:

azimuth (numpy.ndarray or float)

azimuth_ellipticity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the azimuth and ellipticity angle of a Jones vector.

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 137.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

[0, pi]: Array of azimuth angles. ellipticity (numpy.ndarray or float) [-pi/4, pi/4]: Array of ellipticity angles.

Return type:

azimuth (numpy.ndarray or float)

charac_angles(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the characteristic angles (alpha and delay) of a Jones vector.

References

  1. Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.3-33b.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

[0, pi/2]: Array of alpha angles. delay (numpy.ndarray or float): [0, 2*pi]: Array of delay angles.

Return type:

alpha (numpy.ndarray or float)

components(give_Ez=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the x and y field components of the Jones vector.

Parameters:
  • give_Ez (bool) – If True, it returns the z component of the electric field (all values will be 0). Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of electric field along x axis. Ey (numpy.ndarray or float): Array of electric field along y axis. Ez (numpy.ndarray, optional): Array of electric field along z axis.

Return type:

Ex (numpy.ndarray or float)

degree_circular_polarization(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of circular polarization: a coefficient that measures the amount of circular polarization in the beam.

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 39.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of degree of circular polarization.

Return type:

dcp (numpy.ndarray or float)

degree_linear_polarization(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of linear polarization: a coefficient that measures the amount of linear polarization in the beam.

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 39.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of degree of circular polarization.

Return type:

dcp (numpy.ndarray or float)

delay(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the delay (phase shift) between Ex and Ey components of the electric field.

References

  1. Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.3-33b.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of delay angles.

Return type:

(numpy.ndarray or float) [0, 2*pi]

delta(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the delay (phase shift) between Ex and Ey components of the electric field. It is the same method as delay.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of delay angles.

Return type:

delta (numpy.ndarray or float) [0, 2*pi]

eccentricity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eccentricity, the opposite to the ellipticity parameter. It’s 1 for linearly polarized light and 0 for circulary polarized light.

References

Handbook of Optics vol 2. 22.16 (eq.9)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of length of tellipticity parameter.

Return type:

e (numpy.ndarray or float)

ellipse_axes(out_number=True, sort=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the length of major and minor axis (a,b) of the polarization elipse.

References

  1. Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.3-30a and 3-30b
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • sort (bool) – If True, it sorts a and b to be the major and minor axis respectively. Default: True. TODO: Check why this is neccessary.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Major axis b (numpy.ndarray or float): Minor axis

Return type:

a (numpy.ndarray or float)

ellipticity_angle(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the ellipticity angle.

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 137.
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of ellipticity angles.

Return type:

ellipticity (numpy.ndarray or float) [-pi/4, pi/4]

ellipticity_param(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the ellipticity parameter: the ratio between the minos and major polarization ellipse axes. It’s 0 for linearly polarized light and 1 for circulary polarized light.

References

Handbook of Optics vol 2. 22.16 (eq.7)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of length of tellipticity parameter.

Return type:

e (numpy.ndarray or float)

get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Jones vector.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
Returns:

Dictionary with parameters of Jones vector.

Return type:

(dict)

global_phase(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the phase of the first component of the electric field (which is the reference for global phase in py_pol model).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of global phase.

Return type:

(numpy.ndarray or float) [0, 2*pi]

intensity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the intensity of the Jones vector.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of intensities.

Return type:

intensity (numpy.ndarray or float)

irradiance(n=1, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the intensity of the Jones vector.

Parameters:
  • n (float) – Refractive index of the medium.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of irradiance.

Return type:

irradiance (numpy.ndarray or float)

matrix(shape=None, shape_like=None)[source]

Returns the numpy array of Jones vectors.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

2xN numpy array.

Return type:

(numpy.ndarray)

norm(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the norm of the Jones vectors.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of intensities.

Return type:

intensity (numpy.ndarray or float)

py_pol.jones_vector.create_Jones_vectors(name='E', N=1, out_object=True)[source]

Function that creates several Jones_vector objects att he same time from a list of names or a number.

Parameters:
  • names (str, list or tuple) – name of vector for string representation. If list or tuple, it also represents the number of objects to be created.
  • N (int) – Number of elements to be created. This parameter is overrided if name is a list or tuple. Defeult: 1.
  • out_object (bool) – if True and the result is a list of length 1, return a Jones_vector object instead. Default: True.
Returns:

List of Jones vectors

Return type:

E (Jones_vector or list)

py_pol.jones_vector.set_printoptions(N_list=None, list_spaces=None)[source]

Function that modifies the global print options parameters.

Parameters:
  • N_print_list (int) – Number of matrices that will be printed as a list if the shape of the object is 1D.
  • print_list_spaces (int) – Number ofspaces between matrices if they are printed as a list.

4.1.5. py_pol.mueller module

class py_pol.mueller.Analysis_Mueller(parent)[source]

Bases: object

Class for Analysis of Mueller Analysis

Parameters:mueller_matrix (Mueller_matrix) – Mueller Matrix
self.M
Type:Mueller_matrix
self.dict_params

dictionary with parameters

Type:dict
decompose_polar(decomposition='PRD', give_all=False, tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False, transmissions='all', angles='all', depolarization='all')[source]

Polar decomposition of a physically realizable Mueller matrix in a partial depolarizer, retarder and a diattenuator.

TODO: When the depolarizer is singular with 2 or 3 non-zero eigenvalues, the decomposed retarder is often erroneous (60-80% of the time).

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 257.

Parameters:
  • decomposition (string) – string with the order of the elements: depolarizer (P), retarder (R) or diattenuator (D). There are six possible decompositions: PRD, RDP, PDR, RDP, DRP and DPR. Default: PRD.
  • give_all (bool) – If true, the dictionary of parameters will be given in the returned. Default: False.
  • tol (float) – Tolerance in equalities. Default: eps.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (float) – If true, the function prints out some information about the matrices.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • depolarization (string) – Determines the type of depolarization information: INDEX, FACTORS or ALL. Default: All.
Returns:

Mueller matrix of the retarder. Md (Mueller): Mueller matrix of the diattenuator/polarizer. Mp (Mueller): Mueller matrix of the depolarizer. param (dictionary, optional): Dictionary with all the parameters of the decomposed elements.

Return type:

Mr (Mueller)

decompose_pure(decomposition='RP', give_all=False, tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False, transmissions='all', angles='all')[source]

Polar decomposition of a pure Mueller matrix in a retarder and a diattenuator.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 151. S. Y. Lu, R. A. Chipman; “Interpretation of Mueller matrices based on polar decomposition”; J. Opt. Soc. Am. A/Vol. 13, No. 5 (1996)

Parameters:
  • decomposition (string) – string with the order of the elements: retarder (R) or diattenuator/polarizer (D or P). Default: RP.
  • give_all (bool) – If true, the dictionary of parameters will be given in the returned. Default: False.
  • tol (float) – Tolerance in equalities. Default: eps.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • filter (bool) – TODO
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (float) – If true, the function prints out some information about the matrices.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
Returns:

Mueller matrix of the retarder. Md (Mueller): Mueller matrix of the diattenuator. param (dictionary, optional): Dictionary with all the parameters of the decomposed elements.

Return type:

Mr (Mueller)

depolarizer(transmissions='all', angles='all', depolarization='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates some of the parameters from the Mueller matrix of a diattenuator.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • depolarization (string) – Determines the type of depolarization information: INDEX, FACTORS or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

trans_D, transP (list). Transmissions calculated from the diattenuation and polarizance vectors (in that order). Depending on the input parameter transmissions, it can contain the field transmissions, the intensity transmissions or both. angles_D, angles_P (list). Angles of the transmission eigenstate calculated from the diattenuation and polarizance vectors respectively. Depending on the input parameter angles, it can contain the characteristic angles, the azimuth and ellipticity, or all of them. depol (numpy.ndarray or float): Depolarization index. S (list): List with the three principal states.

diattenuator(transmissions='all', angles='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates all the parameters from the Mueller Matrix of a pure homogeneous diattenuator (using the diattenuance vector). If the object is not a pure homogenous diattenuator, some parameters may be wrong.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

transmissions (list). Transmissions of the diattenuator. Depending on the input parameter transmissions, it can contain the field transmissions, the intensity transmissions or both. angles (list). Angles of the transmission eigenstate. Depending on the input parameter angles, it can contain the characteristic angles, the azimuth and ellipticity, or all of them.

filter_physical_conditions(tol=1e-06, ignore_cond=None, keep=False, _counter=0)[source]

Method that filters experimental errors by forcing the Mueller matrix to fulfill the conditions necessary for a matrix to be a real optical component.

Parameters:
  • tol (float) – Tolerance in equalities.
  • ignore_cond (list) – Conditions to ignore. If False or None, no condition is ignored. Default: None.
  • keep (bool) – If true, the object is updated to the filtered result. If false, a new fresh copy is created. Default: True.
  • _counter (int) – Auxiliar variable that shoudln’t be used when calling this function from outside.
Returns:

Filtered Mueller matrix.

Return type:

Mf (4x4 matrix)

filter_purify_number(Neig=3, keep=False)[source]

Method that filters experimental errors by making zero a certain number of eigenvalues of the covariance matrix.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 226.

Parameters:
  • Neig (int) – Number of eigenvalues (1-3) of the covariant matrix to be made 0. Default: 0.
  • keep (bool) – If True, the original object won’t be altered. Default: False.
Returns:

Result.

Return type:

(Mueller)

filter_purify_threshold(threshold=0.01, keep=False)[source]

Method that filters experimental errors by making zero a certain number of eigenvalues of the covariance matrix.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 226.

Parameters:
  • thres (float) – If eigenvalues are lower than thres, they will be make 0. Default: 0.01.
  • keep (bool) – If True, the original object won’t be altered. Default: False.
Returns:

Result.

Return type:

(Mueller)

help()[source]

prints help about dictionary

polarizer(transmissions='all', angles='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates all the parameters from the Mueller Matrix of a pure homogeneous diattenuator (using the polarizance vector). If the object is not a pure homogenous diattenuator, some parameters may be wrong.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • transmissions (string) – Determines the type of transmission output, FIELD, INTENSITY or ALL. Default: All.
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

transmissions (list). Transmissions of the diattenuator. Depending on the input parameter transmissions, it can contain the field transmissions, the intensity transmissions or both. angles (list). Angles of the transmission eigenstate. Depending on the input parameter angles, it can contain the characteristic angles, the azimuth and ellipticity, or all of them.

retarder(angles='all', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates all the parameters from the Mueller Matrix of a pure homogeneous retarder. If the object is not a pure homogenous retarder, some parameters may be wrong.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • angles (string) – Determines the type of angles output, CHARAC (characteristic angles), AZIMUTH (azimuth and ellipticity) or ALL. Default: All.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

R (np.ndarray). Retardance. angles (list). Angles of the transmission eigenstate. Depending on the input parameter angles, it can contain the characteristic angles, the azimuth and ellipticity, or all of them.

class py_pol.mueller.Check_Mueller(parent)[source]

Bases: object

Class for Check of Mueller Matrices

Parameters:mueller_matrix (Mueller_matrix) – Mueller Matrix
self.M
Type:Mueller_matrix
self.dict_params

dictionary with parameters

Type:dict
get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the checks of Mueller matrix.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
help()[source]

Prints help about dictionary.

TODO

is_depolarizer(give_all=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix M corresponds to a depolarizer. It must fullfill several conditions:

  1. Depolarization index > 0.
  2. $m = m^T$ (m being the small m matrix).

References

    1. Lu, R. A. Chipman; “Interpretation of Mueller matrices based on polar decomposition”; J. Opt. Soc. Am. A/Vol. 13, No. 5 (1996)
Parameters:
  • give_all (bool) – If True, the method also gives a list with the individual conditions. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result. partial_conditions (list): List with the partial conditions.

Return type:

cond (numpy.ndarray or bool)

is_diattenuator(give_all=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix M corresponds to a pure homogeneous diattenuator. It must fullfill several conditions:

  1. Diattenuation > 0.
  2. $M = M^T$.
  3. The eigenstates of M are the Stokes vectors (1, D) and (1, -D).

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 142.

Parameters:
  • give_all (bool) – If True, the method also gives a list with the individual conditions. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result. partial_conditions (list): List with the partial conditions.

Return type:

cond (numpy.ndarray or bool)

is_homogeneous(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix is homogeneous, i.e., its two eigenstates are perpendicular. If true, the inhomogeneity parameter must be 0.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 119.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_non_depolarizing(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if matrix is pure, i.e., is non-depolarizing (the degree of polarimetric purity must be 1).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_physical(tol=1e-06, give_all=False, ignore_cond=None, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

A Mueller matrix must fulfill several conditions in order to be physically realizable:

1. $M_{ij}inmathbb{R}$ for i, j = 0, 1, 2 and 3. 2a. $M_{00} geq 0$. 2b. $M_{00} leq 1$ (except in active media). 3. $M_{00}geq abs(M_{ij})$ for i, j = 0, 1, 2 and 3. 4a. $D leq 1$ 4a. $P leq 1$. 5a. $M_{00} (1 + D) leq 1$ (except in active media). 5b. $M_{00} (1 + P) leq 1$ (except in active media). 6. $Tr(M*M^T)leq 4(M_{00})^2$. 7a. $M_{00}^{2}left(1-D

ight)^{2}geqmathop{sum_{i=1}^{3}M_{0i}^{2}left(1-sum_{j=1}^{3} rac{M_{ij}}{M_{00}D} ight)}^{2}$.

7b. $M_{00}^{2}left(1-P

ight)^{2}geqmathop{sum_{i=1}^{3}M_{i0}^{2}left(1-sum_{j=1}^{3} rac{M_{ji}}{M_{00}P} ight)}^{2}$.

8a. $lambda_{i}inmathbb{R}$ 8b. $lambda_{i} geq 0$. 8c. $lambda_{i} leq 1$ (except in active media).

Being D the diattenuation, P the polarizance and $lambda_{i}$ the eigenvalues of the covariance matrix.

References:
Handbook of Optics vol 2. 22.34 (There is an errata in the equation equivalent to condition 7). “Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 187.
Parameters:
tol (float): Tolerance in conditions. Default: tol_default. ignore_cond (list): Conditions to ignore. If False or None, no condition is ignored. Default: None. give_all (bool): If True, the method also gives a list with the individual conditions. Default: False. out_number (bool): if True and the result is a 1x1 array, return a number instead. Default: True. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. verbose (bool): if True prints the parameter. Default: False. draw (bool): If True and the object is a 1D or 2D, plot it. Default: False.
Returns:
cond (numpy.ndarray or bool): Result. partial_conditions (list): List with the partial conditions.
is_polarizer(give_all=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix M corresponds to a pure homogeneous polarizer (diattenuator). It must fullfill several conditions:

  1. Polarizance > 0.
  2. $M = M^T$.
  3. The eigenstates of M are the Stokes vectors (1, D) and (1, -D).

Note: This method is the same as is_diattenuator.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 142.

Parameters:
  • give_all (bool) – If True, the method also gives a list with the individual conditions. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result. partial_conditions (list): List with the partial conditions.

Return type:

cond (numpy.ndarray or bool)

is_pure(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Same as is_non_depolarizing method.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_retarder(give_all=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix M corresponds to a pure retarder.There are three conditions:

  1. Diatteunation = 0.
  2. Polarizance = 0.
  3. M must be unitary ($M^{T}=M^{-1}$).

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 129.

Parameters:
  • give_all (bool) – If True, the method also gives a list with the individual conditions. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result. partial_conditions (list): List with the partial conditions.

Return type:

cond (numpy.ndarray or bool)

is_singular(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Checks if the matrix is singular (det(M) = 0).

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 282.

Parameters:
  • give_all (bool) – If True, the method also gives a list with the individual conditions. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

is_symmetric(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Determines if the object matrix is symmetric (i.e. $$M = M^T$$).

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or bool)

class py_pol.mueller.Mueller(name='M')[source]

Bases: object

Class for Mueller matrices

Parameters:name (str) – name of Mueller matrix, for string representation
M

4x4xN array of floats containing all the Mueller matrices.

Type:np.ndarray
m00

1xN array containing the $M_{00}$ element of all Mueller matrices.

Type:np.ndarray
D

3xN array containing the diattenuation vectors of the Mueller matrices.

Type:np.ndarray
P

3xN array containing the polarizance vectors of the Mueller matrices.

Type:np.ndarray
m

3xN array containing the rest of the Mueller matrices.

Type:np.ndarray
global_phase

1xN array storing the global phase introduced by the optical objects.

Type:np.ndarray
name

Name of the object for print purposes.

Type:string
shape

Shape desired for the outputs.

Type:tuple or list
size

Number of stored Mueller matrices.

Type:int
ndim

Number of dimensions for representation purposes.

Type:int
no_rotation

If True, rotation method do not act upon the object. Useful for objects that shouldn’t be rotated as mirrors.

Type:bool
_type

Type of the object (‘Jones_matrix’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.

Type:string
self.parameters

parameters of the Mueller matrices.

Type:class
self.checks

checks of the Mueller matrices.

Type:class
self.analysis

analysis of the Mueller matrices.

Type:class
add_global_phase(phase=0, unknown_as_zero=False, keep=False)[source]

Method that adds a phase to the Mueller object.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Stokes vectors. Default: 0.
  • unknown_as_zero (bool) – If True, takes unknown phase as zero. Default: False.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Mueller object.

Return type:

(Mueller)

clear()[source]

removes data from stokes vector.

copy(N=1)[source]

Creates a copy of the object.

Parameters:N (int) – Number of copies. Default: 1.
Returns:Result.
Return type:(Jones_matrix)
covariance_matrix(keep=False, shape_like=None, shape=None, change_name=True)[source]

Calculates the covariance matrix of a Mueller matrix.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 171.

Notes

The base of matrices S is used in an uncommon order. In order to obtain the same result as in the book, the formula must be:

\[H=0.25\sum(m[i,j]\,kron([S(i),S^{*}(j))].\]
Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Mueller)

depolarizer_diagonal(d, M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a diagonal depolarizer:

\[M_{p}=\left[egin{array}{cccc} M_{00} & 0 & 0 & 0\ 0 & d_{1} & 0 & 0\ 0 & 0 & d_{2} & 0\ 0 & 0 & 0 & d_{3} \end{array}\]

ight]

Parameters:
d (list, float or numpy.ndarray): Absorption coefficients. If list, it must contain three float or numpy arrays, one for each diagonal value. If float or numpy.ndarray, $d_1 = d_2 = d_3$. M00 (float, default 1): Parameter of average intensity. Default: 1. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
depolarizer_perfect(M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a perfect depolarizer:

\[M_{p}=\left[egin{array}{cccc} M_{00} & 0 & 0 & 0\ 0 & d_{1} & 0 & 0\ 0 & 0 & d_{2} & 0\ 0 & 0 & 0 & d_{3} \end{array}\]

ight]

Parameters:
M00 (float, default 1): Parameter of average intensity. Default: 1. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
depolarizer_states(d, S, Dv=array([0., 0., 0.]), Pv=array([0., 0., 0.]), M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a general depolarizer form its three eigenstates and their depolarization factors (eigenvalues), plus its polarization or polarizance vector.

Parameters:
  • d (list, float or numpy.ndarray) – Depolarization factors (eigenvalues of m). If list, it must contain three float or numpy arrays, one for each diagonal value. If float or numpy.ndarray, $d_1 = d_2 = d_3$.
  • S (list or Stokes) – Principal states. If list, it must contain three Stokes objects. If Stokes, at least one dimension must have dimension 3.
  • Dv (numpy.ndarray) – Diattenuation vector. If None, the polarizance vector is used instead. Default: None.
  • Pv (numpy.ndarray) – Polarizance vector. Used only if Dv is None. If None, the depolarizer will have zero diattenuation and polarizance. Default: None.
  • M00 (float, default 1) – Parameter of average intensity. Default: 1.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_azimuth_ellipticity(p1=1, p2=0, Tmax=None, Tmin=None, azimuth=0, ellipticity=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogenous diattenuator from diattenuator parameters with the intermediate step of calculating the diattenuation vector.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 142.

Parameters:
  • p1 (float or numpy.ndarray) – Electric field transmission coefficient of the transmission eigenstate. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmin (float or numpy.ndarray) – Minimum transmission. If not None, overrides p2. Default: None.
  • azimuth (float) – [0, pi]: Azimuth.
  • ellipticity (float) – [-pi/4, pi/4]: Ellipticity angle.
  • give_all (bool) – If true, it gives also the Jones object as output. Default: False.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_charac_angles(p1=1, p2=0, Tmax=None, Tmin=None, alpha=0, delay=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogenous diattenuator from diattenuator parameters with the intermediate step of calculating the diattenuation vector.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 142.

Parameters:
  • p1 (float or numpy.ndarray) – Electric field transmission coefficient of the transmission eigenstate
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmin (float or numpy.ndarray) – Minimum transmission. If not None, overrides p2. Default: None.
  • alpha (float or numpy.ndarray) – [0, pi/2]: tan(alpha) is the ratio between field amplitudes of X and Y components. Default: 0.
  • delay (float or numpy.ndarray) – [0, 2*pi]: phase difference between X and Y field components. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_linear(p1=1, p2=0, Tmax=None, Tmin=None, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller matrices of pure linear homogeneous diattenuators.

\[M\left( heta=0\]

ight)= rac{1}{2}left[egin{array}{cccc}

p_{1}^{2}+p_{2}^{2} & p_{1}^{2}-p_{2}^{2} & 0 & 0p_{1}^{2}-p_{2}^{2} & p_{1}^{2}+p_{2}^{2} & 0 & 00 & 0 & 2p_{1}p_{2} & 00 & 0 & 0 & 2p_{1}p_{2} end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), (4.79) - p. 143. Handbook of Optics vol 2. 22.16 (Table 1).
Parameters:
p1 (float or numpy.ndarray): Field transmission of the transmission axis. Default: 1. p2 (float or numpy.ndarray): Field transmission of the attenuation axis. Default: 0. Tmax (float or numpy.ndarray): Maximum transmission. If not None, overrides p1. Default: None. Tmin (float or numpy.ndarray): Minimum transmission. If not None, overrides p2. Default: None. azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
diattenuator_perfect(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller 4x4 matrix for a perfect diattenuator (polarizer).

Parameters:
  • azimuth (float or numpy.ndarray) – rotation angle of the high transmission polarizer axis. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_retarder_azimuth_ellipticity(p1=1, p2=1, Tmax=None, Tmin=None, R=0, azimuth=0, ellipticity=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general homogenous diattenuator retarder from the azimuth and ellipticity of the fast eigenstate.

Parameters:
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • azimuth (float or numpy.ndarray) – rotation angle of the high transmission polarizer axis. Default: 0.
  • ellipticity (float) – [-pi/4, pi/]: Ellipticity angle. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_retarder_charac_angles(p1=1, p2=1, Tmax=None, Tmin=None, R=0, alpha=0, delay=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general homogenous diattenuator retarder from the characteristic angles of the fast eigenstate.

Parameters:
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • alpha (float or numpy.ndarray) – [0, pi/2]: tan(alpha) is the ratio between field amplitudes of X and Y components. Default: 0.
  • delay (float or numpy.ndarray) – [0, 2*pi]: phase difference between X and Y field components. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

diattenuator_retarder_linear(p1=1, p2=0, Tmax=None, Tmin=None, R=1.5707963267948966, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Mueller matrices of linear diattenuator retarders with the same eigenstates for diattenuation and retardance.

\[M\left( heta=0\]

ight)= rac{1}{2}left[egin{array}{cccc}

p_{1}^{2}+p_{2}^{2} & p_{1}^{2}-p_{2}^{2} & 0 & 0p_{1}^{2}-p_{2}^{2} & p_{1}^{2}+p_{2}^{2} & 0 & 00 & 0 & 2p_{1}p_{2}cos(

arDelta) & 2p_{1}p_{2}sin( arDelta)

0 & 0 & -2p_{1}p_{2}sin(

arDelta) & 2p_{1}p_{2}cos( arDelta)

end{array}

ight]

References:
Handbook of Optics vol 2. 22.16 (Table 1).
Parameters:
p1 (float or numpy.ndarray): Field transmission of the transmission axis. Default: 1. p2 (float or numpy.ndarray): Field transmission of the attenuation axis. Default: 0. Tmax (float or numpy.ndarray): Maximum transmission. If not None, overrides p1. Default: None. Tmin (float or numpy.ndarray): Minimum transmission. If not None, overrides p2. Default: None. R (float or numpy.ndarray): [0, pi] Retardance introduced to the slow eigenstate respect to the fast eigenstate. Default: 90 degrees. azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
diattenuator_vector(Dv, M00=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogenous diattenuator from the Diattenuation or Polarizance vector.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 142.

Parameters:
  • Dv (3xN numpy.ndarray) – Diattenuation or Polarizance vectors.
  • M00 (float or numpy.ndarray) – Parameter of average intensity. If None, the maximum possible value is used. Default: None.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

filter_amplifier(D=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Mueller object of neutral filters or amplifiers.

Parameters:
  • D (float or numpy.ndarray) – Attenuation (gain if > 1). Default: 1.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

flip(axis=None, keep=False, change_name=True)[source]

Flips the elements stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the flip is performed. If None, the object is flipped as flattened. Default: None.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Mueller)

from_Jones(J, length=1, shape_like=None, shape=None)[source]

Takes a Jones Matrix and converts into Mueller Matrix

\[M(J)=\left[egin{array}{cccc} 1 & 0 & 0 & 1\ 1 & 0 & 0 & -1\ 0 & 1 & 1 & 0\ 0 & i & -i & 0 \end{array}\]

ight]left(Jotimes J^{*} ight)left[egin{array}{cccc}

1 & 0 & 0 & 11 & 0 & 0 & -10 & 1 & 1 & 00 & i & -i & 0 end{array}

ight]^{-1}

References:
“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 107.
Parameters:
J (jones_matrix): Jones matrix object. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (float or numpy.ndarray): Use the shape of this array. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
from_blocks(Dv=array([0., 0., 0.]), Pv=array([0., 0., 0.]), m=array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]), M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that creates a Mueller object from the block components of its matrix.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • Dv (numpy.ndarray) – Diattenuation vector 3xN array.
  • Pv (numpy.ndarray) – Polarizance vector 3xN array.
  • m (numpy.ndarray) – Small matrix m 3x3xN array.
  • m00 (numpy.ndarray) – Parameter of average intensity array of size N.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

from_components(components, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the Mueller matrix object form the arrays of its 16 components components.

Parameters:
  • components (tuple or list) – A 4 element tuple containing the 6 components of the Mueller matrices (M00, M01, …, M32, M33).
  • global_phase (float or numpy.ndarray) – Adds a global phase to the object. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

from_covariance(H, global_phase=0, length=1, shape_like=None, shape=None)[source]

Calculates the Mueller matrix from the covariance matrix:

$M_{ij}=Traceleft[left(sigma_{i}otimessigma_{j}^{*}

ight)H ight]$

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)
Parameters:
H (Mueller or numpy.ndarray): Covariance matrix. global_phase (numpy.ndarray): Adds a global phase to the Stokes object. Default: 0. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
from_list(l, shape_like=None, shape=None)[source]

Create a Jones_matrix object from a list of size 2x2 arrays.

Parameters:
  • l (list) – list of matrices.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

from_matrix(M, global_phase=0, length=1, shape_like=None, shape=None)[source]

Create a Mueller object from an external array.

Parameters:
  • M (numpy.ndarray) – New matrix. At least two dimensions must be of size 4.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

from_normalized(m, M00=None, global_phase=0, shape_like=None, shape=None)[source]

Creates a Mueller object directly from the normalized matrix $m = M/M_{00}$, and $M_{00}$.

Parameters:
  • Matrix (4x4 numpy.matrix) – Mueller matrix
  • M00 (float) – [0, 1] Mean transmission coefficient. Default: maximum possible.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

general_eigenstates(E1, E2=None, p1=1, p2=1, Tmax=None, Tmin=None, R=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the most general pure optical element from its eigenstates.

Parameters:
  • E1 (Jones_vector) – First eigenstate.
  • E2 (Jones_vector) – Second eigenstate. If None, E2 is taken as the perpendicular state to E1, so the optical object is homogenous.
  • p1 (float or numpy.ndarray) – Field transmission of the fast axis. Default: 1.
  • p2 (float or numpy.ndarray) – Electric field transmission coefficient of the extinction eigenstate. Default: 0.
  • Tmax (float or numpy.ndarray) – Maximum transmission. If not None, overrides p1. Default: None.
  • Tmax – Minimum transmission. If not None, overrides p1. Default: None.
  • R (float or numpy.ndarray) – Retardance. Default: 0.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_matrix)

get_list(out_number=True)[source]

Returns a list of 2x2 Jones matrices.

Parameters:out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
Returns:Result.
Return type:(numpy.ndarray or list)
half_waveplate(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller matrices of ideal half-wave retarders.

\[M\left( heta=0\]
ight)=left[egin{array}{cccc}
1 & 0 & 0 & 00 & 1 & 0 & 00 & 0 & -1 & 00 & 0 & 0 & -1 end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), (4.32) - p. 132 Handbook of Optics vol 2. 22.16 (Table 1).
Parameters:
azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
inverse(keep=False, shape_like=None, shape=None, change_name=True)[source]

Calculates the inverse matrix of the Mueller matrix.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Mueller)

mirror(ref=1, ref_field=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller matrix of a mirror.

Parameters:
  • ref (float or numpy.ndarray) – Intensity reflectivity of the mirror. Default: 1.
  • ref_field (float or numpy.ndarray) – Electric field reflectivity coefficient. If not None, it overrides REF. Default: None.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

prod(axis=None, keep=False, change_name=True)[source]

Calculates the product of Mueller matrices stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the product is performed. If None, all matrices are multiplied.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Mueller)

quarter_waveplate(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller matrices of ideal quarter-wave retarder.

\[M\left( heta=0\]
ight)=left[egin{array}{cccc}
1 & 0 & 0 & 00 & 1 & 0 & 00 & 0 & 0 & 10 & 0 & -1 & 0 end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), (4.32) - p. 132 Handbook of Optics vol 2. 22.16 (Table 1).
Parameters:
azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
reciprocal(keep=False, shape_like=None, shape=None, change_name=True)[source]

Calculates the recirpocal of the optical element, so the light tranverses it in the opposite direction. In Mueller formalism, it is calculated as:

\[M^{r}=\left[egin{array}{cccc} 1 & 0 & 0 & 0\ 0 & 1 & 0 & 0\ 0 & 0 & -1 & 0\ 0 & 0 & 0 & 1 \end{array}\]
ight]M^{T}left[egin{array}{cccc}
1 & 0 & 0 & 00 & 1 & 0 & 00 & 0 & -1 & 00 & 0 & 0 & 1 end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 111.
Parameters:
keep (bool): If True, the original element is not updated. Default: False. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. change_name (bool): If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:
(Mueller): Result.
remove_global_phase(keep=False)[source]

Method that removes the phase to the Stokes object.

Parameters:keep (bool) – If True, self is not updated. Default: False.
Returns:Recalculated Stokes object.
Return type:(Stokes)
retarder_azimuth_ellipticity(R, azimuth, ellipticity, M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogeneous retarder from azimuth and ellipticity of the fast eigenstate. The method calculates first the retardance vector, and uses it to calculate the Mueler matrix.

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 125.

Parameters:
  • R (float or numpy.ndarray) – [0, pi] Retardance introduced to the slow eigenstate respect to the fast eigenstate.
  • azimuth (float or numpy.ndarray) – [0, pi]: Azimuth.
  • ellipticity (float or numpy.ndarray) – [-pi/4, pi/4]: Ellipticity angle.
  • M00 (float or numpy.ndarray) – Parameter of average intensity. Default: 1.
  • give_all (bool) – If true, it gives also the Jones object as output. Default: False.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

retarder_charac_angles(R, alpha, delay, M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogeneous retarder from the characteristic angles of the fast eigenstate. The method calculates first the retardance vector, and uses it to calculate the Mueler matrix.

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 125.

Parameters:
  • R (float or numpy.ndarray) – [0, pi] Retardance introduced to the slow eigenstate respect to the fast eigenstate.
  • alpha (float or numpy.ndarray) – [0, pi]: tan(alpha) is the ratio between amplitudes of the electric field of the fast eigenstate.
  • delay (float or numpy.ndarray) – [0, 2*pi]: phase difference between both components of the electric field of the fast eigenstate.
  • M00 (float or numpy.ndarray, default 1) – Parameter of average intensity
  • give_all (bool) – If true, it gives also the Jones object as output. Default: False.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

retarder_linear(R, azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]

Mueller matrix of homogeneous linear retarders.

\[M\left( heta=0\]
ight)=left[egin{array}{cccc}
1 & 0 & 0 & 00 & 1 & 0 & 00 & 0 & cos(Delta) & sin(Delta)0 & 0 & -sin(Delta) & cos(Delta) end{array}

ight]

References:
J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), (4.31) - p. 132 Handbook of Optics vol 2. 22.16 (Table 1).
Parameters:
R (float or numpy.ndarray): [0, pi] Retardance introduced to the slow eigenstate respect to the fast eigenstate. azimuth (float or numpy.ndarray): rotation angle of the high transmission polarizer axis. Default: 0. global_phase (float or numpy.ndarray): Global phase introduced by the optical element. Default: 0. length (int): If final object is of size 1, it is stretched to match this size. Default: 1. shape_like (numpy.ndarray or py_pol object): Use the shape of this object. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None.
Returns:
(Mueller): Created object.
retarder_vector(Rv, R=1.5707963267948966, kind='normalized', M00=1, global_phase=0, length=1, shape_like=None, shape=None)[source]

Method that calculates the most general homogeneous retarder from the retardance vector.

References

“Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 125.

Parameters:
  • Rv (3xN numpy.ndarray) – Retardance vector.
  • R (float or numpy.ndarray) – [0, pi] Retardance introduced to the slow eigenstate respect to the fast eigenstate. Default: 90 degrees.
  • kind (string) – Identifies the type of retardance vector. There are three possibilities: NORMALIZED (default, also called Pauli vector), STRAIGHT or COMPLETE.
  • M00 (float or numpy.ndarray) – Mean transmission coefficient. If different than 1, the object won’t be a pure retarder. Default: 1.
  • global_phase (float or numpy.ndarray) – Global phase introduced by the optical element. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

rotate(angle=0, keep=False, change_name=True)[source]

Rotates a Mueller matrix a certain angle

M_rotated = R(-angle) * self.M * R(angle)

Parameters:
  • angle (float) – angle of rotation in radians.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True and angle is of size 1, changes the object name adding @ XX deg, being XX the total rotation angle. Default: True.
Returns:

When returns_matrix == True. (numpy.matrix): 4x4 matrix when returns_matrix == False.

Return type:

(Mueller)

set_global_phase(phase=0, keep=False, shape_like=None, shape=None)[source]

Method that sets the phase to the Stokes object.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Stokes vectors. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Recalculated Stokes object.

Return type:

(Stokes)

shape_like(obj)[source]

Takes the shape of an object to use in the future.

Parameter:
obj (py_pol object or nd.array): Object to take the shape.
Returns:Result.
Return type:(Jones_matrix)
stretch(length, keep=False, shape=None, shape_like=None)[source]

Method that stretches a Jones matrix to have a higher number of equal elements.

Parameters:
  • length (int) – Number of elements.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Jones vector.

Return type:

(Mueller)

sum(axis=None, keep=False, change_name=True)[source]

Calculates the sum of Mueller matrices stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the summatory is performed. If None, all matrices are summed.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Mueller)

transpose(keep=False, shape_like=None, shape=None, change_name=True)[source]

Calculates the transposed matrices of the Mueller matrices.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

update()[source]

Updates some of the class fields to be coherent.

vacuum(global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates the matrix for vacuum i.e., an optically neutral element.

Parameters:
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Jones matrix. Default: 0.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Mueller)

class py_pol.mueller.Parameters_Mueller(parent)[source]

Bases: object

Class for Mueller Matrix Parameters.

Parameters:
  • self.parent (Mueller_matrix) – Parent object.
  • self.dict_params (dict) – dictionary with parameters.
blocks(normalize=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Method that guives the Mueller matrix block components: $M_{00}$ (mean transmission), $D$ (diattenuation vector), $P$ (polarizance vector) and $m$ (small matrix).

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • normalize (bool) – If True, normalizes the diattenuation vector to M00. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Average intensity. D (numpy.ndarray): Diattenuation vectors 3xN. P (numpy.ndarray): Diattenuation vector 3xN. m (numpy.ndarray): Small m matrix 3x3xN.

Return type:

m00 (float or numpy.ndarray)

components(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Extracts the matrix components of the Mueller matrix.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

array of the 0, 0 element of the matrix. M01 (numpy.ndarray): array of the 0, 1 element of the matrix. … M32 (numpy.ndarray): array of the 3, 2 element of the matrix. M33 (numpy.ndarray): array of the 3, 3 element of the matrix.

Return type:

M00 (numpy.ndarray)

degree_polarizance(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of polarizance of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

depolarization_index(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the depolarization index of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

det(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the determinants of the Mueller matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray, float or complex)

diattenuation(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the diattenuation of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, pp. 200, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

diattenuation_circular(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the circular diattenuation of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

diattenuation_linear(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the linear diattenuation of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

diattenuation_vector(normalize=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Guives the diattenuation vector. The first dimension will always have size 3.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • normalize (bool) – If True, normalizes the diattenuation vector to M00. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray)

eig(values_as_matrix=False, vectors_as_matrix=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenvalues and eigenvectors of the Mueller matrices.

Parameters:
  • values_as_matrix (bool) – If True, the eigenvalues output is a numpy.ndarray instead of a list of arrays. Default: False.
  • vectors_as_matrix (bool) – If True, the eigenvectors output is a numpy.ndarray instead of a list of arrays. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

List with the four eigenvalues (if values_as_matrix is False) or 4xN array (if values_as_matrix is True). eigenvectors (list or numpy.ndarray): List with the four eigenvectors (if vectors_as_matrix is False) or 4x4xN array (if vectors_as_matrix is True).

Return type:

eigenvalues (list or numpy.ndarray)

eigenstates(shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenstates of the optical object. It must be done in Jones formalism, so it is only valid for pure Mueller matrices.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

eigenstates.

Return type:

S1, S2, S3, S4 (Stokes)

eigenvalues(values_as_matrix=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenvalues and eigenstates of the Jones object.

Parameters:
  • values_as_matrix (bool) – If True, the eigenvalues output is a numpy.ndarray instead of a list of arrays. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

4xN eigenvalues matrix (if values_as_matrix is True). v1, v2, v3, v4 (numpy.ndarray or float): Individual eigenvalues (if values_as_matrix is False).

Return type:

v (numpy.ndarray)

eigenvectors(vectors_as_matrix=False, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the eigenvectors of the Mueller matrices.

Parameters:
  • vectors_as_matrix (bool) – If True, the eigenvectors output is a numpy.ndarray instead of a list of arrays. Default: False.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

4x4xN eigenvector matrix (if vectors_as_matrix is True). e1, e2, e3, e4 (numpy.ndarray): 4xN eigenvector matrices (if vectors_as_matrix is False).

Return type:

(numpy.ndarray)

get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Mueller matrix.

Parameters:
  • verbose (bool) – If True, print all parameters. Default: False.
  • draw (bool) – If True, draw all plots/images of the parameters. Default: False.
global_phase(give_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the phase of J00 (which is the reference for global phase in py_pol model).

Parameters:
  • give_nan (bool) – If False, NaN values are transformed into 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

help()[source]

prints help about dictionary TODO

inhomogeneity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the inhomogeneity parameter. This parameter is 0 for homogeneous optical elements and 1 for totally inhomogeneous (degenerate) elements.

Note: The equation of the reference shows at least an incorrect result in the diattenuator retarders.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 119.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

matrix(shape=None, shape_like=None)[source]

Returns the numpy array of Mueller matrices.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

(numpy.array) 4x4xN numpy array.

mean_transmission(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Guives the mean transmission coefficients.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

norm(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the Frobenius norm of the Mueller matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray, float or complex)

polarimetric_purity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of polarimetric purity of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

polarimetric_purity_indices(remove_nan=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the polarimetric purity indices of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 208.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Results.

Return type:

P1, P2, P3 (numpy.ndarray or float)

polarizance(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the polarizance of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

polarizance_circular(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the linear polarizance of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

polarizance_linear(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the linear polarizance of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

polarizance_vector(normalize=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Guives the polarizance vector. The first dimension will always have size 3.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • normalize (bool) – If True, normalizes the diattenuation vector to M00. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray)

retardance(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the retardance of the Mueller matrix of a pure retarder.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 129.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

retardance_vector(kind='norm', shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculate the maximum and minimum transmittance of an optical element.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 128-130.

Parameters:
  • kind (string) – Identifies the type of retardance vector. There are three possibilities: NORMALIZED (default, also called Pauli vector), STRAIGHT or COMPLETE.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

3xN array of the result.

Return type:

(numpy.ndarray)

small_matrix(normalize=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Guives the small matrix m. The first two dimensions will always have size 3.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:
  • normalize (bool) – If True, normalizes the diattenuation vector to M00. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray)

spheric_purity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of spheric purity of the Mueller matrices.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 204.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

trace(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the trace of the Mueller matrices.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(numpy.ndarray or float)

transmissions(kind='Intensity', out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculate the maximum and minimum transmitance of an optical element.

References

Handbook of Optics vol 2. 22.32 (eq.38)

Parameters:
  • kind (str) – There are three options, FIELD, INTENSITY or ALL.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Maximum intensity transmission. T_min (numpy.ndarray): Minimum intensity transmission. p1 (numpy.ndarray): Maximum field transmission. p2 (numpy.ndarray): Minimum field transmission.

Return type:

T_max (numpy.ndarray)

py_pol.mueller.create_Mueller(name='M', N=1, out_object=True)[source]

Method that creates several Jones_matrix objects at he same time from a list of names or a number.

Parameters:
  • M (np.ndarray) – 2xN array containing all the Jones matrices.
  • name (string) – Name of the object for print purposes.
  • shape (tuple or list) – Shape desired for the outputs.
  • size (int) – Number of stores Jones matrices.
  • ndim (int) – Number of dimensions for representation purposes.
  • _type (string) – Type of the object (‘Jones_matrix’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
self.parameters

Class containing the measurable parameters of the Jones matrices.

Type:class
self.checks

Class containing the methods that check something about the Jones matrices.

Type:class
py_pol.mueller.set_printoptions(N_list=None, list_spaces=None)[source]

Method that modifies the global print options parameters.

Parameters:
  • N_print_list (int) – Number of matrices that will be printed as a list if the shape of the object is 1D.
  • print_list_spaces (int) – Number ofspaces between matrices if they are printed as a list.

4.1.6. py_pol.stokes module

We present a number of functions for polarization using Stokes framework:

Class fields
  • M: 2xN array containing all the Stokes vectors.
  • global_phase: Global phase of the light state.
  • name: Name of the object for print purposes.
  • shape: Shape desired for the outputs.
  • size: Number of stores Stokes vectors.
  • _type: Type of the object (‘Jones_vector’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
  • parameters: Object of class Parameters_Jones_vector.
  • checks: Object of class Checks_Jones_vector.
Generation methods
  • from_components: Creates Stokes vectors directly from the 4 elements $S_0$, $S_1$, $S_2$, $S_3$.
  • from_matrix: Creates Stokes vectors from an external 4 x shape numpy array.
  • from_list: Creates a Jones_vector object directly from a list of 4 or 4x1 numpy arrays.
  • from_Jones: Creates Stokes vectors from a Jones_vector object.
  • linear_light: Creates Stokes vectors for pure linear polarizer light.
  • circular_light: Creates Stokes vectors for pure circular polarizer light.
  • elliptical_light Creates Stokes vectors for polarizer elliptical light.
  • general_charac_angles Creates Stokes vectors given by their characteristic angles.
  • general_azimuth_ellipticity Creates Stokes vectors given by their azimuth and ellipticity.
Manipulation methods
  • clear: Removes data and name form Stokes vectors.
  • copy: Creates a copy of the Jones_vector object.
  • stretch: Stretches a Stokes vectors of size 1.
  • shape_like: Takes the shape of another object to use as its own.
  • simplify: Simplifies the Stokes vectors in several ways.
  • rotate: Rotates the Stokes vectors.
  • sum: Calculates the summatory of the Stokes vectors in the object.
  • flip: Flips the object along some dimensions.
  • reciprocal: Calculates the Stokes vectors that propagates backwards.
  • orthogonal: Calculates the orthogonal Stokes vectors.
  • normalize: Normalize the electric field to be normalized in electric field amplitude or intensity.
  • rotate_to_azimuth: Rotates the Stokes vectors to have a certain azimuth.
  • remove_global_phase: Calculates the global phase of the electric field (respect to the X component) and removes it.
  • add_global_phase: Adds a global phase to the Stokes vectors.
  • set_global_phase: Sets the global phase of the Stokes vectors.
  • set_depolarization: Sets the degree of depolarization.
  • add_depolarization: Increases the degree of depolarization.
  • draw_ellipse: Draws the polarization ellipse of the Stokes vectors.
Parameters subclass methods
  • matrix: Gets a numpy array with the Stokes vectors.
  • components: Calculates the electric field components of the Stokes vectors.
  • amplitudes: Calculates the electric field amplitudes of the Stokes vectors.
  • intensity: Calculates the intensity of the Stokes vectors.
  • irradiance: Calculates the irradiance of the Stokes vectors.
  • alpha: Calculates the ratio between electric field amplitudes ($E_x$/$E_y$).
  • delay / delta: Calculates the delay (phase shift) between Ex and Ey components of the electric field.
  • charac_angles: Calculates both alpha and delay, the characteristic angles of the Stokes vectors.
  • azimuth: Calculates azimuth, that is, the orientation angle of the major axis.
  • ellipticity_angle: Calculates the ellipticity angle.
  • azimuth_ellipticity: Calculates both azimuth and ellipticity angles.
  • ellipse_axes: Calculates the length of major and minor axis (a,b).
  • ellipticity_param: Calculates the ellipticity parameter, b/a.
  • eccentricity: Calculates the eccentricity, the complementary of the ellipticity parameter.
  • global_phase: Calculates the global phase of the Stokes vectors (respect to the X component of the electric field).
  • degree_polarization: Calculates the degree of polarization of the Stokes vectors.
  • degree_depolarization: Calculates the degree of depolarization of the Stokes vectors.
  • degree_linear_polarization: Calculates the degree of linear polarization of the Stokes vectors.
  • degree_circular_polarization: Calculates the degree of circular polarization of the Stokes vectors.
  • norm: Calculates the norm of the Stokes vectors.
  • polarized_unpolarized: Divides the Stokes vector in Sp+Su, where Sp is fully-polarized and Su fully-unpolarized.
  • get_all: Returns a dictionary with all the parameters of Stokes vectors.
Checks subclass methods
  • is_physical: Checks if the Stokes vectors are physically realizable.
  • is_linear: Checks if the Stokes vectors are lienarly polarized.
  • is_circular: Checks if the Stokes vectors are circularly polarized.
  • is_right_handed: Checks if the Stokes vectors rotation direction are right handed.
  • is_left_handed: Checks if the Stokes vectors rotation direction are left handed.
  • is_polarized: Checks if the Stokes vectors are at least partially polarized.
  • is_totally_polarized: Checks if the Stokes vectors are totally polarized.
  • is_depolarized: Checks if the Stokes vectors are at least partially depolarized.
  • is_totally_depolarized: Checks if the Stokes vectors are totally depolarized.
  • get_all: Returns a dictionary with all the checks of Stokes vectors.
Analysis subclass methods
  • filter_physical_conditions: Forces the Stokes vectors to be physically realizable.
class py_pol.stokes.Analysis_Stokes(parent)[source]

Bases: object

Class for Analysis of Stokes vetors.

Parameters:stokes_vector (Stokes) – Stokes vector
self.parent
Type:Stokes
self.M
Type:stokes_vector
self.dict_params

dictionary with parameters

Type:dict
filter_physical_conditions(tol=1e-06, keep=False)[source]

Function that filters experimental errors by forcing the Stokes vector to fulfill the conditions necessary for a vector to be real light.

Parameters:
  • tol (float) – Tolerance in equalities.
  • keep (bool) – If true, the object is updated to the filtered result. If false, a new fresh copy is created. Default: True.
Returns:

Filtered Stokes vector.

Return type:

S (Stokes)

help()[source]

prints help about dictionary

class py_pol.stokes.Check_Stokes(parent)[source]

Bases: object

Class for Check of Stokes vectors.

Parameters:stokes_vector (Stokes) – Stokes vector
self.parent
Type:Stokes
self.M
Type:stokes_vector
self.dict_params

dictionary with parameters

Type:dict
get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the checks of Stokes vectors.

Parameters:
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
help()[source]

Prints help about dictionary.

TODO

is_circular(tol=1e-06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are circularly polarized.

Parameters:
  • tol (float) – Tolerance.
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to False. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_depolarized(tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are at least partially depolarized.

Parameters:
  • tol (float) – Tolerance.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_left_handed(tol=1e-06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the polarization rotation direction is left-handed.

Parameters:
  • tol (float) – Tolerance.
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to False. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_linear(tol=1e-06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are linearly polarized.

Parameters:
  • tol (float) – Tolerance.
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to False. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_physical(tol=1e-06, give_all=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Tests the conditions of physical realizability:

  • Condition 1: All components must be real.
  • Condition 2: S0 must be positive.
  • Condition 3: The square sum of S1, S2 and S3 must be equal or lower than S0.

References

Handbook of Optics vol 2. 22.34 “Polarized light and the Mueller Matrix approach”, J. J. Gil, pp 187.

Parameters:
  • tol (float) – Tolerance in equality conditions
  • give_all (bool) – If True, the function will return the individual conditions.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Is real or not. ind (dictionary, optional): dictionary with condition, True/False, distance

Return type:

cond (bool)

is_polarized(tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are at least partially polarized.

Parameters:
  • tol (float) – Tolerance.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_right_handed(tol=1e-06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the polarization rotation direction is right-handed.

Parameters:
  • tol (float) – Tolerance.
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to False. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_totally_depolarized(tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are totally depolarized.

Parameters:
  • tol (float) – Tolerance.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

is_totally_polarized(tol=1e-06, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates if the Stokes vectors are totally polarized.

Parameters:
  • tol (float) – Tolerance.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of the condition.

Return type:

(numpy.ndarray or bool)

class py_pol.stokes.Parameters_Stokes_vector(Stokes)[source]

Bases: object

Class for Stokes vector Parameters

Parameters:Stokes_vector (Stokes_vector) – Stokes Vector
self.M
Type:Stokes_vector
self.dict_params

dictionary with parameters

Type:dict
alpha(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the ratio angle between electric field amplitudes.

\[arcsin(E_y/Ex).\]
Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

amplitudes(give_Ez=False, give_unpol=False, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the $E_x$ and $E_y$ field amplitudes of the polarized part of the Stokes vectos. It may also calculate $E_z$ and the field amplitude of the unpolarized part.

Parameters:
  • give_Ez (bool) – If True, it returns the z component of the electric field (all values will be 0). Default: False.
  • give_unpol (bool) – If True, it returns the unpolarized component of the electric field. Default: False.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of electric field amplitude along x axis. E0y (numpy.ndarray or float): Array of electric field amplitude along y axis. E0z (numpy.array, optional): Array of electric field amplitude along z axis.

Return type:

E0x (numpy.ndarray or float)

azimuth(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the rotation angle of the polarization elipse major axis. If S is not fully polarized, azimuth is computed on the fully polarized part of S. Azimuth ranges from 0 to 180 degres (not included this last value).

References

Handbook of Optics vol 2. 22.16 (eq.8)

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

azimuth_ellipticity(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates both the azimuth and ellipticity of the Stokes object.

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

[0, pi): Azimuth. ellipticity (float or numpy.ndarray): [-pi/4, pi/4]: Ellipticity angle.

Return type:

azimuth (float or numpy.ndarray)

charac_angles(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the characteristic angles of the Stokes object.

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

[0, pi/2]: tan(alpha) is the ratio angle between amplitudes of the electric field. delay (float): [0, 2*pi]: phase difference between both components of the electric field.

Return type:

alpha (float)

components(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the $S_0$, $S_1$, $S_2$ and $S_3$ components of the Stokes vector.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of total intensity. S1 (float or numpy.ndarray): Array of linearly horizontal or vertical polarized intensity. S2 (float or numpy.ndarray): Array of linearly 45º or 135º polarized intensity. S3 (float or numpy.ndarray): Array of circularly polarized intensity.

Return type:

S0 (float or numpy.ndarray)

degree_circular_polarization(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of circular polarization (DCP) of the Stokes vectors.

$DCP=

rac{S_{3}}{S_{0}}$

References:
Handbook of Optics vol 2. 22.16 (eq.5)
Parameters:
use_nan (bool): If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True. out_number (bool): if True and the result is a 1x1 array, return a number instead. Default: True. shape_like (float or numpy.ndarray): Use the shape of this array. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. verbose (bool): if True prints the parameter. Default: False. draw (bool): If True and the object is a 1D or 2D, plot it. Default: False.
Returns:
(float or numpy.ndarray): Result
degree_depolarization(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree ofde polarization (DD) of the Stokes vectors.

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result

Return type:

(float or numpy.ndarray)

degree_linear_polarization(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of linear polarization (DLP) of the Stokes vectors.

$DLP=

rac{sqrt{S_{1}^{2}+S_{2}^{2}{S_{0}}$

References:
Handbook of Optics vol 2. 22.16 (eq.4)
Parameters:
use_nan (bool): If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True. out_number (bool): if True and the result is a 1x1 array, return a number instead. Default: True. shape_like (float or numpy.ndarray): Use the shape of this array. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. verbose (bool): if True prints the parameter. Default: False. draw (bool): If True and the object is a 1D or 2D, plot it. Default: False.
Returns:
(float or numpy.ndarray): Result
degree_polarization(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the degree of polarization (DP) of the Stokes vectors.

$DP=

rac{sqrt{S_{1}^{2}+S_{2}^{2}+S_{3}^{2}}}{S_{0}}$

References:
Handbook of Optics vol 2. 22.16 (eq.3)
Parameters:
use_nan (bool): If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True. out_number (bool): if True and the result is a 1x1 array, return a number instead. Default: True. shape_like (float or numpy.ndarray): Use the shape of this array. Default: None. shape (tuple or list): If no shape_like array is given, use this shape instead. Default: None. verbose (bool): if True prints the parameter. Default: False. draw (bool): If True and the object is a 1D or 2D, plot it. Default: False.
Returns:
(float or numpy.ndarray): Result
delay(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Phase shift between $E_x$ and $E_y$ electric field components.

\[\delta_2 - \delta_1.\]
Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

delta(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Phase shift between $E_x$ and $E_y$ electric field components. This is the same as delay.

\[\delta_2 - \delta_1.\]
Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

eccentricity(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

The eccentricity of the polarization ellipse (0 for circular polarization, 1 for linear).

References

Handbook of Optics vol 2. 22.16 (eq.9)

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

ellipse_axes(out_number=True, sort=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the length of major and minor axis (a,b) of the polarization elipse. This is a wrapper around the Parameters_Jones_Vector.ellipse_axes function.

References

  1. Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.3-30a and 3-30b
Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • sort (bool) – If True, it sorts a and b to be the major and minor axis respectively. Default: True. TODO: Check why this is neccessary.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Major axis b (numpy.ndarray or float): Minor axis

Return type:

a (numpy.ndarray or float)

ellipticity_angle(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the ratio angle between the major and minor axis length. It goes from 0 degrees for linearly polarized light to 45 degrees for circular polarized light. Positive sign means left-handed and negative values right-handed rotation direction.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016) pp 13.

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

ellipticity_param(use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the ellipticity parameter: the ratio between the minor and major polarization ellipse axes. It takes only into account the fully polarized part of the Stokes vector. It goes from 0 for linearly polarized light to 1 for circulary polarized light. Positive sign means left-handed and negative values right-handed rotation direction.

References

Handbook of Optics vol 2. 22.16 (eq.7)

Parameters:
  • use_nan (bool) – If True, unknown values are set to np.nan, otherwise they are set to 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

get_all(verbose=False, draw=False)[source]

Creates a dictionary with all the parameters of Stokes vectors.

Parameters:
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
global_phase(give_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Extracts the global phase of the Stokes vector.

Parameters:
  • give_nan (bool) – If False, NaN values are transformed into 0. Default: True.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

help()[source]

TODO: prints help about dictionary

intensity(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the intensity of the Stokes vector ($S_0$).

References

Handbook of Optics vol 2. 22.16 (eq.2)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

irradiance(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the intensity of the Stokes vector ($S_0$).

References

Handbook of Optics vol 2. 22.16 (eq.2)

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Result.

Return type:

(float or numpy.ndarray)

matrix(shape=None, shape_like=None)[source]

Returns the numpy array of the Stokes object.

Parameters:
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

(float or numpy.ndarray) 2xN numpy array.

norm(out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]

Calculates the algebraic norm of the Stokes vectors.

Parameters:
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
  • draw (bool) – If True and the object is a 1D or 2D, plot it. Default: False.
Returns:

Array of total intensity.

Return type:

S0 (float or numpy.ndarray)

polarized_unpolarized(shape_like=None, shape=None, verbose=False)[source]

Divides the Stokes vector in two, one totally polarized and the other totally unpolarized.

References

Handbook of Optics vol 2. 22.16 (eq.6)

Parameters:
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
  • verbose (bool) – if True prints the parameter. Default: False.
Returns:

Totally polarized Stokes object. Su (Stokes): Totally unpolarized Stokes object.

Return type:

Sp (Stokes)

class py_pol.stokes.Stokes(name='S')[source]

Bases: object

Class for Stokes vectors

Parameters:
  • M (float or numpy.ndarray) – 4xN array containing all the Stokes vectors.
  • name (string) – Name of the object for print purposes.
  • shape (tuple or list) – Shape desired for the outputs.
  • size (int) – Number of stored Stokes vectors.
  • ndim (int) – Number of dimensions for representation purposes.
  • global_phase (float or numpy.ndarray) – Global phase of the Stokes vector. If it is a numpy.ndarray, it must have the same number of elements than self.size. It is used for addition and substraction.
  • _type (string) – Type of the object (‘Stokes’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
self.parameters

Class containing the measurable parameters of Stokes vectors.

Type:class
self.checks

Class containing the methods that check something about the Stokes vectors.

Type:class
self.analysis

Class containing the methods to analyze the Stokes vectors.

Type:class
add_depolarization(degree_pol, degree_depol=None, ratio=array([1., 1., 1.]), keep=True, change_name=True)[source]

Function that reduces de polarization degree of a Stokes vector among the three last components.

Parameters:
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • ratio (np.array) – Ratio between the three components of the depolarization degree. When different from [1, 1, 1]. Default: [1, 1, 1].
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Normalized of at the end of the name. Default: True.
Returns:

Result.

Return type:

(Stokes)

add_global_phase(phase=0, unknown_as_zero=False, keep=False)[source]

Function that adds a phase to the Stokes object.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Stokes vectors. Default: 0.
  • unknown_as_zero (bool) – If True, takes unknown phase as zero. Default: False.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Stokes object.

Return type:

(Stokes)

circular_light(kind='d', intensity=1, amplitude=None, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates Stokes vectors for pure circular polarizer light

Parameters:
  • kind (str) – ‘d’,’r’ - right, dextro. ‘l’, ‘i’ - left, levo.
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • degree_pol (numpy.array or float) – Array of polarization degree. Default: 1.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Stokes object. Default: default_phase.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

clear()[source]

Removes all data from the Stokes object.

copy(N=1)[source]

Creates a copy of the object.

Parameters:N (int) – Number of copies. Default: 1.
Returns:Result.
Return type:(Stokes or list)
draw_ellipse(*args, **kwargs)[source]

Draws polarization ellipse of Jones vector.

Parameters:
  • N_angles (int) – Number of angles to plot the ellipses. Default: 91.
  • limit (float) – limit for drawing. If empty itis obtained from ampltiudes.
  • filename (str) – name of filename to save the figure.
  • figsize (tuple) – A tuple of length 2 containing the figure size. Default: (8,8).
  • draw_arrow (bool) – If True, draws an arrow containing the turning sense of the polarization. Does not work with linear polarization vectors. Default: True.
  • depol_central (bool) – If True, draws a central circle containing the unpolarized field amplitude. Default: False.
  • depol_contour (bool) – If True, draws a line enveloping the polarization ellipse in ordeer to plot the depolarization. Default: False.
  • depol_dist (bool) – If True, plots the probability distribution of the electric field. Default: False.
  • subplots (string, tuple or None) – If AS_SHAPE, divides the figure in several subplots as the shape of the py_pol object. If INDIVIDUAL, each vector is represented in its own subaxis, trying to use a square grid. If tuple, divides the figure in that same number of subplots. If None, all ellipses are plot in the same axes. Default: None.
  • N_prob (int) – Number of points in each dimension for probability distributions. Default: 256.
  • contour_levels (tuple) – Contains the contour levels (normalized to 1). Default: (0.1,).
  • cmap (str or color object) – Default colormap for probability distributions. Default: hot.
Returns:

handle to axis. fig (handle): handle to figure.

Return type:

ax (handle)

draw_poincare(*args, **kwargs)[source]

“Draws stokes vector. TODO

Parameters:
angle_view (float, float): elevation, azimuth label (str): text for label of plot filename (str): is not empty saves figure
elliptical_light(a=1, b=1, kind='r', azimuth=0, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Stokes object of the most general light calculated from the polarization ellipse parameters.

Parameters:
  • a (numpy.array or float) – Array of electric amplitude of x axis. Default: 1.
  • b (numpy.array or float) – Array of electric amplitude of y axis. Default: 1.
  • kind (str) – ‘d’,’r’ - right, dextro. ‘l’, ‘i’ - left, levo.
  • azimuth (numpy.array or float) – Angle of the a axis respect to the x axis. Default: 0.
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Stokes object. Default: default_phase.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

flip(axis=None, keep=False, change_name=True)[source]

Flips the elements stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the flip is performed. If None, the object is flipped as flattened. Default: None.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_vector)

from_Jones(E, degree_pol=1, degree_depol=None, length=1, shape_like=None, shape=None)[source]

Creates a Stokes object from a Stokes vectors object or a matrix corresponding to a Stokes vectors.

\[s_0 = abs(E_x)^2 + abs(E_y)^2\]
\[s_1 = (abs(E_x)^2 - abs(E_y)^2) p_1\]
\[s_2 = 2 real(E_x E_y^*) p_1\]
\[s_3 = -2 imag(E_x E_y^*) p_2\]
Parameters:
  • E (Jones_vector object) – Stokes vectors.
  • degree_pol (float or numpy.ndarray) – Degree of polarization of the new Stokes vector. Default: 1.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

from_components(components, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates Stokes vectors directly from the 4 elements [s0, s1, s2, s3]

Parameters:
  • components (tuple) – A 4 element tuple containing the 4 components of the Stokes vectors (S0, S1, S2, S3).
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • length (int) – If amplitude and azimuth are not specified, it is created a 4 x length array of jones vectors. Default: 1.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

from_distribution(Ex, Ey, ind_d=-1, method='direct', N_periods=1, shape_like=None, shape=None)[source]

Determine the Stokes vectors from a temporal or spatial electric field distribution [(Ex(t), Ey(t)].

Parameters:
  • Ex (numpy.ndarray or float) – X component of the electric field
  • Ey (numpy.ndarray or float) – Y component of the electric field
  • ind_d (int) – Index of the spatial or temporal dimension. Default: -1.
  • method (string) – Method for calculating the field amplitude and delay: DIRECT or FIT. Default: direct.
  • N_periods (float) – Number of periods in the representation data. It is used by the fit algorithm (real case only) for calculating the frequency. If the value is not exact, convergency may decrease. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Jones_vector)

from_list(l, degree_pol=1, degree_depol=None, global_phase=0, shape_like=None, shape=None)[source]

Create a Stokes object from a list of size 4 or 4x1 numpy arrays.

Parameters:
  • l (list) – list of matrices.
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

from_matrix(M, degree_pol=1, degree_depol=None, global_phase=0, shape_like=None, shape=None)[source]

Creates a Stokes object from an external array.

Parameters:
  • M (numpy.ndarray) – New matrix. At least one dimension must be of size 4.
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (numpy.ndarray) – Adds a global phase to the Stokes object. Default: 0.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

general_azimuth_ellipticity(azimuth=0, ellipticity=0, intensity=1, amplitude=None, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates Stokes vectors given by their azimuth and ellipticity.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 137.

Parameters:
  • azimuth (float) – [0, pi]: azimuth.
  • ellipticity (float) – [-pi/4, pi/4]: ellipticity.
  • if it is different than None. Default (inetnsity) – None.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • degree_pol (numpy.array or float) – Array of polarization degree. Default: 1.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Stokes object. Default: default_phase.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Stokes vector.

Return type:

S (4x1 numpy.matrix)

general_charac_angles(alpha=0, delay=0, intensity=1, amplitude=None, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates Stokes vectors given by their characteristic angles.

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016),pp 137.

Parameters:
  • alpha (float) – [0, pi]: tan(alpha) is the ratio between field amplitudes of X and Y components.
  • delay (float) – [0, 2*pi]: phase difference between X and Y field components.
  • if it is different than None. Default (inetnsity) – None.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • degree_pol (numpy.array or float) – Array of polarization degree. Default: 1.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Stokes object. Default: default_phase.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Stokes vector.

Return type:

S (4x1 numpy.matrix)

get_list(out_number=True)[source]

Returns a list of 4x1 Stokes vectors.

Parameters:out_number (bool) – if True and the result is a list of size 1, return a number instead. Default: True.
Returns:(numpy.ndarray or list)
linear_light(intensity=1, azimuth=0, amplitude=None, degree_pol=1, degree_depol=None, global_phase=0, length=1, shape_like=None, shape=None)[source]

Creates a Stokes vector of linear polarizer light.

Parameters:
  • intensity (numpy.array or float) – Array of intensity. Default: 1.
  • azimuth (numpy.array or float) – Array of azimuths. Default: 0.
  • amplitude (numpy.array or float) – Array of electric field amplitude. Overrides inetnsity if it is different than None. Default: None.
  • degree_pol (numpy.array or float) – Array of polarization degree. Default: 1.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • global_phase (float or numpy.ndarray) – Adds a global phase to the Stokes object. Default: default_phase.
  • length (int) – If final object is of size 1, it is stretched to match this size. Default: 1.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Created object.

Return type:

(Stokes)

normalize(keep=False, change_name=True)[source]

Function that normalizes the Stokes vectors to have Intensity = 1.

Parameters:
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Normalized of at the end of the name. Default: True.
Returns:

Result.

Return type:

(Stokes)

remove_global_phase(keep=False)[source]

Function that removes the phase to the Stokes object.

Parameters:keep (bool) – If True, self is not updated. Default: False.
Returns:Recalculated Stokes object.
Return type:(Stokes)
rotate(angle=0, keep=False, change_name=True)[source]

Rotates a jones vector a certain angle.

M_rotated = rotation_matrix_Jones(-angle) * self.M

Parameters:
  • angle (float) – Rotation angle in radians.
  • keep (bool) – If True, the original element is not updated. Default: False.
  • change_name (bool) – If True and angle is of size 1, changes the object name adding @ XX deg, being XX the total rotation angle. Default: True.
Returns:

Rotated object.

Return type:

(Jones_vector)

rotate_to_azimuth(azimuth=0, keep=False)[source]

Function that rotates the Stokes vectors to have a certain azimuth.

Parameters:
  • azimuth (string or np.ndarray) – Azimuth of the Stokes vectors. ‘X’, ‘Y’, ‘-X’ and ‘-Y’ are the same as 0, 90, 180 and 270 degrees respectively. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Normalized Stokes vectors.

Return type:

(Jones_vector)

set_depolarization(degree_pol, degree_depol=None, ratio=array([1., 1., 1.]), keep=True, change_name=True)[source]

Function that reduces de polarization degree of a Stokes vector among the three last components.

Parameters:
  • degree_pol (float) – Polarization degree.
  • degree_depol (float) – Depolarization degree. Overrides degree_pol if different than None. Default: None.
  • ratio (np.array) – Ratio between the three components of the depolarization degree. When different from [1, 1, 1]. Default: [1, 1, 1].
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Normalized of at the end of the name. Default: True.
Returns:

Result.

Return type:

(Stokes)

set_global_phase(phase=0, keep=False, length=1, shape_like=None, shape=None)[source]

Function that sets the phase to the Stokes object.

Parameters:
  • phase (float or np.ndarray) – Phase to be added to the Stokes vectors. Default: 0.
  • keep (bool) – If True, self is not updated. Default: False.
  • length (int) – If amplitude and azimuth are not specified, it is created a 4 x length array of jones vectors. Default: 1.
  • shape_like (float or numpy.ndarray) – Use the shape of this array. Default: None.
  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.
Returns:

Recalculated Stokes object.

Return type:

(Stokes)

stretch(length=1, keep=False)[source]

Function that stretches the object to have a higher number of equal elements.

Parameters:
  • length (int) – Number of elements. Default: 1.
  • keep (bool) – If True, self is not updated. Default: False.
Returns:

Recalculated Stokes vectors.

Return type:

(Jones_vector)

sum(axis=None, keep=False, change_name=True)[source]

Calculates the sum of Stokes vectors stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the sum is performed. If None, all vectors are summed.
  • keep (bool) – if True, the original element is not updated. Default: False.
  • change_name (bool) – If True, changes the object name adding Sum of . of at the beggining of the name. Default: True.
Returns:

Modified object.

Return type:

(Jones_matrix)

update()[source]

Internal function. Checks that the .M dimensions are correct.

py_pol.stokes.create_Stokes(name='S', N=1, out_object=True)[source]

Function that creates several Stokes objects att he same time from a list of names or a number.

Parameters:
  • names (str, list or tuple) – name of vector for string representation. If list or tuple, it also represents the number of objects to be created.
  • N (int) – Number of elements to be created. This parameter is overrided if name is a list or tuple. Defeult: 1.
  • out_object (bool) – if True and the result is a list of length 1, return a Stokes object instead. Default: True.
Returns:

List of Stokes vectors

Return type:

S (Stokes or list)

py_pol.stokes.set_printoptions(N_list=None, list_spaces=None)[source]

Function that modifies the global print options parameters.

TODO: Single global function for all modules

Parameters:
  • N_print_list (int) – Number of matrices that will be printed as a list if the shape of the object is 1D.
  • print_list_spaces (int) – Number ofspaces between matrices if they are printed as a list.

4.1.7. py_pol.utils module

Common functions to classes

py_pol.utils.NumberOfSubplots(n)[source]

Auxiliar function to calculate the number of desired subplots.

py_pol.utils.PrintMatrices(list, Nspaces=3)[source]

Creates the print string of a list of matrices to be printed in a line.

Parameters:
  • list (list) – list of matrices.
  • Nspaces (int) – Number of spaces between matrices.
Returns:

String to be printed.

Return type:

str (string)

py_pol.utils.PrintParam(param, verbose=True, draw=True, statistics=True, shape=None, title='', heading='')[source]

Function to print the information during the calculation of some parameters.

Parameters:
  • param (np.array, list or tuple) – List of variables to be represented.
  • verbose (bool) – If True, print the numeric values. Default: True.
  • draw (bool) – If True, plot 1D and 2D parameters. Default: True.
  • statistics (bool) – If True, a basic statistical analysis will be performed. Default: True.
  • shape (list or tuple) – Shape of the elements.
  • title (string or list) – Title or list of titles (1-D and 2-D elements).
py_pol.utils.azimuth_elipt_2_charac_angles(azimuth, ellipticity, out_number=True)[source]

Function that converts azimuth and elipticity to characteristic angles in Jones space.

\[cos(2 \alpha) = cos(2 \phi) * cos(2 \chi)\]
\[tan(\delta) = \frac{tan(2 \chi)}{sin(2 \phi)}\]

TODO: Improve the 2D way of calculating

References

J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016), pp 137 and 1543.

Parameters:
  • azimuth (float or numpy.ndarray) – Azimuth (angle of rotation).
  • ellipticity (float or numpy.ndarray) – Elipticity angle.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
Returns:

tan(alpha) is the ratio between the maximum amplitudes of the polarization elipse in X-Y coordinates. delta (float) [0, 2*pi]: phase difference between both components of the eigenstates in Jones formalism.

Return type:

alpha (float) [0,np.pi]

py_pol.utils.charac_angles_2_azimuth_elipt(alpha, delta)[source]

Function that converts azimuth and elipticity to characteristic angles in Jones space.

\[cos(2 \alpha) = cos(2 \phi) * cos(2 \chi)\]
\[tan(\delta) = \frac{tan(2 \chi)}{sin(2 \phi)}\]

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 137 and 154.
Parameters:
  • alpha (float) – tan(alpha) is the ratio between the maximum
  • of the polarization elipse in X-Y coordinates. (amplitudes) –
  • delta (float) – phase difference between both components of the eigenstates in Jones formalism.
Returns:

Azimuth (angle of rotation). ellipticity (float) [-pi/4,np.pi/4]: Elipticity angle.

Return type:

azimuth (float) [0,np.pi]

py_pol.utils.check_eig(q, m, M)[source]

Function that checks the eigenvalues and eigenvectors.

py_pol.utils.combine_indices(list_ind)[source]

Combines the information given by np.unravel_index.

py_pol.utils.comparison(proposal, solution, maximum_diff=1e-06)[source]

This functions is mainly for testing. It compares compares proposal to solution.

Parameters:
  • proposal (numpy.matrix) – proposal of result.
  • solution (numpy.matrix) – results of the test.
  • maximum_diff (float) – maximum difference allowed.
Returns:

True if comparison is possitive, else False.

Return type:

(bool)

py_pol.utils.delta_kron(a, b)[source]

Computes the Kronecker delta.

Parameters:b (a,) – Numbers.
Returns:Result.
Return type:d (int)
py_pol.utils.distance(x1, x2)[source]

Compute distance between two vectors.

Parameters:
  • x1 (numpy.ndarray) – vector 1
  • x2 (numpy.ndarray) – vector 2
Returns:

distance between vectors.

Return type:

(float)

py_pol.utils.divide_in_blocks(M)[source]

Function that creates a mueller matrix from their block components.

References: J.J. Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016)

Parameters:M (4x4 matrix) – Mueller matrix of the diattenuator.
Returns:Diattenuation vector. Pv (1x3 or 3x1 float): Diattenuation vector. m (3x3 matrix): Small m matrix. m00 (float, default 1): [0, 1] Parameter of average intensity.
Return type:Dv (1x3 or 3x1 float)
py_pol.utils.execute_multiprocessing(__function_process__, dict_parameters, num_processors, verbose=False)[source]

Executes multiprocessing reading a dictionary.

Parameters:
  • __function_process__ (func) – function to process, it only accepts a dictionary
  • dict_parameters (dict) – dictionary / array with parameters
  • num_processors (int) – Number of processors. if 1 no multiprocessing is used
  • verbose (bool) – Prints processing time.
Returns:

results of multiprocessing (float): processing time

Return type:

data

Example:

def __function_process__(xd):
    x = xd['x']
    y = xd['y']
    # grt = copy.deepcopy(grating)
    suma = x + y
    return dict(sumas=suma, ij=xd['ij'])

def creation_dictionary_multiprocessing():
    # create parameters for multiprocessing
    t1 = time.time()
    X = sp.linspace(1, 2, 10)
    Y = sp.linspace(1, 2, 1000)
    dict_parameters = []
    ij = 0
    for i, x in enumerate(X):
        for j, y in enumerate(Y):
            dict_parameters.append(dict(x=x, y=y, ij=[ij]))
            ij += 1
    t2 = time.time()
    print "time creation dictionary = {}".format(t2 - t1)
    return dict_parameters
py_pol.utils.expand_objects(lista, length=1, copy=False)[source]

Expand a list of objects.

Parameters:
  • lista (list) – List of py_pol objects.
  • length (int) – If some variables must be expanded but all of them have length 1, this will be the length of the new variables. Default: 1.
  • copy (bool) – If True, the object are copied. Default: False.
Returns:

List of expanded objects.

Return type:

new_list (list)

py_pol.utils.extract_azimuth_elipt(vector, use_nan=True)[source]

Function that extracts azimuth and ellipticity from a diattenuation, polarizance or retardance vector. All of them are of the form of: TODO.

\[cos(2 \alpha) = cos(2 \phi) * cos(2 \chi)\]
\[tan(\delay) = \tan(2 \chi) / sin(2 \phi)\]

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 128 and 142.
Parameters:vector (np.array 1x3 or 3x1) – vector to be measured
Returns:Azimuth (angle of rotation). ellipticity (float) [-pi/4,np.pi/4]: Elipticity angle.
Return type:azimuth (float) [0,np.pi]
py_pol.utils.extract_charac_angles(vector, use_nan=True, type='diattenuator')[source]

Function that extracts azimuth and ellipticity from a diattenuation, polarizance or retardance vector. All of them are of the form of: TODO.

\[cos(2 \alpha) = cos(2 \phi) * cos(2 \chi)\]
\[tan(\delay) = \frac{tan(2 \chi)}{sin(2 \phi)}\]

References

    1. Gil, “Polarized light and the Mueller Matrix approach”, pp 128 and 142.
Parameters:vector (np.array 1x3 or 3x1) – vector to be measured
Returns:tan(alpha) is the ratio between the maximum amplitudes of the polarization elipse in X-Y coordinates. delay (float) [0, 2*pi]: phase difference between both components of the eigenstates in Jones formalism.
Return type:alpha (float) [0,np.pi]
py_pol.utils.fit_cos(par, x, y)[source]

Function to fit a cos function using the least_squares function from scipy.optimize.

py_pol.utils.fit_distribution(param, dist, irrelevant=0)[source]
py_pol.utils.fit_sine(t, data, has_draw=True)[source]

fit a sine function

py_pol.utils.inv_pypol(M)[source]

Calculates the inverse matrix of the matrix of a py_pol object.

Parameters:M (numpy.ndarray) – Array to calculate the inverse. Its shape must be (NxNxM). The result will have the same shape.
Returns:Result.
Return type:(numpy.ndarray)
py_pol.utils.iscolumn(v)[source]

Checks if the array v is a column array or not.

Parameters:v (array) – Array to be tested.
Returns:True if v is a column array.
Return type:cond (bool)
py_pol.utils.isrow(v)[source]

Checks if the array v is a row array or not.

Parameters:v (array) – Array to be tested.
Returns:True if v is a row array.
Return type:cond (bool)
py_pol.utils.kron_axis(a, b, axis=None)[source]

Function that implements the kronecker product along a given axis.

Parameters:
  • b (a,) – Arrays to perform the operation.
  • axis (int) – Axis to perform the operation. a and b sizes in the rest of dimensions must be the same. If None, default np.kron is used.
Result:
(numpy.ndarray): Result.
py_pol.utils.list_of_objects(size, type_object)[source]

Creates a list of objects.

py_pol.utils.list_of_objects_depercated(size, type_object)[source]

Creates a list of objects.

py_pol.utils.matmul_pypol(M1, M2)[source]

Calculates the multiplication of two matrices from pypol objects.

Parameters:
  • M1, (numpy.ndarray) – Left array to multiply. Its shape must be (NxNxM).
  • M1, – Right array to multiply. Its shape must be (NxNxM) or (NxM). The result will have the same shape.
Returns:

Result.

Return type:

(numpy.ndarray)

py_pol.utils.merge_indices(ind1, ind2, axis)[source]

Merges two sets of indices with poritions given by axis.

py_pol.utils.multitake(arr, indices, axes)[source]

Function that implements the numpy.take function in multiple axes.

Parameters:
  • arr (numpy.ndarray) – Original array.
  • indices (tuple or list) – List with the indices values. In this function, only one value per axis is allowed.
  • axes (tuple or list) – List of axes.
Returns:

Taken array.

Return type:

arr (numpy.ndarray)

py_pol.utils.nearest(vector, number)[source]

Computes the nearest element in vector to number.

Parameters:
  • vector (numpy.ndarray) – array with numbers
  • number (float) – number to determine position
Returns:

index - index of vector which is closest to number. (float): value - value of vector[index]. (float): distance - difference between number and chosen element.

Return type:

(int)

py_pol.utils.nearest2(vector, numbers)[source]

Computes the nearest element in vector to numbers.

Parameters:
  • vector (numpy.ndarray) – array with numbers
  • number (numpy.ndarray) – numbers to determine position
Returns:

index - indexes of vector which is closest to number. (numpy.ndarray): value - values of vector[indexes]. (numpy.ndarray): distance - difference between numbers and chosen elements.

Return type:

(numpy.ndarray)

py_pol.utils.obj_error(sol, test, shape=None, shape_like=None, out_number=None)[source]

Calculates the difference between two abjects and calculates the error as the norm.

py_pol.utils.order_eig(val, vect, kind='normal')[source]

Function that orders the eigenvalues from max to min, and then orders the eigenvectors following the same order.

Parameters:
  • val (numpy.ndarray) – Array of eigenvalues.
  • vect (numpy.ndarray) – Matrix with the eigenvectors as columns.
  • kind (string) – Choses if the sort order is normal (min to max) or reverse (max to min).
Returns:

Array of ordered eigenvalues. m (numpy.ndarray): Matrix with the eigenvectors ordered as columns.

Return type:

q (numpy.ndarray)

py_pol.utils.params_to_list(J, verbose=False)[source]

Makes a list from data provided at parameters.dict_params

Parameters:
  • J (object) – Object Jones_vector, Jones_matrix, Stokes or Mueller.
  • verbose (bool) – If True prints the parameters
Returns:

List with parameters from dict_params.

Return type:

(list)

py_pol.utils.prepare_variables(vars, expand=[False], length=1, obj=None, give_shape=False)[source]

Function that forces all variables of creation methods to be arrays, checks if all variables are a number or arrays of the same size, and expands the required variables if neccessary. If an object is introduced, it also checks that the length of the variables corresponds to the required lengtth for the object.

Parameters:
  • vars (list) – List of variables.
  • expand (bool or list) – List of bools indicating which variables must be expanded.
  • length (int) – If some variables must be expanded but all of them have length 1, this will be the length of the new variables.
  • obj (Py_pol object) – Optical element object.
Returns:

List of prepared variables. obj (Py_pol object): Optical element object (only if an obj was given to the function). shape (tuple): Shape of the variable with higher dimensionality.

Return type:

vars (list)

py_pol.utils.prepare_variables_blocks(M00=None, Dv=None, Pv=None, m=None, extend=[False, False, False, False], multiply_by_M00=False, length=1, obj=None, other_shape=None, give_shape=False)[source]

Function that forces Mueller matrix block variables to be arrays of the desired size, checks they are compatible between them, and expands the required variables. If an object is introduced, it also checks that the length of the variables corresponds to the required lengtth for the object.

Parameters:
  • M00 (numpy.ndarray or float) – Mean transmission coefficient.
  • Dv (numpy.ndarray) – Diattenuation vector. At least one of its dimensions must be of size 3.
  • Pv (numpy.ndarray) – Polarizance vector. At least one of its dimensions must be of size 3.
  • m (numpy.ndarray) – Small matrix m. At least two of its dimensions must be of size 3.
  • extend (tuple or list with 4 bools) – For each value, stretch the corresponding variable to match max size. Default: [False] * 4.
  • multiply_by_M00 (bool) – If True, multiplies Dv, Pv and m by M00.
  • length (int) – If some variables must be expanded but all of them have length 1, this will be the length of the new variables.
  • obj (Py_pol object) – Optical element object.
  • give_shape (bool) – If True, the output includes the shape variable.
  • other_shape (int, tuple or list) – Other suggested shape given by prepare_variables function.
Returns:

1xN array. Dv (numpy.ndarray): 3xN array. Pv (numpy.ndarray): 3xN array. m (numpy.ndarray): 3x3xN array. obj (Py_pol object): Optical element object (only if an obj was given to the function). shape (tuple): Shape of the variable with higher dimensionality.

Return type:

M00 (numpy.ndarray or float)

py_pol.utils.put_in_limits(x, typev, out_number=True)[source]

When dealing with polarization elipse coordinates, make sure that they are in the valid limits, which are set in the declaration of this class.

Parameters:
  • x (1xN array) – Value
  • typev (string) – Which type of variable is: alpha, delta, azimuth or ellipticity.
  • out_number (bool) – if True and the result is a 1x1 array, return a number instead. Default: True.
Returns:

Corresponding angle inside the valid limits.

Return type:

y (1xN array)

py_pol.utils.repair_name(name_initial)[source]

Repairs name when several angles are included.

Example

M1 @45.00deg @45.00deg @45.00deg @45.00deg @45.00deg @45.00deg @45.00deg

passes to:

M1 @135.00deg

Parameters:name_initial (str) – String with the name.
Returns:Repaired name
Return type:(str)
py_pol.utils.reshape(vars, shape_like=None, shape_fun=None, shape=None, obj=None)[source]

Reshapes an array of parameters to have the desired shape.

Parameters:
  • vars (list) – List of variables.
  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object to reshape the variables.
  • shape_fun (tuple, list or string) – User-defined shape. If it is a string (like ‘array’) no manipulation is performed.
  • shape (tuple or list) – Default shape.
  • obj (py_pol object) – Py_pol object to take the shape from. Its preference is less than shape_like.
Returns:

Reshaped list of variables.

Return type:

vars (list)

py_pol.utils.rotation_matrix_Jones(angle, length=1)[source]

Creates an array of Jones 2x2 rotation matrices.

Parameters:
  • angle (np.array) – array of angle of rotation, in radians.
  • length (int) – If some variables must be expanded but all of them have length 1, this will be the length of the new variables.
Returns:

2x2xN matrix

Return type:

numpy.array

py_pol.utils.rotation_matrix_Mueller(angle=0)[source]

Mueller 4x4 matrix for rotation

References

Gil, Ossikovski (4.30) - p. 131 Handbook of Optics vol 2. 22.16 (eq.8) is with changed sign in sin

Parameters:angle (float) – angle of rotation with respect to 0 deg.
Returns:4x4xN rotation matrix.
Return type:(numpy.array)
py_pol.utils.select_shape(obj=None, shape_var=None, shape_fun=None, shape_like=None)[source]

Selects which shape to save.

Parameters:
  • obj (py_pol object) – Object to be applied the shape. It is given here to check if the new shape is correct.
  • shape_var (tuple or list) – Shape of variables.
  • shape_fun (tuple or list) – Shape introduced manually by the user.
  • shape_like (numpy.ndarray or py_pol object) – Object to take the shape from.
Returns:

Selected shape. ndim (int): Number of dimensions.

Return type:

shape (tuple or list)

py_pol.utils.take_shape(objs)[source]

Calculates the shape with higher dimensionality.

py_pol.utils.which_quad(angle, octant=True)[source]

Auxiliary function to calculate which quadrant or octant angle belongs to. Half angles means that it is exactly between two quarants.

Parameters:(float) – Angle to determine the quadrant.
Returns:Quadrant
Return type:(float)

4.1.8. Module contents

Top-level package for Python polarization.