Welcome to Python polarization’s documentation!¶
Python polarization¶
 Free software: MIT license
 Documentation: https://pypol.readthedocs.io/en/latest/
Features¶
Pypol is a Python library for Jones and StokesMueller polarization optics. It has 4 main module:
 jones_vector  for generation of polarization states in 2x1 Jones formalism.
 jones_matrix  for generation of 2x2 matrix polarizers.
 stokes  for generation of polarization states in 2x2 Stokes formalism.
 mueller  for generation of 4x4 matrix polarizers.
Each one has its own class, with multiple methods for generation, operation and parameters extraction.
Examples¶
Jones formalism¶
Generating Jones vectors and Matrices
from py_pol.jones_vector import Jones_vector
from py_pol.jones_matrix import Jones_matrix
from py_pol.utils import degrees
j0 = Jones_vector("j0")
j0.linear_light(angle=45*degrees)
m0 = Jones_matrix("m0")
m0.diattenuator_linear( p1=0.75, p2=0.25, angle=45*degrees)
m1 = Jones_matrix("m1")
m1.quarter_waveplate(angle=0 * degrees)
j1=m1*m0*j0
Extracting information form Jones Vector.
print(j0,'\n')
print(j0.parameters)
j0 = [+0.707; +0.707]'
parameters of j0:
intensity : 1.000 arb.u
alpha : 45.000 deg
delay : 0.000 deg
azimuth : 45.000 deg
ellipticity angle: 0.000 deg
a, b : 1.000 0.000
phase : 0.000 deg
print(j1,'\n')
print(j1.parameters)
m1 * m0 @45.00 deg * j0 = [+0.530+0.000j; +0.000+0.530j]'
parameters of m1 * m0 @45.00 deg * j0:
intensity : 0.562 arb.u
alpha : 45.000 deg
delay : 90.000 deg
azimuth : 8.618 deg
ellipticity angle: 45.000 deg
a, b : 0.530 0.530
phase : 0.000 deg
Extracting information form Jones Matrices.
print(m0,'\n')
print(m0.parameters)
m0 @45.00 deg =
[+0.500, +0.250]
[+0.250, +0.500]
parameters of m0 @45.00 deg:
is_homogeneous: True
delay: 0.000 deg
diattenuation: 0.800
print(m1,'\n')
print(m1.parameters)
m1 =
[+1+0j, +0+0j]
[+0+0j, +0+1j]
parameters of m1:
is_homogeneous: True
delay: 90.000 deg
diattenuation: 0.000
StokesMueller formalism¶
Generating Stokes vectors and Mueller matrices.
from py_pol.stokes import Stokes
from py_pol.mueller import Mueller
from py_pol.utils import degrees
j0 = Stokes("j0")
j0.linear_light(angle=45*degrees)
m1 = Mueller("m1")
m1.diattenuator_linear(p1=1, p2=0, angle=0*degrees)
j1=m1*j0
Extracting information from Stokes vectors.
Determining the intensity of a Stokes vector:
i1=j0.parameters.intensity()
print("intensity = {:4.3f} arb. u.".format(i1))
intensity = 1.000 arb. u.
Determining all the parameters of a Stokes vector:
print(j0,'\n')
print(j0.parameters)
j0 = [ +1; +0; +1; +0]
parameters of j0:
intensity : 1.000 arb. u.
amplitudes : E0x 0.707, E0y 0.707, E0_unpol 0.000
degree polarization : 1.000
degree linear pol. : 1.000
degree circular pol.: 0.000
alpha : 45.000 deg
delay : 0.000 deg
azimuth : 45.000 deg
ellipticity angle : 0.000 deg
ellipticity param : 0.000
eccentricity : 1.000
polarized vector : [+1.000; +0.000; +1.000; +0.000]'
unpolarized vector : [+0.000; +0.000; +0.000; +0.000]'
print(j1,'\n')
print(j1.parameters)
m1 * j0 = [+0.500; +0.500; +0.000; +0.000]
parameters of m1 * j0:
intensity : 0.500 arb. u.
amplitudes : E0x 0.707, E0y 0.000, E0_unpol 0.000
degree polarization : 1.000
degree linear pol. : 1.000
degree circular pol.: 0.000
alpha : 0.000 deg
delay : 0.000 deg
azimuth : 0.000 deg
ellipticity angle : 0.000 deg
ellipticity param : 0.000
eccentricity : 1.000
polarized vector : [+0.500; +0.500; +0.000; +0.000]'
unpolarized vector : [+0.000; +0.000; +0.000; +0.000]'
Extracting information from Mueller matrices.
m2 = Mueller("m2")
m2.diattenuator_retarder_linear(D=90*degrees, p1=1, p2=0.5, angle=0)
delay = m2.parameters.retardance()
print("delay = {:2.1f}º".format(delay/degrees))
delay = 90.0º
There is a function in Parameters_Jones_Vector class, .get_all() that will compute all the parameters available and stores in a dictionary .dict_params(). Info about dict parameters can be revised using the print function.
print(m2,'\n')
m2.parameters.get_all()
print(m2.parameters)
m2 =
[+0.6250, +0.3750, +0.0000, +0.0000]
[+0.3750, +0.6250, +0.0000, +0.0000]
[+0.0000, +0.0000, +0.0000, +0.5000]
[+0.0000, +0.0000, 0.5000, +0.0000]
Parameters of m2:
Transmissions:
 Mean : 62.5 %.
 Maximum : 100.0 %.
 Minimum : 25.0 %.
Diattenuation:
 Total : 0.600.
 Linear : 0.600.
 Circular : 0.000.
Polarizance:
 Total : 0.600.
 Linear : 0.600.
 Circular : 0.000.
Spheric purity : 0.872.
Retardance : 1.571.
Polarimetric purity : 1.000.
Depolarization degree : 0.000.
Depolarization factors:
 Euclidean distance : 1.732.
 Depolarization factor : 0.000.
Polarimetric purity indices:
 P1 : 1.000.
 P2 : 1.000.
 P3 : 1.000.
There are many types of Mueller matrices. The Check_Mueller calss implements all the checks that can be performed in order to clasify a Mueller matrix. They are stored in the checks field of Mueller class.
m1 = Mueller("m1")
m1.diattenuator_linear(p1=1, p2=0.2, angle=0*degrees)
print(m1,'\n')
c1 = m1.checks.is_physical()
c2 = m1.checks.is_homogeneous()
c3 = m1.checks.is_retarder()
print('The linear diattenuator is physical: {}; hogeneous: {}; and a retarder: {}.'.format(c1, c2, c3))
m1 =
[+0.520, +0.480, +0.000, +0.000]
[+0.480, +0.520, +0.000, +0.000]
[+0.000, +0.000, +0.200, +0.000]
[+0.000, +0.000, +0.000, +0.200]
The linear diattenuator is physical: True; hogeneous: True; and a retarder: False.
Drawings¶
The modules also allows to obtain graphical representation of polarization.
Drawing polarization ellipse for Jones vectors.
Drawing polarization ellipse for Stokes vectors with random distribution due to unpolarized part of light.
Drawing Stokes vectors in Poincare sphere.
Authors¶
Luis Miguel Sanchez Brea <optbrea@ucm.es>
Jesus del Hoyo <jhoyo@ucm.es>
Universidad Complutense de Madrid, Faculty of Physical Sciences, Department of Optics Plaza de las ciencias 1, ES28040 Madrid (Spain)
Citing¶
L.M. Sanchez Brea, J. del Hoyo “pypol, python module for polarization optics”, https://pypi.org/project/pypol/ (2019)
References¶
 D Goldstein “Polarized light” 2nd edition, Marcel Dekker (1993).
 JJ Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016).
 C Brosseau “Fundamentals of Polarized Light” Wiley (1998).
 R MartinezHerrero, P.M. Mejias, G.Piquero “Characterization of partially polarized light fields” Springer series in Optical sciences (2009).
 JM Bennet “Handbook of Optics 1” Chapter 5 ‘Polarization’.
 RA Chipman “Handbook of Optics 2” Chapter 2 ‘Polarimetry’.
 SY Lu and RA Chipman, “Homogeneous and inhomogeneous Jones matrices”, J. Opt. Soc. Am. A 11(2) 766 (1994).
