Package: py-pol
Python polarizationFree software: MIT licenseDocumentation:https://py-pol.readthedocs.ioFeaturesPy-pol is a Python library for Jones and Stokes-Mueller polarization optics. It has 4 main modules:jones_vector - Light polarization states in Jones formalism (2x1 vectors).jones_matrix - Optical elements polarization properties in Jones formalism (2x2 matrices).stokes - Light polarization states in Mueller-Stokes formalism (4x1 vectors).mueller - Optical elements polarization properties in Mueller-Stokes formalism (4x4 matrices).Each one has its own class, with multiple methods for generation, operation and parameters extraction.ExamplesJones formalismGenerating Jones vectors and Matricesfrompy_pol.jones_vectorimportJones_vectorfrompy_pol.jones_matriximportJones_matrixfrompy_pol.utilsimportdegreesj0=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*j0Extracting information form Jones Vector.print(j0,'\n')print(j0.parameters)j0=[+0.707;+0.707]parametersofj0:intensity:1.000arb.ualpha:45.000degdelay:0.000degazimuth:45.000degellipticityangle:0.000dega,b:1.0000.000phase:0.000degprint(j1,'\n')print(j1.parameters)m1*m0@45.00deg*j0=[+0.530+0.000j;+0.000+0.530j]'parametersofm1*m0@45.00deg*j0:intensity:0.562arb.ualpha:45.000degdelay:90.000degazimuth:8.618degellipticityangle:-45.000dega,b:0.5300.530phase:0.000degExtracting information form Jones Matrices.print(m0,'\n')print(m0.parameters)m0@45.00deg=[+0.500,+0.250][+0.250,+0.500]parametersofm0@45.00deg:is_homogeneous:Truedelay:0.000degdiattenuation:0.800print(m1,'\n')print(m1.parameters)m1=[+1+0j,+0+0j][+0+0j,+0+1j]parametersofm1:is_homogeneous:Truedelay:90.000degdiattenuation:0.000Stokes-Mueller formalismGenerating Stokes vectors and Mueller matrices.frompy_pol.stokesimportStokesfrompy_pol.muellerimportMuellerfrompy_pol.utilsimportdegreesj0=Stokes("j0")j0.linear_light(angle=45*degrees)m1=Mueller("m1")m1.diattenuator_linear(p1=1,p2=0,angle=0*degrees)j1=m1*j0Extracting 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.000arb.u.Determining all the parameters of a Stokes vector:print(j0,'\n')print(j0.parameters)j0=[+1;+0;+1;+0]parametersofj0:intensity:1.000arb.u.amplitudes:E0x0.707,E0y0.707,E0_unpol0.000degreepolarization:1.000degreelinearpol.:1.000degreecircularpol.:0.000alpha:45.000degdelay:0.000degazimuth:45.000degellipticityangle:0.000degellipticityparam:0.000eccentricity:1.000polarizedvector:[+1.000;+0.000;+1.000;+0.000]'unpolarizedvector:[+0.000;+0.000;+0.000;+0.000]'print(j1,'\n')print(j1.parameters)m1*j0=[+0.500;+0.500;+0.000;+0.000]parametersofm1*j0:intensity:0.500arb.u.amplitudes:E0x0.707,E0y0.000,E0_unpol0.000degreepolarization:1.000degreelinearpol.:1.000degreecircularpol.:0.000alpha:0.000degdelay:0.000degazimuth:0.000degellipticityangle:0.000degellipticityparam:0.000eccentricity:1.000polarizedvector:[+0.500;+0.500;+0.000;+0.000]'unpolarizedvector:[+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]Parametersofm2: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.Sphericpurity:0.872.Retardance:1.571.Polarimetricpurity:1.000.Depolarizationdegree:0.000.Depolarizationfactors:-Euclideandistance:1.732.-Depolarizationfactor:0.000.Polarimetricpurityindices:-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]Thelineardiattenuatorisphysical:True;hogeneous:True;andaretarder:False.DrawingsThe 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.AuthorsJesus del Hoyo <jhoyo@ucm.es>Luis Miguel Sanchez Brea <optbrea@ucm.es>Universidad Complutense de Madrid,
Faculty of Physical Sciences,
Department of Optics
Plaza de las ciencias 1,
ES-28040 Madrid (Spain)CitingHoyo, L. M. Sanchez-Brea, A. Soria-Garcia, “Open source library for polarimetric calculations “py_pol””, Proc. SPIE 11875, Computational Optics 2021, 1187506 (14 September 2021); doi: 10.1117/12.2597163,https://spie.org/Publications/Proceedings/Paper/10.1117/12.2597163?SSO=1.del Hoyo, L.M. Sanchez Brea, “py-pol, Python module for polarization optics”,https://pypi.org/project/py-pol/(2019)ReferencesGoldstein “Polarized light” 2nd edition, Marcel Dekker (1993).Gil, R. Ossikovsky “Polarized light and the Mueller Matrix approach”, CRC Press (2016).Brosseau “Fundamentals of Polarized Light” Wiley (1998).Martinez-Herrero, P. M. Mejias, G. Piquero “Characterization of partially polarized light fields” Springer series in Optical sciences (2009).Bennet “Handbook of Optics 1” Chapter 5 ‘Polarization’.Chipman “Handbook of Optics 2” Chapter 2 ‘Polarimetry’.Lu and RA Chipman, “Homogeneous and inhomogeneous Jones matrices”,  J. Opt. Soc. Am. A 11(2) 766 (1994).AcknowlegmentsThis software was initially developed for the project Retos-ColaboraciÃ³n 2016 “Ecograb” (RTC-2016-5277-5) and “Teluro-AEI” (RTC2019-007113-3) of Ministerio de EconomÃ­a y Competitivdad (Spain) and the European funds for regional development (EU), led by Luis Miguel Sanchez-Brea.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History1.1.3bugfix zeroslikebugfix not taking shape = False as flatten the object.1.1.2bugfix Jones_vector.parameters.global_phase1.1.1from_list can also be used with lists of Py_pol objects, lists and tuples. Also, all elemeents may have more than one elemnt.minor bugfixes1.1.0 (2022-3-31)Added base class Py_polObjects are now iterable3D drawings changed to PlotlyNew density and existence methods1.0.4 (2022-02-07)Bug fix related to variable limits1.0.4 (2021-07-19)Bug fixes1.0.3 (2021-01-22)Bug fixes1.0.2 (2020-07-04)Implemented workaround of axis_equal issue.1.0.0 (2020-06-04)py_pol multidimensional. Alpha stateThis is a big overhaul with many changes. All of them are based on the possibility of storing several vector/matrices in the same object. This reduces significantly the time required to perform the same operation to multiple vectors/matrices, using numpy methods instead of for loops. We have calculated that the reduction is around one order of magnitude.New methods have been introduced. First, methods available for Mueller / Stoes modules have been created also for Jones (when possible). Also, some bugs and errors in the calculations have been solved.Finally, some method and argument names have been changed to be consistent between different classes. Also, the default value of arguments with the same name have also been unified.The biggest TO DO we have are tests. Right now, we only have tests for the Jones_vector class. However, we thought that it would be useful to release this version so the community can use it.NOTE: Due to the change of argument and method names, this version is not compatible with the previous ones.0.2.2 (2019-09-04)Bug fixes.0.2.1 (2019-09-04)Bug fixes.Solve incidents.Start to homogenize structures for both Jones and Stokes.0.2.0 (2019-05-25)pre-alpha stateUpgrade to Python 3Stable version including tests0.1.5 (2019-02-25)Jones_vector, Jones_matrix, Stokes works.Jones_vector: simplify function to represent better Jones vectors.tests drawing: Made tests for drawingMueller is in progress.Functions = 9/10Documentation = 8/10Tutorial = 8/10.Examples = 8/10.Tests = 8/10Drawing = 10/10. Finished. Polarization ellipse for Jones and Stokes (partially random). Stokes on PoincarÃ© sphere.0.1.4 (2019-02-03)bug fixes0.1.3 (2019-01-22)Fixed axis_equal issue.Jones_vector, Jones_matrix, Stokes works.Mueller is in progress.Functions = 9/10Documentation = 8/10Tutorial = 7/10.Examples = 6/10.Drawing = 0/10.0.1.1 (2018-12-22)First release on PyPI in alpha state.0.0.0 (2018-11-22)First implementation of py_pol.