Acknowlegments¶
This software was initially developed for the project RetosColaboración 2016 “Ecograb” RTC201652775: Ministerio de Economía y Competitivdad (Spain) and the European funds for regional development (EU), led by Luis Miguel SanchezBrea
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutterpypackage project template.
Installation¶
Stable release¶
To install Python polarization, run this command in your terminal:
$ pip install py_pol
This is the preferred method to install Python polarization, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for Python polarization can be downloaded from the Bitbucket repo.
You can either clone the public repository:
$ git clone git@bitbucket.org:optbrea/py_pol.git
$ git clone https://optbrea@bitbucket.org/optbrea/py_pol.git
Once you have a copy of the source, you can install it with:
$ python setup.py install
py_pol¶
py_pol package¶
Submodules¶
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:
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
 MartinezHerrero, P.M. Mejias, G.Piquero “Characterization of partially polarized light fields” Springer series in Optical sciences (2009) ISBN 9783642013263, 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:

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:

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:

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:

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:

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:

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:

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:

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 (5254)
 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:

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:

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:

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:

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 halfwaveplate \(\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:

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:

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:

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:

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:

quarter_waveplate
(azimuth=0, global_phase=0, length=1, shape_like=None, shape=None)[source]¶ Jones matrix of an ideal quarterwaveplate \(\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:

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:

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:

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:

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:

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_en_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:

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:

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:

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:

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:

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:

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:

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”, ShihYau 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.
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 lefthanded.
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 righthanded.
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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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
 Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.335
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
 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
 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
 Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.333b.
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
 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
 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
 Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.333b.
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
 Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.330a and 330b
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
 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.
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=1e06, 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 nonzero eigenvalues, the decomposed retarder is often erroneous (6080% 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=1e06, 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=1e06, 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 (13) 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)

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.

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:
 Depolarization index > 0.
 $m = m^T$ (m being the small m matrix).
References
 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:
 Diattenuation > 0.
 $M = M^T$.
 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 nondepolarizing (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=1e06, 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(1Dight)^{2}geqmathop{sum_{i=1}^{3}M_{0i}^{2}left(1sum_{j=1}^{3} rac{M_{ij}}{M_{00}D} ight)}^{2}$.
7b. $M_{00}^{2}left(1Pight)^{2}geqmathop{sum_{i=1}^{3}M_{i0}^{2}left(1sum_{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:
 Polarizance > 0.
 $M = M^T$.
 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:
 Diatteunation = 0.
 Polarizance = 0.
 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)

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:

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:

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 halfwave 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 quarterwave 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:

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)

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 128130.
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.
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 fullypolarized and Su fullyunpolarized.
 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.
M
¶ Type: stokes_vector

self.
dict_params
¶ dictionary with parameters
Type: dict

filter_physical_conditions
(tol=1e06, 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)


class
py_pol.stokes.
Check_Stokes
(parent)[source]¶ Bases:
object
Class for Check of Stokes vectors.
Parameters: stokes_vector (Stokes) – Stokes vector 
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.

is_circular
(tol=1e06, 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=1e06, 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=1e06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]¶ Calculates if the polarization rotation direction is lefthanded.
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=1e06, 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=1e06, 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=1e06, 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=1e06, use_nan=True, out_number=True, shape_like=None, shape=None, verbose=False, draw=False)[source]¶ Calculates if the polarization rotation direction is righthanded.
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=1e06, 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=1e06, 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
 Golstein “Polarized light” 2nd ed Marcel Dekker (2003), 3.4 eq.330a and 330b
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 lefthanded and negative values righthanded 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 lefthanded and negative values righthanded 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)

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)

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:

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:

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:

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:

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:

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:

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.
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 (1D and 2D 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 XY 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
 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 XY 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.
comparison
(proposal, solution, maximum_diff=1e06)[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
 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
 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 XY 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.
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.
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) – Userdefined 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)
Module contents¶
Toplevel package for Python polarization.
Tutorials¶
Tutorials¶
These documents help to start to use the four basic modules of py_pol: Jones_vector, Jones_matrix, Stokes and Mueller. There is also a fifth tutorial centered in the representation of polarization states.
Draw¶
There are two usual methods for light waves polarization representation: polarization ellipse and Poincaré sphere.
[1]:
%load_ext autoreload
%autoreload 2
import numpy as np
from py_pol.jones_vector import Jones_vector, degrees
from py_pol.stokes import Stokes
Polarization ellipse¶
Pure states¶
The trajectory of the electric field vector of pure (totally polarized) light waves is an ellipse. This ellipse is often used to represent polarization states, as it allows identifying easily some of its properties. py_pol has a method in Jones_vector and Stokes classes to plot the polarization ellipses: draw_ellipse.
[2]:
J = Jones_vector('Circular light')
J.circular_light(intensity=2, kind='r')
print(J)
axis, fig = J.draw_ellipse(draw_arrow=True, figsize=(5,5))
Circular light =
[+1.000+0.000j]
[+0.000+1.000j]
Same for Stokes objects.
[3]:
S = Stokes('Circular light')
S.circular_light(intensity=2, kind='r')
print(S)
axis, fig = S.draw_ellipse(draw_arrow=True, figsize=(5,5))
Circular light =
[+2.000]
[+0.000]
[+0.000]
[+2.000]
Plot multiple ellipses in a single plot¶
py_pol objects may have more than one element stored inside. The most basic method of representation consists on plotting all the ellipses in the same figure:
[4]:
# It is the same for Stokes class
S = Stokes('Elliptical light')
angles = np.linspace(0, 180*degrees, 7)
S.general_azimuth_ellipticity(amplitude=2, azimuth=angles, ellipticity=15*degrees)
S.draw_ellipse(draw_arrow=True, figsize=(6, 6))
[4]:
(<Figure size 432x432 with 1 Axes>,
[<AxesSubplot:title={'center':'Elliptical light'}, xlabel='$E_x (V/m)$', ylabel='$E_y (V/m)$'>])
Plot several ellipses in multiple plots¶
It is possible to divide the plots into several ones using the subplots argument. The first option is INDIVIDUAL, which represents each ellipse in its own subplot. These subplots are represented in a square grid (or the closest to a square grid, depending on the number of elements of the object):
[5]:
J = Jones_vector('Linear light')
angles = np.linspace(0, 180*degrees, 5)
J.linear_light(amplitude=2, azimuth=angles)
_ = J.draw_ellipse(draw_arrow=True, subplots='Individual', figsize=(6, 12))
The second option is AS_SHAPE, which uses the shape of the object. 1D objects will be plotted as a row array of plots with one ellipse in each subplot. 2D arrays will be plotted as a matrix array with the same shape as the object. Objects of higher dimensionality will be plotted as a matrix array with the shape of the two first dimensions, plotting more than one ellipse per subplot.
[6]:
# 1D object
J = Jones_vector('Linear light')
angles = np.linspace(0, 180*degrees, 5)
J.linear_light(amplitude=2, azimuth=angles)
_ = J.draw_ellipse(draw_arrow=True, subplots='As_shape', figsize=(15, 4))
[7]:
# 2D object
J = Jones_vector('Light source')
az = np.linspace(0, 90*degrees, 5)
el = np.linspace(0, 45*degrees, 3)
AZ, EL = np.meshgrid(az, el)
J.general_azimuth_ellipticity(amplitude=2, azimuth=AZ, ellipticity=EL)
_ = J.draw_ellipse(draw_arrow=True, subplots='as_shape', figsize=(16, 13))
[8]:
# Higher dimensionality object
J = Jones_vector('Light source')
angles = np.linspace(0, 90*degrees, 5)
ell = np.linspace(15, 40, 5)*degrees
intensity = np.linspace(1, 3, 3)
Ell, I, Angles = np.meshgrid(ell, intensity, angles)
J.general_azimuth_ellipticity(azimuth=Angles, ellipticity=Ell, intensity=I)
_ = J.draw_ellipse(draw_arrow=True, depol_central=True, subplots='as_shape', figsize=(20, 15))
Finally, it is possible to give the method a 2element tuple as the desired shape.
[9]:
J = Jones_vector('Light source')
angles = np.linspace(0, 90*degrees, 10)
ell = np.linspace(15, 40, 6)*degrees
Ell, Angles = np.meshgrid(ell, angles)
J.general_azimuth_ellipticity(azimuth=Angles, ellipticity=Ell, intensity=2)
_ = J.draw_ellipse(draw_arrow=True, depol_central=True, subplots=(3,5), figsize=(20, 15))
Plot partially polarized states¶
Partially polarized states can be decomposed in a totally polarized state plus a totally depolarized state. The totally unpolarized light electric field vector position will be random, with its module dependent on the unpolarized intensity. Then, the total electric field will be the coherent sum of both fields.
py_pol can plot partially polarized states in three different ways. The first one is plotting at the same time the totally polarized part ellipse and the circle whose radius is the expected electric field amplitude of the unpolarized part. This is done by setting the depol_central argument as True.
[10]:
S = Stokes('Light source')
angles = np.linspace(0, 90*degrees, 5)
ell = np.linspace(15, 40, 5)*degrees
deg = np.linspace(0.2, 0.6, 3)
Ell, Deg, Angles = np.meshgrid(ell, deg, angles)
S.general_azimuth_ellipticity(amplitude=2, azimuth=Angles, ellipticity=Ell, degree_depol=Deg)
# print(J)
_ = S.draw_ellipse(draw_arrow=True, depol_central=True, subplots='as_shape', figsize=(20, 15))
The second way is plotting the ellipses which outline the region with a certain probability of finding the total electric field vector. This is done by setting the depol_contour argument as True. The argument contour_levels contains the probability levels which the lines contain. If several ones are used, several lines will be plotted.
[11]:
S = Stokes('Light source')
S.general_azimuth_ellipticity(amplitude=2, azimuth=45*degrees, ellipticity=15*degrees, degree_depol=0.2)
_ = S.draw_ellipse(draw_arrow=True, depol_contour=True, contour_levels=(0.05, 0.2, 0.5,))
The last method is plotting the probability distribution of the electric field. This is done by setting the depol_prob argument to True. The colormap of the probability distribution is varied using the cmap argument.
NOTE: This possibility forces the INDIVIDUAL option of subplots.
[12]:
S = Stokes('Light source')
S.general_azimuth_ellipticity(amplitude=2, azimuth=45*degrees, ellipticity=15*degrees, degree_depol=0.2)
_ = S.draw_ellipse(draw_arrow=True, depol_prob=True, depol_contour=True, contour_levels=(0.05, 0.2, 0.5,))
Poincaré sphere¶
The second representation method is the Poincaré sphere. Each Stokes vector can be represented in a sphere using \(S_1\), \(S_2\) and \(S_3\) as \(x\), \(y\) and \(z\) coordinates. Pure states represent the surface of the wphere, the origin of the sphere for a totally depolarized state (natural light), and the rest of the sphere volume correspond to partially polarized light.
A Stokes object can be plotted in a Poincaré sphere using the draw_poincare method:
[14]:
S = Stokes('Linear light')
S.linear_light(azimuth=0)
print(S)
S.draw_poincare(axis_equal=True)
Linear light =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
[14]:
([<Axes3DSubplot:title={'center':'Linear light'}, xlabel='$S_1$', ylabel='$S_2$'>],
<Figure size 432x432 with 1 Axes>)
Again, Stokes objects with more than one vector can be used.
[15]:
S = Stokes('Linear light')
S.linear_light(azimuth=np.linspace(0,180,13)*degrees)
ax, fig = S.draw_poincare()
If an object has multiple Stokes vectors, the figure may be divided into subplots using the subplots argument:
[16]:
S = Stokes('Linear light')
S.linear_light(azimuth=np.linspace(0,90,5)*degrees)
ax, fig = S.draw_poincare(figsize=(16,5), subplots='as_shape')
py_pol has a powerful option to improve the data representation. By default, Stokes vectors are normalized before plotting them in the Poincaré sphere. This allows comparing the vectors easily, but the intensity information is lost.
But we can set the color_scatter argumento to INTENSITY in order to set the point color to match the intensity.
[17]:
S = Stokes('Linear light')
S.linear_light(azimuth=np.linspace(0,90,5)*degrees, intensity=np.linspace(1,5,5))
ax, fig = S.draw_poincare(figsize=(20,5), subplots='as_shape', color_scatter='Intensity')
The images plot points by deffault. However, it is possible to plot the lines between them when more than two points are plotted in the same image by changing the kind argument to LINE or BOTH:
[18]:
S = Stokes('Linear light')
S.linear_light(azimuth=np.linspace(0,90,5)*degrees, intensity=np.linspace(1,5,5))
ax, fig = S.draw_poincare(figsize=(20,5), kind='both', color_scatter='Intensity')
Other considerations¶
Save the figure as an image file¶
Finally, it is possible to save the figures if a valid file name is given to the filename argument.
[19]:
S = Stokes('Source 1')
angles = np.linspace(0, 90*degrees, 5)
ell = np.linspace(15, 40, 5)*degrees
deg = np.linspace(0.1, 0.5, 3)
Ell, Deg, Angles = np.meshgrid(ell, deg, angles)
S.general_azimuth_ellipticity(amplitude=2, azimuth=Angles, ellipticity=Ell, degree_depol=Deg)
# print(J)
_ = S.draw_ellipse(draw_arrow=True, depol_central=True, subplots='as_shape', figsize=(20, 15), filename='Subplots figure.jpg')
Image Subplots figure.jpg saved succesfully!
Jones_matrix class¶
Jones_matrix is a class that manages Jones matrices. It allows the user to create and manipulate them.
Creating an instance¶
An instance must be created before starting to operate with the Jones matrix. The initialization accepts one argument: the name of the vector. This name will be used for printing:
[2]:
from py_pol.jones_matrix import Jones_matrix, create_Jones_matrices
from py_pol.utils import degrees
import numpy as np
[3]:
J = Jones_matrix("empty_polarizer")
print(J)
empty_polarizer is empty
Several Jones_matrix objects can be created at the same time using the function create_Jones_matrices.
[4]:
J1, J2 = create_Jones_matrices(name=('Element 1', 'Element 2'))
print(J1, J2)
list_of_J = create_Jones_matrices(N=3)
print(list_of_J)
Element 1 is empty
Element 2 is empty
[J is empty
, J is empty
, J is empty
]
Jones_matrix class fields¶
Jones_matrix class objects have some fields where some methods and information is stored:
 M: 2x2xN array containing all the Jones matrices.
 name: Name of the object for print purposes.
 shape: Shape desired for the outputs.
 size: Number of stored Jones matrices.
 ndim: Number of dimensions for representation purposes.
 no_rotation: If True, rotation method do not act upon the object. Useful for objects that shouldn’t be rotated as mirrors.
 **_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.
 parameters: Object of class Parameters_Jones_matrix.
 checks: Object of class Checks_Jones_matrix.
 analysis: Object of class Analysis_Jones_matrix.
[5]:
J = Jones_matrix("Linear diattenuator")
angles = np.linspace(0, 90*degrees, 5)
J.diattenuator_linear(p1=1, p2=0.1, azimuth=angles)
print('Array: ', J.M)
print('Name: ', J.name)
print('Shape: ', J.shape)
print('Size: ', J.size)
print('Size: ', J.ndim)
print('Type: ', J._type, '\n')
print('Parameters (global phase): \n', J.parameters.global_phase(), '\n')
print('Checks (element is homogeneous): \n', J.checks.is_homogeneous(), '\n')
print('Analysis (as diattenuator): \n', J.analysis.diattenuator(), '\n')
Array: [[[1.00000000e+00+0.j 8.68198052e01+0.j 5.50000000e01+0.j
2.31801948e01+0.j 1.00000000e01+0.j]
[0.00000000e+00+0.j 3.18198052e01+0.j 4.50000000e01+0.j
3.18198052e01+0.j 5.51091060e17+0.j]]
[[0.00000000e+00+0.j 3.18198052e01+0.j 4.50000000e01+0.j
3.18198052e01+0.j 5.51091060e17+0.j]
[1.00000000e01+0.j 2.31801948e01+0.j 5.50000000e01+0.j
8.68198052e01+0.j 1.00000000e+00+0.j]]]
Name: Linear diattenuator
Shape: [5]
Size: 5
Size: 1
Type: Jones_matrix
Parameters (global phase):
[0. 0. 0. 0. 0.]
Checks (element is homogeneous):
[ True True True True True]
Analysis (as diattenuator):
([array([1., 1., 1., 1., 1.]), array([0.01, 0.01, 0.01, 0.01, 0.01]), array([1., 1., 1., 1., 1.]), array([0.1, 0.1, 0.1, 0.1, 0.1])], [array([0. , 0.39269908, 0.78539816, 1.17809725, 1.57079633]), array([0., 0., 0., 0., 0.]), array([0. , 0.39269908, 0.78539816, 1.17809725, 1.57079633]), array([0., 0., 0., 0., 0.])])
That is, the output beam is linearly polarized in the direction of the linear polarized axis, and some light is absorbed by the polarized.
Generating of optical elements¶
As shown in the previous example, the Jones matrix is initialized with all elements equal to zero. There are many methods that can be used to generate a more desirable vector:
 from_components: Creates a Jones_matrix object directly from the 4 elements (m00, m01, m10, m11).
 from_matrix: Creates a Jones_matrix object directly from a 2x2 numpy arrays.
 from_list: Creates a Jones_matrix object directly from a list of 2x2 numpy arrays.
 from_Mueller: Takes a nondepolarizing Mueller Matrix and converts into Jones matrix.
 vacuum: Creates the matrix for vacuum.
 mirror: Creates the matrix for a mirror. NOTE: Don’t rotate this matrix.
 filter_amplifier: Creates the matrix for a neutral filter or amplifier element
 diattenuator_perfect: Creates a perfect linear diattenuator.
 diattenuator_linear: Creates a real polarizer with perpendicular axes.
 diattenuator_retarder_linear: Creates a linear diattenuator retarder with the same axes for diattenuation and retardance.
 diattenuator_charac_angles: Creates the most general homogeneous diattenuator with orthogonal eigenstates from the characteristic angles of the main eigenstate.
 diattenuator_azimuth_ellipticity: Creates the general homogeneous diattenuator with orthogonal eigenstates from the characteristic angles of the main eigenstate.
 quarter_waveplate: Creates a quarterwaveplate.
 half_waveplate: Creates a halfwaveplate.
 retarder_linear: Creates a retarder using delay.
 retarder_material: Creates a retarder using physical properties of a anisotropic material.
 retarder_charac_angles: Creates the most general homogenous retarder with orthogonal eigenstates from the characteristic angles of the main eigenstate.
 retarder_azimuth_ellipticity: Creates the general homogeneous retarder with orthogonal eigenstates from the characteristic angles of the main eigenstate.
For a more detailed description of each method, refer to the individual documentation of each one.
Example: Linear polarizer.
[6]:
J = Jones_matrix("Polarizer")
J.diattenuator_perfect(azimuth=10*degrees)
print(J)
Polarizer @ 10.00 deg =
[+0.970+0.000j +0.171+0.000j]
[+0.171+0.000j +0.030+0.000j]
The previous example only stores one Jones matrix. It is possible to store many Jones matrices in the same object. This is useful specially when the same operation is performed upon all of them, as rotation. In this way, it is not required to use for loops, reducing significantly the computation time.
There are many ways of creating several Jones matrices in the same object. The first way is creating an object with several identical vectors. This is performed using the length argument of most of creation methods:
[7]:
J = Jones_matrix("Polarizer")
J.diattenuator_perfect(azimuth = 30*degrees, length = 3)
print(J)
Polarizer =
[+0.750+0.000j +0.433+0.000j] [+0.750+0.000j +0.433+0.000j] [+0.750+0.000j +0.433+0.000j]
[+0.433+0.000j +0.250+0.000j] [+0.433+0.000j +0.250+0.000j] [+0.433+0.000j +0.250+0.000j]
A second way of creating several Jones matrices at the same time is using an array as one of the parameters. Take into account that, if you use this option, all parameters must have the same number of elements or just one element. Otherwise, the program will throw an exception.
[8]:
J = Jones_matrix("Polarizer")
angles = np.linspace(0, 90*degrees, 5)
J.diattenuator_perfect(azimuth = angles)
print(J)
Polarizer =
[+1.000+0.000j +0.000+0.000j] [+0.854+0.000j +0.354+0.000j] [+0.500+0.000j +0.500+0.000j] [+0.146+0.000j +0.354+0.000j] [+0.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j] [+0.354+0.000j +0.146+0.000j] [+0.500+0.000j +0.500+0.000j] [+0.354+0.000j +0.854+0.000j] [+0.000+0.000j +1.000+0.000j]
If the parameters have dimension higher than 1, the program will store that information in order to make prints and plots. In that case, the print function separates the four components Jones matrices:
[9]:
J = Jones_matrix("Polarizer")
angles = np.random.rand(3,3) * 180*degrees
J.diattenuator_perfect(azimuth = angles)
print(J)
Polarizer J00 =
[[0.92738976+0.j 0.39685518+0.j 0.59831546+0.j]
[0.42990437+0.j 0.0760078 +0.j 0.91420785+0.j]
[0.89896352+0.j 0.68884951+0.j 0.56107686+0.j]]
Polarizer J01 =
[[0.25949565+0.j 0.48924549+0.j 0.49023879+0.j]
[ 0.49506222+0.j 0.26501059+0.j 0.28005688+0.j]
[ 0.30137702+0.j 0.46296421+0.j 0.4962556 +0.j]]
Polarizer J10 =
[[0.25949565+0.j 0.48924549+0.j 0.49023879+0.j]
[ 0.49506222+0.j 0.26501059+0.j 0.28005688+0.j]
[ 0.30137702+0.j 0.46296421+0.j 0.4962556 +0.j]]
Polarizer J11 =
[[0.07261024+0.j 0.60314482+0.j 0.40168454+0.j]
[0.57009563+0.j 0.9239922 +0.j 0.08579215+0.j]
[0.10103648+0.j 0.31115049+0.j 0.43892314+0.j]]
It is possible to transform Mueller objects into Jones_matrix objects and viceversa.
[10]:
#TODO
Features of creation methods¶
py_pol model sets the origin of phase in \(J_{00}\). It means that the parameter global_phase of most creation methods and the methods remove_global_phase and set_global_phase (see below) will take it as the reference.
[11]:
J = Jones_matrix("Polarizer")
J.diattenuator_perfect(azimuth = 45*degrees, global_phase = 90*degrees)
print(J)
J.remove_global_phase()
print(J)
Polarizer @ 45.00 deg =
[+0.000+0.500j +0.000+0.500j]
[+0.000+0.500j +0.000+0.500j]
Polarizer @ 45.00 deg =
[+0.500+0.000j +0.500+0.000j]
[+0.500+0.000j +0.500+0.000j]
Basic operations¶
Some physical phenomena that affects polarization optical elements is described by simple operations performed to their Jones matrices.
Multiplication of a Jones matrix by a Jones vector¶
When a light beam \(E_1\) goes through a polarization optical element \(J_1\), the polarization state of the output beam can be determined as: \(E_2 = J_1 * E_1\). This can be implemented in py_pol as:
[12]:
from py_pol.jones_vector import Jones_vector
J1 = Jones_matrix("J1")
J1.diattenuator_perfect(azimuth=0*degrees)
print(J1)
E1 = Jones_vector("E1")
E1.linear_light(azimuth=45*degrees)
print(E1)
E2 = J1 * E1
print(E2)
J1 =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j]
E1 =
[+0.707+0.000j]
[+0.707+0.000j]
J1 * E1 =
[+0.707+0.000j]
[+0.000+0.000j]
Multiplication of 2 Jones matrices¶
When two polarizing elementsare placed one after the other in the light path, first \(J_1\) and then \(J_2\), the system composed of both elements can be described by a single Jones matrix \(J_3\), which is calculated as \(J_3 = J_2 * J_1\).
Example: Matrix representing a perfect linear polarized and a \(\lambda/4\) retarder.
[13]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect()
print(J1)
J2 = Jones_matrix("Retarder")
J2.quarter_waveplate(azimuth=45*degrees)
print(J2)
J3 = J2 * J1
print(J3)
Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j]
Retarder @ 45.00 deg =
[+0.5000.500j +0.500+0.500j]
[+0.500+0.500j +0.5000.500j]
Retarder @ 45.00 deg * Polarizer =
[+0.5000.500j +0.000+0.000j]
[+0.500+0.500j +0.000+0.000j]
Multiplication by a constant¶
The absorption and gain experienced by a light wave that goes through a polarization optical element can be increased or decreased by multiplying its Jones matrix by a real number.
[14]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect(azimuth=30*degrees)
print(J1)
J2 = 2 * J1
print(J2)
J2 = J1 / 2
print(J2)
Polarizer @ 30.00 deg =
[+0.750+0.000j +0.433+0.000j]
[+0.433+0.000j +0.250+0.000j]
Polarizer @ 30.00 deg * 2 =
[+1.500+0.000j +0.866+0.000j]
[+0.866+0.000j +0.500+0.000j]
Polarizer @ 30.00 deg / 2 =
[+0.375+0.000j +0.217+0.000j]
[+0.217+0.000j +0.125+0.000j]
The global phase change experienced by the light wave can also be changed by multiplying the Jones matrix of the element by a complex number.
[15]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect(azimuth=30*degrees)
print(J1)
c = 1j
J2 = c * J1
print(J2)
Polarizer @ 30.00 deg =
[+0.750+0.000j +0.433+0.000j]
[+0.433+0.000j +0.250+0.000j]
Polarizer @ 30.00 deg * 1j =
[+0.000+0.750j +0.000+0.433j]
[+0.000+0.433j +0.000+0.250j]
Addition of two Jones matrices¶
The physical meaning of this operation is a little bit more complex. Imagine a light wave \(E_0\) which goes through two spatially separated polarization optical elements \(J_1\) and \(J_2\). If the light waves are then coherently added, the behavior of the two elements can be described by a single Jones matrix \(J_3 = J_1 + J_2\).
[16]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect()
print(J1)
J2 = Jones_matrix("Retarder")
J2.quarter_waveplate(azimuth=45*degrees)
print(J2)
J3 = J2 + J1
print(J3)
Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j]
Retarder @ 45.00 deg =
[+0.5000.500j +0.500+0.500j]
[+0.500+0.500j +0.5000.500j]
Retarder @ 45.00 deg + Polarizer =
[+1.5000.500j +0.500+0.500j]
[+0.500+0.500j +0.5000.500j]
Equality¶
It is possible to compare two Jones_matrix objects and tell if they are the same. It just compares the matrix components, not the rest of object fields.
[17]:
J1 = Jones_matrix("Retarder 1")
J1.quarter_waveplate(azimuth=0*degrees)
print(J1)
J2 = Jones_matrix("Retarder 2")
J2.quarter_waveplate(azimuth=0.01*degrees)
print(J2)
print('Comparison: ', E1==E2)
Retarder 1 =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.0001.000j]
Retarder 2 @ 0.01 deg =
[+1.0000.000j +0.000+0.000j]
[+0.000+0.000j +0.0001.000j]
Comparison: False
Operations and multidimensionality¶
The basic operations of Jones_matrix objects are subject to the same casting rules as numpy arrays. This means that they can be easily used even if one or both elements of the operation have more than one element.
Here are some examples:
[18]:
# Multiplication of two Jones matrices
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect()
print(J1)
J2 = Jones_matrix("Retarder")
angles = np.linspace(0, 90*degrees, 4)
J2.quarter_waveplate(azimuth=angles)
print(J2)
J3 = J2 * J1
print(J3)
Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j]
Retarder =
[+1.000+0.000j +0.000+0.000j] [+0.7500.250j +0.433+0.433j] [+0.2500.750j +0.433+0.433j] [+0.0001.000j +0.000+0.000j]
[+0.000+0.000j +0.0001.000j] [+0.433+0.433j +0.2500.750j] [+0.433+0.433j +0.7500.250j] [+0.000+0.000j +1.0000.000j]
Retarder * Polarizer =
[+1.000+0.000j +0.000+0.000j] [+0.7500.250j +0.000+0.000j] [+0.2500.750j +0.000+0.000j] [+0.0001.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j] [+0.433+0.433j +0.000+0.000j] [+0.433+0.433j +0.000+0.000j] [+0.000+0.000j +0.000+0.000j]
[19]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_perfect(azimuth=30*degrees)
print(J1)
c = 1j + np.random.rand(4)
J2 = c * J1
print(J2)
Polarizer @ 30.00 deg =
[+0.750+0.000j +0.433+0.000j]
[+0.433+0.000j +0.250+0.000j]
J =
[+0.201+0.750j +0.116+0.433j] [+0.279+0.750j +0.161+0.433j] [+0.281+0.750j +0.162+0.433j] [+0.439+0.750j +0.253+0.433j]
[+0.116+0.433j +0.067+0.250j] [+0.161+0.433j +0.093+0.250j] [+0.162+0.433j +0.094+0.250j] [+0.253+0.433j +0.146+0.250j]
[20]:
J1 = Jones_matrix("Polarizer")
angles = np.linspace(0, 90*degrees, 4)
J1.diattenuator_perfect(azimuth=angles)
print(J1)
J2 = Jones_matrix("Retarder")
J2.quarter_waveplate(azimuth=90*degrees+angles)
print(J2)
J3 = J2 + J1
print(J3)
Polarizer =
[+1.000+0.000j +0.000+0.000j] [+0.750+0.000j +0.433+0.000j] [+0.250+0.000j +0.433+0.000j] [+0.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j] [+0.433+0.000j +0.250+0.000j] [+0.433+0.000j +0.750+0.000j] [+0.000+0.000j +1.000+0.000j]
Retarder =
[+0.0001.000j +0.000+0.000j] [+0.2500.750j 0.4330.433j] [+0.7500.250j 0.4330.433j] [+1.0000.000j 0.0000.000j]
[+0.000+0.000j +1.0000.000j] [0.4330.433j +0.7500.250j] [0.4330.433j +0.2500.750j] [0.0000.000j +0.0001.000j]
Retarder + Polarizer =
[+1.0001.000j +0.000+0.000j] [+1.0000.750j +0.0000.433j] [+1.0000.250j 0.0000.433j] [+1.0000.000j 0.0000.000j]
[+0.000+0.000j +1.0000.000j] [+0.0000.433j +1.0000.250j] [0.0000.433j +1.0000.750j] [0.0000.000j +1.0001.000j]
Jones matrix manipulation¶
There are other operations implemented for the Jones_matrix class:
 get: Gets a matrix with the electric field components.
 clear: Removes data and name form the object.
 copy: Creates a copy of the object.
 stretch: Stretches an object of size 1.
 shape_like: Takes the shape of another object to use as its own.
 rotate: Rotates the Jones matrix.
 sum: Calculates the summatory of the Jones matrices in the object.
 prod: Calculates the product of the Jones matrices in the object.
 flip: Flips the object along some dimensions.
 remove_global_phase: Removes the phase introduced by the optical element (respect to J00).
 add_global_phase: Increases the phase introduced by the optical element.
 set_global_phase: Sets the phase introduced by the optical element.
 reciprocal: The optical element is fliped so the light transverses it in the opposite direction.
 transpose: Transposes the Jones matrix of the element.
 hermitan: Calculates the hermitan matrix of the Jones matrix.
 inverse: Calculates the inverse matrix of the Jones matrix.
All the methods return a Jones_matrix object. For a more detailed description of each method, refer to the individual documentation of each one.
Example: inverse.
[21]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_linear(p1=1, p2=0.2)
print(J1,'\n')
Inv = J1.inverse()
print(Inv)
Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.200+0.000j]
Inverse of Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +5.000+0.000j]
All manipulation methods have the keep argument that specifies if the originial object must be preserved or transformed. If keep is True (default is False), a new object is created:
[22]:
J1 = Jones_matrix("Polarizer")
J1.diattenuator_linear(p1=1, p2=0.2)
J2 = J1.rotate(angle=45*degrees, keep=True)
J2.name = 'J2'
print(J1, J2)
J2 = J1.rotate(angle=45*degrees, keep=False)
J2.name = 'J2'
print(J1, J2)
Polarizer =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.200+0.000j]
J2 =
[+0.600+0.000j +0.400+0.000j]
[+0.400+0.000j +0.600+0.000j]
J2 =
[+0.600+0.000j +0.400+0.000j]
[+0.400+0.000j +0.600+0.000j]
J2 =
[+0.600+0.000j +0.400+0.000j]
[+0.400+0.000j +0.600+0.000j]
Jones_matrix objects allow taking elements and changing them through indices like a numpy.ndarray.
Examples:
[23]:
M = np.random.rand(2, 2, 3, 5)
J = Jones_matrix('Original')
J.from_matrix(M)
print(J)
J2 = J[0:3]
print(J2)
Original J00 =
[[0.17510164+0.j 0.90009612+0.j 0.90864028+0.j 0.80668589+0.j
0.06629195+0.j]
[0.31405351+0.j 0.78052721+0.j 0.45654285+0.j 0.42873277+0.j
0.92761816+0.j]
[0.9396647 +0.j 0.60477187+0.j 0.50198431+0.j 0.61036638+0.j
0.56997934+0.j]]
Original J01 =
[[6.43874806e01+0.j 1.21179152e02+0.j 8.69558301e01+0.j
6.53909626e01+0.j 4.03319805e01+0.j]
[3.78898924e01+0.j 6.01676517e01+0.j 7.17148797e01+0.j
9.38899266e01+0.j 3.74398685e01+0.j]
[6.95491079e01+0.j 6.04097596e01+0.j 6.95335190e01+0.j
8.17588301e01+0.j 9.33009502e04+0.j]]
Original J10 =
[[0.62298474+0.j 0.4600892 +0.j 0.12334305+0.j 0.61967967+0.j
0.46749487+0.j]
[0.18318243+0.j 0.48389836+0.j 0.61270776+0.j 0.00176341+0.j
0.55661916+0.j]
[0.59911603+0.j 0.87555946+0.j 0.08608425+0.j 0.42310329+0.j
0.04718173+0.j]]
Original J11 =
[[0.05733518+0.j 0.85467621+0.j 0.59302419+0.j 0.65789627+0.j
0.70655268+0.j]
[0.32429708+0.j 0.25568017+0.j 0.46142276+0.j 0.58159404+0.j
0.32411156+0.j]
[0.45779306+0.j 0.55784751+0.j 0.22033798+0.j 0.22148682+0.j
0.14676281+0.j]]
Original_picked =
[+0.175+0.000j +0.644+0.000j] [+0.900+0.000j +0.012+0.000j] [+0.909+0.000j +0.870+0.000j]
[+0.623+0.000j +0.057+0.000j] [+0.460+0.000j +0.855+0.000j] [+0.123+0.000j +0.593+0.000j]
[24]:
J1 = Jones_matrix("Polarizer")
angles = np.linspace(0, 90*degrees, 4)
J1.diattenuator_perfect(azimuth=angles)
print(J1)
J2 = Jones_matrix("Retarder")
J2.quarter_waveplate()
print(J2)
J1[2] = J2
J1.name = 'Modified'
print(J1)
Polarizer =
[+1.000+0.000j +0.000+0.000j] [+0.750+0.000j +0.433+0.000j] [+0.250+0.000j +0.433+0.000j] [+0.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j] [+0.433+0.000j +0.250+0.000j] [+0.433+0.000j +0.750+0.000j] [+0.000+0.000j +1.000+0.000j]
Retarder =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.0001.000j]
Modified =
[+1.000+0.000j +0.000+0.000j] [+0.750+0.000j +0.433+0.000j] [+1.000+0.000j +0.000+0.000j] [+0.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j] [+0.433+0.000j +0.250+0.000j] [+0.000+0.000j +0.0001.000j] [+0.000+0.000j +1.000+0.000j]
Parameters of Jones_matrix¶
Several parameters can be measured from a Jones matrix. They are implemented in the independent class Parameters_Jones_Matrix, which is stored in the parameters field of Jones_matrix class.
 matrix: Gets a numpy array with all the matrices.
 components: Extracts the four components of the Jones matrix.
 inhomogeneity: Calculates the inhomogeneity parameter.
 diattenuation / polarizance: Calculates the diattenuation of the matrix.
 retardance: Calculates the retardance (or delay) introduced between the fast and slow axes.
 global_phase: Calculates the phase introduced by the optical element (respect to J00).
 transmissions: Calculates the maximum and minimum field and/or intensity transmissions.
 mean_transmission: Calculates the mean intensity transmission.
 eig: Calculates the eigenvalues and eigenstates (eigenvectors) of the Jones matrices.
 eigenvalues: Calculates the eigenvalues and of the Jones matrices.
 eigenstates: Calculates the eigenstates (eigenvectors) of the Jones matrices.
 det: Calculates the determinant and of the Jones matrices.
 trace: Calculates the trace of the Jones matrices.
 norm: Calculates the norm of the Jones matrices.
 get_all: Returns a dictionary with all the parameters of the object.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[25]:
J = Jones_matrix("Diattenuator retarder")
J.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5, azimuth=30*degrees)
R = J.parameters.retardance()
print("Retardance = {:2.1f}º".format(R/degrees))
Retardance = 90.0º
When several Jones matrices are stored in the object, setting verbose argument to True makes the method print the values in screen. Also, 1D or 2D figures can be shown if the draw argument is set to True:
..
[26]:
J = Jones_matrix("Diattenuator retarder")
R = np.linspace(0, 180*degrees, 13)
J.diattenuator_retarder_linear(R=R, p1=1, p2=0.5, azimuth=30*degrees)
R = J.parameters.retardance(verbose=True, draw=True)
The retardance of Diattenuator retarder is (deg.):
[ 0. 15. 30. 45. 60. 75. 90. 105. 120. 135. 150. 165. 180.]
The mean value is 90.0 + 56.124860801609124
[30]:
J = Jones_matrix("Diattenuator")
p1 = np.linspace(0.5, 1, 128)
p2 = np.linspace(0, 0.5, 128)
P1, P2 = np.meshgrid(p1, p2)
J.diattenuator_linear(p1=P1, p2=P2, azimuth=30*degrees)
P1, P2 = J.parameters.transmissions(kind='field', draw=True)
The field transmissions of Diattenuator are:
The mean value of param Maximum (int.) is 0.7500000000003215 + 0.14546964399033177
The mean value of param Minimum (int.) is 0.24999999999967848 + 0.14546964399033177
There is a function in Parameters_Jones_Matrix class, .get_all() that computes all the parameters available and stores in a dictionary .dict_params(). This function is called when using print upon the Parameters_Jones_Matrix class.
Example:
[32]:
J = Jones_matrix("Diattenuator retarder")
J.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5, azimuth=30*degrees)
print(J,'\n')
print(J.parameters)
Diattenuator retarder @ 30.00 deg =
[+0.750+0.125j +0.4330.217j]
[+0.4330.217j +0.250+0.375j]
The matrix components of Diattenuator retarder @ 30.00 deg are:
J00
(0.7500000000000001+0.12499999999999997j)
J01
(0.43301270189221930.21650635094610965j)
J10
(0.43301270189221930.21650635094610965j)
J11
(0.24999999999999997+0.37500000000000006j)
Low dimensionality, figure not available.
The diattenuation of Diattenuator retarder @ 30.00 deg is:
[0.6]
Low dimensionality, figure not available.
The retardance of Diattenuator retarder @ 30.00 deg is (deg.):
90.00000000000001
Low dimensionality, figure not available.
The global phase of Diattenuator retarder @ 30.00 deg is (deg.):
9.462322208025613
Low dimensionality, figure not available.
The inhomogeneity parameter of Diattenuator retarder @ 30.00 deg is:
8.881784197001253e17
Low dimensionality, figure not available.
The intensity transmissions of Diattenuator retarder @ 30.00 deg are:
Maximum (int.)
1.0000000000000002
Minimum (int.)
0.24999999999999994
Low dimensionality, figure not available.
The field transmissions of Diattenuator retarder @ 30.00 deg are:
Maximum (int.)
1.0
Minimum (int.)
0.49999999999999994
Low dimensionality, figure not available.
The mean transmission of Diattenuator retarder @ 30.00 deg is:
0.3750000000000001
Low dimensionality, figure not available.
The determinant of Diattenuator retarder @ 30.00 deg is:
(2.775557561562892e17+0.5j)
Low dimensionality, figure not available.
The trace of Diattenuator retarder @ 30.00 deg is:
(1+0.5j)
Low dimensionality, figure not available.
The norm of Diattenuator retarder @ 30.00 deg is:
1.118033988749895
Low dimensionality, figure not available.
The eigenvalues of Diattenuator retarder @ 30.00 deg are:
v1
[1.+0.j]
v2
[4.16333634e17+0.5j]
Low dimensionality, figure not available.
The eigenvectors of Diattenuator retarder @ 30.00 deg are:
e1x
[0.8660254+0.j]
e1y
[0.51.21579299e17j]
e2x
[0.53.20579308e17j]
e2y
[0.8660254+0.j]
Low dimensionality, figure not available.
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:287: SyntaxWarning: "is" with a literal. Did you mean "=="?
if other._type is 'Jones_vector':
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:1133: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:1349: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:1488: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:1900: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
d:\codigo_ucm\py_pol\py_pol\jones_matrix.py:2332: ComplexWarning: Casting complex values to real discards the imaginary part
D = np.array(D, dtype=float)
Checks of Jones_matrix¶
There are several checks that can be performed upon a Jones vector. They are implemented in the independent class Checks_Jones_matrix, which is stored in the checks field of Jones_matrix class.
 is_phisycall: Check if the Jones matrices correspond to physically realizable optical elements.
 is_homogeneous: Determines if the matrices correspond to homogeneous optical elements.
 is_retarder: Checks if the Jones matrices correspond to homogeneous retarders.
 is_diattenuator / is_polarizer: Checks if the Jones matrices correspond to homogeneous diattenuators.
 is_symmetric: Checks if the Jones matrices are symmetric.
 is_conjugate_symmetric: Checks if the Jones matrices are conjugate symmetric.
 get_all: Returns a dictionary with all the checks of the object.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[33]:
J = Jones_matrix("Diattenuator retarder")
J.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5, azimuth=30*degrees)
cond = J.checks.is_retarder(verbose=True)
Diattenuator retarder @ 30.00 deg is an homogeneous retarder:
False
As with the Parameters_Jones_matrix class, 1D and 2D plot draws are also implemented for this class. Also, the print function calls to get_all:
[34]:
R = np.random.rand(20) * 180*degrees
R[R < 50*degrees] = 0 # In some cases, the diattenuator retarder is reduced to a pure diattenuator
J = Jones_matrix("Diattenuator retarder")
J.diattenuator_retarder_linear(R=R, p1=1, p2=0.5, azimuth=30*degrees)
cond = J.checks.is_diattenuator(draw=True)
Diattenuator retarder is an homogeneous diattenuator:
The mean value is 0.25 + 0.4330127018922193
Analysis of Jones_matrix¶
There are several analysis that can be performed upon a Jones vector. They are implemented in the independent class Analysis_Jones_matrix, which is stored in the analysis field of Jones_matrix class.
 decompose_pure: Decomposes the Jones matrices in two: an homogeneous retarder and diattenuator.
 diattenuator / polarizer: Analyzes the Jones matrices as if they were diattenuators.
 retarder: Analyzes the Jones matrices as if they were retarders.
 get_all: Returns a dictionary with all the analysis information of the object.
Note: Some methods are still to be finished.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[37]:
# Create a random diattenuator
p1, p2 = np.random.rand(2)
alpha, delta = np.random.rand(2) * 90*degrees
delta = delta*4
Jd = Jones_matrix("Diattenuator")
Jd.diattenuator_charac_angles(p1=p1, p2=p2, alpha=alpha, delay=delta)
print(Jd)
# Create a random retarder
R, alpha, delta = np.random.rand(3) * 90*degrees
(R, delta) = (R*2, delta*4)
Jr = Jones_matrix("Retarder")
Jr.retarder_charac_angles(R=R, alpha=alpha, delay=delta)
print(Jr)
# Multiply them and try to decompose
J = Jr * Jd
J.name = 'Product'
Jr2, Jd2 = J.analysis.decompose_pure(decomposition='RD')
print(Jd2, Jr2)
Diattenuator =
[+0.462+0.000j 0.006+0.006j]
[0.0060.006j +0.608+0.000j]
Retarder =
[+0.826+0.000j +0.4400.352j]
[0.254+0.502j 0.1690.809j]
Product Diattenuator =
[+0.462+0.000j 0.006+0.006j]
[0.0060.006j +0.608+0.000j]
Product Retarder =
[+0.826+0.000j +0.4400.352j]
[0.254+0.502j 0.1690.809j]
[ ]:
Jones_vector class¶
Jones_Vector is a class that manages Jones vectors. It allows the user to create and manipulate them.
Creating an instance¶
An instance must be created before starting to operate with the Jones vector. The initialization accepts one argument: the name of the vector. This name will be used for printing:
[2]:
from py_pol.jones_vector import Jones_vector, create_Jones_vectors
from py_pol.utils import degrees
import numpy as np
d:\codigo_ucm\py_pol\py_pol\jones_vector.py:203: SyntaxWarning: "is" with a literal. Did you mean "=="?
if other._type is 'Jones_vector':
d:\codigo_ucm\py_pol\py_pol\jones_vector.py:224: SyntaxWarning: "is" with a literal. Did you mean "=="?
if other._type is 'Jones_vector':
d:\codigo_ucm\py_pol\py_pol\jones_vector.py:975: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
d:\codigo_ucm\py_pol\py_pol\jones_vector.py:1307: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if global_phase is not 0:
[3]:
E = Jones_vector("Source 1")
print(E)
Source 1 is empty
Several Jones_vector objects can be created at the same time using the function create_Jones_vectors.
[4]:
E1, E2 = create_Jones_vectors(name=('Source 2', 'Source 3'))
print(E1, E2)
list_of_E = create_Jones_vectors(N=3)
print(list_of_E)
Source 2 is empty
Source 3 is empty
[E is empty
, E is empty
, E is empty
]
Jones_vector class fields¶
Jones_vector class objects have some fields where some methods and information stored:
 M: 2xN array containing all the Jones vectors.
 name: Name of the object for print purposes.
 size: Number of stored Jones vectors.
 shape: Shape desired for the outputs.
 ndim: Number of dimensions for representation purposes.
 **_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.
[5]:
E = Jones_vector("Source 1")
amp = np.random.rand(3,3)
E.linear_light(azimuth = 0, amplitude=amp)
print('Array: ', E.M)
print('Name: ', E.name)
print('Size: ', E.size)
print('Shape: ', E.shape)
print('Number of dimensions: ', E.ndim)
print('Type: ', E._type, '\n')
print('Parameters (intensity): \n', E.parameters.intensity(), '\n')
print('Checks (circularly polarized): \n', E.checks.is_circular(), '\n')
Array: [[0.42489842+0.j 0.62622041+0.j 0.97220609+0.j 0.61160548+0.j
0.94799541+0.j 0.4672298 +0.j 0.81473292+0.j 0.16008501+0.j
0.18007924+0.j]
[0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j]]
Name: Source 1
Size: 9
Shape: [3, 3]
Number of dimensions: 2
Type: Jones_vector
Parameters (intensity):
[[0.18053866 0.392152 0.94518468]
[0.37406126 0.8986953 0.21830368]
[0.66378973 0.02562721 0.03242853]]
Checks (circularly polarized):
[[False False False]
[False False False]
[False False False]]
Generating polarization states¶
As shown in the previous example, the Jones vector is initialized with all elements equal to zero. There are many methods that can be used to generate a more desirable vector:
 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 2xN 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 is 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[6]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 30*degrees, amplitude=1)
print(E)
Source 1 =
[+0.866+0.000j]
[+0.500+0.000j]
The previous example only stores one Jones vector. It is possible to store many Jones vectors in the same object. This is useful specially when the same operation is performed upon all of them, as rotation. In this way, it is not required to use for loops, reducing significantly the computation time.
There are many ways of creating several Jones vectors in the same object. The first way is creating an object with several identical vectors. This is performed using the length argument:
[7]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees, amplitude=2, length = 5)
print(E)
Source 1 =
[+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j]
[+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j] [+1.414+0.000j]
A second way of creating several vectors at the same time is using an array as one of the parameters. Take into account that, if you use this option, all parameters must have the same number of elements or just one element. Otherwise, the program will throw an exception.
[8]:
E = Jones_vector("Source 1")
angles = np.linspace(0, 90*degrees, 5)
E.linear_light(azimuth = angles, amplitude=2)
print(E)
Source 1 =
[+2.000+0.000j] [+1.848+0.000j] [+1.414+0.000j] [+0.765+0.000j] [+0.000+0.000j]
[+0.000+0.000j] [+0.765+0.000j] [+1.414+0.000j] [+1.848+0.000j] [+2.000+0.000j]
If the parameters have dimension higher than 1, the program will store that information in order to make prints and plots. In that case, the print function separates the two components Jones vectors:
[9]:
E = Jones_vector("Source 1")
amp = np.random.rand(3,3)
E.linear_light(azimuth = 0, amplitude=amp)
print(E)
Source 1 Ex =
[[0.58345592+0.j 0.34259168+0.j 0.83323172+0.j]
[0.04041141+0.j 0.42440684+0.j 0.84811839+0.j]
[0.71128329+0.j 0.08263032+0.j 0.9582417 +0.j]]
Source 1 Ey =
[[0.+0.j 0.+0.j 0.+0.j]
[0.+0.j 0.+0.j 0.+0.j]
[0.+0.j 0.+0.j 0.+0.j]]
Features of creation methods¶
py_pol model sets the origin of phase in \(E_x\). It means that the parameter global_phase of most creation methods and the methods remove_global_phase and set_global_phase (see below) will take it as the reference.
[10]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees, global_phase=90*degrees)
print(E)
E.remove_global_phase()
print(E)
Source 1 =
[+0.000+0.707j]
[+0.000+0.707j]
Source 1 =
[+0.707+0.000j]
[+0.707+0.000j]
All creation methods that accepts an amplitude or an intensity parameter (\(a\) and \(b\) for elliptical_light) in order to set the electric field amplitude (the norm of the electric field vector) or the intensity. If both of them are given together to the method, it will use the amplitude:
[11]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees, amplitude=5)
print(E)
_ = E.parameters.intensity(verbose=True)
E = Jones_vector("Source 2")
E.linear_light(azimuth = 45*degrees, intensity=2)
print(E)
_ = E.parameters.intensity(verbose=True)
E = Jones_vector("Source 3")
E.linear_light(azimuth = 45*degrees, intensity=2, amplitude=5)
print(E)
_ = E.parameters.intensity(verbose=True)
Source 1 =
[+3.536+0.000j]
[+3.536+0.000j]
The intensity of Source 1 is (a.u.):
25.0
Source 2 =
[+1.000+0.000j]
[+1.000+0.000j]
The intensity of Source 2 is (a.u.):
2.000000000000001
Source 3 =
[+3.536+0.000j]
[+3.536+0.000j]
The intensity of Source 3 is (a.u.):
25.0
Basic operations¶
Some physical phenomena that affects polarized light is described by simple operations performed to their Jones vectors.
Addition of two Jones vectors¶
The interference of two light waves can be represented by the sum of their Jones vectors.
[12]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 0*degrees, amplitude=1)
print(E1)
E2 = Jones_vector("Source 2")
E2.linear_light(azimuth = 45*degrees, amplitude=1, global_phase = 45*degrees)
print(E2)
E3 = E1 + E2
print(E3)
Source 1 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 2 =
[+0.500+0.500j]
[+0.500+0.500j]
Source 1 + Source 2 =
[+1.500+0.500j]
[+0.500+0.500j]
Multiply by a constant¶
The absorption and gain experienced by a light wave is described by multiplying its Jones vector by a real positive number \(c\). The light wave will experience absorption if \(c<0\) and gain if \(c>0\):
[13]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 0*degrees, amplitude = 0.5)
print(E1)
E2 = 2 * E1
print(E2)
E2 = E1*3
print(E2)
E2 = E1/3
print(E2)
Source 1 =
[+0.500+0.000j]
[+0.000+0.000j]
Source 1 * 2 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 1 * 3 =
[+1.500+0.000j]
[+0.000+0.000j]
Source 1 / 3 =
[+0.167+0.000j]
[+0.000+0.000j]
If the constant is complex, the constant phase will be added to the global phase of the light, while its absolute value will increase or decrease the electric field amplitude.
Take into account that real negative values are a special case of complex numbers whose phase is 180º.
[14]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 0*degrees, amplitude = 0.5)
print(E1)
c = 0.50.5j
E2 = c * E1
print(E2)
c = 1j
E2 = c * E1
print(E2)
Source 1 =
[+0.500+0.000j]
[+0.000+0.000j]
Source 1 * (0.50.5j) =
[+0.2500.250j]
[+0.000+0.000j]
Source 1 * 1j =
[+0.000+0.500j]
[+0.000+0.000j]
Equality¶
It is possible to compare two Jones_vector objects and tell if they are the same. It just compares electric field, not the rest of object fields.
[15]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 0*degrees)
print(E1)
E2 = Jones_vector("Source 2")
E2.linear_light(azimuth = 0.01*degrees)
print(E2)
print('Comparison: ', E1==E2)
Source 1 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 2 =
[+1.000+0.000j]
[+0.000+0.000j]
Comparison: False
Operations and multidimensionality¶
The basic operations of Jones_vector objects are subject to the same casting rules as numpy arrays. This means that they can be easily used even if one or both elements of the operation have more than one element.
Here are some examples:
[16]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 0*degrees, amplitude=1)
print(E1)
E2 = Jones_vector("Source 2")
angles = np.linspace(0, 90*degrees, 5)
E2.linear_light(azimuth = angles, amplitude=1, global_phase = 45*degrees)
print(E2)
E3 = E1 + E2
print(E3)
Source 1 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 2 =
[+0.707+0.707j] [+0.653+0.653j] [+0.500+0.500j] [+0.271+0.271j] [+0.000+0.000j]
[+0.000+0.000j] [+0.271+0.271j] [+0.500+0.500j] [+0.653+0.653j] [+0.707+0.707j]
Source 1 + Source 2 =
[+1.707+0.707j] [+1.653+0.653j] [+1.500+0.500j] [+1.271+0.271j] [+1.000+0.000j]
[+0.000+0.000j] [+0.271+0.271j] [+0.500+0.500j] [+0.653+0.653j] [+0.707+0.707j]
[17]:
E1 = Jones_vector("Source 1")
E1.linear_light(azimuth = 30*degrees, amplitude = 1)
print(E1)
c = np.linspace(0.1, 2.3, 5)
E2 = c * E1
print(E2)
Source 1 =
[+0.866+0.000j]
[+0.500+0.000j]
E =
[+0.087+0.000j] [+0.563+0.000j] [+1.039+0.000j] [+1.516+0.000j] [+1.992+0.000j]
[+0.050+0.000j] [+0.325+0.000j] [+0.600+0.000j] [+0.875+0.000j] [+1.150+0.000j]
[18]:
E1 = Jones_vector("Source 1")
angles = np.linspace(0, 90*degrees, 5)
E1.linear_light(azimuth = 90*degrees + angles, amplitude=1)
print(E1)
E2 = Jones_vector("Source 2")
E2.linear_light(azimuth = angles, amplitude=1, global_phase = 45*degrees)
print(E2)
E3 = E1  E2
print(E3)
Source 1 =
[+0.000+0.000j] [0.383+0.000j] [0.707+0.000j] [0.924+0.000j] [1.000+0.000j]
[+1.000+0.000j] [+0.924+0.000j] [+0.707+0.000j] [+0.383+0.000j] [+0.000+0.000j]
Source 2 =
[+0.707+0.707j] [+0.653+0.653j] [+0.500+0.500j] [+0.271+0.271j] [+0.000+0.000j]
[+0.000+0.000j] [+0.271+0.271j] [+0.500+0.500j] [+0.653+0.653j] [+0.707+0.707j]
Source 1  Source 2 =
[0.7070.707j] [1.0360.653j] [1.2070.500j] [1.1940.271j] [1.0000.000j]
[+1.000+0.000j] [+0.6530.271j] [+0.2070.500j] [0.2710.653j] [0.7070.707j]
Jones vector manipulation¶
There are several operations that can be applied to a Jones vector.
 get: Gets a matrix with the electric field components.
 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.
All the functions return the Jones_vector object. For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[19]:
E1 = Jones_vector('Source 1')
E1.linear_light(azimuth=0*degrees)
print(E1)
E1.rotate(angle=45*degrees)
print(E1)
Source 1 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 1 @ 45.00 deg =
[+0.707+0.000j]
[+0.707+0.000j]
All manipulation methods have the keep argument that specifies if the originial object must be preserved or transformed. If keep is True (default is False), a new object is created:
[20]:
E1 = Jones_vector('Source 1')
E1.linear_light(azimuth=0*degrees)
E2 = E1.rotate(angle=45*degrees, keep=True)
E2.name = 'Source 2'
print(E1, E2)
E2 = E1.rotate(angle=45*degrees, keep=False)
E2.name = 'Source 2'
print(E1, E2)
Source 1 =
[+1.000+0.000j]
[+0.000+0.000j]
Source 2 =
[+0.707+0.000j]
[+0.707+0.000j]
Source 2 =
[+0.707+0.000j]
[+0.707+0.000j]
Source 2 =
[+0.707+0.000j]
[+0.707+0.000j]
Jones_vector objects allow taking elements and changing them through indices like a numpy.ndarray.
Examples:
[21]:
M = np.random.rand(2, 3, 5)
E = Jones_vector('Original')
E.from_matrix(M)
print(E)
E2 = E[0:3]
print(E2)
Original Ex =
[[0.59846507 0.76895564 0.4976668 0.88884345 0.16612203]
[0.00779228 0.70250326 0.48527475 0.21955637 0.03129468]
[0.67954502 0.97966195 0.42200705 0.48249309 0.59698486]]
Original Ey =
[[0.80449835 0.3444458 0.37697052 0.61480205 0.66917071]
[0.66473943 0.73639115 0.79999352 0.0440224 0.23428444]
[0.7501775 0.99535776 0.54259311 0.94779494 0.51348343]]
Original_picked =
[+0.598] [+0.769] [+0.498]
[+0.804] [+0.344] [+0.377]
[22]:
E2.linear_light()
E3 = E.copy()
E3.name = 'Cambiado'
E3[0:3,0:2] = E2
print(E3)
Cambiado Ex =
[[1. +0.j 1. +0.j 0.4976668 +0.j 0.88884345+0.j
0.16612203+0.j]
[1. +0.j 1. +0.j 0.48527475+0.j 0.21955637+0.j
0.03129468+0.j]
[1. +0.j 1. +0.j 0.42200705+0.j 0.48249309+0.j
0.59698486+0.j]]
Cambiado Ey =
[[0. +0.j 0. +0.j 0.37697052+0.j 0.61480205+0.j
0.66917071+0.j]
[0. +0.j 0. +0.j 0.79999352+0.j 0.0440224 +0.j
0.23428444+0.j]
[0. +0.j 0. +0.j 0.54259311+0.j 0.94779494+0.j
0.51348343+0.j]]
Parameters of Jones_vector¶
Several parameters can be measured from a Jones vector. They are implemented in the independent class Parameters_Jones_vector, which is stored in the parameters field of Jones_vector class.
 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[23]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees)
I0 = E.parameters.intensity()
print(I0)
1.0
When several Jones vectors are stored in the object, setting verbose argument to True makes the method print the values in screen. Also, 1D or 2D figures can be shown if the draw argument is set to True:
[24]:
az = np.linspace(0, 180*degrees, 12)
E = Jones_vector("Source 1")
E.general_azimuth_ellipticity(azimuth=az)
az = E.parameters.azimuth(draw=True, verbose=True)
The azimuth of Source 1 is (deg.):
[0.00000000e+00 1.63636364e+01 3.27272727e+01 4.90909091e+01
6.54545455e+01 8.18181818e+01 9.81818182e+01 1.14545455e+02
1.30909091e+02 1.47272727e+02 1.63636364e+02 7.01670930e15]
The mean value is 74.99999999999999 + 54.46016058467961
[25]:
az = np.linspace(0, 180*degrees, 128)
el = np.linspace(45*degrees, 45*degrees, 128)
AZ, EL = np.meshgrid(az, el)
E = Jones_vector("Source 1")
E.general_azimuth_ellipticity(azimuth=AZ, ellipticity=EL)
AZ, EL = E.parameters.azimuth_ellipticity(draw=True)
The azimuth and ellipticity angles of Source 1 are (deg.):
The mean value of param Azimuth (deg.) is 91.25244140625 + 52.246912162199024
The mean value of param Ellipticity angle (deg.) is 1.7763568394002505e15 + 26.184535918359188
There is a method in Parameters_Jones_vector class, get_all that computes all the parameters available and stores in a dictionary .dict_params(). Using the print function upon the Parameters_Jones_vector class invokes the method get_all.
Example:
[26]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees)
print(E,'\n')
print(E.parameters)
Source 1 =
[+0.707+0.000j]
[+0.707+0.000j]
The elctric field components of Source 1 are (V/m):
Ex (V/m)
(0.7071067811865476+0j)
Ey (V/m)
(0.7071067811865476+0j)
Low dimensionality, figure not available.
The elctric field amplitudes of Source 1 are (V/m):
Ex (V/m)
0.7071067811865476
Ey (V/m)
0.7071067811865476
Low dimensionality, figure not available.
The intensity of Source 1 is (a.u.):
1.0
Low dimensionality, figure not available.
The norm of Source 1 is (a.u.):
1.0
Low dimensionality, figure not available.
The irradiance of Source 1 is (W/m^2):
0.0013272104690361798
Low dimensionality, figure not available.
The ratio angle between electric field amplitudes of Source 1 is (deg.):
45.0
Low dimensionality, figure not available.
Delay between electric field components of Source 1 is (deg.):
0.0
Low dimensionality, figure not available.
The azimuth of Source 1 is (deg.):
44.999999999999986
Low dimensionality, figure not available.
The ellipticity angle of Source 1 is (deg.):
0.0
Low dimensionality, figure not available.
The global phase of Source 1 is (deg.):
0.0
Low dimensionality, figure not available.
The ellipse axes of Source 1 are (V/m):
a (V/m)
1.0
b (V/m)
0.0
Low dimensionality, figure not available.
The ellipticity parameter of Source 1 is:
0.0
Low dimensionality, figure not available.
The eccentricity of Source 1 is:
1.0
Low dimensionality, figure not available.
The degree of circular polarization of Source 1 is:
0.0
Low dimensionality, figure not available.
The degree of linear polarization of Source 1 is:
1.0
Low dimensionality, figure not available.
Checks of Jones_vector¶
There are several checks that can be performed upon a Jones vector. They are implemented in the independent class Checks_Jones_vector, which is stored in the checks field of Jones_vector class.
 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[27]:
E = Jones_vector("Source 1")
E.linear_light(azimuth = 45*degrees)
cond = E.checks.is_linear()
print(cond)
True
1D and 2D plot draws are also implemented for this class:
[28]:
alpha = np.linspace(45*degrees, 45*degrees, 56)
delay = np.linspace(0, 360*degrees, 56)
Alpha, Delay = np.meshgrid(alpha, delay)
E = Jones_vector("Source 1")
E.general_charac_angles(alpha=Alpha, delay=Delay)
_ = E.checks.is_right_handed(draw=True)
(3136,) (3136,)
Source 1 is right handed:
The mean value is nan + nan
[ ]:
Mueller class¶
Mueller is a class that manages Mueller 4x4 polarization matrix. It allows the user to create and manipulate them. The difference between Mueller and Jones formalisms is that Mueller matrices can depolarize light, while Jones matrices can affect to the global phase of the electric field. However, Mueller objects store the global phase (if any) and use it when it is relevant.
Creating an instance¶
An instance must be created before starting to operate with the Mueller matrix. The initialization accepts one argument: the name of the vector. This name will be used for printing:
[1]:
from py_pol.mueller import Mueller, create_Mueller, degrees
from py_pol.stokes import Stokes
import numpy as np
M1 = Mueller("Object 1")
print(M1)
Object 1 is empty
Several Mueller objects can be created at the same time using the function create_Mueller.
[2]:
M2, M3 = create_Mueller(name=('Object 2', 'Object 3'))
print(M2, M3)
list_of_M = create_Mueller(N=3)
print(list_of_M)
Object 2 is empty
Object 3 is empty
[M is empty
, M is empty
, M is empty
]
Mueller class fields¶
Mueller class objects have some fields where some methods and information is stored: * M: 4x4xN array containing all the Mueller matrices. * name: Name of the object for print purposes. * shape: Shape desired for the outputs. * size: Number of stored Mueller matrices. * ndim: Number of dimensions for representation purposes. * no_rotation: If True, rotation method do not act upon the object. Useful for objects that shouldn’t be rotated as mirrors. * **_type**: Type of the object (‘Mueller’). This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.
 parameters: parameters of the Mueller matrices.
 checks: checks of the Mueller matrices.
 analysis: analysis of the Mueller matrices.
[3]:
M1 = Mueller("diattenuator_linear")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(M1.M)
[[[0.5]
[0.5]
[0. ]
[0. ]]
[[0.5]
[0.5]
[0. ]
[0. ]]
[[0. ]
[0. ]
[0. ]
[0. ]]
[[0. ]
[0. ]
[0. ]
[0. ]]]
Generating polarization devices¶
As shown in the previous example, the Mueller matrix is initialized with all elements equal to zero. There are many methods that can be used to generate a more desirable vector:
 from_components: Creates a Mueller matrix directly from the 16 \(M_{ij}\) elements.
 from_matrix: Creates a Mueller object directly from a 4x4xN matrix.
 from_normalized: Creates a Mueller matrix directly from a normalized 4x4 matrix (\(M_{norm} = M/M_{00}\)).
 from_Jones: Creates a Mueller Matrix equivalent to a Jones matrix.
 from_blocks: Creates a Mueller matrix from the blocks of its decomposition.
 from_covariance: Creates a Mueller matrix from the equivalent covariant matrix.
 from_inverse: Creates a Mueller matrix from the inverse matrix.
 from_list: Creates a Jones_matrix object directly from a list of 4x4 numpy arrays.
 vacuum: Creates the matrix for vacuum.
 mirror: Creates the matrix for a mirror. NOTE: This matrix mus not be rotated.
 filter_amplifier: Creates the matrix for a neutral filter or amplifier element.
 depolarizer_perfect: Creates a perfect depolarizer.
 depolarizer_diagonal: Creates a depolarizer with elements just in the diagonal.
 depolarizer_states: Creates a general depolarizer from the diattenuation, polarizance and eigenstate vectors.
 diattenuator_perfect: Creates a perfect linear polarizer.
 diattenuator_linear: Creates a real diattenuator with perpendicular axes.
 diattenuator_charac_angles: Creates the most general homogeneous diattenuator with orthogonal eigenstates from the characteristic angles of the main eigenstate.
 diattenuator_azimuth_ellipticity: Creates the most general homogenous diattenuator from the characteristic angles of the main eigenstate.
 diattenuator_vector: Creates the most general homogenous diattenuator from the diattenuation vector.
 quarter_waveplate: Creates a perfect retarder with 90º retardance.
 half_waveplate: Creates a perfect retarder with 180º retardance.
 retarder_linear: Creates a linear retarder.
 retarder_charac_angles: Creates the most general homogeneous retarder from the characteristic angles of the fast eigenstate.
 retarder_azimuth_ellipticity: Creates the most general homogeneous retarder from the characteristic angles of the fast eigenstate.
 retarder_from_vector: Creates the most general homogeneous retarder from the retardance vector.
 diattenuator_retarder_linear: Creates an homogeneous linear diattenuator retarder with the same axes for diattenuation and retardance.
 diattenuator_retarder_azimuth_ellipticity: Creates the most general homogeneous diattenuator retarder with the same axes for diattenuation and retardance from the azimuth and ellipticity angle.
 diattenuator_retarder_charac_angles: Creates the most general homogeneous diattenuator retarder with the same axes for diattenuation and retardance from the characteristic angles.
 general_eigenstates: Generates the most general pure optical element from its eigenstates.
For a more detailed description of each method, refer to the individual documentation of each one.
Example: Linear diattenuator.
[4]:
M1 = Mueller("Linear diattenuator")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(M1)
Linear diattenuator =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
The previous example only stores one Mueller matrix. However, it is possible to store many Mueller matrices in the same object. This is useful specially when the same operation is performed upon all of them, as rotation. In this way, it is not required to use for loops, reducing significantly the computation time.
There are many ways of creating several Mueller matrices in the same object. The first way is creating an object with several identical matrices. This is performed using the length argument present in most creation methods:
[5]:
M1 = Mueller("Linear diattenuator")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees, length=5)
print(M1)
Linear diattenuator =
[+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
A second way of creating several matrices at the same time is using an array as one (or more) of the parameters of the creation methods. Take into account that, if you use this option, all parameters must have the same number of elements or just one element. Otherwise, the program will throw an exception.
[6]:
angles = np.linspace(0, 90*degrees, 5)
M1 = Mueller("Linear diattenuator")
M1.diattenuator_linear(p1=1, p2=0, azimuth=angles)
print(M1)
Linear diattenuator =
[+0.500 +0.500 +0.000 +0.000] [+0.500 +0.354 +0.354 +0.000] [+0.500 +0.000 +0.500 +0.000] [+0.500 0.354 +0.354 +0.000] [+0.500 0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000] [+0.354 +0.250 +0.250 +0.000] [+0.000 +0.000 +0.000 +0.000] [0.354 +0.250 0.250 +0.000] [0.500 +0.500 0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.354 +0.250 +0.250 +0.000] [+0.500 +0.000 +0.500 +0.000] [+0.354 0.250 +0.250 +0.000] [+0.000 0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
If the parameters have dimension higher than 1, the program will store that information in order to make prints and plots. In that case, the print function separates the two components Jones vectors:
[7]:
angles = np.random.rand(3,3) * 180*degrees
M1 = Mueller("Linear diattenuator")
M1.diattenuator_linear(p1=1, p2=0, azimuth=angles)
print(M1)
Linear diattenuator M00 =
[[0.5 0.5 0.5]
[0.5 0.5 0.5]
[0.5 0.5 0.5]]
Linear diattenuator M01 =
[[ 0.4963735 0.26388031 0.41606682]
[ 0.12355667 0.23285935 0.0149987 ]
[ 0.27418891 0.17970438 0.37525708]]
Linear diattenuator M02 =
[[ 0.06011114 0.42469657 0.27728757]
[ 0.48449329 0.44246641 0.49977499]
[ 0.41811535 0.46659011 0.33042718]]
Linear diattenuator M03 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M10 =
[[ 0.4963735 0.26388031 0.41606682]
[ 0.12355667 0.23285935 0.0149987 ]
[ 0.27418891 0.17970438 0.37525708]]
Linear diattenuator M11 =
[[4.92773302e01 1.39265641e01 3.46223204e01]
[3.05324994e02 1.08446955e01 4.49922081e04]
[1.50359116e01 6.45873306e02 2.81635755e01]]
Linear diattenuator M12 =
[[ 0.05967515 0.22413813 0.23074032]
[ 0.11972475 0.20606488 0.01499195]
[ 0.22928518 0.16769658 0.24799028]]
Linear diattenuator M13 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M20 =
[[ 0.06011114 0.42469657 0.27728757]
[ 0.48449329 0.44246641 0.49977499]
[ 0.41811535 0.46659011 0.33042718]]
Linear diattenuator M21 =
[[ 0.05967515 0.22413813 0.23074032]
[ 0.11972475 0.20606488 0.01499195]
[ 0.22928518 0.16769658 0.24799028]]
Linear diattenuator M22 =
[[0.0072267 0.36073436 0.1537768 ]
[0.4694675 0.39155305 0.49955008]
[0.34964088 0.43541267 0.21836424]]
Linear diattenuator M23 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M30 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M31 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M32 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Linear diattenuator M33 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Features of creation methods¶
Mueller formalism does not take into account the global phase of the light states. However, Mueller objects store the phase they add to light in the global_phase field. Use None if the global phase is unknown.
Most creation methods accept a global_phase argument that can be used to introduce it.
[8]:
M1 = Mueller("Linear diattenuator")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees, global_phase=90*degrees)
print(M1.global_phase / degrees)
M1.remove_global_phase()
print(M1.global_phase / degrees)
[0.]
0.0
Some creation methods accept a p1 and p2 or a Tmax and Tmin parameters in order to set the electric field or intensity maximum and minimum transmissions respectively. If both sets of parameters are given together to the method, it will use the intensity transmissions, ignoring the field transmissions:
[9]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(M1)
M1 = Mueller("Diattenuator 2")
M1.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=0*degrees)
print(M1)
M1 = Mueller("Diattenuator 3")
M1.diattenuator_linear(p1=1, p2=0, Tmax=0.8, Tmin=0.2, azimuth=0*degrees)
print(M1)
Diattenuator 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Diattenuator 2 =
[+0.500 +0.300 +0.000 +0.000]
[+0.300 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.400 +0.000]
[+0.000 +0.000 +0.000 +0.400]
Diattenuator 3 =
[+0.500 +0.300 +0.000 +0.000]
[+0.300 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.400 +0.000]
[+0.000 +0.000 +0.000 +0.400]
Basic operations¶
Some physical phenomena that affects optical objects are described by simple operations performed to their Mueller matrices.
Addition of two Mueller matrices¶
If a light state gets through two (or more) optical objects in paralel (i.e., two halves of the light source gets twhrough two different optical elements), this phenomenom is represented by the sum of their Mueller matrices. If both of them have the same global phase, it is maintained. If not, it is changed to None (unknown).
Take into notice that the sum of two physically realizable Mueller matrices is not necessary a physically realizable Mueller matrix.
[10]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
M2 = Mueller("Diattenuator 2")
M2.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=0*degrees)
print(M1+M2)
Diattenuator 1 + Diattenuator 2 =
[+1.000 +0.800 +0.000 +0.000]
[+0.800 +1.000 +0.000 +0.000]
[+0.000 +0.000 +0.400 +0.000]
[+0.000 +0.000 +0.000 +0.400]
Multiply by a constant¶
A change in the absorption or gain of an optical object is represented by multiplying it by a constant. Take into account that Mueller formalism describes intensity transmissions, so the constant represents a variation in Intensity absorption or gain.
[11]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(2 * M1)
print(M1*3)
print(M1/2)
2 * Diattenuator 1 =
[+1.000 +1.000 +0.000 +0.000]
[+1.000 +1.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
3 * Diattenuator 1 =
[+1.500 +1.500 +0.000 +0.000]
[+1.500 +1.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Diattenuator 1 / 2 =
[+0.250 +0.250 +0.000 +0.000]
[+0.250 +0.250 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
If the constant is complex, the constant phase will be added to the global phase of the light, while its absolute value will increase or decrease the light intensity.
Take into account that real negative values are a special case of complex numbers whose phase is 180º.
[12]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees, global_phase=0*degrees)
result = 2j * M1
print(result, result.global_phase/degrees)
result = 1 * M1
print(result, result.global_phase/degrees)
2j * Diattenuator 1 =
[+1.000 +1.000 +0.000 +0.000]
[+1.000 +1.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[90.]
1 * Diattenuator 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[180.]
Multiplication of a Stokes vector by a Mueller matrix¶
This operation represents a light wave (described by the Stokes vector) getting through an optical element.
[13]:
S1 = Stokes('Light source')
S1.linear_light(azimuth=0)
print(S1)
M1 = Mueller("Diattenuator 1")
M1.diattenuator_perfect(azimuth=45*degrees)
print(M1*S1)
Light source =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Diattenuator 1 @ 45.00 deg * Light source =
[+0.500]
[+0.000]
[+0.500]
[+0.000]
Multiplication of Mueller matrices¶
When a light wave is going to get through two (or more) optical objects, the total system can be represented by a single Mueller matrix which is the product of the individual Mueller matrices. The left to right order of the matrices must be the last to first object to be transversed.
Example: “circular polarizer”.
[14]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_perfect(azimuth=0*degrees)
M2 = Mueller("Retarder 1")
M2.quarter_waveplate(azimuth=45*degrees)
print(M2*M1)
Retarder 1 @ 45.00 deg * Diattenuator 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
Equality¶
It is possible to compare two Mueller objects and tell if they are the same. It just compares the Mueller matrices and the global phase, not the rest of object fields.
[15]:
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees, global_phase=0)
print(M1)
M2 = Mueller("Diattenuator 2")
M2.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees, global_phase=0)
print(M2)
print(M1 == M2)
M1.set_global_phase(90*degrees)
print(M1 == M2)
Diattenuator 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Diattenuator 2 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[ True]
[False]
Operations and multidimensionality¶
The basic operations of Stokes objects are subject to the same casting rules as numpy arrays. This means that they can be easily used even if one or both elements of the operation have more than one element.
Here are some examples:
[16]:
# sum
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
M2 = Mueller("Diattenuator 2")
M2.diattenuator_linear(Tmax=np.linspace(0.6, 1, 5), Tmin=0.2, azimuth=0*degrees)
print(M1+M2)
Diattenuator 1 + Diattenuator 2 =
[+0.900 +0.700 +0.000 +0.000] [+0.950 +0.750 +0.000 +0.000] [+1.000 +0.800 +0.000 +0.000] [+1.050 +0.850 +0.000 +0.000] [+1.100 +0.900 +0.000 +0.000]
[+0.700 +0.900 +0.000 +0.000] [+0.750 +0.950 +0.000 +0.000] [+0.800 +1.000 +0.000 +0.000] [+0.850 +1.050 +0.000 +0.000] [+0.900 +1.100 +0.000 +0.000]
[+0.000 +0.000 +0.346 +0.000] [+0.000 +0.000 +0.374 +0.000] [+0.000 +0.000 +0.400 +0.000] [+0.000 +0.000 +0.424 +0.000] [+0.000 +0.000 +0.447 +0.000]
[+0.000 +0.000 +0.000 +0.346] [+0.000 +0.000 +0.000 +0.374] [+0.000 +0.000 +0.000 +0.400] [+0.000 +0.000 +0.000 +0.424] [+0.000 +0.000 +0.000 +0.447]
[17]:
# product by a constant
M1 = Mueller("Diattenuator 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(np.linspace(0, 1, 5) * M1)
M =
[+0.000 +0.000 +0.000 +0.000] [+0.125 +0.125 +0.000 +0.000] [+0.250 +0.250 +0.000 +0.000] [+0.375 +0.375 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.125 +0.125 +0.000 +0.000] [+0.250 +0.250 +0.000 +0.000] [+0.375 +0.375 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
[18]:
# Multiplication of Mueller matrices
M1 = Mueller("Diattenuator 1")
M1.diattenuator_perfect(azimuth=0*degrees)
M2 = Mueller("Retarder 1")
angles = np.linspace(0, 90*degrees, 5)
M2.quarter_waveplate(azimuth=angles)
print(M2*M1)
Retarder 1 * Diattenuator 1 =
[+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000] [+0.250 +0.250 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [+0.250 +0.250 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.250 +0.250 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000] [0.250 0.250 +0.000 +0.000] [0.000 0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000] [+0.354 +0.354 +0.000 +0.000] [+0.500 +0.500 +0.000 +0.000] [+0.354 +0.354 +0.000 +0.000] [+0.000 +0.000 +0.000 +0.000]
Mueller matrix manipulation¶
There are several operations that can be applied to a Mueller matrix.
 update: Recalculates some parameters as the number of elements, the dimensions associated to the shape, and such things.
 clear: Removes data and name form the object.
 copy: Creates a copy of the object.
 stretch: Stretches an object of size 1.
 shape_like: Takes the shape of another object to use as its own.
 rotate: Rotates the Mueller matrix.
 sum: Calculates the summatory of the Jones matrices in the object.
 prod: Calculates the product of the Jones matrices in the object.
 flip: Flips the object along some dimensions.
 remove_global_phase: Removes the phase introduced by the optical element.
 add_global_phase: Increases the phase introduced by the optical element.
 set_global_phase: Sets the phase introduced by the optical element.
 reciprocal: Flips the optical element so the light transverses it in the opposite direction.
 transpose: Transposes the Mueller matrix of the element.
 inverse: Calculates the inverse matrix of the Mueller matrix.
 covariant_matrix: This method calculates the covariant matrix of the Mueller matrix of the object.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[19]:
M1 = Mueller("Object 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
print(M1,'\n')
M1.rotate(angle=45*degrees)
print(M1)
Object 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Object 1 @ 45.00 deg =
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Most manipulation methods have the keep argument that specifies if the originial object must be preserved or transformed. If keep is True (default is False), a new object is created:
[20]:
M1 = Mueller("Object 1")
M1.diattenuator_linear(p1=1, p2=0, azimuth=0*degrees)
M2 = M1.rotate(angle=45*degrees, keep=True)
print(M1, M2)
M2 = M1.rotate(angle=45*degrees, keep=False)
print(M1, M2)
Object 1 =
[+0.500 +0.500 +0.000 +0.000]
[+0.500 +0.500 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Object 1 @ 45.00 deg =
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Object 1 @ 45.00 deg =
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Object 1 @ 45.00 deg =
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
[+0.500 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.000]
Mueller objects allow taking elements and changing them through indices like a numpy.ndarray.
Examples:
[21]:
M = np.random.rand(4, 4, 5)
M1 = Mueller('Original')
M1.from_matrix(M)
print(M1)
M2 = M1[1:3]
print(M2)
Original =
[+0.342 +0.336 +0.949 +0.258] [+0.711 +0.203 +0.279 +0.321] [+0.033 +0.483 +0.069 +0.307] [+0.636 +0.500 +0.018 +0.275] [+0.456 +0.396 +0.517 +0.882]
[+0.324 +0.745 +0.886 +0.364] [+0.037 +0.711 +0.610 +0.043] [+0.214 +0.441 +0.909 +0.537] [+0.719 +0.572 +0.085 +0.927] [+0.774 +0.943 +0.573 +0.344]
[+0.630 +0.315 +0.096 +0.769] [+0.706 +0.787 +0.094 +0.448] [+0.008 +0.889 +0.643 +0.544] [+0.944 +0.726 +0.956 +0.336] [+0.177 +0.714 +0.951 +0.744]
[+0.019 +0.224 +0.241 +0.864] [+0.503 +0.295 +0.114 +0.143] [+0.608 +0.470 +0.753 +0.979] [+0.205 +0.406 +0.147 +0.029] [+0.696 +0.446 +0.430 +0.554]
Original_picked =
[+0.711 +0.203 +0.279 +0.321] [+0.033 +0.483 +0.069 +0.307]
[+0.037 +0.711 +0.610 +0.043] [+0.214 +0.441 +0.909 +0.537]
[+0.706 +0.787 +0.094 +0.448] [+0.008 +0.889 +0.643 +0.544]
[+0.503 +0.295 +0.114 +0.143] [+0.608 +0.470 +0.753 +0.979]
[22]:
M1 = Mueller('Original')
angles = np.linspace(0,180*degrees, 25)
M1.diattenuator_perfect(azimuth=angles, shape=[5,5])
print(M1)
M2 = M1[1:3,2:4]
print(M2)
Original M00 =
[[0.5 0.5 0.5 0.5 0.5]
[0.5 0.5 0.5 0.5 0.5]
[0.5 0.5 0.5 0.5 0.5]
[0.5 0.5 0.5 0.5 0.5]
[0.5 0.5 0.5 0.5 0.5]]
Original M01 =
[[ 5.00000000e01 4.82962913e01 4.33012702e01 3.53553391e01
2.50000000e01]
[ 1.29409523e01 3.06161700e17 1.29409523e01 2.50000000e01
3.53553391e01]
[4.33012702e01 4.82962913e01 5.00000000e01 4.82962913e01
4.33012702e01]
[3.53553391e01 2.50000000e01 1.29409523e01 9.18485099e17
1.29409523e01]
[ 2.50000000e01 3.53553391e01 4.33012702e01 4.82962913e01
5.00000000e01]]
Original M02 =
[[ 0.00000000e+00 1.29409523e01 2.50000000e01 3.53553391e01
4.33012702e01]
[ 4.82962913e01 5.00000000e01 4.82962913e01 4.33012702e01
3.53553391e01]
[ 2.50000000e01 1.29409523e01 6.12323400e17 1.29409523e01
2.50000000e01]
[3.53553391e01 4.33012702e01 4.82962913e01 5.00000000e01
4.82962913e01]
[4.33012702e01 3.53553391e01 2.50000000e01 1.29409523e01
1.22464680e16]]
Original M03 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M10 =
[[ 5.00000000e01 4.82962913e01 4.33012702e01 3.53553391e01
2.50000000e01]
[ 1.29409523e01 3.06161700e17 1.29409523e01 2.50000000e01
3.53553391e01]
[4.33012702e01 4.82962913e01 5.00000000e01 4.82962913e01
4.33012702e01]
[3.53553391e01 2.50000000e01 1.29409523e01 9.18485099e17
1.29409523e01]
[ 2.50000000e01 3.53553391e01 4.33012702e01 4.82962913e01
5.00000000e01]]
Original M11 =
[[5.00000000e01 4.66506351e01 3.75000000e01 2.50000000e01
1.25000000e01]
[3.34936491e02 1.87469973e33 3.34936491e02 1.25000000e01
2.50000000e01]
[3.75000000e01 4.66506351e01 5.00000000e01 4.66506351e01
3.75000000e01]
[2.50000000e01 1.25000000e01 3.34936491e02 1.68722976e32
3.34936491e02]
[1.25000000e01 2.50000000e01 3.75000000e01 4.66506351e01
5.00000000e01]]
Original M12 =
[[ 0.00000000e+00 1.25000000e01 2.16506351e01 2.50000000e01
2.16506351e01]
[ 1.25000000e01 3.06161700e17 1.25000000e01 2.16506351e01
2.50000000e01]
[2.16506351e01 1.25000000e01 6.12323400e17 1.25000000e01
2.16506351e01]
[ 2.50000000e01 2.16506351e01 1.25000000e01 9.18485099e17
1.25000000e01]
[2.16506351e01 2.50000000e01 2.16506351e01 1.25000000e01
1.22464680e16]]
Original M13 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M20 =
[[ 0.00000000e+00 1.29409523e01 2.50000000e01 3.53553391e01
4.33012702e01]
[ 4.82962913e01 5.00000000e01 4.82962913e01 4.33012702e01
3.53553391e01]
[ 2.50000000e01 1.29409523e01 6.12323400e17 1.29409523e01
2.50000000e01]
[3.53553391e01 4.33012702e01 4.82962913e01 5.00000000e01
4.82962913e01]
[4.33012702e01 3.53553391e01 2.50000000e01 1.29409523e01
1.22464680e16]]
Original M21 =
[[ 0.00000000e+00 1.25000000e01 2.16506351e01 2.50000000e01
2.16506351e01]
[ 1.25000000e01 3.06161700e17 1.25000000e01 2.16506351e01
2.50000000e01]
[2.16506351e01 1.25000000e01 6.12323400e17 1.25000000e01
2.16506351e01]
[ 2.50000000e01 2.16506351e01 1.25000000e01 9.18485099e17
1.25000000e01]
[2.16506351e01 2.50000000e01 2.16506351e01 1.25000000e01
1.22464680e16]]
Original M22 =
[[0.00000000e+00 3.34936491e02 1.25000000e01 2.50000000e01
3.75000000e01]
[4.66506351e01 5.00000000e01 4.66506351e01 3.75000000e01
2.50000000e01]
[1.25000000e01 3.34936491e02 7.49879891e33 3.34936491e02
1.25000000e01]
[2.50000000e01 3.75000000e01 4.66506351e01 5.00000000e01
4.66506351e01]
[3.75000000e01 2.50000000e01 1.25000000e01 3.34936491e02
2.99951957e32]]
Original M23 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M30 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M31 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M32 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original M33 =
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
Original_picked M00 =
[[0.5 0.5]
[0.5 0.5]]
Original_picked M01 =
[[0.12940952 0.25 ]
[0.5 0.48296291]]
Original_picked M02 =
[[ 4.82962913e01 4.33012702e01]
[ 6.12323400e17 1.29409523e01]]
Original_picked M03 =
[[0. 0.]
[0. 0.]]
Original_picked M10 =
[[0.12940952 0.25 ]
[0.5 0.48296291]]
Original_picked M11 =
[[0.03349365 0.125 ]
[0.5 0.46650635]]
Original_picked M12 =
[[1.25000000e01 2.16506351e01]
[6.12323400e17 1.25000000e01]]
Original_picked M13 =
[[0. 0.]
[0. 0.]]
Original_picked M20 =
[[ 4.82962913e01 4.33012702e01]
[ 6.12323400e17 1.29409523e01]]
Original_picked M21 =
[[1.25000000e01 2.16506351e01]
[6.12323400e17 1.25000000e01]]
Original_picked M22 =
[[4.66506351e01 3.75000000e01]
[7.49879891e33 3.34936491e02]]
Original_picked M23 =
[[0. 0.]
[0. 0.]]
Original_picked M30 =
[[0. 0.]
[0. 0.]]
Original_picked M31 =
[[0. 0.]
[0. 0.]]
Original_picked M32 =
[[0. 0.]
[0. 0.]]
Original_picked M33 =
[[0. 0.]
[0. 0.]]
Parameters of Mueller matrices¶
Several parameters can be measured from a Mueller Matrix. They are implemented in the independent class Parameters_Jones_Matrix, which is stored in the parameters field of Jones_matrix class.
 matrix: Gets a numpy array with all the matrices.
 components: Extracts the four components of the Mueller matrix.
 global_phase: Extracts the global phase introduced by the object.
 blocks: Method that divides a mueller matrix in their blocks: mean transmission (\(M_{00}\)), diattenuation and polarizance vectors and small matrix m.
 diattenuation_vector: Extracts the 3xN array of diattenuation vectors.
 polarizance_vector: Extracts the 3xN array of polarizance vectors.
 small_matrix: Extracts the 3x3xN array of small matrix m.
 retardance_vector: Extracts the 3xN array of retardance vectors (if exists).
 mean_transmission: Calculates the mean transmission coefficient.
 transmissions: Calculates the maximum and minimum transmissions.
 inhomogeneity: Calculates the inhomogeneity parameter.
 diattenuation: Calculates the diattenuation of a Mueller matrix.
 diattenuation_linear: Calculates the linear diattenuation of a Mueller matrix.
 diattenuation_circular: Calculates the circular diattenuation of a Mueller matrix.
 polarizance: Calculates the polarizance of a Mueller matrix.
 polarizance_linear: Calculates the linear polarizance of a Mueller matrix.
 polarizance_circular: Calculates the delay of the matrix.
 degree_polarizance: Calculates the degree of polarizance.
 spheric_purity: Calculates the spheric purity grade.
 retardance: Calculates the retardance (also refered as delay) of the Mueller matrix of a pure retarder.
 polarimetric_purity: Calculates the degree of polarimetric purity of a Mueller matrix.
 depolarization_index: Calculates the depolarization_index of a Mueller matrix.
 polarimetric_purity_indices: Calculates the polarimetric purity indices of a Mueller matrix.
 eig: Calculates the eigenvalues and eigenstates (eigenvectors) of the Mueller matrices.
 eigenvalues: Calculates the eigenvalues and of the Mueller matrices.
 eigenvectors: Calculates the eigenvectors of the Mueller matrices.
 eigenstates: Calculates the eigenstates (Stokes vectors of the eigenvectors) of the Mueller matrices.
 det: Calculates the determinant and of the Mueller matrices.
 trace: Calculates the trace of the Mueller matrices.
 norm: Calculates the norm of the Mueller matrices.
 get_all: Returns a dictionary with all the parameters of the object.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[23]:
M1 = Mueller("Diattenuator retarder")
M1.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5)
ret = M1.parameters.retardance()
print("Retardance = {:2.1f}º".format(ret/degrees))
Retardance = 90.0º
When several Stokes vectors are stored in the object, setting verbose argument to True makes the method print the values in screen. Also, 1D or 2D figures can be shown if the draw argument is set to True:
[24]:
M1 = Mueller("Diattenuator retarder")
M1.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5)
ret = M1.parameters.retardance(verbose=True)
The retardance of Diattenuator retarder is (deg):
90.0
[25]:
M1 = Mueller("Diattenuator retarder")
ret = np.linspace(0, 180*degrees, 124)
M1.diattenuator_retarder_linear(R=ret, p1=1, p2=0.5)
ret = M1.parameters.retardance(draw=True)
The retardance of Diattenuator retarder is (deg):
The mean value is 89.14306286525556 + 36.17075878552775
[26]:
M1 = Mueller("Diattenuator")
p1 = np.linspace(0.5, 1, 124)
p2 = np.linspace(0, 0.5, 124)
P1, P2 = np.meshgrid(p1, p2)
M1.diattenuator_azimuth_ellipticity(p1=P1, p2=P2, azimuth=30*degrees, ellipticity=15*degrees)
p1, p2 = M1.parameters.transmissions(kind='Field', draw=True)
The field transmissions of Diattenuator are:
The mean value of param Maximum (int.) is 0.75 + 0.14550631161866215
d:\codigo_ucm\py_pol\py_pol\mueller.py:2108: RuntimeWarning: invalid value encountered in true_divide
cte = (1  skd) / d**2
The mean value of param Minimum (int.) is 0.25 + 0.14550631161866218
There is a function in Parameters_Mueller class, get_all that will compute all the parameters available and stores in a dictionary dict_params. Info about dict parameters can be revised using the print function.
Example:
[27]:
M1 = Mueller("Diattenuator retarder")
M1.diattenuator_retarder_linear(R=90*degrees, p1=1, p2=0.5)
print(M1.parameters)
The mean transmission of Diattenuator retarder is:
0.625
Low dimensionality, figure not available.
The inhomogeneity parameter of Diattenuator retarder is:
0.44721359549995804
Low dimensionality, figure not available.
The diattenuation of Diattenuator retarder is:
0.6
Low dimensionality, figure not available.
The linear diattenuation of Diattenuator retarder is:
0.6
Low dimensionality, figure not available.
The circular diattenuation of Diattenuator retarder is:
0.0
Low dimensionality, figure not available.
The polarizance of Diattenuator retarder is:
0.6
Low dimensionality, figure not available.
The linear polarizance of Diattenuator retarder is:
0.6
Low dimensionality, figure not available.
The circular polarizance of Diattenuator retarder is:
0.0
Low dimensionality, figure not available.
The degree of spherical purity of Diattenuator retarder is:
0.8717797887081348
Low dimensionality, figure not available.
The retardance of Diattenuator retarder is (deg):
90.0
Low dimensionality, figure not available.
The degree of polarimetric purity of Diattenuator retarder is:
1.0
Low dimensionality, figure not available.
The depolarization index of Diattenuator retarder is:
0.0
Low dimensionality, figure not available.
The polarimetric purity indices of Diattenuator retarder are:
P1
1.0
P2
1.0
P3
1.0
Low dimensionality, figure not available.
The intensity transmissions of Diattenuator retarder are:
Maximum (int.)
1.0
Minimum (int.)
0.25
Low dimensionality, figure not available.
The field transmissions of Diattenuator retarder are:
Maximum (int.)
1.0
Minimum (int.)
0.5
Low dimensionality, figure not available.
The retardance of Diattenuator retarder is (deg):
90.0
Low dimensionality, figure not available.
The eigenvalues of Diattenuator retarder are:
v1
(1+0j)
v2
(0.2499999999999999+0j)
v3
(3.061616997868383e17+0.5000000000000001j)
v4
(3.061616997868383e170.5000000000000001j)
Low dimensionality, figure not available.
The eigenvectors of Diattenuator retarder are:
e1 I
[0.70710678+0.j]
e1 Q
[0.70710678+0.j]
e1 U
[0.+0.j]
e1 V
[0.+0.j]
e2 I
[0.70710678+0.j]
e2 Q
[0.70710678+0.j]
e2 U
[0.+0.j]
e2 V
[0.+0.j]
e3 I
[0.+0.j]
e3 Q
[0.+0.j]
e3 U
[0.0.70710678j]
e3 V
[0.70710678+0.j]
e4 I
[0.0.j]
e4 Q
[0.0.j]
e4 U
[0.+0.70710678j]
e4 V
[0.707106780.j]
Low dimensionality, figure not available.
The determinant of Diattenuator retarder is:
0.06249999999999998
Low dimensionality, figure not available.
The trace of Diattenuator retarder is:
1.25
Low dimensionality, figure not available.
The norm of Diattenuator retarder is:
1.25
Low dimensionality, figure not available.
Checks on Mueller Matrices¶
There are many types of Mueller matrices. The Check_Mueller calss implements all the checks that can be performed in order to clasify a Mueller matrix. They are stored in the checks field of Mueller class.
 is_physical: Conditions of physical realizability.
 is_non_depolarizing / is_pure: Checks if matrix is nondepolarizing.
 is_homogeneous: Checks if the matrix is homogeneous (eigenstates are orthogonal). It is implemented in two different ways.
 is_retarder: Checks if the matrix M corresponds to a pure retarder.
 is_diattenuator / is_polarizer: Checks if the matrix M corresponds to a pure homogeneous diattenuator.
 is_depolarizer: Checks if the object corresponds to a depolarizer.
 is_singular: Checks if the matrix is singular (at least one of its eigenvalues is 0).
 is_symmetric: Checks if the Mueller matrices are symmetric.
 get_all: Returns a dictionary with all the checks of the object.
Example: linear diattenuator.
[28]:
M1 = Mueller("Diattenuator")
M1.diattenuator_linear(p1=1, p2=0.5)
print(M1)
M1.parameters.inhomogeneity(verbose=True)
c1 = M1.checks.is_physical(verbose=True)
c2 = M1.checks.is_homogeneous(verbose=True)
c3 = M1.checks.is_retarder(verbose=True)
Diattenuator =
[+0.625 +0.375 +0.000 +0.000]
[+0.375 +0.625 +0.000 +0.000]
[+0.000 +0.000 +0.500 +0.000]
[+0.000 +0.000 +0.000 +0.500]
The inhomogeneity parameter of Diattenuator is:
0.0
Diattenuator is physically realizable:
True
Diattenuator is homogeneous:
True
Diattenuator is a retarder:
False
1D and 2D plot draws are also implemented for this class:
[29]:
M1 = Mueller("Diattenuator")
p1 = np.linspace(0.5, 1, 124)
p2 = np.linspace(0, 0.5, 124)
P1, P2 = np.meshgrid(p1, p2)
M1.diattenuator_linear(p1=P1, p2=P2, azimuth=30*degrees)
M1.checks.is_diattenuator(draw=True)
d:\codigo_ucm\py_pol\py_pol\mueller.py:6627: RuntimeWarning: invalid value encountered in true_divide
(1, Dv[0, :] / par, Dv[1, :] / par, Dv[2, :] / par))
d:\codigo_ucm\py_pol\py_pol\mueller.py:6629: RuntimeWarning: invalid value encountered in true_divide
(1, Dv[0, :] / par, Dv[1, :] / par, Dv[2, :] / par))
Diattenuator is a diattenuator:
The mean value is 0.9999349635796045 + 0.008064253881137646
[29]:
array([[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
...,
[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
[False, True, True, ..., True, True, True]])
There is a function in Checks_Mueller class, .get_all() that will compute all the checks available and store them in a dictionary .dict_params(). Info about dict checks can be revised using the print function.
Example:
[30]:
M1 = Mueller("Diattenuator")
M1.diattenuator_linear(p1=1, p2=0.5)
print(M1.checks)
Diattenuator is physically realizable:
True
Low dimensionality, figure not available.
Diattenuator is pure (nondepolarizing):
True
Low dimensionality, figure not available.
Diattenuator is homogeneous:
True
Low dimensionality, figure not available.
Diattenuator is a retarder:
False
Low dimensionality, figure not available.
Diattenuator is a diattenuator:
[ True]
Low dimensionality, figure not available.
Diattenuator is a depolarizer:
[False]
Low dimensionality, figure not available.
Diattenuator is singular:
False
Low dimensionality, figure not available.
Diattenuator is symmetric:
True
Low dimensionality, figure not available.
Analysis of Mueller matrices¶
Several analysis can be performed from a Mueller Matrix. They are implemented in the independent class Analysis_Mueller, which is stored in the analysis field of Mueller class.
 diattenuator: Calculates all the parameters from the Mueller Matrix of a diattenuator.
 polarizer: Calculates all the parameters from the Mueller Matrix of a diattenuator using the polarizance vector. If the polarizer is homogeneous, this is equivalent to the previous method.
 retarder: Calculates all the parameters from the Mueller Matrix of a retarder.
 depolarizer: Calculates some of the parameters from the Mueller matrix of a diattenuator.
 filter_physical_conditions: Method that filters experimental errors by forcing the Mueller matrix M to fulfill the conditions necessary for a matrix to be physicall.
 filter_purify_number: Purifies a Mueller matrix by choosing the number of eigenvalues of the covariant matrix that will be made 0.
 filter_purify_threshold: Purifies a Mueller matrix by making 0 the eigenvalues of the covariant matrix lower than a certain threshold.
 decompose_pure: Polar decomposition of a pure Mueller matrix in a retarder and a diattenuator.
 decompose_polar: Polar decomposition of a general Mueller matrix in a depolarizer, retarder and a diattenuator.
[31]:
M1 = Mueller("Diattenuator")
M1.diattenuator_azimuth_ellipticity(p1=1, p2=0.5, azimuth=75*degrees, ellipticity=30*degrees)
print(M1)
M1.analysis.diattenuator(verbose=True);
Diattenuator =
[+0.625 0.162 +0.094 +0.325]
[0.162 +0.523 0.014 0.047]
[+0.094 0.014 +0.508 +0.027]
[+0.325 0.047 +0.027 +0.594]
Analysis of Diattenuator as diattenuator:
 Transmissions of Diattenuator are:
Max. transmission
1.0
Min. transmission
0.25
p1
1.0
p2
0.5
 Angles of Diattenuator are:
Alpha
[57.82945314]
Delay
[73.89788625]
Azimuth
[75.]
Ellipticity angle
[30.]
[ ]:
Stokes class¶
Stokes is a class that manages Stokes vectors. It allows the user to create and manipulate them. The difference between Stokes and Jones formalisms is that Stokes vectors can handle partially polarized light, while Jones vectors can track the global phase of the electric field. However, Stokes objects store the global phase (if any) and use it when it is relevant.
Creating an instance¶
An instance must be created before starting to operate with the Stokes vector. The initialization accepts one argument: the name of the vector. This name will be used for printing:
[31]:
from py_pol.stokes import Stokes, create_Stokes, degrees
import numpy as np
S1 = Stokes("Source 1")
print(S1)
Source 1 is empty
Several Stokes objects can be created at the same time using the function create_Stokes.
[32]:
S2, S3 = create_Stokes(name=('Source 2', 'Source 3'))
print(S2, S3)
list_of_S = create_Stokes(N=3)
print(list_of_S)
Source 2 is empty
Source 3 is empty
[S is empty
, S is empty
, S is empty
]
Generating polarization states¶
As shown in the previous example, the Stokes matrix is initialized with all elements equal to zero. There are many methods that can be used to generate a more desirable vector:
 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example: Light linearly polarized.
[33]:
S1 = Stokes("Linear polarization")
S1.linear_light(azimuth=30*degrees)
print(S1)
Linear polarization @ 30.00 deg =
[+1.000]
[+0.500]
[+0.866]
[+0.000]
The previous example only stores one Stokes vector. However, it is possible to store many Stokes vectors in the same object. This is useful specially when the same operation is performed upon all of them, as rotation. In this way, it is not required to use for loops, reducing significantly the computation time.
There are many ways of creating several Stokes vectors in the same object. The first way is creating an object with several identical vectors. This is performed using the length argument present in most creation methods:
[34]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees, intensity=2, length = 5)
print(S)
Source 1 =
[+2.000] [+2.000] [+2.000] [+2.000] [+2.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
[+2.000] [+2.000] [+2.000] [+2.000] [+2.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
A second way of creating several vectors at the same time is using an array as one (or more) of the parameters of the creation methods. Take into account that, if you use this option, all parameters must have the same number of elements or just one element. Otherwise, the program will throw an exception.
[35]:
S = Stokes("Source 1")
angles = np.linspace(0, 90*degrees, 5)
S.linear_light(azimuth = angles, intensity=2)
print(S)
Source 1 =
[+2.000] [+2.000] [+2.000] [+2.000] [+2.000]
[+2.000] [+1.414] [+0.000] [1.414] [2.000]
[+0.000] [+1.414] [+2.000] [+1.414] [+0.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
If the parameters have dimension higher than 1, the program will store that information in order to make prints and plots. In that case, the print function separates the four components of the Stokes vectors:
[36]:
S = Stokes("Source 1")
I = np.random.rand(3,3)
S.linear_light(azimuth = 30*degrees, intensity=I)
print(S)
Source 1 S0 =
[[0.78228899 0.76888678 0.50079408]
[0.01413399 0.92077346 0.97311471]
[0.83729663 0.826152 0.88411832]]
Source 1 S1 =
[[0.39114449 0.38444339 0.25039704]
[0.007067 0.46038673 0.48655736]
[0.41864832 0.413076 0.44205916]]
Source 1 S2 =
[[0.67748214 0.66587549 0.4337004 ]
[0.0122404 0.7974132 0.84274206]
[0.72512015 0.71546862 0.76566892]]
Source 1 S3 =
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
Features of creation methods¶
Stokes formalism does not take into account the global phase of the light states. However, Stokes objects store it in the global_phase field. Use None if the global phase is unknown.
Most creation methods accept a global_phase argument that can be used to introduce it.
[37]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees, global_phase=90*degrees)
print(S.global_phase / degrees)
S.remove_global_phase()
print(S.global_phase)
[90.]
0
Many creation methods accept an amplitude or an intensity parameter (\(a\) and \(b\) for elliptical_light) in order to set the electric field amplitude (the norm of the electric field vector) or the intensity. If both of them are given together to the method, it will use the amplitude:
[38]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees, amplitude=5)
print(S)
_ = S.parameters.intensity(verbose=True)
S = Stokes("Source 2")
S.linear_light(azimuth = 45*degrees, intensity=2)
print(S)
_ = S.parameters.intensity(verbose=True)
S = Stokes("Source 3")
S.linear_light(azimuth = 45*degrees, intensity=2, amplitude=5)
print(S)
_ = S.parameters.intensity(verbose=True)
Source 1 @ 45.00 deg =
[+25.000]
[+0.000]
[+25.000]
[+0.000]
The intensity of Source 1 @ 45.00 deg is (a.u.):
25.0
Source 2 @ 45.00 deg =
[+2.000]
[+0.000]
[+2.000]
[+0.000]
The intensity of Source 2 @ 45.00 deg is (a.u.):
2.0
Source 3 @ 45.00 deg =
[+25.000]
[+0.000]
[+25.000]
[+0.000]
The intensity of Source 3 @ 45.00 deg is (a.u.):
25.0
Also, most creation methods accept two parameters: degree_pol and degree_depol, which represent the degrees of polarization and depolarization respectively. This allows creating partially polarized light states using the same methods.
Both degrees are complementary, so if both of them are given to the method, only degree_depol is used.
[39]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees, intensity=5, degree_pol=0.8)
print(S)
S = Stokes("Source 2")
S.linear_light(azimuth = 45*degrees, intensity=5, degree_depol=0.8)
print(S)
S = Stokes("Source 3")
S.linear_light(azimuth = 45*degrees, intensity=5, degree_pol=0.8, degree_depol=0.8)
print(S)
Source 1 @ 45.00 deg =
[+5.000]
[+0.000]
[+4.000]
[+0.000]
Source 2 @ 45.00 deg =
[+5.000]
[+0.000]
[+3.000]
[+0.000]
Source 3 @ 45.00 deg =
[+5.000]
[+0.000]
[+3.000]
[+0.000]
Basic operations¶
Some physical phenomena that affects polarized light are described by simple operations performed to their Stokes vectors.
Addition of two Stokes vectors¶
The interference of two light waves can be represented by the sum of their Stokes vectors. However, the global phase is important when two light states interfere, i.e., two vectors are added together. If both global phases are known (coherent sum), the polarized part of the Stokes vectors are transformed into Jones objects and added together. The result is tranformed back to a Stokes vector and the unpolarized parts are added.
[40]:
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, amplitude=1, global_phase=0)
print(S1)
S2 = Stokes("Source 2")
S2.linear_light(azimuth = 0*degrees, amplitude=1, global_phase=90*degrees)
print(S2)
S3 = S1 + S2
print(S3)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 1 + Source 2 =
[+2.000]
[+2.000]
[+0.000]
[+0.000]
If one or both phases are unknown (they have a None value), the Stokes vectors are added directly (incoherent sum).
[41]:
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, amplitude=1, global_phase=None)
print(S1)
S2 = Stokes("Source 2")
S2.linear_light(azimuth = 0*degrees, amplitude=1, global_phase=90*degrees)
print(S2)
S3 = S1 + S2
print(S3)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 1 + Source 2 =
[+2.000]
[+2.000]
[+0.000]
[+0.000]
Multiply by a constant¶
The absorption and gain experienced by a light wave is described by multiplying its Jones vector by a real positive number \(c\). The light wave will experience absorption if \(c<0\) and gain if \(c>0\):
[42]:
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, amplitude = 0.5)
print(S1)
S2 = 2 * S1
print(S2)
S2 = S1*3
print(S2)
S2 = S1/3
print(S2)
Source 1 =
[+0.250]
[+0.250]
[+0.000]
[+0.000]
2 * Source 1 =
[+0.500]
[+0.500]
[+0.000]
[+0.000]
3 * Source 1 =
[+0.750]
[+0.750]
[+0.000]
[+0.000]
Source 1 / 3 =
[+0.083]
[+0.083]
[+0.000]
[+0.000]
If the constant is complex, the constant phase will be added to the global phase of the light, while its absolute value will increase or decrease the light intensity.
Take into account that real negative values are a special case of complex numbers whose phase is 180º.
[43]:
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, intensity = 1)
print(S1)
_ = S1.parameters.global_phase(verbose=True)
c = 1j
S2 = c * S1
print(S2)
_ = S2.parameters.global_phase(verbose=True)
c = 0.50.5j
S2 = c * S1
print(S2)
_ = S2.parameters.global_phase(verbose=True)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
The global phase of Source 1 is (deg):
0.0
1j * Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
The global phase of 1j * Source 1 is (deg):
90.0
(0.50.5j) * Source 1 =
[+0.707]
[+0.707]
[+0.000]
[+0.000]
The global phase of (0.50.5j) * Source 1 is (deg):
45.0
Equality¶
It is possible to compare two Stokes objects and tell if they are the same. It just compares the Stokes vectors and the global phase, not the rest of object fields.
[44]:
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees)
print(S1)
S2 = Stokes("Source 2")
angles = np.linspace(0, 90*degrees, 5)
S2.linear_light(azimuth = angles)
print(S2)
print('Comparison: ', S1==S2, '\n\n')
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, global_phase=0)
print(S1)
S2 = Stokes("Source 2")
S2.linear_light(azimuth = 0*degrees, global_phase=0.01)
print(S2)
print('Comparison: ', S1==S2)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000] [+1.000] [+1.000] [+1.000] [+1.000]
[+1.000] [+0.707] [+0.000] [0.707] [1.000]
[+0.000] [+0.707] [+1.000] [+0.707] [+0.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
Source 1  Source 2 =
[+0.000] [+0.152] [+0.586] [+1.235] [+2.000]
[+0.000] [0.141] [0.414] [0.472] [0.000]
[+0.000] [0.058] [0.414] [1.141] [2.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
[0. 0. 0. 0. 0.]
Comparison: [ True False False False False]
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 1  Source 2 =
[+0.000]
[+0.000]
[+0.000]
[+0.000]
[0]
Comparison: [False]
Operations and multidimensionality¶
The basic operations of Stokes objects are subject to the same casting rules as numpy arrays. This means that they can be easily used even if one or both elements of the operation have more than one element.
Here are some examples:
[45]:
# Sum
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 0*degrees, amplitude=1)
print(S1)
S2 = Stokes("Source 2")
angles = np.linspace(0, 90*degrees, 5)
S2.linear_light(azimuth = angles, amplitude=1, global_phase = 45*degrees)
print(S2)
S3 = S1 + S2
print(S3)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000] [+1.000] [+1.000] [+1.000] [+1.000]
[+1.000] [+0.707] [+0.000] [0.707] [1.000]
[+0.000] [+0.707] [+1.000] [+0.707] [+0.000]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
Source 1 + Source 2 =
[+3.414] [+3.307] [+3.000] [+2.541] [+2.000]
[+3.414] [+3.014] [+2.000] [+0.834] [+0.000]
[+0.000] [+1.248] [+2.000] [+2.014] [+1.414]
[+0.000] [+0.541] [+1.000] [+1.307] [+1.414]
[46]:
# Multply by a constant
S1 = Stokes("Source 1")
S1.linear_light(azimuth = 30*degrees, amplitude = 1)
print(S1)
c = np.linspace(0.1, 2.3, 5)
S2 = c * S1
print(S2)
Source 1 @ 30.00 deg =
[+1.000]
[+0.500]
[+0.866]
[+0.000]
Source 1 @ 30.00 deg =
[+0.100] [+0.650] [+1.200] [+1.750] [+2.300]
[+0.050] [+0.325] [+0.600] [+0.875] [+1.150]
[+0.087] [+0.563] [+1.039] [+1.516] [+1.992]
[+0.000] [+0.000] [+0.000] [+0.000] [+0.000]
Stokes vectors manipulation¶
There are several operations that can be applied to a Stokes vector.
 get: Gets a matrix with the electric field components.
 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[47]:
S1 = Stokes('Source 1')
S1.linear_light(azimuth=0*degrees)
print(S1)
S1.rotate(angle=45*degrees)
print(S1)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 1 @ 45.00 deg =
[+1.000]
[+0.000]
[+1.000]
[+0.000]
Most manipulation methods have the keep argument that specifies if the originial object must be preserved or transformed. If keep is True (default is False), a new object is created:
[48]:
S1 = Stokes('Source 1')
S1.linear_light(azimuth=0*degrees)
S2 = S1.rotate(angle=45*degrees, keep=True)
S2.name = 'Source 2'
print(S1, S2)
S2 = S1.rotate(angle=45*degrees, keep=False)
S2.name = 'Source 2'
print(S1, S2)
Source 1 =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Source 2 =
[+1.000]
[+0.000]
[+1.000]
[+0.000]
Source 2 =
[+1.000]
[+0.000]
[+1.000]
[+0.000]
Source 2 =
[+1.000]
[+0.000]
[+1.000]
[+0.000]
Stokes objects allow taking elements and changing them through indices like a numpy.ndarray.
Examples:
[49]:
M = np.random.rand(4, 3, 5)
S1 = Stokes('Original')
S1.from_matrix(M)
print(S1)
S2 = S1[0:3]
print(S2)
Original S0 =
[[0.24840339 0.32313402 0.05107956 0.11969216 0.6784634 ]
[0.10818894 0.18045813 0.21383293 0.85123954 0.71846167]
[0.18589228 0.98792255 0.12697663 0.80158249 0.69691473]]
Original S1 =
[[0.57723636 0.25699519 0.22407303 0.44512362 0.31340967]
[0.06532965 0.01611792 0.22472426 0.47173991 0.70135821]
[0.72198979 0.68660731 0.90963795 0.89776843 0.9493245 ]]
Original S2 =
[[0.25219523 0.41606424 0.09042519 0.67654934 0.58324481]
[0.47063032 0.85555929 0.13338127 0.33734191 0.85657209]
[0.87003926 0.09777541 0.19373622 0.86950104 0.69639677]]
Original S3 =
[[0.83950824 0.37648794 0.22697632 0.69571213 0.63051223]
[0.03661993 0.35507896 0.45065475 0.10087443 0.48481941]
[0.68499671 0.59790976 0.14872438 0.56511226 0.29843615]]
Original_picked =
[+0.248] [+0.323] [+0.051]
[+0.577] [+0.257] [+0.224]
[+0.252] [+0.416] [+0.090]
[+0.840] [+0.376] [+0.227]
[50]:
S3.linear_light()
S4 = S1.copy()
S4.name = 'Cambiado'
S4[0:3,0:2] = S3
print(S4)
Cambiado S0 =
[[1. 1. 0.05107956 0.11969216 0.6784634 ]
[1. 1. 0.21383293 0.85123954 0.71846167]
[1. 1. 0.12697663 0.80158249 0.69691473]]
Cambiado S1 =
[[1. 1. 0.22407303 0.44512362 0.31340967]
[1. 1. 0.22472426 0.47173991 0.70135821]
[1. 1. 0.90963795 0.89776843 0.9493245 ]]
Cambiado S2 =
[[0. 0. 0.09042519 0.67654934 0.58324481]
[0. 0. 0.13338127 0.33734191 0.85657209]
[0. 0. 0.19373622 0.86950104 0.69639677]]
Cambiado S3 =
[[0. 0. 0.22697632 0.69571213 0.63051223]
[0. 0. 0.45065475 0.10087443 0.48481941]
[0. 0. 0.14872438 0.56511226 0.29843615]]
Parameters of Stokes vector¶
Several parameters can be measured from a Stokes vector. They are implemented in the independent class Parameters_Stokes_vector, which is stored in the parameters field of Stokes class.
 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 fullypolarized and Su fullyunpolarized.
 get_all: Returns a dictionary with all the parameters of Stokes vectors.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[51]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees)
I0 = S.parameters.intensity()
print(I0)
1.0
When several Stokes vectors are stored in the object, setting verbose argument to True makes the method print the values in screen. Also, 1D or 2D figures can be shown if the draw argument is set to True:
[52]:
az = np.linspace(0, 180*degrees, 12)
S = Stokes("Source 1")
S.general_azimuth_ellipticity(azimuth=az)
az = S.parameters.azimuth(draw=True, verbose=True)
The azimuth of Source 1 is (deg):
[ 0. 16.36363636 32.72727273 49.09090909 65.45454545
81.81818182 98.18181818 114.54545455 130.90909091 147.27272727
163.63636364 0. ]
The mean value is 75.0 + 54.46016058467962
[53]:
az = np.linspace(0, 180*degrees, 128)
el = np.linspace(45*degrees, 45*degrees, 128)
AZ, EL = np.meshgrid(az, el)
S = Stokes("Source 1")
S.general_azimuth_ellipticity(azimuth=AZ, ellipticity=EL)
AZ, EL = S.parameters.azimuth_ellipticity(draw=True, use_nan=False)
The azimuth of Source 1 is (deg):
The mean value is 87.20947265625 + 53.089012724898296
The ellipticity angle of Source 1 is (deg):
The mean value is 1.7763568394002505e15 + 26.184535918359188
There is a method in Parameters_Stokes class, get_all that computes all the parameters available and stores in a dictionary .dict_params(). Using the print function upon the Parameters_Stokes class invokes the method get_all.
Example:
[54]:
S1 = Stokes("Source 1")
S1. general_charac_angles(alpha=25*degrees, delay=90*degrees, intensity=1, degree_pol=0.75)
print(S1,'\n')
print(S1.parameters)
Source 1 =
[+1.000]
[+0.482]
[+0.000]
[+0.575]
The intensity of Source 1 is (a.u.):
1.0
Low dimensionality, figure not available.
The elctric field amplitudes of Source 1 are (V/m):
Ex (V/m)
0.7848855672213959
Ey (V/m)
0.36599815077066683
Eu (V/m)
0.4999999999999999
Low dimensionality, figure not available.
The global phase of Source 1 is (deg):
0.0
Low dimensionality, figure not available.
The degree of depolarization of Source 1 is:
0.6614378277661475
Low dimensionality, figure not available.
The degree of polarization of Source 1 is:
0.7500000000000001
Low dimensionality, figure not available.
The degree of linear polarization of Source 1 is:
0.48209070726490455
Low dimensionality, figure not available.
The degree of circular polarization of Source 1 is:
0.5745333323392335
Low dimensionality, figure not available.
The alpha of Source 1 is (deg):
25.000000000000004
Low dimensionality, figure not available.
The delay of Source 1 is (deg):
90.0
Low dimensionality, figure not available.
The ellipticity parameter of Source 1 is:
0.4663076581549985
Low dimensionality, figure not available.
The ellipticity angle of Source 1 is (deg):
24.999999999999993
Low dimensionality, figure not available.
The azimuth of Source 1 is (deg):
2.090547128679534e15
Low dimensionality, figure not available.
The eccentricity of Source 1 is:
0.8846226132911147
Low dimensionality, figure not available.
Polarized Source 1 =
[+0.750]
[+0.482]
[+0.000]
[+0.575]
Unpolarized Source 1 =
[+0.250]
[+0.000]
[+0.000]
[+0.000]
The norm of Source 1 is (a.u.):
[1.25]
Low dimensionality, figure not available.
Checks of Stokes vectors¶
There are several checks that can be performed upon a Stokes vector. They are implemented in the independent class Checks_Stokes, which is stored in the checks field of Stokes class.
 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.
For a more detailed description of each method, refer to the individual documentation of each one.
Example:
[55]:
S = Stokes("Source 1")
S.linear_light(azimuth = 45*degrees)
cond = S.checks.is_linear()
print(cond)
1.0
1D and 2D plot draws are also implemented for this class:
[56]:
alpha = np.linspace(30*degrees, 30*degrees, 128)
delay = np.linspace(0, 360*degrees, 128)
Alpha, Delay = np.meshgrid(alpha, delay)
S = Stokes("Source 1")
S.general_charac_angles(alpha=Alpha, delay=Delay)
_ = S.checks.is_right_handed(verbose=True, draw=True, use_nan=False)
Source 1 is right handed:
[[False False False ... False False False]
[ True True True ... True True True]
[ True True True ... True True True]
...
[False False False ... False False False]
[False False False ... False False False]
[False False False ... False False False]]
The mean value is 0.4921875 + 0.4999389611180049
Analysis of Stokes vectors¶
There there is one analysis that can be performed upon a Stokes vector. It is implemented in the independent class Analysis_Stokes, which is stored in the analysis field of Stokes class.
 filter_physical_conditions: Forces the Stokes vectors to be physically realizable.
For a more detailed description, refer to its documentation.
Example:
[57]:
S1 = Stokes("Source 1")
M = np.random.rand(4,6) * 2  1
S1.from_matrix(M)
print(S1)
S2 = S1.analysis.filter_physical_conditions(keep=True)
S2.name = 'Corrected source'
print(S2)
Source 1 =
[0.961] [+0.085] [+0.277] [0.364] [0.455] [+0.013]
[0.606] [0.204] [0.078] [+0.289] [0.495] [0.236]
[+0.813] [0.151] [0.366] [0.718] [+0.722] [0.798]
[+0.278] [+0.061] [+0.105] [+0.229] [0.689] [+0.464]
Corrected source =
[0.961] [+0.085] [+0.277] [0.364] [0.455] [+0.013]
[0.606] [0.204] [0.078] [+0.289] [0.495] [0.236]
[+0.813] [0.151] [0.366] [0.718] [+0.722] [0.798]
[+0.278] [+0.061] [+0.105] [+0.229] [0.689] [+0.464]
[ ]:
Examples¶
Introductory¶
These tutorials cover the basics of polarization, as well as some bestpractices in using the package effectively.
Example 1: Malus law¶
In this example, we analyze, from a computational point of view the Malus law (https://en.wikipedia.org/wiki/Polarizer) for Jones and StokesMueller formalisms. We will also analyze the cases of perfect and imperfect polarizers.
A polarizer is an ideal optical device that allows light to be transmitted without loss when the electric field vector is parallel to the polarizer transmission axis, and blocks it when perpendicular to the transmission axis (i.e., parallel to the extinction axis). In the case of two ideal polarizers, and a circularly polariced incident light wave, the light intensity that passes through them depends on the angle between their transmission axes:
\(I(\theta) = \frac{I_{0}}{2} * cos(\theta_1  \theta_0)^2\).
Being \(I_0\) the intensity of the incident wave and \(\theta_i\) the azimuth of the ith polarizer.
The case of imperfect polarizers is slightly different. They block part of the light that passes through them when the electric field is parallel to their transmission axis. This is described by their electric field maximum transmission (\(p_1\)) or their intensity maximum transmission (\(T_{max} = p_1^2\)). Also, those polarizers don’t block all of the light that passes through them when the electric field is parallel to the extinction axis. This is described by their electric field minimum transmission (\(p_2\)) or their intensity minimum transmission (\(T_{min} = p_2^2\)). In that case, the equation of the Malus law gets a little more complicated:
\(I(\theta) = \frac{I_{0}}{2} * [T_{min} + (T_{max}  T_{min}) * cos(\theta_1  \theta_0)^2]\).
Jones formalism¶
Let us start by Jones formalism. Jones formalism is easier to visualize and understand.
Perfect polarizers¶
This is the easiest case. Start by importing all the required modules and classes.
[1]:
import numpy as np
from py_pol import degrees
from py_pol.jones_vector import Jones_vector
from py_pol.jones_matrix import Jones_matrix
It is usual to work with circular polarization for the incident wave as, in that case, the intensity that passes through the first polarizer is independent of the azimuth of the polarizer.
[2]:
# Incident wave
E0 = Jones_vector('Incident wave')
E0.circular_light(intensity=1)
print(E0)
Incident wave =
[+0.707+0.000j]
[+0.000+0.707j]
Now, let us define the first ideal polarizer, with the azimuth of the transmission axis at 50º, and a second polarizer with angles between 0º and 360º.
[6]:
# First polarizer
P0 = Jones_matrix('Polarizer 0')
P0.diattenuator_perfect(azimuth=50 * degrees)
print(P0)
# Second polarizer
P1 = Jones_matrix('Polarizer 1')
angles = np.linspace(0, 360*degrees, 361) # Steps of 1 degree
P1.diattenuator_perfect(azimuth=angles);
print(P1[0], P1[180], P1[1])
Polarizer 0 @ 50.00 deg =
[+0.413+0.000j +0.492+0.000j]
[+0.492+0.000j +0.587+0.000j]
Polarizer 1_picked =
[+1.000+0.000j +0.000+0.000j]
[+0.000+0.000j +0.000+0.000j]
Polarizer 1_picked =
[+1.000+0.000j 0.000+0.000j]
[0.000+0.000j +0.000+0.000j]
Polarizer 1_picked =
[+1.000+0.000j 0.000+0.000j]
[0.000+0.000j +0.000+0.000j]
The resulting electric field is calculated by multiplying the original field \(E_0\) by the two polarizers, first \(P_0\) and then \(P_1\). In polarization, the first optical element to be passed through must be at the right position:
[22]:
E_final = P1 * P0 * E0
E_final.name = 'Output wave'
Now, let us plot the intensity in terms of the angle. All the methods in the parameters class allow doing it setting the draw argument to True.
[23]:
I_perfect = E_final.parameters.intensity(draw=True)
The intensity of Output wave is (a.u.):
The mean value is 0.2498797450293165 + 0.1765464271966945
The maximum of intensity is achieved when the transmission angles of \(P_0\) and \(P_1\) are parallel: when the azimuth of \(P_1\) = 50º and 230º.
Imperfect polarizers¶
Imperfect polarizers can be considered a good model for most real polarizers. Again, start by importing the required modules and classes.
[10]:
import numpy as np
from py_pol import degrees
from py_pol.jones_vector import Jones_vector
from py_pol.jones_matrix import Jones_matrix
It is usual to work with circular polarization for the incident wave as, in that case, the intensity that passes through the first polarizer is independent of the azimuth of the polarizer.
[7]:
# Incident wave
E0 = Jones_vector('Incident wave')
E0.circular_light(intensity=1)
print(E0)
Incident wave =
[+0.707+0.000j]
[+0.000+0.707j]
The ideal polarizers described by their transmissions and azimuth are called linear polarizers (the states of maximum and minimum transmission are linear polarization states). Let us define the first linear polarizer, with the azimuth of the transmission axis at 50º, and a second polarizer with angles between 0º and 360º. We will use some transmission values far from the ideal behavior.
[9]:
# First polarizer
P0 = Jones_matrix('Polarizer 0')
P0.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=50 * degrees)
print(P0)
# Second polarizer
P1 = Jones_matrix('Polarizer 1')
angles = np.linspace(0, 360*degrees, 361) # Steps of 1 degree
P1.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=angles);
print(P1[0], P1[180], P1[1])
Polarizer 0 @ 50.00 deg =
[+0.632+0.000j +0.220+0.000j]
[+0.220+0.000j +0.710+0.000j]
Polarizer 1_picked =
[+0.894+0.000j +0.000+0.000j]
[+0.000+0.000j +0.447+0.000j]
Polarizer 1_picked =
[+0.894+0.000j 0.000+0.000j]
[0.000+0.000j +0.447+0.000j]
Polarizer 1_picked =
[+0.894+0.000j 0.000+0.000j]
[0.000+0.000j +0.447+0.000j]
The resulting electric field is calculated by multiplying the original field \(E_0\) by the two polarizers, first \(P_0\) and then \(P_1\). In polarization, the first optical element to be passed through must be at the right position:
[27]:
E_final = P1 * P0 * E0
E_final.name = 'Output wave'
Now, let us plot the intensity in terms of the angle. All the methods in the parameters class allow doing it setting the draw argument to True.
[28]:
I_imperfect = E_final.parameters.intensity(draw=True)
The intensity of Output wave is (a.u.):
The mean value is 0.2499567082105539 + 0.06355671379081002
The maximum of intensity is achieved when the transmission angles of \(P_0\) and \(P_1\) are parallel: when the azimuth of \(P_1\) = 50º and 230º. However, this case differs from the case of perfect polarizers as the maximum achieved intensity is smaller and the minimum intensity is higher.
MuellerStokes formalism¶
MuellerStokes formalism is more complicated than Jones formalism, but allows working with partial polarization states. This example uses completely polarized light, but it is a good example to start using Mueller and Stokes classes.
Perfect polarizers¶
This is the easiest case. Start by importing all the required modules and classes.
[2]:
import numpy as np
from py_pol import degrees
from py_pol.stokes import Stokes
from py_pol.mueller import Mueller
It is usual to work with circular polarization for the incident wave as, in that case, the intensity that passes through the first polarizer is independent of the azimuth of the polarizer.
[3]:
# Incident wave
S0 = Stokes('Incident wave')
S0.circular_light(intensity=1)
print(S0)
Incident wave =
[+1.000]
[+0.000]
[+0.000]
[+1.000]
Now, let us define the first ideal polarizer, with the azimuth of the transmission axis at 50º, and a second polarizer with angles between 0º and 360º.
[29]:
# First polarizer
P0 = Mueller('Polarizer 0')
P0.diattenuator_perfect(azimuth=50 * degrees)
# Second polarizer
P1 = Mueller('Polarizer 0')
angles = np.linspace(0, 360*degrees, 361) # Steps of 1 degree
P1.diattenuator_perfect(azimuth=angles);
The resulting Stokes vector is calculated by multiplying the original Stokes vector \(S_0\) by the two polarizers, first \(P_0\) and then \(P_1\). In polarization, the first optical element to be passed through must be at the right position:
[30]:
S_final = P1 * P0 * S0
S_final.name = 'Output wave'
d:\codigo_ucm\py_pol\py_pol\stokes.py:806: RuntimeWarning: divide by zero encountered in true_divide
np.abs(ratio[2])**2 * S3**2) / S0
Now, let us plot the intensity in terms of the angle. All the methods in the parameters class allow doing it setting the draw argument to True.
[31]:
I_perfect = S_final.parameters.intensity(draw=True)
The intensity of Output wave is (a.u.):
The mean value is 0.24987974502931648 + 0.17654642719669453
The maximum of intensity is achieved when the transmission angles of \(P_0\) and \(P_1\) are parallel: when the azimuth of \(P_1\) = 50º and 230º.
Imperfect polarizers¶
Imperfect polarizers can be considered a good model for most real polarizers. Again, start by importing the required modules and classes.
[24]:
import numpy as np
from py_pol import degrees
from py_pol.stokes import Stokes
from py_pol.mueller import Mueller
It is usual to work with circular polarization for the incident wave as, in that case, the intensity that passes through the first polarizer is independent of the azimuth of the polarizer.
[3]:
# Incident wave
S0 = Stokes('Incident wave')
S0.circular_light(intensity=1)
print(S0)
Incident wave =
[+1.000]
[+0.000]
[+0.000]
[+1.000]
The ideal polarizers described by their transmissions and azimuth are called linear polarizers (the states of maximum and minimum transmission are linear polarization states). Let us define the first linear polarizer, with the azimuth of the transmission axis at 50º, and a second polarizer with angles between 0º and 360º. We will use some transmission values far from the ideal behavior.
[32]:
# First polarizer
P0 = Mueller('Polarizer 0')
P0.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=50 * degrees)
# Second polarizer
P1 = Mueller('Polarizer 0')
angles = np.linspace(0, 360*degrees, 361) # Steps of 1 degree
P1.diattenuator_linear(Tmax=0.8, Tmin=0.2, azimuth=angles);
The resulting Stokes vector is calculated by multiplying the original Stokes vector \(S_0\) by the two polarizers, first \(P_0\) and then \(P_1\). In polarization, the first optical element to be passed through must be at the right position:
[33]:
S_final = P1 * P0 * S0
S_final.name = 'Output wave'
Now, let us plot the intensity in terms of the angle. All the methods in the parameters class allow doing it setting the draw argument to True.
[34]:
I_perfect = S_final.parameters.intensity(draw=True)
The intensity of Output wave is (a.u.):
The mean value is 0.24995670821055394 + 0.06355671379081004
The maximum of intensity is achieved when the transmission angles of \(P_0\) and \(P_1\) are parallel: when the azimuth of \(P_1\) = 50º and 230º. However, this case differs from the case of perfect polarizers as the maximum achieved intensity is smaller and the minimum intensity is higher.
Example 2: Classic Zeno effect¶
The classic Zeno effect analyzes the intensity transmitted by a certain number of perfect polarizers with equally spaced azimuths between 0º and 90º. Using only two polarizers, as their transmission axes are perpendicular to each other, the output intensity of the system will be zero. As the number of polarizers increases, the output intensity will also increase. In the limit of infinite polarizers, if the incident light is linearly polarized with the same azimuth than the first polarizer, the output wave will have the same intensity than the incident light.
This example will show the classic Zeno effect both in Jones and Mueller formalisms. We will also analyze the influence of using imperfect polarizers.
Jones formalism¶
Let us start by Jones formalism. Jones formalism is easier to visualize and understand.
Perfect polarizers¶
This is the easiest case. Start by importing all the required modules and classes.
[2]:
from py_pol import degrees
from py_pol.jones_vector import Jones_vector
from py_pol.jones_matrix import Jones_matrix
import matplotlib.pyplot as plt
import numpy as np
We will work using linear polarization with the same azimuth as the first polarizer (0º).
[3]:
# Incident wave
E0 = Jones_vector('Incident wave')
E0.linear_light(intensity=1, azimuth=0*degrees)
print(E0)
Incident wave =
[+1.000+0.000j]
[+0.000+0.000j]
Now, we will construct two arrays, one with the number of polarizers and other with the output intensity.
[77]:
Nmax = 30
Narray = np.arange(2,Nmax+1)
J = Jones_matrix('System')
I = np.zeros(Nmax1)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, N) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_perfect(azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
E_final = J * E0
# Store the intensity
I[ind] = E_final.parameters.intensity(out_number=False)
Finally, plot the result.
[78]:
# Plot the result
plt.figure()
plt.plot(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Perfect polarizers', fontsize=24);
It is possible to show how the transmitted intensity gets closer to 1 using logarithmic scale.
[79]:
Npoins = 100
Narray = np.logspace(1,5, Npoins)
J = Jones_matrix('System')
I = np.zeros(Npoins)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, int(N)) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_perfect(azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
E_final = J * E0
# Store the intensity
I[ind] = E_final.parameters.intensity(out_number=False)
[80]:
# Plot the result
plt.figure()
plt.semilogx(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Perfect polarizers', fontsize=24);
Imperfect polarizers¶
Imperfect polarizers will have a leak (\(T_{min}\) > 0) and, much more important for the Zeno effect, will not perfectly transmit the transmission state (\(T_{max}\) < 1). We will use some values of commercial polarizers with antireflecting coating:
 \(T_{max}\) = 0.99.
 \(T_{min}\) = 1e4.
[81]:
Nmax = 30
Narray = np.arange(2,Nmax+1)
J = Jones_matrix('System')
I = np.zeros(Nmax1)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, N) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_linear(Tmax=0.99, Tmin=1e4, azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
E_final = J * E0
# Store the intensity
I[ind] = E_final.parameters.intensity(out_number=False)
[82]:
# Plot the result
plt.figure()
plt.plot(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Imperfect polarizers', fontsize=24)
# Find the maximum
Imax = np.max(I)
Nmax = np.argmax(I) + 2
print('The maximum obtained intensity is {} for {} polarizers.'.format(Imax, Nmax))
The maximum obtained intensity is 0.7201695688246019 for 17 polarizers.
In this case, the increase in transmission expected by the increase of the number of polarizers does not compensate the extra loss produced by the imperfect polarizer transmission. This produces a maximum of the transmitted intensity (using 17 polarizers for this data).
MuellerStokes formalism¶
MuellerStokes formalism is more complicated than Jones formalism, but allows working with partial polarization states. This example uses completely polarized light, but it is a good example to start using Mueller and Stokes classes.
Perfect polarizers¶
This is the easiest case. Start by importing all the required modules and classes.
[83]:
import numpy as np
import matplotlib.pyplot as plt
from py_pol import degrees
from py_pol.stokes import Stokes
from py_pol.mueller import Mueller
We will work using linear polarization with the same azimuth as the first polarizer (0º).
[84]:
# Incident wave
S0 = Stokes('Incident wave')
S0.linear_light(intensity=1, azimuth=0*degrees)
print(S0)
Incident wave =
[+1.000]
[+1.000]
[+0.000]
[+0.000]
Now, we will construct two arrays, one with the number of polarizers and other with the output intensity.
[85]:
Nmax = 30
Narray = np.arange(2,Nmax+1)
J = Mueller('System')
I = np.zeros(Nmax1)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, N) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_perfect(azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
S_final = J * S0
# Store the intensity
I[ind] = S_final.parameters.intensity(out_number=False)
Finally, plot the result.
[86]:
# Plot the result
plt.figure()
plt.plot(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Perfect polarizers', fontsize=24);
It is possible to show how the transmitted intensity gets closer to 1 using logarithmic scale.
[87]:
Npoins = 100
Narray = np.logspace(1,5, Npoins)
J = Mueller('System')
I = np.zeros(Npoins)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, int(N)) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_perfect(azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
S_final = J * S0
# Store the intensity
I[ind] = S_final.parameters.intensity(out_number=False)
[88]:
# Plot the result
plt.figure()
plt.semilogx(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Perfect polarizers', fontsize=24);
Imperfect polarizers¶
Imperfect polarizers will have a leak (\(T_{min}\) > 0) and, much more important for the Zeno effect, will not perfectly transmit the transmission state (\(T_{max}\) < 1). We will use some values of commercial polarizers with antireflecting coating:
 \(T_{max}\) = 0.99.
 \(T_{min}\) = 1e4.
[89]:
Nmax = 30
Narray = np.arange(2,Nmax+1)
J = Mueller('System')
I = np.zeros(Nmax1)
# For loop to calculate the intensities
for ind, N in enumerate(Narray):
# Create the system of polarizers
angles = np.linspace(90*degrees, 0*degrees, N) # Start by 90º and end in 0º because the rightest element is the first to be crossed by the light wave
J.diattenuator_linear(Tmax=0.99, Tmin=1e4, azimuth=angles)
# Multiply them
J.prod()
# Multiply the system matrix by the incident light wave to obtain the output
S_final = J * S0
# Store the intensity
I[ind] = S_final.parameters.intensity(out_number=False)
[91]:
# Plot the result
plt.figure()
plt.plot(Narray, I, 'ko')
plt.xlabel('# polarizers', fontsize=22)
plt.ylabel('$I_{transmited}$', fontsize=22)
plt.title('Imperfect polarizers', fontsize=24)
# Find the maximum
Imax = np.max(I)
Nmax = np.argmax(I) + 2
print('The maximum obtained intensity is {} for {} polarizers.'.format(Imax, Nmax))
The maximum obtained intensity is 0.720169568824601 for 17 polarizers.
Advanced¶
Example 3: Analysis¶
In Optics, polarimetry is the discipline that studies the measurement and interpretation of the polarization of light waves, and the behavior of optical elements upon the polarization of light waves. In other words, it studies the measurement and analysis of Jones/Stokes vectors (light waves) and Jones/Mueller matrices (optical objects). This example is devoted to show the different analysis possibilities offered by py_pol.
[9]:
import numpy as np
from py_pol import degrees
from py_pol.jones_vector import Jones_vector
from py_pol.jones_matrix import Jones_matrix
from py_pol.stokes import Stokes, create_Stokes
from py_pol.mueller import Mueller
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
Analysis of light waves¶
Theory of Jones vectors¶
A transversal light wave can be described as:
\(\overrightarrow{E}=\left[\begin{array}{c} E_{x}\\ E_{y}\\ 0 \end{array}\right]e^{i\left(kz\omega t\right)}e^{i\varphi}=\overrightarrow{E}_{pol}e^{i\left(kz\omega t\right)}\)
Being \(\varphi\) the global phase, \(z\) the propagation direction of light, $k=:nbsphinxmath:left\Vert `:nbsphinxmath:overrightarrow{k}`:nbsphinxmath:right\Vert `$ the wavevector modulus, :math:omega` the angular frequency and \(\overrightarrow{E}_{pol}\) the polarization Jones vector composed of two complex components \(E_x\) and \(E_y\). Any complex 2x1 vector can describe a physically realizable light wave polarization state.
The Jones vector is completely described by four parameters. There are several sets of parameters that can be used. Some of the most used ones are the following:
 The real and imaginary parts of \(E_x\) and \(E_y\).
 Global phase (phase of \(E_x\), \(\varphi\)), electric field amplitudes (\(\leftE_{x}\right\) and \(\leftE_{y}\right\)) and the phase difference between components (\(\delta\)).
 Global phase, semimajor and semiminor ellipse axes (\(a\) and \(b\) respectively) and the semimajor axis azimuth (\(\phi\)).
 Global phase, wave intensity (\(I=\leftE_{x}\right^{2}+\leftE_{y}\right^{2}\)) and the characteristic angles \(\alpha\) (ratio angle: \(\tan\alpha=\frac{\leftE_{y}\right}{\leftE_{x}\right}\)) and \(\delta\).
 Global phase, wave intensity, azimuth (\(\phi\)) and ellipticity angle (\(\tan\chi=\frac{b}{a}\)).
Most of these parameters can be easily visualized in the ellipse produced by the real part of \(\overrightarrow{E}\):
It is worth noting that not all the values for the four angles should be used. Specifically:
 \(\;\alpha\;\in\;[0º, 90º]\)
 \(\;\delta\;\in\;[0º, 360º)\)
 \(\;\phi\;\in\;[0º, 180º)\)
 \(\;\chi\;\in\;[45º, 45º]\)
Also, there are some cases where two or more different values correspond to the same polarization state. For example, righthanded circular polarization corresponds to \(\chi=45º\) and any azimuth value.
Analyze a Jones vector means calculating one set of 4 parameters. We chose to use mainly the two last sets of parameters, as their physical meaning is easily understood and highly compatible with polarimetry experiments.
In some special cases, one one of the parameters used to describe the light wave may be undetermined. For example, circular polarization states does not have a determined azimuth.
Example of analysis of Jones vectors¶
All the parameters described above can be easily calculated from a Jones_vector object through the parameters subclass. This subclass also provides some other parameters that can be useful.
[2]:
# Create a random Jones vector
E = Jones_vector('Random polarization')
E_real = np.random.rand(2, 10)
E_imag = np.random.rand(2, 10)
E.from_matrix(M=E_real+1j*E_imag)
print(E)
Random polarization =
[+1.000+0.373j] [+0.745+0.982j] [+0.421+0.062j] [+0.328+0.216j] [+0.520+0.298j] [+0.350+0.941j] [+0.089+0.464j] [+0.845+0.579j] [+0.675+0.215j] [+0.468+0.175j]
[+0.797+0.388j] [+0.578+0.631j] [+0.915+0.942j] [+0.177+0.308j] [+0.686+0.451j] [+0.179+0.659j] [+0.181+0.677j] [+0.443+0.927j] [+0.024+0.792j] [+0.952+0.084j]
[3]:
# Calculate a set of parameters
gp = E.parameters.global_phase(verbose=True)
I = E.parameters.intensity(verbose=True)
azimuth = E.parameters.azimuth(verbose=True)
ellipticity = E.parameters.ellipticity_angle(verbose=True)
The global phase of Random polarization is (deg.):
[20.47881277 52.82310549 8.37669939 33.4224342 29.80730163 69.62319614
79.10493956 34.41232349 17.71335467 20.46600872]
The mean value is 36.62281760625346 + 22.124347087961016
The intensity of Random polarization is (a.u.):
[1.92452675 2.25289393 1.90468351 0.28056211 1.0330991 1.47356069
0.71500272 2.10269023 1.13019968 1.16393945]
The mean value is 1.3981158181111537 + 0.6117112533271021
The azimuth of Random polarization is (deg.):
[39.67195812 34.73076642 75.06633859 41.80155297 53.9204441