Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

diffractio

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diffractio - npm Package Compare versions

Comparing version
0.1.8
to
0.1.9
+3
entry_points.txt
[console_scripts]
diffractio = diffractio.cli:main
Metadata-Version: 2.1
Name: diffractio
Version: 0.1.9
Summary: Optical Diffraction and Interference (scalar and vectorial)
Home-page: https://bitbucket.org/optbrea/diffractio/src/master/
Author: Luis Miguel Sanchez Brea
Author-email: optbrea@ucm.es
License: MIT license
Keywords: diffractio,optics,diffraction,interference,Rayleigh-Sommerfeld,Beam Propagation Method,BPM,WPM,CZT,RS,VRS
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: Pillow
Requires-Dist: ipympl
Requires-Dist: ipywidgets
Requires-Dist: numexpr
Requires-Dist: opencv-python
Requires-Dist: pandas
Requires-Dist: psutil
Requires-Dist: py-pol
Requires-Dist: screeninfo
================================================
Python Diffraction-Interference module
================================================
.. image:: https://img.shields.io/pypi/dm/diffractio
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/pypi/v/diffractio.svg
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/travis/optbrea/diffractio.svg
:target: https://bitbucket.org/optbrea/diffractio/src/master/
.. image:: https://readthedocs.org/projects/diffractio/badge/?version=latest
:target: https://diffractio.readthedocs.io/en/latest/
:alt: Documentation Status
* Free software: MIT license
* Documentation: https://diffractio.readthedocs.io/en/latest/
.. image:: logo.png
:width: 75
:align: right
Features
----------------------
Diffractio is a Python library for Diffraction and Interference Optics.
It implements Scalar and vector Optics. The main algorithms used are:
* Fast Fourier Transform (FFT).
* Rayleigh Sommerfeld (RS).
* Chirp z-transform (CZT).
* Plane Wave Descomposition (PWD).
* Beam Propagation Method (BPM).
* Wave Propagation Method (WPM).
* Vectorial Rayleigh-Sommerfeld (VRS).
* Vector Fast Fourier Tranform (VFFT).
* Vector Chirp z-transform (VCZT).
When possible, multiprocessing is implemented for a faster computation.
The **scalar** propagation schemes are implemented in modules:
* X - fields are defined in the x axis.
* Z - fields are defined in the z axis (for visualiztion and analysis).
* XZ - fields are defined in the xz plane, being z the propagation direction.
* XY - fields are defined in the xy transversal plane.
* XYZ - fields are defined in the xyz volume.
Each scheme present three modules:
* sources: Generation of light.
* masks: Masks and Diffractive Optical elements.
* fields: Propagation techniques, parameters and general functions.
The **vector** propagation schemes are implemented in modules:
* vector_XY - Ex, Ey, and Ez electric field components are defined, which allows polarization analysis.
There are additional schemes used mainly for representation.
* vector_X - fields are defined in the z axis (for visualiztion and analysis).
* vector_Z - fields are defined in the z axis (for visualiztion and analysis).
* vector_XZ - fields are defined in the xz axis (for visualiztion and analysis).
* vector_XYZ - fields are defined in the xyz axis (for visualiztion and analysis).
For the vector analysis, we also use the py_pol module: https://pypi.org/project/py-pol/
Sources
========
One main part of this software is the generation of optical fields such as:
* Plane waves.
* Spherical waves.
* Gaussian beams.
* Bessel beams.
* Vortex beams.
* Laguerre beams.
* Hermite-Gauss beams.
* Zernike beams.
.. image:: readme1.png
:width: 400
Masks
=============
Another important part of Diffractio is the generation of masks and Diffractive Optical Elements such as:
* Slits, double slits, circle, square, ring ...
* Lenses, diffractive lenses, aspherical lenses...
* Axicon, prisms, biprism, image, rough surface, gray scale ...
* Gratings: Ronchi, phase, radial, angular, sine, forked, blazed, 2D, chess...
.. image:: readme2.png
:height: 400
In the XZ scheme there is also a number of masks:
* image, sphere, layer, lenses, wedge, prism, probe, gratings...
* Additionally, any X_mask can be extruded to the XZ scheme.
* Masks from functions
* Surfaces can be added to objects
.. image:: readme3.png
:height: 400
Fields
=========
Several propagation algorithms for propagation of light are implemented in the *fields* modules:
* **Fast Fourier Transform (FFT)** which allows, in a single step, to determine the field at the far field.
* **Rayleigh-Sommerfeld (RS)** [Appl. Opt., 45(6) 1102–1110, (2006)] RS allows, in a single step, to propagate to a near or far observation plane, which allows fast computations. The fields and the masks must be defined in a plane.
* **Beam propagation method (BPM)** [Appl. Opt. 24, 3390-3998 (1978)] which allows to analyze the propation of light in volumetric elements, such as spheres, cylinders and other complex forms, provided that the spatial variations in the refraction index are small. It allows graded index structures. It presents a complexity of O(n) in the two-dimensional and O(n2) in the three-dimensional case. It is computed according to the split-step propagation scheme.
* **Wave Propagation Method (WPM)**. [Appl. Opt. 32, 4984 (1993)] WPM was introduced in order to overcome the major limitations of the beam propagation method (BPM). With the WPM, the range of application can be extended from the simulation of waveguides to simulation of other optical elements like lenses, prisms and gratings. WPM can accurately simulate scalar light propagation in inhomogeneous media at high numerical apertures, and provides valid results for propagation angles up to 85° and that it is not limited to small index variations in the axis of propagation. Fast implementation with discrete number of refraction indexes is also implemented.
* **Chirped Z-Transform (CZT)**. [Light: Science and Applications, 9(1), (2020)] CZT allows, in a single step, to propagate to a near or far observation plane. It present advantages with respecto to RS algorithm, since the region of interest and the sampling numbers can be arbitrarily chosen, endowing the proposed method with superior flexibility. CZT algorithm allows to have a XY mask and compute in XY, Z, XZ, XYZ schemes, simply defining the output arrays.
* **Vector Rayleigh-Sommerfeld (VRS)**. The VRS method [Laser Phys. Lett. 10(6) 065004 (2013)] allows to propagate (Ex,Ey,Ez) fields offering the advantage of significant reduction in computation, from flat diffractive elements (Thin Element Approximation) with full control of polarization. It addresses simultaneously both longitudinal polarization. This approach offers the advantage of significant reduction in computation.
* **Vector Chirped Z-Transform (VCZT)**. [Light: Science and Applications, 9(1), (2020)]. CZT is also implemented in vector fields.
"""
The fields, masks and sources can be stored in files.
Also drawings can be easily obtained, for intensity, phase, fields, etc.
In some modules, videos can be generated for a better analysis of optical fields.
.. image:: readme6.png
:width: 600
.. image:: readme6.png
:width: 600
Vector beams
==================================
Here, we implement new classes where the E_x, E_y, and E_z fields are generated and propagated using Rayleigh-Sommerfeld and Chirped z-transform algorithms.
Also, simple and complex polarizing masks can be created.
**Intensity of vector field**
.. image:: readme4.png
:width: 700
**Polarization: Stokes parameters**
.. image:: readme5.png
:width: 700
Other features
=================
* Intensity, MTF and other parameters are obtained from the optical fields.
* Fields can be added simply with the + signe, and interference is produced. Masks can be multiplied, added and substracted in order to make complex structures
* Resampling fields in order to analyze only areas of interest.
* Save and load data for future analysis.
* Rayleigh-Sommerfeld implementation is performed in multiprocessing for fast computation.
* Polychromatic and extended source problems can also be analyzed using multiprocessing.
Authors
---------------------------
* 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)
.. image:: logoUCM.png
:width: 125
:align: right
Citing
---------------------------
L.M. Sanchez Brea, "Diffractio, python module for diffraction and interference optics", https://pypi.org/project/diffractio/ (2019)
References for algorithms
---------------------------
**RS**
* Shen, F. & Wang, A. "Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula. Appl. Opt. 45, 1102–1110 (2006).
**WPM**
* K.-H. Brenner, W. Singer, “Light propagation through micro lenses: a new simulation method”, Appl. Opt., 32(6) 4984-4988 (1993).
* Schmidt, S. et al. "Wave-optical modeling beyond the thin-element-approximation" Opt. Express 24, 30188 (2016).
* Brenner, K.H. "A high-speed version of the wave propagation method applied to micro-optics." 16th Workshop on Information Optics (WIO). IEEE (2017)
* Schmidt, S., et al. "Rotationally symmetric formulation of the wave propagation method-application to the straylight analysis of diffractive lenses" Opt. Lett. 42, 1612 (2017).
**VRS**
* Ye, H. et al. "Creation of a longitudinally polarized subwavelength hotspot with an ultra-thin planar lens: Vectorial Rayleigh-Sommerfeld method" Laser Phys. Lett. 10, (2013).
**CZT**
* Bluestein, L., "A linear filtering approach to the computation of the discrete Fourier transform," Northeast Electronics Research and Engineering Meeting Record 10, 218-219 (1968).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VCZT**
* Leutenegger M. et al. "Fast focus field calculations" Optics Express 14(23) 11277 (2006).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VWPM** (not implemented yet)
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". J. Opt. Soc. Am. A 27, 709 (2010).
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". PhD thesis (Mannheim, 2010).
Other References
---------------------------
* J.W. Goodman, "Introduction to Fourier Optics" McGraw-Hill, 1996.
* B.E. Saleh y M. C. Teich, "Fundamentals of photonics" John Wiley & Sons, 2019.
* Z.Qiwen, "Vectorial optical fields: Fundamentals and applications" World scientific, 2013.
* "Numerical Methods in Photonics Lecture Notes". http://ecee.colorado.edu/~mcleod/teaching/nmip/lecturenotes.html.
Credits
---------------------------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
____
pytest --cov=diffractio tests/
diffractio/__init__.py,sha256=e8cuWDDikZMwVWgG3HbXHq0TxtHOOlQxdymZFsuXLr8,1833
diffractio/config.py,sha256=QNdmPS8XDnI35cls5bEBqsEkQN21E5XqxtBs6CdmMxc,631
diffractio/scalar_fields_X.py,sha256=OrrndOf2nomy-8_-9bSsXOOY_etWGFFcFiskGbyNI9k,59849
diffractio/scalar_fields_XY.py,sha256=kX5zY7EFsz9tBSrCaA3Xfxjt_xjlhBzO7_FVunM2CEQ,104000
diffractio/scalar_fields_XYZ.py,sha256=nkJH53MmPSxXtEr1LYLsxE54N1YRCFX6R6JpNqoknLU,57962
diffractio/scalar_fields_XZ.py,sha256=2muS4tYrW2bMWnqEnbddx4g-tA3cxOoiKd9Ya4JGFaE,75279
diffractio/scalar_fields_Z.py,sha256=fcEYLCDfYoye6KZwpeOq45BXdGdwCqqOMnbV4BMJfBA,14406
diffractio/scalar_masks_X.py,sha256=E2hxBj1Kz0ZjMkgl_v9qrTW5l2IloD7UcewaSLd-Atg,34162
diffractio/scalar_masks_XY.py,sha256=cynaWfWMs9YNCJn7Bj84E9Ka9JFjxdzXI_84u0cAEGo,80838
diffractio/scalar_masks_XYZ.py,sha256=_bxIn4Zf5EW_iU3fRjYmTTEhcHtPHwLEn2ihPZlvb3Y,6462
diffractio/scalar_masks_XZ.py,sha256=8sbmthypEBj9dddMiObTc1XunTDGm0898GiSK3x17gE,58114
diffractio/scalar_sources_X.py,sha256=B0ztxZJwMEbNoiu8Ee19nfJpnRC0e6DBKS73jv3ndMQ,7293
diffractio/scalar_sources_XY.py,sha256=0BBDMly30DNNL7pZTCnDNPhppZ110V6QNSMRxUkwV38,17918
diffractio/utils_common.py,sha256=zlUVJq72bpY-HF3DesqdDdhoi8OKRjtqWLB3vXuhN9s,5963
diffractio/utils_drawing.py,sha256=HY8VPcDDUiqe2IZ_18jDRSP8MQyhIvyugWlLyayGWHk,12990
diffractio/utils_math.py,sha256=7Rl7QKBAeRnI4J4-DjtLJKG34V8lZLUBCBiBbnGHbyA,31567
diffractio/utils_multiprocessing.py,sha256=mIkFDOTSGiG12v5YwfIv1lkCuzyAH_pVz2AU9FuPmDU,4951
diffractio/utils_optics.py,sha256=bGME1E46JYCX0RcR-Uc1Gq7XXipMwB1B-SLwqOLQ0DM,32050
diffractio/utils_slicer.py,sha256=QLheSWa-8DUYcEZYyzOZpXlOvrjSw8KLJcx52kkyuhk,8358
diffractio/utils_tests.py,sha256=KOaazXYjYcgM67l2YnPt3FMxVITa9gC0EqsObDDQPQ8,4792
diffractio/vector_fields_X.py,sha256=UuOYAQIs_d8_XgqdgIh1D5NgexaIdBIwXE2XegaCiDc,24753
diffractio/vector_fields_XY.py,sha256=pS8eL3g6Y4G0T4c3K2jyUgGYW7uE0-RWK8OsaMc0KgA,66081
diffractio/vector_fields_XYZ.py,sha256=cZY3Kpk6Y4KRVhr0ebgZl8wRnFTh3-JnDjNbPb9vR00,26437
diffractio/vector_fields_XZ.py,sha256=M_yENh6kioY4SGBOXQ0X2QkYbYhqrxT2iXc6GMWpnIs,35416
diffractio/vector_fields_Z.py,sha256=xfakeRt2TTA30Fh5V3WaI5yjZSbacUhKbAUy-sEtUq8,24875
diffractio/vector_masks_XY.py,sha256=UVQEl6stc1NsBbdFhCWYSQ7mhdLgCSiOkXaxDV0wIZU,23196
diffractio/vector_sources_XY.py,sha256=HvhWahqnTZ3TDYsXp4XTMQSkU7qXroeCzN0N2hatZ7g,13270
diffractio-0.1.9.dist-info/AUTHORS.rst,sha256=dp34i4VkwX0a3Jcy7u-_YL0opILTLPAs9W5dXd1lZoM,393
diffractio-0.1.9.dist-info/LICENSE,sha256=tmQjWmJpxJSS7wT0j7PRC2xXK4BDMUuSvr2NZnw6zwo,1082
diffractio-0.1.9.dist-info/METADATA,sha256=aW58l3iDVwL-BNK9IRKmjxz5W3JvZtgQ97iNHQ1-IRA,11725
diffractio-0.1.9.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
diffractio-0.1.9.dist-info/entry_points.txt,sha256=h2W6do0ZNOe2OoYPnsNO5AF3b1wBVDjovtwYWud-I5g,52
diffractio-0.1.9.dist-info/top_level.txt,sha256=KHPPxOOdQQcwze_smTJK2F8mXs2SrqsxXnYBZ_enoFc,11
diffractio-0.1.9.dist-info/RECORD,,
diffractio
Wheel-Version: 1.0
Generator: bdist_wheel (0.37.1)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any
+3
-3

@@ -45,3 +45,3 @@ # !/usr/bin/env python3

__email__ = 'optbrea@ucm.es'
__version__ = '0.1.8'
__version__ = '0.1.9'

@@ -69,4 +69,4 @@ name = 'diffractio'

from matplotlib import rcParams
from matplotlib import rcParams
rcParams['figure.dpi']=75
rcParams['figure.dpi'] = 75

@@ -346,2 +346,51 @@ # !/usr/bin/env python3

def inverse_amplitude(self, new_field=False):
"""Inverts the amplitude of the mask, phase is equal as initial
Parameters:
new_field (bool): If True it returns a Scalar_mask_X object, else, it modifies the existing object.
Returns:
Scalar_mask_X: If new_field is True, it returns a Scalar_mask_X object.
"""
from .scalar_masks_X import Scalar_mask_X
amplitude = np.abs(self.u)
phase = np.angle(self.u)
new_amplitude = (1 - amplitude) * np.exp(1.j * phase)
if new_field is False:
self.u = new_amplitude
else:
new = Scalar_mask_X(self.x, self.wavelength)
new.u = new_amplitude
return new
def inverse_phase(self, new_field=False):
"""Inverts the phase of the mask, amplitude is equal as initial
Parameters:
new_field (bool): If True it returns a Scalar_mask_X object, else, it modifies the existing object.
Returns:
Scalar_mask_X: If new_field is True, it returns a Scalar_mask_X object.
"""
from .scalar_masks_X import Scalar_mask_X
amplitude = np.abs(self.u)
phase = np.angle(self.u)
new_amplitude = amplitude * np.exp(-1.j * phase)
if new_field is False:
self.u = new_amplitude
else:
new = Scalar_mask_X(self.x, self.wavelength)
new.u = new_amplitude
return new
def filter(self, size=0):

@@ -398,2 +447,20 @@ """

def pupil(self, x0, radius):
"""Place a pupil in the field.
Parameters:
x0 (float): center of pupil.
radius (float): radius of pupil.
"""
xmin = x0 - radius
xmax = x0 + radius
pupil = np.zeros_like(self.x)
ix = (self.x < xmax) & (self.x > xmin)
pupil[ix] = 1
self.u = self.u * pupil
def insert_array_masks(self, t1, x_pos, clean=True, kind_position='left'):

@@ -763,3 +830,3 @@ """Insert several identical masks t1 in self.u according to positions x_pos

# matrix=False,
# xout=None,
# xout=None,None
# yout=None

@@ -828,3 +895,3 @@ # fast=False,

def CZT(self, z, xout=None, verbose=False):
def CZT(self, z, xout, verbose=False):
"""Chirped z-transform.

@@ -831,0 +898,0 @@

@@ -56,3 +56,3 @@ # !/usr/bin/env python3

"""equal than Scalar_field_X"""
super().__init__(x, wavelength, info)
super().__init__(x, wavelength, n_background, info)
self.type = 'Scalar_mask_X'

@@ -184,3 +184,3 @@

def slit(self, x0=0, size=100 * um):
def slit(self, x0, size):
"""Slit: 1 inside, 0 outside

@@ -192,8 +192,5 @@

"""
# Definicion de la slit
xmin = x0 - size / 2
xmax = x0 + size / 2
# Definicion de la transmitancia
u = np.zeros_like(self.x)

@@ -1007,2 +1004,3 @@ ix = (self.x < xmax) & (self.x > xmin)

t.u = t.u + i0j * t2.u
self.u[-1] = self.u[-2]

@@ -1009,0 +1007,0 @@ self.u = t.u

@@ -76,4 +76,3 @@ #!/usr/bin/env python3

info: text to describe the instance of the class"""
super().__init__(x, z, wavelength, n_background,
info)
super().__init__(x, z, wavelength, n_background, info)
self.type = 'Scalar_mask_XZ'

@@ -80,0 +79,0 @@

@@ -59,3 +59,3 @@ # !/usr/bin/env python3

def plane_wave(self, A=1, theta=0 * degrees, z0=0 * um):
"""Plane wave. self.u = A * exp(1.j * k * (self.x * sin(theta) + z0 * cos(theta)))
"""Plane wave.

@@ -99,8 +99,3 @@ Parameters:

def spherical_wave(self,
A=1,
x0=0 * um,
z0=-1000 * um,
radius=100 * um,
normalize=False):
def spherical_wave(self, A, x0, z0, radius, normalize=False):
"""Spherical wave. self.u = amplitude * A * exp(-1.j * sign(z0) * k * Rz) / Rz

@@ -107,0 +102,0 @@

@@ -74,3 +74,3 @@ # !/usr/bin/env python3

self.Y * sin(theta) * sin(phi) + z0 * cos(theta)))
According to https://en.wikipedia.org/wiki/Spherical_coordinate_system: physics (ISO 80000-2:2019 convention)

@@ -163,14 +163,25 @@

r0 (float, float): (x,y) position of source
z0 (float): z position of source
mask (bool): If true, masks the spherical wave with radius
radius (float): size of slit for mask
z0 (float) or (float, float): z0 or (zx0, zy0) position of source. When two parameters, the source is stigmatic
radius (float): radius for mask
normalize (bool): If True, maximum of field is 1
"""
k = 2 * pi / self.wavelength
k = 2 * np.pi / self.wavelength
x0, y0 = r0
if isinstance(z0, (int, float)):
z0 = (z0, z0)
z0x, z0y = z0
R2 = (self.X - x0)**2 + (self.Y - y0)**2
Rz = sqrt((self.X - x0)**2 + (self.Y - y0)**2 + z0**2)
# Rz = sqrt((self.X - x0)**2 + (self.Y - y0)**2 + z0**2)
if z0x == 0:
R_x = 1e10
else:
R_x = np.sqrt((self.X - x0)**2 + z0x**2)
if z0y == 0:
R_y = 1e10
else:
R_y = np.sqrt((self.Y - y0)**2 + z0y**2)
if radius > 0:

@@ -181,3 +192,3 @@ amplitude = (R2 <= radius**2)

self.u = amplitude * A * exp(-1.j * sign(z0) * k * Rz) / Rz
self.u = amplitude * A * np.exp(-1.j * np.sign(z0x) * k * R_x)*np.exp(-1.j * np.sign(z0y) * k * R_y) / np.sqrt(R_x*R_y)

@@ -184,0 +195,0 @@ if normalize is True:

@@ -211,3 +211,3 @@ #!/usr/bin/env python3

i_pos_integer = np.where(Trues == True)[0]
i_pos_integer = i_pos_integer[1:-1]
i_pos_integer = i_pos_integer[0:-1]
x_minima = x[i_pos_integer]

@@ -214,0 +214,0 @@ y_minima = y[i_pos_integer]

@@ -206,14 +206,27 @@ # !/usr/bin/env python3

def apply_scalar_mask(self, u_mask):
"""The same mask u_mask is applied to all the Jones Matrix.
def apply_scalar_mask(self, mask, state, is_intensity=True):
"""The same mask (binary) is applied to all the Jones Matrix.
Parameters:
u_mask (scalar_mask_XY): mask to apply.
mask (scalar_mask_XY): mask to apply.
state (Jones Matrix): Polarization state to apply
is intensity (bool): If True, abs(mask)**2 is applied.
"""
self.M00 = self.M00 * u_mask.u
self.M01 = self.M01 * u_mask.u
self.M10 = self.M10 * u_mask.u
self.M11 = self.M11 * u_mask.u
if is_intensity:
t = np.abs(mask.u)**2
else:
t = mask.u
self.M00 = state[0, 0] * t
self.M01 = state[0, 1] * t
self.M10 = state[1, 0] * t
self.M11 = state[1, 1] * t
# Change elements = -0 to 0, to represent correctly phases.
self.M01.real = np.where(np.real(self.M01) == -0, 0, np.real(self.M01))
self.M10.real = np.where(np.real(self.M10) == -0, 0, np.real(self.M10))
self.M00.real = np.where(np.real(self.M00) == -0, 0, np.real(self.M00))
self.M11.real = np.where(np.real(self.M11) == -0, 0, np.real(self.M11))
def complementary_masks(self,

@@ -243,4 +256,4 @@ mask,

self.M00 = t * state_1[0, 0] + (1 - t) * state_0[0, 0]
self.M01 = t * state_1[0, 1] + (1 - t) * state_0[1, 0]
self.M10 = t * state_1[1, 0] + (1 - t) * state_0[0, 1]
self.M01 = t * state_1[0, 1] + (1 - t) * state_0[0, 1]
self.M10 = t * state_1[1, 0] + (1 - t) * state_0[1, 0]
self.M11 = t * state_1[1, 1] + (1 - t) * state_0[1, 1]

@@ -272,6 +285,5 @@

mask_new.u = np.real(mask_new.u)
mask_new.u = mask_new.u.astype(np.int)
mask_new.u = mask_new.u.astype(int)
for i, state in enumerate(states):
# print(state)
i_level = (mask_new.u == i)

@@ -282,3 +294,2 @@ self.M00[i_level] = state.M[0, 0, 0]

self.M10[i_level] = state.M[1, 0, 0]
# print(self.M00[i_level][0], self.M01[i_level][0], self.M10[i_level][0], self.M11[i_level][0])

@@ -371,3 +382,3 @@ def from_py_pol(self, polarizer):

Parameters:
kind (str): 'amplitude', 'phase', 'all'
kind (str): 'amplitude', 'phase', 'field', 'jones', 'all'
"""

@@ -394,3 +405,3 @@ from matplotlib import rcParams

if kind in ('amplitude', 'all'):
if kind in ('amplitude', 'field', 'all'):
plt.set_cmap(CONF_DRAWING['color_intensity'])

@@ -424,4 +435,4 @@ fig, axs = plt.subplots(2,

plt.suptitle("amplitudes", fontsize=20)
cax = plt.axes([.89, 0.2, 0.03, 0.6])
plt.suptitle("amplitudes", fontsize=15)
cax = plt.axes([0.89, 0.2, 0.03, 0.6])
cbar = plt.colorbar(im1, cax=cax, shrink=0.66)

@@ -437,3 +448,3 @@ cbar.set_ticks([0, 0.25, 0.5, 0.75, 1.0])

if kind in ('phases', 'all'):
if kind in ('phases', 'field', 'all'):
plt.set_cmap(CONF_DRAWING['color_phase'])

@@ -474,3 +485,3 @@ fig, axs = plt.subplots(2,

plt.suptitle("phases", fontsize=20)
plt.suptitle("phases", fontsize=15)
cax = plt.axes([.89, 0.2, 0.03, 0.6])

@@ -487,2 +498,89 @@ cbar = plt.colorbar(im1, cax=cax, shrink=0.66)

if kind in ('jones', 'all'):
plt.set_cmap(CONF_DRAWING['color_stokes'])
fig, axs = plt.subplots(2,
2,
sharex='col',
sharey='row',
gridspec_kw={
'hspace': 0.25,
'wspace': 0.025
})
fig.set_figwidth(xsize)
fig.set_figheight(1.25 * ysize)
im1 = axs[0, 0].imshow(np.real(self.M00),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[0, 0].set_title("J00")
im1 = axs[0, 1].imshow(np.real(self.M01),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[0, 1].set_title("J01")
im1 = axs[1, 0].imshow(np.real(self.M10),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[1, 0].set_title("J10")
im1 = axs[1, 1].imshow(np.real(self.M11),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[1, 1].set_title("J11")
#intensity_max = np.real(self.M00.max())
plt.tight_layout()
plt.suptitle("$\Re$ (Jones)", fontsize=15)
cax = plt.axes([0.89, 0.2, 0.03, 0.6])
cbar = plt.colorbar(im1, cax=cax, shrink=0.66)
fig, axs = plt.subplots(2,
2,
sharex='col',
sharey='row',
gridspec_kw={
'hspace': 0.25,
'wspace': 0.025
})
fig.set_figwidth(xsize)
fig.set_figheight(1.25 * ysize)
im1 = axs[0, 0].imshow(np.imag(self.M00),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[0, 0].set_title("J00")
im1 = axs[0, 1].imshow(np.imag(self.M01),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[0, 1].set_title("J01")
im1 = axs[1, 0].imshow(np.imag(self.M10),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[1, 0].set_title("J10")
im1 = axs[1, 1].imshow(np.imag(self.M11),
extent=extension,
origin='lower')
im1.set_clim(-1, 1)
axs[1, 1].set_title("J11")
#intensity_max = np.real(self.M00.max())
plt.tight_layout()
plt.suptitle("$\Im$ (Jones)", fontsize=15)
cax = plt.axes([0.89, 0.2, 0.03, 0.6])
cbar = plt.colorbar(im1, cax=cax, shrink=0.66)
# if kind in ('phase', 'all'):

@@ -489,0 +587,0 @@ # plt.set_cmap(CONF_DRAWING['color_phase'])

.. highlight:: shell
============
Contributing
============
Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions
----------------------------
Report Bugs
~~~~~~~~~~~
Report bugs at https://bitbucket.com/optbrea/diffractio/issues.
If you are reporting a bug, please include:
* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.
Fix Bugs
~~~~~~~~
Look through the Bitbucket issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Implement Features
~~~~~~~~~~~~~~~~~~
Look through the Bitbucket issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.
Write Documentation
~~~~~~~~~~~~~~~~~~~
Python diffraction and interference could always use more documentation, whether as part of the
official Python diffraction and interference docs, in docstrings, or even on the web in blog posts,
articles, and such.
Submit Feedback
~~~~~~~~~~~~~~~
The best way to send feedback is to file an issue at https://bitbucket.com/optbrea/diffractio/issues.
If you are proposing a feature:
* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)
Get Started!
------------
Ready to contribute? Here's how to set up `diffractio` for local development.
1. Fork the `diffractio` repo on Bitbucket.
2. Clone your fork locally::
$ git clone git@bitbucket.org:optbrea/diffractio.git
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
$ mkvirtualenv diffractio
$ cd diffractio/
$ python setup.py develop
4. Create a branch for local development::
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::
$ flake8 diffractio tests
$ python setup.py test or py.test
$ tox
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub::
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the Bitbucket website.
Pull Request Guidelines
-----------------------------
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check
https://travis-ci.org/optbrea/diffractio/pull_requests
and make sure that the tests pass for all supported Python versions.
Tips
----
To run a subset of tests::
$ py.test tests.test_diffractio
Deploying
---------
A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
[console_scripts]
diffractio = diffractio.cli:main

Sorry, the diff of this file is not supported yet

Metadata-Version: 2.1
Name: diffractio
Version: 0.1.8
Summary: Optical Diffraction and Interference (scalar and vectorial)
Home-page: https://bitbucket.org/optbrea/diffractio/src/master/
Author: Luis Miguel Sanchez Brea
Author-email: optbrea@ucm.es
License: MIT license
Keywords: diffractio,optics,diffraction,interference,Rayleigh-Sommerfeld,Beam Propagation Method,BPM,WPM,CZT,RS,VRS
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
License-File: LICENSE
License-File: AUTHORS.rst
================================================
Python Diffraction-Interference module
================================================
.. image:: https://img.shields.io/pypi/dm/diffractio
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/pypi/v/diffractio.svg
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/travis/optbrea/diffractio.svg
:target: https://bitbucket.org/optbrea/diffractio/src/master/
.. image:: https://readthedocs.org/projects/diffractio/badge/?version=latest
:target: https://diffractio.readthedocs.io/en/latest/
:alt: Documentation Status
* Free software: MIT license
* Documentation: https://diffractio.readthedocs.io/en/latest/
.. image:: logo.png
:width: 75
:align: right
Features
----------------------
Diffractio is a Python library for Diffraction and Interference Optics.
It implements Scalar and vector Optics. The main algorithms used are:
* Fast Fourier Transform (FFT).
* Rayleigh Sommerfeld (RS).
* Chirp z-transform (CZT).
* Plane Wave Descomposition (PWD).
* Beam Propagation Method (BPM).
* Wave Propagation Method (WPM).
* Vectorial Rayleigh-Sommerfeld (VRS).
* Vector Fast Fourier Tranform (VFFT).
* Vector Chirp z-transform (VCZT).
When possible, multiprocessing is implemented for a faster computation.
The **scalar** propagation schemes are implemented in modules:
* X - fields are defined in the x axis.
* Z - fields are defined in the z axis (for visualiztion and analysis).
* XZ - fields are defined in the xz plane, being z the propagation direction.
* XY - fields are defined in the xy transversal plane.
* XYZ - fields are defined in the xyz volume.
Each scheme present three modules:
* sources: Generation of light.
* masks: Masks and Diffractive Optical elements.
* fields: Propagation techniques, parameters and general functions.
The **vector** propagation schemes are implemented in modules:
* vector_XY - Ex, Ey, and Ez electric field components are defined, which allows polarization analysis.
There are additional schemes used mainly for representation.
* vector_X - fields are defined in the z axis (for visualiztion and analysis).
* vector_Z - fields are defined in the z axis (for visualiztion and analysis).
* vector_XZ - fields are defined in the xz axis (for visualiztion and analysis).
* vector_XYZ - fields are defined in the xyz axis (for visualiztion and analysis).
For the vector analysis, we also use the py_pol module: https://pypi.org/project/py-pol/
Sources
========
One main part of this software is the generation of optical fields such as:
* Plane waves.
* Spherical waves.
* Gaussian beams.
* Bessel beams.
* Vortex beams.
* Laguerre beams.
* Hermite-Gauss beams.
* Zernike beams.
.. image:: readme1.png
:width: 400
Masks
=============
Another important part of Diffractio is the generation of masks and Diffractive Optical Elements such as:
* Slits, double slits, circle, square, ring ...
* Lenses, diffractive lenses, aspherical lenses...
* Axicon, prisms, biprism, image, rough surface, gray scale ...
* Gratings: Ronchi, phase, radial, angular, sine, forked, blazed, 2D, chess...
.. image:: readme2.png
:height: 400
In the XZ scheme there is also a number of masks:
* image, sphere, layer, lenses, wedge, prism, probe, gratings...
* Additionally, any X_mask can be extruded to the XZ scheme.
* Masks from functions
* Surfaces can be added to objects
.. image:: readme3.png
:height: 400
Fields
=========
Several propagation algorithms for propagation of light are implemented in the *fields* modules:
* **Fast Fourier Transform (FFT)** which allows, in a single step, to determine the field at the far field.
* **Rayleigh-Sommerfeld (RS)** [Appl. Opt., 45(6) 1102–1110, (2006)] RS allows, in a single step, to propagate to a near or far observation plane, which allows fast computations. The fields and the masks must be defined in a plane.
* **Beam propagation method (BPM)** [Appl. Opt. 24, 3390-3998 (1978)] which allows to analyze the propation of light in volumetric elements, such as spheres, cylinders and other complex forms, provided that the spatial variations in the refraction index are small. It allows graded index structures. It presents a complexity of O(n) in the two-dimensional and O(n2) in the three-dimensional case. It is computed according to the split-step propagation scheme.
* **Wave Propagation Method (WPM)**. [Appl. Opt. 32, 4984 (1993)] WPM was introduced in order to overcome the major limitations of the beam propagation method (BPM). With the WPM, the range of application can be extended from the simulation of waveguides to simulation of other optical elements like lenses, prisms and gratings. WPM can accurately simulate scalar light propagation in inhomogeneous media at high numerical apertures, and provides valid results for propagation angles up to 85° and that it is not limited to small index variations in the axis of propagation. Fast implementation with discrete number of refraction indexes is also implemented.
* **Chirped Z-Transform (CZT)**. [Light: Science and Applications, 9(1), (2020)] CZT allows, in a single step, to propagate to a near or far observation plane. It present advantages with respecto to RS algorithm, since the region of interest and the sampling numbers can be arbitrarily chosen, endowing the proposed method with superior flexibility. CZT algorithm allows to have a XY mask and compute in XY, Z, XZ, XYZ schemes, simply defining the output arrays.
* **Vector Rayleigh-Sommerfeld (VRS)**. The VRS method [Laser Phys. Lett. 10(6) 065004 (2013)] allows to propagate (Ex,Ey,Ez) fields offering the advantage of significant reduction in computation, from flat diffractive elements (Thin Element Approximation) with full control of polarization. It addresses simultaneously both longitudinal polarization. This approach offers the advantage of significant reduction in computation.
* **Vector Chirped Z-Transform (VCZT)**. [Light: Science and Applications, 9(1), (2020)]. CZT is also implemented in vector fields.
"""
The fields, masks and sources can be stored in files.
Also drawings can be easily obtained, for intensity, phase, fields, etc.
In some modules, videos can be generated for a better analysis of optical fields.
.. image:: readme6.png
:width: 600
.. image:: readme6.png
:width: 600
Vector beams
==================================
Here, we implement new classes where the E_x, E_y, and E_z fields are generated and propagated using Rayleigh-Sommerfeld and Chirped z-transform algorithms.
Also, simple and complex polarizing masks can be created.
**Intensity of vector field**
.. image:: readme4.png
:width: 700
**Polarization: Stokes parameters**
.. image:: readme5.png
:width: 700
Other features
=================
* Intensity, MTF and other parameters are obtained from the optical fields.
* Fields can be added simply with the + signe, and interference is produced. Masks can be multiplied, added and substracted in order to make complex structures
* Resampling fields in order to analyze only areas of interest.
* Save and load data for future analysis.
* Rayleigh-Sommerfeld implementation is performed in multiprocessing for fast computation.
* Polychromatic and extended source problems can also be analyzed using multiprocessing.
Authors
---------------------------
* 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)
.. image:: logoUCM.png
:width: 125
:align: right
Citing
---------------------------
L.M. Sanchez Brea, "Diffractio, python module for diffraction and interference optics", https://pypi.org/project/diffractio/ (2019)
References for algorithms
---------------------------
**RS**
* Shen, F. & Wang, A. "Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula. Appl. Opt. 45, 1102–1110 (2006).
**WPM**
* K.-H. Brenner, W. Singer, “Light propagation through micro lenses: a new simulation method”, Appl. Opt., 32(6) 4984-4988 (1993).
* Schmidt, S. et al. "Wave-optical modeling beyond the thin-element-approximation" Opt. Express 24, 30188 (2016).
* Brenner, K.H. "A high-speed version of the wave propagation method applied to micro-optics." 16th Workshop on Information Optics (WIO). IEEE (2017)
* Schmidt, S., et al. "Rotationally symmetric formulation of the wave propagation method-application to the straylight analysis of diffractive lenses" Opt. Lett. 42, 1612 (2017).
**VRS**
* Ye, H. et al. "Creation of a longitudinally polarized subwavelength hotspot with an ultra-thin planar lens: Vectorial Rayleigh-Sommerfeld method" Laser Phys. Lett. 10, (2013).
**CZT**
* Bluestein, L., "A linear filtering approach to the computation of the discrete Fourier transform," Northeast Electronics Research and Engineering Meeting Record 10, 218-219 (1968).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VCZT**
* Leutenegger M. et al. "Fast focus field calculations" Optics Express 14(23) 11277 (2006).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VWPM** (not implemented yet)
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". J. Opt. Soc. Am. A 27, 709 (2010).
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". PhD thesis (Mannheim, 2010).
Other References
---------------------------
* J.W. Goodman, "Introduction to Fourier Optics" McGraw-Hill, 1996.
* B.E. Saleh y M. C. Teich, "Fundamentals of photonics" John Wiley & Sons, 2019.
* Z.Qiwen, "Vectorial optical fields: Fundamentals and applications" World scientific, 2013.
* "Numerical Methods in Photonics Lecture Notes". http://ecee.colorado.edu/~mcleod/teaching/nmip/lecturenotes.html.
Credits
---------------------------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
____
pytest --cov=diffractio tests/
Pillow
ipympl
ipywidgets
numexpr
opencv-python
pandas
psutil
py_pol
screeninfo

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

.. include:: ../AUTHORS.rst
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# diffractio documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
# relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
# -- General configuration ---------------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# extensions = [
# 'sphinx.ext.autodoc',
# 'sphinx.ext.viewcode',
# ]
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.mathjax',
'sphinx.ext.napoleon', 'nbsphinx', 'sphinx.ext.todo'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
# source_suffix = ['.rst', '.md', '.ipynb']
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Python diffraction and interference'
copyright = u"2019, Luis Miguel Sanchez Brea"
author = u"Luis Miguel Sanchez Brea"
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
# version = diffractio.__version__
version = '0.1.8'
# The full version, including alpha/beta/rc tags.
# release = diffractio.__version__
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = [
'_build', 'Thumbs.db', '.DS_Store', '_build', '**.ipynb_checkpoints'
]
# LM: exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output -------------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a
# theme further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# -- Options for HTMLHelp output ---------------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'diffractiodoc'
# -- Options for LaTeX output ------------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'diffractio.tex',
u'Python diffraction and interference Documentation',
u'Luis Miguel Sanchez Brea', 'manual'),
]
# -- Options for manual page output ------------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'diffractio',
u'Python diffraction and interference Documentation', [author
], 1)]
# -- Options for Texinfo output ----------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'diffractio',
u'Python diffraction and interference Documentation', author,
'diffractio'),
]
# Module items sort order
autodoc_member_order = 'bysource'
.. include:: ../CONTRIBUTING.rst
diffractio package
==================
Submodules
----------
diffractio.config module
------------------------
.. automodule:: diffractio.config
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_fields\_X module
-----------------------------------
.. automodule:: diffractio.scalar_fields_X
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_fields\_XY module
------------------------------------
.. automodule:: diffractio.scalar_fields_XY
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_fields\_XYZ module
-------------------------------------
.. automodule:: diffractio.scalar_fields_XYZ
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_fields\_XZ module
------------------------------------
.. automodule:: diffractio.scalar_fields_XZ
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_fields\_Z module
-----------------------------------
.. automodule:: diffractio.scalar_fields_Z
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_masks\_X module
----------------------------------
.. automodule:: diffractio.scalar_masks_X
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_masks\_XY module
-----------------------------------
.. automodule:: diffractio.scalar_masks_XY
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_masks\_XYZ module
------------------------------------
.. automodule:: diffractio.scalar_masks_XYZ
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_masks\_XZ module
-----------------------------------
.. automodule:: diffractio.scalar_masks_XZ
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_sources\_X module
------------------------------------
.. automodule:: diffractio.scalar_sources_X
:members:
:undoc-members:
:show-inheritance:
diffractio.scalar\_sources\_XY module
-------------------------------------
.. automodule:: diffractio.scalar_sources_XY
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_common module
-------------------------------
.. automodule:: diffractio.utils_common
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_drawing module
--------------------------------
.. automodule:: diffractio.utils_drawing
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_math module
-----------------------------
.. automodule:: diffractio.utils_math
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_multiprocessing module
----------------------------------------
.. automodule:: diffractio.utils_multiprocessing
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_optics module
-------------------------------
.. automodule:: diffractio.utils_optics
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_slicer module
-------------------------------
.. automodule:: diffractio.utils_slicer
:members:
:undoc-members:
:show-inheritance:
diffractio.utils\_tests module
------------------------------
.. automodule:: diffractio.utils_tests
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_fields\_X module
-----------------------------------
.. automodule:: diffractio.vector_fields_X
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_fields\_XY module
------------------------------------
.. automodule:: diffractio.vector_fields_XY
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_fields\_XYZ module
-------------------------------------
.. automodule:: diffractio.vector_fields_XYZ
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_fields\_XZ module
------------------------------------
.. automodule:: diffractio.vector_fields_XZ
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_fields\_Z module
-----------------------------------
.. automodule:: diffractio.vector_fields_Z
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_masks\_XY module
-----------------------------------
.. automodule:: diffractio.vector_masks_XY
:members:
:undoc-members:
:show-inheritance:
diffractio.vector\_sources\_XY module
-------------------------------------
.. automodule:: diffractio.vector_sources_XY
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: diffractio
:members:
:undoc-members:
:show-inheritance:
Examples
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
source/examples/gauss_beam.ipynb
source/examples/reflection_refraction.ipynb
source/examples/diffraction_slit.ipynb
source/examples/arago_point.ipynb
source/examples/diffraction_objects.ipynb
source/examples/scattering_small_cylinders.ipynb
source/examples/fresnel_biprism.ipynb
source/examples/lenses.ipynb
source/examples/fresnel_lens.ipynb
source/examples/talbot_effect.ipynb
source/examples/blazed_grating.ipynb
source/examples/dammann.ipynb
source/examples/variable_refraction_index.ipynb
source/examples/vector_double_slit_experiment.ipynb
source/examples/VRS_paper.ipynb
About functiong
==========================
.. toctree::
:maxdepth: 4
:numbered:
:glob:
source/functioning/developing_new_functions.ipynb
source/functioning/surfaces.ipynb
source/functioning/artifacts_bpm.ipynb
source/functioning/multiprocessing.ipynb
source/functioning/power_z_propagation.ipynb
source/functioning/phase_intensity.ipynb
source/functioning/quality_factor.ipynb
source/functioning/WPM_ws.ipynb
.. include:: ../HISTORY.rst
Welcome to Diffractio: Python diffraction and interference's documentation!
===================================================================================
.. toctree::
:maxdepth: 4
:caption: Contents:
:numbered:
:glob:
readme
installation
usage
modules
new
tutorials
examples
functioning
contributing
authors
results
history
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. highlight:: shell
============
Installation
============
Stable release
--------------
To install Python diffraction and interference, run this command in your terminal:
.. code-block:: console
# Linux:
$ pip3 install diffractio
# Windows:
$ pip install diffractio
This is the preferred method to install Python diffraction and interference, 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.
.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
Additional packages
------------------------
Diffractio uses also the following non-standard modules:
* py-pol
In some schemes, the following modules are also required:
* numpy, scipy, matplotlib
* Pillow, numexpr, pandas, screeninfo, opencv-python
* ipywidgets, ipympl
They should previously be installed before Diffractio module.
From sources
------------
The sources for Python diffraction and interference can be downloaded from the `Bitbucket repo`_.
You can either clone the public repository:
.. code-block:: console
$ git clone git@bitbucket.org:optbrea/diffractio.git
$ git clone https://optbrea@bitbucket.org/optbrea/diffractio.git
Once you have a copy of the source, you can install it with:
.. code-block:: console
# Linux:
$ python3 setup.py install
# Windows:
$ python setup.py install
.. _Bitbucket repo: https://bitbucket.org/optbrea/diffractio/src/master/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=python3 -msphinx
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=diffractio
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
echo.then set the SPHINXBUILD environment variable to point to the full
echo.path of the 'sphinx-build' executable. Alternatively you may add the
echo.Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python3 -msphinx
SPHINXPROJ = diffractio
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diffractio
==========
.. toctree::
:maxdepth: 4
diffractio
.. include:: ../NEW.rst
.. include:: ../README.rst

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

.. include:: ../RESULTS.rst

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Algorithms
=============
Propagation algorithms is a fundamental key in Diffractio package. The algorithms implmented are:
**Scalar Propagation**
* Fast Fourier Transform (FFT).
* Rayleigh Sommerfeld (RS).
* Plane Wave Descomposition (PWD).
* Beam Propagation Method (BPM).
* Wave Propagation Method (WPM).
* Chirp z-transform (CZT).
**Vector propagation**
* Vector Fast Fourier Tranform (VFFT).
* Vector Rayleigh-Sommerfeld (VRS).
* Vector Chirped z-transform (VCZT)
**Fast Fourier Transform (FFT)**
It allows, in a single step to determine the field at the far field.
The fields and the masks must be defined in a plane.
**Rayleigh-Sommerfeld (RS)**
- Shen, F., and Wang, A. (2006). Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula. Applied Optics, 45(6), 1102–1110. https://doi.org/10.1364/AO.45.001102
Single step to propagate to a near or far observation plane, which allows fast computations.
**Beam propagation method (BPM)**
- Feit, M. D., and Fleck, J. A. (1978). Light propagation in graded-index optical fibers.
Propation of light in volumetric elements, provided that the spatial variations in the refraction index are small. It allows graded index structures. It presents a complexity of O(n) in the two-dimensional and O(n2) in the three-dimensional case. Computed according to split-step propagation scheme.
**Wave Propagation Method (WPM)**
- Brenner, K.-H. H., and Singer, W. (1993). Light propagation through microlenses: a new simulation method. Applied Optics, 32(26), 4984–4988. https://doi.org/10.1364/ao.32.004984
- Brenner, K. H. (2017). A high-speed version of the wave propagation method applied to micro-optics. 2017 16th Workshop on Information Optics, WIO 2017, 1, 2–4. https://doi.org/10.1109/WIO.2017.8038108
- Schmidt, S., Thiele, S., Herkommer, A., Tünnermann, A., and Gross, H. (2017). Rotationally symmetric formulation of the wave propagation method-application to the straylight analysis of diffractive lenses. Optics Letters, 42(8), 1612. https://doi.org/10.1364/ol.42.001612
Solves the major limitations of the beam propagation method (BPM). The wave propagation scheme provides valid results for propagation angles up to 85° and that it is not limited to small index variations in the axis of propagation. Very fast with a discrete number of refraction indexes.
**Chirped z Transform (CZT)**
- Leutenegger, M., Rao, R., Leitgeb, R. A., and Lasser, T. (2006). Fast focus field calculations. Optics Express, 14(23), 11277–11291. http://lob.epfl.ch/
- Hu, Y., Wang, Z., Wang, X., Ji, S., Zhang, C., Li, J., Zhu, W., Wu, D., and Chu, J. (2020). Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method. Light: Science and Applications, 9(1). https://doi.org/10.1038/s41377-020-00362-z
**Vector Fast Fourier Transform (VFFT)**
- todo
**Vector Rayleigh-Sommerfeld (VRS)**
- Ye, H., Qiu, C. W., Huang, K., Teng, J., Luk’Yanchuk, B., and Yeo, S. P. (2013). Creation of a longitudinally polarized subwavelength hotspot with an ultra-thin planar lens: Vectorial Rayleigh-Sommerfeld method. Laser Physics Letters, 10(6). https://doi.org/10.1088/1612-2011/10/6/065004
The VRS method propagates (Ex,Ey,Ez) fields offering the advantage of significant reduction in computation, from flat diffractive elements (Thin Element Approximation) with full control of polarization. It addresses simultaneously both longitudinal polarization. This approach offers the advantage of significant reduction in computation.
**Vector Chirped Z Transform (VCZT)**
- Hu, Y., Wang, Z., Wang, X., Ji, S., Zhang, C., Li, J., Zhu, W., Wu, D., and Chu, J. (2020). Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method. Light: Science and Applications, 9(1). https://doi.org/10.1038/s41377-020-00362-z
.. toctree::
:maxdepth: 4
:numbered:
:glob:
FFT.ipynb
RS.ipynb
BPM.ipynb
WPM.ipynb
CZT.ipynb
VFFT.ipynb
VRS.ipynb
VCZT.ipynb
comparison/RS_vs_WPM.ipynb
comparison/WPM_vs_BPM.ipynb
comparison/CZT_vs_RS.ipynb

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Some info about drawing and videos
=======================================
.. toctree::
:maxdepth: 4
:numbered:
:glob:
logarithm.ipynb
creating_video.ipynb
use_interact_visualize_profiles.ipynb
interactive_in_diffractio.ipynb
external_qt.ipynb

Sorry, the diff of this file is too big to display

Scalar_X
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
tutorial_x.ipynb
sources_x.ipynb
masks_x.ipynb

Sorry, the diff of this file is not supported yet

Scalar_XY
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
tutorial_xy.ipynb
sources_xy.ipynb
masks_xy.ipynb
masks_xy_procedures.ipynb

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Scalar_XYZ
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
tutorial_xyz.ipynb
wpm-bpm 3d.ipynb
wpm_without_storing.ipynb
masks_xyz.ipynb

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Scalar_XZ
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
tutorial_xz.ipynb
masks_xz.ipynb
drawing_xz.ipynb

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Scalar_Z
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
scalar_field_z.ipynb
Vector_XY
==========================
.. toctree::
:maxdepth: 4
:numbered:
:glob:
tutorial_vector_XY.ipynb
tutorial_vector_sources_XY.ipynb
tutorial_vector_masks_XY.ipynb
tutorial_vector_XY_draw.ipynb
Tutorials
=============
.. toctree::
:maxdepth: 4
:numbered:
:glob:
source/tutorial/algorithms/tutorial.rst
source/tutorial/scalar_X/tutorial.rst
source/tutorial/scalar_Z/tutorial.rst
source/tutorial/scalar_XZ/tutorial.rst
source/tutorial/scalar_XY/tutorial.rst
source/tutorial/scalar_XYZ/tutorial.rst
source/tutorial/vector_XY/tutorial.rst
source/tutorial/drawing/tutorial.rst
source/tutorial/functioning/functioning.rst
=====
Usage
=====
To use Python diffraction and interference in a project:
.. code-block:: python
import diffractio
X fields
=================
.. code-block:: python
from diffractio import um, nm, mm, np
from diffractio.scalar_fields_X import Scalar_field_X
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.scalar_masks_X import Scalar_mask_X
x = np.linspace(-500 * um, 500 * um, 4096)
wavelength = .6328 * um
u0 = Scalar_source_X(x, wavelength)
u0.gauss_beam(x0=0, w0=300*um, z0=0)
u0.draw(filename='usage1.png')
t0=Scalar_mask_X(x, wavelength)
t0.slit(x0=0, size=250*um)
t0.draw(filename='usage2.png')
u1=t0*u0
u2 = u1.RS(z=5 * mm, new_field=True)
u2.draw(filename='usage3.png')
.. figure:: usage1.png
:width: 600
.. figure:: usage2.png
:width: 600
.. figure:: usage3.png
:width: 600
XZ fields
=================
.. code-block:: python
from diffractio import um, nm, mm, np,degrees
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.scalar_fields_XZ import Scalar_field_XZ
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
x0 = np.linspace(-100 * um, 100 * um, 512)
z0 = np.linspace(0 * um, 300 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=0 * um, z0=0 * um, w0=75 * um, theta=0 * degrees)
u0.draw(kind='field', filename='usage4.png')
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.rectangle(r0=(0 * um, 100 * um),
size=(100 * um, 100 * um),
angle=45 * degrees,
refraction_index=2)
u1.draw_refraction_index(filename='usage5.png', scale='scaled')
u1.WPM(verbose=False)
u1.draw(logarithm=True, normalize='maximum', draw_borders=True, filename='usage6.png', scale='scaled');
.. figure:: usage4.png
:width: 600
.. figure:: usage5.png
:width: 600
.. figure:: usage6.png
:width: 600
XY fields
=================
.. code-block:: python
from diffractio import um, nm, mm, np, degrees
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.scalar_fields_XY import Scalar_field_XY
from diffractio.scalar_masks_XY import Scalar_mask_XY
length = 1000*um
x0 = np.linspace(-length/2, length/2, 512)
y0 = np.linspace(-length/2, length/2, 512)
wavelength = 0.6238 * um
focus=10*mm
u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u0.zernike_beam(A=1, r0=(0, 0), radius=length / 2, n=[ 0,4,], m=[0,3,], c_nm=[ 1,0.25,])
u0.draw(kind='phase', filename='usage7.png')
t0 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t0.fresnel_lens(
r0=(0 * um, 0 * um),
radius=(500 * um, 500 * um),
focal=(focus,focus),
angle=0 * degrees,
kind='amplitude',
phase=np.pi)
t0.draw(filename='usage8.png')
u1 = u0 * t0
u2 = u1.RS(z=focus, new_field=True)
u2.cut_resample(
x_limits=(-100 * um, 100 * um),
y_limits=(-100 * um, 100 * um),
num_points=[1024, 1024],
new_field=False)
u2.draw(kind='intensity', logarithm=True, filename='usage9.png')
.. figure:: usage7.png
:width: 600
.. figure:: usage8.png
:width: 600
.. figure:: usage9.png
:width: 600
XYZ fields
=================
.. code-block:: python
from diffractio import degrees, eps, mm, no_date, np, um
from diffractio.scalar_fields_XYZ import Scalar_field_XYZ
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_masks_XYZ import Scalar_mask_XYZ
from diffractio.scalar_sources_XY import Scalar_source_XY
x0 = np.linspace(-25 * um, 25 * um, 128)
y0 = np.linspace(-25 * um, 25 * um, 128)
z0 = np.linspace(100 * um, 500 * um, 256)
wavelength = .6328 * um
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(
r0=(0 * um, 0 * um), radius=(10 * um, 10 * um), angle=0 * degrees)
t1.draw(filename='usage10.png')
uxyz = Scalar_mask_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
uxyz.incident_field(u0=t1)
uxyz.RS(verbose=True, num_processors=4)
uxyz.draw_XYZ(y0=0 * mm, logarithm=True, normalize='maximum',filename='xyz_RS.png')
.. figure:: usage10.png
:width: 600
.. figure:: xyz_RS.png
:width: 600
XY Vector fields
==================================
.. code-block:: python
from diffractio import degrees, mm, nm, np, plt, sp, um
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_fields_XY import Scalar_field_XY
from diffractio.vector_sources_XY import Vector_source_XY
from diffractio.vector_masks_XY import Vector_mask_XY
from diffractio.vector_fields_XY import Vector_field_XY
x0 = np.linspace(-125 * um, 125 * um, 256)
y0 = np.linspace(-125 * um, 125 * um, 256)
wavelength = 0.6328 * um
u0 = Scalar_source_XY(x0, y0, wavelength)
u0.gauss_beam(
r0=(0, 0),
w0=(100 * um, 100 * um),
z0=0 * um,
A=1,
theta=0. * degrees,
phi=0 * degrees)
EM0 = Vector_source_XY(x0, y0, wavelength)
EM0.azimuthal_wave(u=u0, r0=(0, 0), radius=(200, 200))
EM0.draw(kind='ellipses')
plt.title('Before mask')
plt.savefig('usage12.png')
t0 = Scalar_mask_XY(x0, y0, wavelength)
t0.two_levels(level1=0, level2=1, x_edge=0, angle=0)
M0 = Vector_mask_XY(x=x0, y=y0, wavelength=wavelength)
state_0 = np.array([[1, 0],[0, 0]])
state_1 = np.array([[0, 0],[0, 1]])
M0.complementary_masks(t0, state_0, state_1)
EM1 = EM0 * M0
EM1.draw(kind='ellipses')
plt.title('After mask')
plt.savefig('usage13.png')
EM2 = EM1.RS(z=10 * mm)
EM2.draw(kind='ellipses')
plt.title('After propagation')
plt.savefig('usage14.png')
.. figure:: usage12.png
:width: 600
.. figure:: usage13.png
:width: 600
.. figure:: usage14.png
:width: 600

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

=======
History
=======
0.0.0 (2017-01-01)
------------------------
Pre-alpha state.
* I have been developing and using the module diffractio for at least 5 years for teaching and research. It was in python2 version and not completely clear.
0.0.1 (2019-02-09)
------------------------
Pre-alpha state.
* Modules are passed to python3.
0.0.2 (2019-10-01)
------------------------
Alpha state
* copyreg removed (previous not worked)
* change fft to scipy: "from scipy.fftpack import fft, ifft, fftshift"
First release on PyPI in pre-alpha state.
0.0.5 (2019-10-06)
------------------------
Alpha state
* Included vector (fields, sources, masks) modules, tests, and tutorial.
0.0.6 (2019-10-22)
------------------------
Alpha state
* Finished first version of examples and tutorial.
0.0.7 and 0.0.8 (2020-05-02)
--------------------------------
Alpha state
* convert_mask -> extrude_mask
* Improved documentation
* Implemented PWD
* Reduced size of html
0.0.9 and 0.0.10 (2020-05-02)
--------------------------------
Alpha state
* Improvement to documentation (readthedocs)
0.0.11 and 0.0.12 (2021-05-09)
--------------------------------
Alpha state
* Solved big errata in vector_paraxial_masks
* Solved errata in XY: kernelRS and kernelRSinverse
* Improved documentation, tutorial and examples of vector_paraxial
* Scalar_mask_XY: dots
* Scalar_mask_X: dots
* change save_data in all classes to simplify
* Changes in docs to include WPM
* Execution tests
0.0.13 (2021-08-11)
--------------------------------
Alpha state
* wpm bpm 3d, wpm without storing, xy search focus
* fix bug 2D gratings
* fix bug aspheric X and new aspheric XY
0.1.0 (2022-10-12)
--------------------------------
Beta state
* Fix bugs:
- radial and azimuthal vector waves
- Change in criterion of plane waves to Physics (ISO 80000-2:2019 convention): https://en.wikipedia.org/wiki/Spherical_coordinate_system#Coordinate_system_conversions
- constant_wave -> constant_polarization in vector_sources_XY
- mask_circle -> pupil
-
* New vector_fields_XY:
- vector_paraxial_fields -> vector_fields
* New schemes mainly for representation:
- Scalar_field_Z
- vector_X, vector_Z, vector_XZ, vector_XYZ
* New Scalar_mask_XY:
- angular_aperture
- edge_series
- slit_series
- rings
* New propagation algorithms:
- WPM and BPM in 3D
- WPM and BPM in 3D without storing intermediate planes
- VFFT (vector FFT and inverse FFT)
- VRS (vector Rayleigh-Sommerfeld propagation, with Ez field)
- Chirped z-transform (CZT) for scalar fields
- Chirped z-transform (CZT) for vector fields
* Other:
- Pupil function in XY and vector XY
- Remove mask parameter from lenses. This may produce incompatibilities with former code
- Improving drawings
0.1.1 (2022-10-16)
--------------------------------
* Vector fields are not longer paraxial.
- The propagation algorithms implemented (VRS, VFFT and VCZT) provide :E_z: field. This allows to analyze longitudinal fields.The modules and classes elliminate changes their name. For example vector_paraxial_fields_X is now vector_fields_X.
* New propagation algorithm Chirped Z-Transform (CZT) is avaliable for X and XY fields.
- This algorithms produce similar results to RS and VRS fields, but there are significant advantages:
- The output field is not necessarily the same as the input field. This is important, for example, when analyzing the focus of a lens, since the computing time is dedicated to areas with light.
- The output field does not necessarily have the same dimensionality of the input field. For example, when the mask is XY, we can have the data only at (x=0, y=0, z) axis.
- Acceleration in computing and reduction of memory usage.
* New modules for visualization and data analysis are provided.
- Scalar_field_Z can be used, for example, to analysis of intensity light at axis.
- Vector_fields_Z, Vector_fields_XZ, and Vector_fields_XYZ have been developed, as VCZT algorithm can provide these data.
* Plane Wave Descomposition algorithm (PWD) is deprecated.
* Some importante bugs have been solved. For example the definition of the spherical coordinates in some sources (which not used standard physics criterion).
* Mask parameters is removed in some XY masks, as lenses, FPZ, etc. The new way to do this is the .pupil() function.
* Smooth_refraction index can be used also for Wave Propagation Method algorithm (WPM).
0.1.8 (2023-10-07)
--------------------------------
* Fix bugs:
- Bug in XYZ video
- Blazed grating wrong defined.
* New features:
- XY masks: new polygon, regular_polygon, and star functions.
- XY masks: new circular_sector function.
- X, XY, XYZ fields: new conjugate function.
- WPM function without storing all the data.
Future
--------------------------------
- Implement plotly for drawings
include AUTHORS.rst
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif *.pdf *.mp4 *.avi
Metadata-Version: 2.1
Name: diffractio
Version: 0.1.8
Summary: Optical Diffraction and Interference (scalar and vectorial)
Home-page: https://bitbucket.org/optbrea/diffractio/src/master/
Author: Luis Miguel Sanchez Brea
Author-email: optbrea@ucm.es
License: MIT license
Keywords: diffractio,optics,diffraction,interference,Rayleigh-Sommerfeld,Beam Propagation Method,BPM,WPM,CZT,RS,VRS
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
License-File: LICENSE
License-File: AUTHORS.rst
================================================
Python Diffraction-Interference module
================================================
.. image:: https://img.shields.io/pypi/dm/diffractio
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/pypi/v/diffractio.svg
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/travis/optbrea/diffractio.svg
:target: https://bitbucket.org/optbrea/diffractio/src/master/
.. image:: https://readthedocs.org/projects/diffractio/badge/?version=latest
:target: https://diffractio.readthedocs.io/en/latest/
:alt: Documentation Status
* Free software: MIT license
* Documentation: https://diffractio.readthedocs.io/en/latest/
.. image:: logo.png
:width: 75
:align: right
Features
----------------------
Diffractio is a Python library for Diffraction and Interference Optics.
It implements Scalar and vector Optics. The main algorithms used are:
* Fast Fourier Transform (FFT).
* Rayleigh Sommerfeld (RS).
* Chirp z-transform (CZT).
* Plane Wave Descomposition (PWD).
* Beam Propagation Method (BPM).
* Wave Propagation Method (WPM).
* Vectorial Rayleigh-Sommerfeld (VRS).
* Vector Fast Fourier Tranform (VFFT).
* Vector Chirp z-transform (VCZT).
When possible, multiprocessing is implemented for a faster computation.
The **scalar** propagation schemes are implemented in modules:
* X - fields are defined in the x axis.
* Z - fields are defined in the z axis (for visualiztion and analysis).
* XZ - fields are defined in the xz plane, being z the propagation direction.
* XY - fields are defined in the xy transversal plane.
* XYZ - fields are defined in the xyz volume.
Each scheme present three modules:
* sources: Generation of light.
* masks: Masks and Diffractive Optical elements.
* fields: Propagation techniques, parameters and general functions.
The **vector** propagation schemes are implemented in modules:
* vector_XY - Ex, Ey, and Ez electric field components are defined, which allows polarization analysis.
There are additional schemes used mainly for representation.
* vector_X - fields are defined in the z axis (for visualiztion and analysis).
* vector_Z - fields are defined in the z axis (for visualiztion and analysis).
* vector_XZ - fields are defined in the xz axis (for visualiztion and analysis).
* vector_XYZ - fields are defined in the xyz axis (for visualiztion and analysis).
For the vector analysis, we also use the py_pol module: https://pypi.org/project/py-pol/
Sources
========
One main part of this software is the generation of optical fields such as:
* Plane waves.
* Spherical waves.
* Gaussian beams.
* Bessel beams.
* Vortex beams.
* Laguerre beams.
* Hermite-Gauss beams.
* Zernike beams.
.. image:: readme1.png
:width: 400
Masks
=============
Another important part of Diffractio is the generation of masks and Diffractive Optical Elements such as:
* Slits, double slits, circle, square, ring ...
* Lenses, diffractive lenses, aspherical lenses...
* Axicon, prisms, biprism, image, rough surface, gray scale ...
* Gratings: Ronchi, phase, radial, angular, sine, forked, blazed, 2D, chess...
.. image:: readme2.png
:height: 400
In the XZ scheme there is also a number of masks:
* image, sphere, layer, lenses, wedge, prism, probe, gratings...
* Additionally, any X_mask can be extruded to the XZ scheme.
* Masks from functions
* Surfaces can be added to objects
.. image:: readme3.png
:height: 400
Fields
=========
Several propagation algorithms for propagation of light are implemented in the *fields* modules:
* **Fast Fourier Transform (FFT)** which allows, in a single step, to determine the field at the far field.
* **Rayleigh-Sommerfeld (RS)** [Appl. Opt., 45(6) 1102–1110, (2006)] RS allows, in a single step, to propagate to a near or far observation plane, which allows fast computations. The fields and the masks must be defined in a plane.
* **Beam propagation method (BPM)** [Appl. Opt. 24, 3390-3998 (1978)] which allows to analyze the propation of light in volumetric elements, such as spheres, cylinders and other complex forms, provided that the spatial variations in the refraction index are small. It allows graded index structures. It presents a complexity of O(n) in the two-dimensional and O(n2) in the three-dimensional case. It is computed according to the split-step propagation scheme.
* **Wave Propagation Method (WPM)**. [Appl. Opt. 32, 4984 (1993)] WPM was introduced in order to overcome the major limitations of the beam propagation method (BPM). With the WPM, the range of application can be extended from the simulation of waveguides to simulation of other optical elements like lenses, prisms and gratings. WPM can accurately simulate scalar light propagation in inhomogeneous media at high numerical apertures, and provides valid results for propagation angles up to 85° and that it is not limited to small index variations in the axis of propagation. Fast implementation with discrete number of refraction indexes is also implemented.
* **Chirped Z-Transform (CZT)**. [Light: Science and Applications, 9(1), (2020)] CZT allows, in a single step, to propagate to a near or far observation plane. It present advantages with respecto to RS algorithm, since the region of interest and the sampling numbers can be arbitrarily chosen, endowing the proposed method with superior flexibility. CZT algorithm allows to have a XY mask and compute in XY, Z, XZ, XYZ schemes, simply defining the output arrays.
* **Vector Rayleigh-Sommerfeld (VRS)**. The VRS method [Laser Phys. Lett. 10(6) 065004 (2013)] allows to propagate (Ex,Ey,Ez) fields offering the advantage of significant reduction in computation, from flat diffractive elements (Thin Element Approximation) with full control of polarization. It addresses simultaneously both longitudinal polarization. This approach offers the advantage of significant reduction in computation.
* **Vector Chirped Z-Transform (VCZT)**. [Light: Science and Applications, 9(1), (2020)]. CZT is also implemented in vector fields.
"""
The fields, masks and sources can be stored in files.
Also drawings can be easily obtained, for intensity, phase, fields, etc.
In some modules, videos can be generated for a better analysis of optical fields.
.. image:: readme6.png
:width: 600
.. image:: readme6.png
:width: 600
Vector beams
==================================
Here, we implement new classes where the E_x, E_y, and E_z fields are generated and propagated using Rayleigh-Sommerfeld and Chirped z-transform algorithms.
Also, simple and complex polarizing masks can be created.
**Intensity of vector field**
.. image:: readme4.png
:width: 700
**Polarization: Stokes parameters**
.. image:: readme5.png
:width: 700
Other features
=================
* Intensity, MTF and other parameters are obtained from the optical fields.
* Fields can be added simply with the + signe, and interference is produced. Masks can be multiplied, added and substracted in order to make complex structures
* Resampling fields in order to analyze only areas of interest.
* Save and load data for future analysis.
* Rayleigh-Sommerfeld implementation is performed in multiprocessing for fast computation.
* Polychromatic and extended source problems can also be analyzed using multiprocessing.
Authors
---------------------------
* 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)
.. image:: logoUCM.png
:width: 125
:align: right
Citing
---------------------------
L.M. Sanchez Brea, "Diffractio, python module for diffraction and interference optics", https://pypi.org/project/diffractio/ (2019)
References for algorithms
---------------------------
**RS**
* Shen, F. & Wang, A. "Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula. Appl. Opt. 45, 1102–1110 (2006).
**WPM**
* K.-H. Brenner, W. Singer, “Light propagation through micro lenses: a new simulation method”, Appl. Opt., 32(6) 4984-4988 (1993).
* Schmidt, S. et al. "Wave-optical modeling beyond the thin-element-approximation" Opt. Express 24, 30188 (2016).
* Brenner, K.H. "A high-speed version of the wave propagation method applied to micro-optics." 16th Workshop on Information Optics (WIO). IEEE (2017)
* Schmidt, S., et al. "Rotationally symmetric formulation of the wave propagation method-application to the straylight analysis of diffractive lenses" Opt. Lett. 42, 1612 (2017).
**VRS**
* Ye, H. et al. "Creation of a longitudinally polarized subwavelength hotspot with an ultra-thin planar lens: Vectorial Rayleigh-Sommerfeld method" Laser Phys. Lett. 10, (2013).
**CZT**
* Bluestein, L., "A linear filtering approach to the computation of the discrete Fourier transform," Northeast Electronics Research and Engineering Meeting Record 10, 218-219 (1968).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VCZT**
* Leutenegger M. et al. "Fast focus field calculations" Optics Express 14(23) 11277 (2006).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VWPM** (not implemented yet)
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". J. Opt. Soc. Am. A 27, 709 (2010).
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". PhD thesis (Mannheim, 2010).
Other References
---------------------------
* J.W. Goodman, "Introduction to Fourier Optics" McGraw-Hill, 1996.
* B.E. Saleh y M. C. Teich, "Fundamentals of photonics" John Wiley & Sons, 2019.
* Z.Qiwen, "Vectorial optical fields: Fundamentals and applications" World scientific, 2013.
* "Numerical Methods in Photonics Lecture Notes". http://ecee.colorado.edu/~mcleod/teaching/nmip/lecturenotes.html.
Credits
---------------------------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
____
pytest --cov=diffractio tests/
================================================
Python Diffraction-Interference module
================================================
.. image:: https://img.shields.io/pypi/dm/diffractio
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/pypi/v/diffractio.svg
:target: https://pypi.org/project/diffractio/
.. image:: https://img.shields.io/travis/optbrea/diffractio.svg
:target: https://bitbucket.org/optbrea/diffractio/src/master/
.. image:: https://readthedocs.org/projects/diffractio/badge/?version=latest
:target: https://diffractio.readthedocs.io/en/latest/
:alt: Documentation Status
* Free software: MIT license
* Documentation: https://diffractio.readthedocs.io/en/latest/
.. image:: logo.png
:width: 75
:align: right
Features
----------------------
Diffractio is a Python library for Diffraction and Interference Optics.
It implements Scalar and vector Optics. The main algorithms used are:
* Fast Fourier Transform (FFT).
* Rayleigh Sommerfeld (RS).
* Chirp z-transform (CZT).
* Plane Wave Descomposition (PWD).
* Beam Propagation Method (BPM).
* Wave Propagation Method (WPM).
* Vectorial Rayleigh-Sommerfeld (VRS).
* Vector Fast Fourier Tranform (VFFT).
* Vector Chirp z-transform (VCZT).
When possible, multiprocessing is implemented for a faster computation.
The **scalar** propagation schemes are implemented in modules:
* X - fields are defined in the x axis.
* Z - fields are defined in the z axis (for visualiztion and analysis).
* XZ - fields are defined in the xz plane, being z the propagation direction.
* XY - fields are defined in the xy transversal plane.
* XYZ - fields are defined in the xyz volume.
Each scheme present three modules:
* sources: Generation of light.
* masks: Masks and Diffractive Optical elements.
* fields: Propagation techniques, parameters and general functions.
The **vector** propagation schemes are implemented in modules:
* vector_XY - Ex, Ey, and Ez electric field components are defined, which allows polarization analysis.
There are additional schemes used mainly for representation.
* vector_X - fields are defined in the z axis (for visualiztion and analysis).
* vector_Z - fields are defined in the z axis (for visualiztion and analysis).
* vector_XZ - fields are defined in the xz axis (for visualiztion and analysis).
* vector_XYZ - fields are defined in the xyz axis (for visualiztion and analysis).
For the vector analysis, we also use the py_pol module: https://pypi.org/project/py-pol/
Sources
========
One main part of this software is the generation of optical fields such as:
* Plane waves.
* Spherical waves.
* Gaussian beams.
* Bessel beams.
* Vortex beams.
* Laguerre beams.
* Hermite-Gauss beams.
* Zernike beams.
.. image:: readme1.png
:width: 400
Masks
=============
Another important part of Diffractio is the generation of masks and Diffractive Optical Elements such as:
* Slits, double slits, circle, square, ring ...
* Lenses, diffractive lenses, aspherical lenses...
* Axicon, prisms, biprism, image, rough surface, gray scale ...
* Gratings: Ronchi, phase, radial, angular, sine, forked, blazed, 2D, chess...
.. image:: readme2.png
:height: 400
In the XZ scheme there is also a number of masks:
* image, sphere, layer, lenses, wedge, prism, probe, gratings...
* Additionally, any X_mask can be extruded to the XZ scheme.
* Masks from functions
* Surfaces can be added to objects
.. image:: readme3.png
:height: 400
Fields
=========
Several propagation algorithms for propagation of light are implemented in the *fields* modules:
* **Fast Fourier Transform (FFT)** which allows, in a single step, to determine the field at the far field.
* **Rayleigh-Sommerfeld (RS)** [Appl. Opt., 45(6) 1102–1110, (2006)] RS allows, in a single step, to propagate to a near or far observation plane, which allows fast computations. The fields and the masks must be defined in a plane.
* **Beam propagation method (BPM)** [Appl. Opt. 24, 3390-3998 (1978)] which allows to analyze the propation of light in volumetric elements, such as spheres, cylinders and other complex forms, provided that the spatial variations in the refraction index are small. It allows graded index structures. It presents a complexity of O(n) in the two-dimensional and O(n2) in the three-dimensional case. It is computed according to the split-step propagation scheme.
* **Wave Propagation Method (WPM)**. [Appl. Opt. 32, 4984 (1993)] WPM was introduced in order to overcome the major limitations of the beam propagation method (BPM). With the WPM, the range of application can be extended from the simulation of waveguides to simulation of other optical elements like lenses, prisms and gratings. WPM can accurately simulate scalar light propagation in inhomogeneous media at high numerical apertures, and provides valid results for propagation angles up to 85° and that it is not limited to small index variations in the axis of propagation. Fast implementation with discrete number of refraction indexes is also implemented.
* **Chirped Z-Transform (CZT)**. [Light: Science and Applications, 9(1), (2020)] CZT allows, in a single step, to propagate to a near or far observation plane. It present advantages with respecto to RS algorithm, since the region of interest and the sampling numbers can be arbitrarily chosen, endowing the proposed method with superior flexibility. CZT algorithm allows to have a XY mask and compute in XY, Z, XZ, XYZ schemes, simply defining the output arrays.
* **Vector Rayleigh-Sommerfeld (VRS)**. The VRS method [Laser Phys. Lett. 10(6) 065004 (2013)] allows to propagate (Ex,Ey,Ez) fields offering the advantage of significant reduction in computation, from flat diffractive elements (Thin Element Approximation) with full control of polarization. It addresses simultaneously both longitudinal polarization. This approach offers the advantage of significant reduction in computation.
* **Vector Chirped Z-Transform (VCZT)**. [Light: Science and Applications, 9(1), (2020)]. CZT is also implemented in vector fields.
"""
The fields, masks and sources can be stored in files.
Also drawings can be easily obtained, for intensity, phase, fields, etc.
In some modules, videos can be generated for a better analysis of optical fields.
.. image:: readme6.png
:width: 600
.. image:: readme6.png
:width: 600
Vector beams
==================================
Here, we implement new classes where the E_x, E_y, and E_z fields are generated and propagated using Rayleigh-Sommerfeld and Chirped z-transform algorithms.
Also, simple and complex polarizing masks can be created.
**Intensity of vector field**
.. image:: readme4.png
:width: 700
**Polarization: Stokes parameters**
.. image:: readme5.png
:width: 700
Other features
=================
* Intensity, MTF and other parameters are obtained from the optical fields.
* Fields can be added simply with the + signe, and interference is produced. Masks can be multiplied, added and substracted in order to make complex structures
* Resampling fields in order to analyze only areas of interest.
* Save and load data for future analysis.
* Rayleigh-Sommerfeld implementation is performed in multiprocessing for fast computation.
* Polychromatic and extended source problems can also be analyzed using multiprocessing.
Authors
---------------------------
* 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)
.. image:: logoUCM.png
:width: 125
:align: right
Citing
---------------------------
L.M. Sanchez Brea, "Diffractio, python module for diffraction and interference optics", https://pypi.org/project/diffractio/ (2019)
References for algorithms
---------------------------
**RS**
* Shen, F. & Wang, A. "Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula. Appl. Opt. 45, 1102–1110 (2006).
**WPM**
* K.-H. Brenner, W. Singer, “Light propagation through micro lenses: a new simulation method”, Appl. Opt., 32(6) 4984-4988 (1993).
* Schmidt, S. et al. "Wave-optical modeling beyond the thin-element-approximation" Opt. Express 24, 30188 (2016).
* Brenner, K.H. "A high-speed version of the wave propagation method applied to micro-optics." 16th Workshop on Information Optics (WIO). IEEE (2017)
* Schmidt, S., et al. "Rotationally symmetric formulation of the wave propagation method-application to the straylight analysis of diffractive lenses" Opt. Lett. 42, 1612 (2017).
**VRS**
* Ye, H. et al. "Creation of a longitudinally polarized subwavelength hotspot with an ultra-thin planar lens: Vectorial Rayleigh-Sommerfeld method" Laser Phys. Lett. 10, (2013).
**CZT**
* Bluestein, L., "A linear filtering approach to the computation of the discrete Fourier transform," Northeast Electronics Research and Engineering Meeting Record 10, 218-219 (1968).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VCZT**
* Leutenegger M. et al. "Fast focus field calculations" Optics Express 14(23) 11277 (2006).
* Hu Y. et al. "Efficient full-path optical calculation of scalar and vector diffraction using the Bluestein method" Light: Science & Applications 9(119) (2020)
**VWPM** (not implemented yet)
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". J. Opt. Soc. Am. A 27, 709 (2010).
* Fertig, M., Brenner, K.-H. "Vector wave propagation method". PhD thesis (Mannheim, 2010).
Other References
---------------------------
* J.W. Goodman, "Introduction to Fourier Optics" McGraw-Hill, 1996.
* B.E. Saleh y M. C. Teich, "Fundamentals of photonics" John Wiley & Sons, 2019.
* Z.Qiwen, "Vectorial optical fields: Fundamentals and applications" World scientific, 2013.
* "Numerical Methods in Photonics Lecture Notes". http://ecee.colorado.edu/~mcleod/teaching/nmip/lecturenotes.html.
Credits
---------------------------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
____
pytest --cov=diffractio tests/
[bumpversion]
current_version = 0.1.8
commit = True
tag = True
[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
[bumpversion:file:diffractio/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
[bdist_wheel]
universal = 1
[flake8]
exclude = docs
[aliases]
test = pytest
[tool:pytest]
collect_ignore = ['setup.py']
[egg_info]
tag_build =
tag_date = 0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""The setup script."""
from setuptools import find_packages, setup
with open('README.rst', encoding='utf8') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst', encoding='utf8') as history_file:
history = history_file.read()
# requirements = [
# 'Click>=6.0', 'numpy', 'scipy', 'matplotlib','nbsphinx',
# ]
requirements = [
'screeninfo', 'Pillow', 'numexpr', 'pandas', 'psutil', 'py_pol',
'ipywidgets', 'ipympl', 'opencv-python'
]
setup_requirements = [
'pytest-runner',
]
test_requirements = [
'pytest',
]
setup(
author="Luis Miguel Sanchez Brea",
author_email='optbrea@ucm.es',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
description="Optical Diffraction and Interference (scalar and vectorial)",
entry_points={
'console_scripts': [
'diffractio=diffractio.cli:main',
],
},
install_requires=requirements,
license="MIT license",
# long_description=readme + '\n\n' + history,
long_description=readme,
include_package_data=True,
keywords=[
'diffractio', 'optics', 'diffraction', 'interference',
'Rayleigh-Sommerfeld', 'Beam Propagation Method', 'BPM', 'WPM', 'CZT',
'RS', 'VRS'
],
name='diffractio',
packages=find_packages(include=['diffractio']),
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://bitbucket.org/optbrea/diffractio/src/master/',
version='0.1.8',
zip_safe=False,
)
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test for scalar_fields_XYZ
"""
import datetime
import os
import sys
from diffractio import degrees, eps, mm, no_date, np, um
from diffractio.scalar_fields_XYZ import Scalar_field_XYZ
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_masks_XYZ import Scalar_mask_XYZ
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.utils_tests import comparison, save_figure_test
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_fields_XYZ"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_fields_XYZ(object):
def test_save_load(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 100 * um
numdata = 16 # 256
x0 = np.linspace(-length / 2, length / 2, numdata)
y0 = np.linspace(-length / 2, length / 2, numdata)
z0 = np.linspace(-length / 2, length / 2, numdata)
wavelength = 0.5 * um
t1 = Scalar_field_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
t1.u = np.ones_like(t1.u)
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='_save')
del t1
t2 = Scalar_field_XYZ(x=None, y=None, z=None, wavelength=None)
t2.load_data(filename=filename + '.npz', verbose=True)
save_figure_test(newpath, func_name, add_name='_load')
assert True
def test_clear_field(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
length = 100 * um
numdata = 32 # 256
x0 = np.linspace(-length / 2, length / 2, numdata)
y0 = np.linspace(-length / 2, length / 2, numdata)
z0 = np.linspace(-length / 2, length / 2, numdata)
wavelength = 0.5 * um
u0 = Scalar_field_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
proposal = 0 * u0.u
u0.clear_field()
solution = u0.u
assert comparison(proposal, solution, eps)
def test_other(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 100 * um
numdata = 32 # 256
x0 = np.linspace(-length / 2, length / 2, numdata)
y0 = np.linspace(-length / 2, length / 2, numdata)
wavelength = 0.5 * um
period = 10 * um
z_talbot = 2 * period**2 / wavelength
z0 = np.linspace(2 * z_talbot, 6 * z_talbot, 32)
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(A=1, r0=(0, 0), z0=0, w0=(150 * um, 150 * um))
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.ronchi_grating(period=10 * um, x0=0 * um, angle=0 * degrees)
t3 = u1 * t1
uxyz = Scalar_field_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
uxyz.incident_field(t3)
uxyz.RS()
uxyz.draw_XYZ(logarithm=False, normalize='maximum')
uxyz.info = """info:
test_other(self):
"""
filename = uxyz.save_data(filename=filename + '.npz')
del uxyz
# u2 = scalar_fields_XYZ(None, None, None)
# u2.load_data(
# filename=filename+'.npz', verbose=True)
# u2.draw_XYZ(logarithm=False, normalize='maximum')
# u2.save_data(filename=filename+'.npz')
# save_figure_test(newpath, func_name)
assert True
def test_show_index_refraccion(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 50 * um
numdataX = 64
numdataZ = 64
longitud = 50 * um
x0 = np.linspace(-length / 2, length / 2, numdataX)
y0 = np.linspace(-length / 2, length / 2, numdataX)
z0 = np.linspace(-longitud, longitud, numdataZ)
wavelength = 0.55 * um
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(20 * um, 20 * um),
angle=0 * degrees)
uxyz = Scalar_mask_XYZ(x=x0,
y=y0,
z=z0,
wavelength=wavelength,
n_background=1.,
info='')
uxyz.incident_field(t1)
uxyz.cylinder(r0=(0 * um, 0 * um, 0),
radius=(20 * um, 20 * um),
length=longitud,
refraction_index=1.5,
axis=(0, 0, 0),
angle=0 * degrees)
uxyz.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_RS(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 32)
y0 = np.linspace(-25 * um, 25 * um, 32)
z0 = np.linspace(100 * um, 500 * um, 32)
wavelength = .6328 * um
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(10 * um, 10 * um),
angle=0 * degrees)
uxyz = Scalar_mask_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
uxyz.sphere(r0=(0 * um, 0 * um, 200 * um),
radius=(50 * um, 50 * um, 50 * um),
refraction_index=2 + 1j,
angles=(0 * degrees, 0 * degrees, 0 * degrees))
uxyz.incident_field(u0=t1)
uxyz.RS(verbose=True, num_processors=4)
uxyz.draw_XYZ(kind='intensity', logarithm=False, normalize='maximum')
uxyz.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_propagacion_RS_focal_lens(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
length = 500 * um
x0 = np.linspace(-length / 2, length / 2, 16)
y0 = np.linspace(-length / 2, length / 2, 16)
z0 = np.linspace(2 * mm, 7 * mm, 16)
wavelength = 0.6328 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(A=1, r0=(0, 0), z0=0, w0=(150 * um, 150 * um))
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.ronchi_grating(period=20 * um, x0=0 * um, angle=0 * degrees)
t2 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t2.lens(r0=(0 * um, 0 * um),
radius=(200 * um, 200 * um),
focal=(5 * mm, 5 * mm),
angle=0 * degrees)
t3 = u1 * t1 * t2
uxyz = Scalar_field_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
uxyz.incident_field(t3)
uxyz.RS()
u_xy = uxyz.to_Scalar_field_XY(iz0=None,
z0=3 * mm,
is_class=True,
matrix=False)
u_xy.draw(kind='intensity')
uxyz.draw_XY(z0=2 * mm, filename='{}a_{}'.format(newpath, func_name))
uxyz.draw_XY(z0=4.5 * mm, filename='{}b_{}'.format(newpath, func_name))
uxyz.draw_XZ(y0=0 * mm,
logarithm=True,
filename='{}_c{}'.format(newpath, func_name))
# uxyz.draw_XYZ(logarithm=False, normalize='maximum')
# uxyz.draw_volume(logarithm=1, normalize='maximum', maxintensity=None)
return uxyz
def test_propagacion_RS_Talbot_video(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 200 * um
x0 = np.linspace(-length / 2, length / 2, 16)
y0 = np.linspace(-length / 2, length / 2, 16)
wavelength = 0.5 * um
period = 10 * um
z_talbot = 2 * period**2 / wavelength
z0 = np.linspace(2 * z_talbot, 6 * z_talbot, 16)
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(A=1, r0=(0, 0), z0=0, w0=(150 * um, 150 * um))
u1.plane_wave(A=1, theta=0 * degrees, phi=0 * degrees)
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.ronchi_grating(period=10 * um, x0=0 * um, angle=0 * degrees)
t3 = u1 * t1
uxyz = Scalar_field_XYZ(x=x0, y=y0, z=z0, wavelength=wavelength)
uxyz.incident_field(t3)
uxyz.RS()
uscalar_fields_XY = uxyz.to_Scalar_field_XY(z0=3 * mm)
uscalar_fields_XY.draw(kind='intensity', cut_value=None)
uxyz.draw_XY(z0=2 * mm, filename='{}a_{}'.format(newpath, func_name))
uxyz.draw_XY(z0=4.5 * mm, filename='{}b_{}'.format(newpath, func_name))
uxyz.draw_XZ(y0=0 * mm,
logarithm=True,
filename='{}_c{}'.format(newpath, func_name))
# uxyz.draw_XYZ(logarithm=False, normalize='maximum')
# uxyz.draw_volume(logarithm=1, normalize='maximum', maxintensity=None)
uxyz.save_data(filename=filename + '.npz', add_name='')
uxyz.video(filename=filename + '.avi', kind='intensity', frame=True)
return uxyz
def test_BPM(self):
"""
cylinder torcido que hace de lente en una direccion solo
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 80 * um
numdataX = 32
numdataZ = 32
longitud = 400 * um
radiusFibra = 10 * um
x0 = np.linspace(-length / 2, length / 2, numdataX)
y0 = np.linspace(-length / 2, length / 2, numdataX)
z0 = np.linspace(0, longitud, numdataZ)
wavelength = 0.55 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(A=1,
r0=(0 * um, 0 * um),
w0=(radiusFibra / 1, radiusFibra / 1),
z0=0,
theta=0. * degrees,
phi=0 * degrees)
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(radiusFibra, radiusFibra),
angle=0 * degrees)
u2 = u1 * t1
uxyz = Scalar_mask_XYZ(x=x0,
y=y0,
z=z0,
wavelength=wavelength,
n_background=1.,
info='')
uxyz.incident_field(u2)
# uxyz.cylinder(
# r0=(0 * um, 0 * um, 0),
# radius=(2 * radiusFibra, 2 * radiusFibra),
# length=longitud,
# refraction_index=2)
uxyz.BPM()
uxyz.draw_XYZ(logarithm=True, normalize='maximum')
uxyz.draw_refraction_index()
uxyz.draw_XZ(y0=0.01,
logarithm=True,
normalize='false',
draw_borders=False)
# uxyz.draw_volume(logarithm=True, normalize='maximum')
uxyz.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
return uxyz
def test_video(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 80 * um
numdataX = 32
numdataZ = 32
longitud = 50 * um
radiusFibra = 10 * um
x0 = np.linspace(-length / 2, length / 2, numdataX)
y0 = np.linspace(-length / 2, length / 2, numdataX)
z0 = np.linspace(0, longitud, numdataZ)
wavelength = 2 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.plane_wave()
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(4 * radiusFibra, 2 * radiusFibra),
angle=45 * degrees)
u2 = u1 * t1
uxyz = Scalar_mask_XYZ(x=x0,
y=y0,
z=z0,
wavelength=wavelength,
n_background=1.,
info='')
uxyz.incident_field(u2)
uxyz.BPM()
uxyz.video(filename=filename + '.avi', kind='intensity', frame=False)
uxyz.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_xy_2_xyz(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 200 * um
numdata = 32
x0 = np.linspace(-length / 2, length / 2, numdata)
y0 = np.linspace(-length / 2, length / 2, numdata)
z0 = np.linspace(.1 * mm, .2 * mm, 64)
wavelength = 0.6328 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.plane_wave()
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.square(r0=(0 * um, 0 * um),
size=(20 * um, 20 * um),
angle=0 * degrees)
t2 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t2.ronchi_grating(period=10 * um, x0=20 * um, angle=0 * degrees)
u2 = u1 * t1 * t2
u2.draw()
fields_XY = []
for i in range(len(z0)):
u3 = u2.RS(z=z0[i], new_field=True)
fields_XY.append(u3)
z0p = np.linspace(1 * mm, 7 * mm, numdata)
uxyz = Scalar_field_XYZ(x=x0, y=y0, z=z0p, wavelength=wavelength)
uxyz.incident_field(u2)
uxyz.xy_2_xyz(fields_XY, z0)
# uxyz.draw_volume()
uxyz.video(filename=filename + '.avi', kind='intensity', frame=True)
u3.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_cut_resample(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 50 * um
numdataX = 32
numdataZ = 32
longitud = 512 * um
radiusFibra = 25 * um
x0 = np.linspace(-length, length, numdataX)
y0 = np.linspace(-length, length, numdataX)
z0 = np.linspace(0, longitud, numdataZ)
wavelength = 0.55 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.plane_wave()
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(radiusFibra, radiusFibra),
angle=0 * degrees)
u2 = u1 * t1
uxyz = Scalar_mask_XYZ(x=x0,
y=y0,
z=z0,
wavelength=wavelength,
n_background=1.,
info='')
uxyz.incident_field(u2)
uxyz.sphere(r0=(0 * um, 0 * um, radiusFibra),
radius=(radiusFibra, radiusFibra, radiusFibra),
refraction_index=2,
angles=(0, 0, 0))
# uxyz.draw_refraction_index()
uxyz.draw_XYZ()
uxyz2 = uxyz.cut_resample(x_limits=(-25 * um, 25 * um),
y_limits=(-25 * um, 25 * um),
z_limits=(0 * um, 250 * um),
num_points=[],
new_field=True,
interp_kind=(3, 1))
uxyz2.draw_XYZ()
# uxyz2.draw_refraction_index()
uxyz2.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
-13 -2.7377
-12.5 -5.3664
-12 -6.7107
-11.5 -7.6529
-11 -8.3366
-10.5 -8.8504
-10 -9.3111
-9.5 -9.6747
-9 -9.9809
-8.5 -10.2391
-8 -10.4564
-7.5 -10.6546
-7 -10.786
-6.5 -10.9072
-6 -11.0022
-5.5 -11.0741
-5 -11.1238
-4.5 -11.1711
-4 -11.1711
-3.5 -11.172
-3 -11.1594
-2.5 -11.1366
-2 -11.1043
-1.5 -11.0755
-1 -11.0454
-0.5 -11.0269
0 -11.02
0.5 -11.0269
1 -11.0454
1.5 -11.0755
2 -11.1043
2.5 -11.1366
3 -11.1594
3.5 -11.172
4 -11.1711
4.5 -11.1711
5 -11.1238
5.5 -11.0741
6 -11.0022
6.5 -10.9072
7 -10.786
7.5 -10.6546
8 -10.4564
8.5 -10.2391
9 -9.9809
9.5 -9.6747
10 -9.3111
10.5 -8.8504
11 -8.3366
11.5 -7.6529
12 -6.7107
12.5 -5.3664
13 -2.7377
-11.5 -0.1014
-11 -0.9674
-10.5 -1.8335
-10 -2.6995
-9.5 -3.5655
-9 -4.4315
-8.5 -5.2878
-8 -6.02
-7.5 -6.6344
-7 -7.1614
-6.5 -7.6193
-6 -8.02
-5.5 -8.3716
-5 -8.6803
-4.5 -8.9503
-4 -9.1852
-3.5 -9.3875
-3 -9.5594
-2.5 -9.7025
-2 -9.818
-1.5 -9.9069
-1 -9.9699
-0.5 -10.0075
0 -10.02
0.5 -10.0075
1 -9.9699
1.5 -9.9069
2 -9.818
2.5 -9.7025
3 -9.5594
3.5 -9.3875
4 -9.1852
4.5 -8.9503
5 -8.6803
5.5 -8.3716
6 -8.02
6.5 -7.6193
7 -7.1614
7.5 -6.6344
8 -6.02
8.5 -5.2878
9 -4.4315
9.5 -3.5655
10 -2.6995
10.5 -1.8335
11 -0.9674
11.5 -0.1014

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""tests for scalar_fields_X"""
import copyreg
import datetime
import os
import sys
import time
import types
import numpy as np
from diffractio import degrees, mm, no_date, num_max_processors, plt, um
from diffractio.scalar_fields_X import (Scalar_field_X,
extended_polychromatic_source,
extended_source_multiprocessing,
polychromatic_multiprocessing)
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.utils_multiprocessing import (_pickle_method, _unpickle_method,
execute_multiprocessing)
from diffractio.utils_optics import gauss_spectrum
from diffractio.utils_tests import save_figure_test
copyreg.pickle(types.MethodType, _pickle_method, _unpickle_method)
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_fields_X"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
def __experiment_extended_source__(x0):
x = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.850 * um
z0 = -500 * mm
period = 50 * um
focal = 5 * mm
red = Scalar_mask_X(x, wavelength)
red.ronchi_grating(x0=0 * um, period=period, fill_factor=0.5)
lens = Scalar_mask_X(x, wavelength)
lens.lens(x0=0, focal=focal, radius=30 * mm)
u1 = Scalar_source_X(x, wavelength)
u1.spherical_wave(A=1., x0=x0, z0=z0, normalize=True)
u2 = u1 * red * lens
u2.RS(z=focal, new_field=False, verbose=False)
return u2
def __function_polychromatic__(wavelength):
x0 = np.linspace(-75 * um, 75 * um, 1024 * 8)
t1 = Scalar_mask_X(x0, wavelength)
t1.slit(x0=0, size=100 * um)
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(x0=0 * um, w0=200 * um, z0=0 * um, A=1, theta=0. * degrees)
u1 = f1 * t1
u1.RS(z=10 * um, new_field=False, verbose=False)
return u1
def __experiment_grating_movement__(dict_params):
delta_x = dict_params['delta_x']
period = dict_params['period']
t1 = dict_params['t1']
t2 = dict_params['t2']
t2.ronchi_grating(period=period, x0=delta_x, fill_factor=0.5)
u2 = t1 * t2
return u2
class Test_Scalar_fields_X(object):
def test_extended_source_simple(self):
"""
tomamos una red de difraccion y analizamos el efecto Lau con fuente extensa
La fuente extensa la definimos como suma de fuentes puntuales esfericas
Esquema: Fuente extensa, red, lens, vista en plano focal
"""
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
# definiciones
x = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.850 * um
num_fuentes = 101
S = 3000 * um
z0 = -500 * mm
period = 50 * um
focal = 5 * mm
red = Scalar_mask_X(x, wavelength)
red.ronchi_grating(x0=0 * um, period=period, fill_factor=0.5)
lens = Scalar_mask_X(x, wavelength)
lens.lens(x0=0, focal=focal, radius=30 * mm)
u1 = Scalar_source_X(x, wavelength)
# posiciones de la fuente
x0s = np.linspace(-S / 2, S / 2, num_fuentes)
intensities = Scalar_field_X(x, wavelength)
time1 = time.time()
for x0 in x0s:
u1.spherical_wave(A=1, x0=x0, z0=z0, normalize=True)
u2 = u1 * lens * red
u2.RS(z=focal, new_field=False, verbose=False)
intensities.u = intensities.u + abs(u2.u)**2
intensities.u = intensities.u / intensities.u.max()
time_proc = time.time() - time1
print("num_proc: {}, time={}".format(1, time_proc))
intensities.draw(kind='amplitude')
save_figure_test(newpath, func_name)
assert True
def test_polychromatic(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
wavelengths = np.linspace(.3 * um, .9 * um, 101)
w_central = wavelengths.mean()
spectrum_gauss = gauss_spectrum(wavelengths=wavelengths,
w_central=w_central,
Dw=0.4,
normalize=True)
intensity, u_s, time_proc = polychromatic_multiprocessing(
__function_polychromatic__,
wavelengths,
spectrum_gauss,
num_processors=num_max_processors,
verbose=True)
intensity0, u_s0, time_proc0 = polychromatic_multiprocessing(
__function_polychromatic__,
w_central,
1,
num_processors=1,
verbose=True)
plt.figure()
plt.plot(u_s0.x, intensity0, 'k', lw=2, label='monochromatic')
plt.plot(u_s[0].x, intensity, 'r', lw=2, label='polychromatic')
plt.legend()
save_figure_test(newpath, func_name)
assert True
def test_extended_source_multiprocessing(self):
"""Tomamos una red de difraccion y analizamos el efecto Lau con fuente extensa
La fuente extensa la definimos como suma de fuentes puntuales esfericas
Esquema: Fuente extensa, red, lens, vista en plano focal
"""
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
x0s = np.linspace(-1500 * um, 1500 * um, 101)
x0_central = 0 * um
intensity, u_s, time_proc = extended_source_multiprocessing(
__experiment_extended_source__,
x0s,
num_processors=num_max_processors,
verbose=True)
intensity0, u_s0, time_proc0 = extended_source_multiprocessing(
__experiment_extended_source__,
x0_central,
num_processors=1,
verbose=True)
plt.figure()
plt.plot(u_s0.x, intensity0, 'k', lw=2, label='punctual source')
plt.plot(u_s[0].x, intensity, 'r', lw=2, label='extended source')
plt.legend()
save_figure_test(newpath, func_name)
assert True
def test_grating_movement(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
def creation_dictionary(deltas_x, period, t1, t2):
# create Parameters: for multiprocessing
dict_Parameters = []
for i, delta_x in enumerate(deltas_x):
dict_Parameters.append(
dict(delta_x=delta_x, period=period, t1=t1, t2=t2))
return dict_Parameters
x0 = np.linspace(-400 * um, 400 * um, 1024 * 8)
wavelength = 0.85 * um
period = 50 * um
z_talbot = 2 * period**2 / wavelength
z0 = z_talbot / 2
delay = 0.001
t1 = Scalar_mask_X(x0,
wavelength,
info="__experiment_grating_movement__")
t1.ronchi_grating(period=period, x0=0 * um, fill_factor=0.5)
t1.RS(z=z0, new_field=False)
t2 = Scalar_mask_X(x0,
wavelength,
info="__experiment_grating_movement__")
t2.ronchi_grating(period=period, x0=0 * um, fill_factor=0.5)
deltas_x = np.linspace(-60 * um, 60 * um, 51) # 512
num_processors = num_max_processors
dict_Parameters = creation_dictionary(deltas_x=deltas_x,
period=period,
t1=t1,
t2=t2)
u_s, time_proc = execute_multiprocessing(
__experiment_grating_movement__,
dict_Parameters,
num_processors,
verbose=True)
x = u_s[0].x
perfil = np.zeros_like(deltas_x)
fig = plt.figure()
ax1 = fig.add_subplot(211)
h1, = ax1.plot(x, np.zeros_like(x), 'k', lw=2)
ax1.set_xlim(x[0], x[-1])
ax1.set_ylim(0, 2)
ax1.set_xlabel(r'$x (\mu m)$')
ax2 = fig.add_subplot(212)
h2, = ax2.plot(deltas_x, perfil, 'k', lw=2)
ax2.set_xlim(deltas_x[0], deltas_x[-1])
ax2.set_ylim(0, .5)
ax2.set_xlabel(r'$\Delta x (\mu m)$')
incr_frames = 1
for i in range(0, len(deltas_x), incr_frames):
intensidad = abs(u_s[i].u)**2 # sacar fuera
perfil[i] = intensidad.mean()
plt.suptitle(r"$\delta x={:6.2f}\,\mu m$".format(deltas_x[i]),
fontsize=18)
h1.set_ydata(intensidad)
h2.set_ydata(perfil)
plt.draw()
plt.pause(delay)
plt.pause(0.25)
save_figure_test(newpath, func_name)
assert True
def __experiment_double_slit_dictionary__(dict_params):
x0 = dict_params['x0']
wavelength = dict_params['wavelength']
z = dict_params['z']
slit_size = dict_params['slit_size']
separation = dict_params['separation']
t1 = Scalar_mask_X(x0, wavelength)
t1.slit(x0=0, size=20 * um)
t1.double_slit(x0=0, size=slit_size, separation=separation)
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(x0=0 * um, w0=200 * um, z0=0 * um, A=1, theta=0. * degrees)
u1 = f1 * t1
u1.RS(z, new_field=False, verbose=False)
return u1
def __experiment_double_slit_array__(slit_size):
x0 = np.linspace(-75 * um, 75 * um, 1024 * 8)
wavelength = 0.6328 * um
separation = 50 * um
z = 100 * um
t1 = Scalar_mask_X(x0, wavelength)
t1.slit(x0=0, size=20 * um)
t1.double_slit(x0=0, size=slit_size, separation=separation)
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(x0=0 * um, w0=200 * um, z0=0 * um, A=1, theta=0. * degrees)
u1 = f1 * t1
u1.RS(z, new_field=False, verbose=False)
return u1
def __experiment_extended_polychromatic_source__(dict_params):
wavelength = dict_params['wavelength']
x0 = dict_params['x0']
x = np.linspace(-1250 * um, 1250 * um, 1024 * 8)
periodo = 100 * um
z = 5 * periodo**2 / (0.6 * um)
z0 = -50 * mm
t1 = Scalar_mask_X(x, wavelength)
t1.ronchi_grating(period=periodo, x0=0 * um, fill_factor=0.5)
f1 = Scalar_source_X(x, wavelength)
f1.spherical_wave(A=1, x0=x0, z0=z0, normalize=True)
u1 = f1 * t1
u1.RS(z, new_field=False, verbose=False)
return u1
class Test_Scalar_fields_X_multiprocessing(object):
def test_multiprocessing_dictionary(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
def creation_dictionary(wavelengths, x0, z, slit_size, separation):
# create Parameters: for multiprocessing
dict_Parameters = []
for i, wavelength in enumerate(wavelengths):
dict_Parameters.append(
dict(x0=x0,
wavelength=wavelength,
z=z,
slit_size=slit_size,
separation=separation))
return dict_Parameters
x0 = np.linspace(-100 * um, 100 * um, 1024)
wavelengths = np.linspace(0.3 * um, 0.8 * um, 101)
spectrum_gauss = gauss_spectrum(wavelengths=wavelengths,
w_central=0.6,
Dw=0.1,
normalize=True)
num_processors = num_max_processors
dict_Parameters0 = dict(x0=x0,
wavelength=0.6 * um,
z=.05 * mm,
slit_size=50 * um,
separation=75 * um)
dict_Parameters = creation_dictionary(wavelengths=wavelengths,
x0=x0,
z=.05 * mm,
slit_size=50 * um,
separation=75 * um)
I0 = __experiment_double_slit_dictionary__(dict_Parameters0)
I_wavelengths, time_proc = execute_multiprocessing(
__experiment_double_slit_dictionary__,
dict_Parameters,
num_processors,
verbose=False)
print("num_proc= {}, time={}".format(num_processors, time_proc))
intensity = np.zeros_like(I_wavelengths[0].x)
for i in range(len(wavelengths)):
intensity = intensity + spectrum_gauss[i] * abs(
I_wavelengths[i].u)**2
plt.figure()
plt.plot(x0, abs(I0.u)**2, 'k', lw=2, label='monochromatic')
plt.plot(x0, intensity, 'r', lw=2, label='polychromatic')
plt.title('polychromatic')
plt.legend()
save_figure_test(newpath, func_name)
assert True
def test_multiprocessing_array(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
slit_sizes = np.linspace(5 * um, 50 * um, 10)
num_processors = num_max_processors
u_s, time_proc = execute_multiprocessing(
__experiment_double_slit_array__,
slit_sizes,
num_processors,
verbose=True)
plt.figure()
ax = plt.subplot(111)
for i, slit_size in enumerate(slit_sizes):
ax.plot(u_s[i].x,
abs(u_s[i].u)**2 + 2 * i,
lw=2,
label=r"${:2.2f}\,\mu m$".format(slit_size))
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
# Put a legend to the right of the current axis
ax.legend(fontsize=8,
frameon=False,
loc='center left',
bbox_to_anchor=(1, 0.5))
save_figure_test(newpath, func_name)
assert True
def test_extended_polychromatic_source(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
x0s = np.linspace(-150 * um, 150 * um, 21)
wavelengths = np.linspace(.45 * um, .65 * um, 11)
w_central = wavelengths.mean()
spectrum_gauss = gauss_spectrum(wavelengths=wavelengths,
w_central=w_central,
Dw=0.4,
normalize=True)
u0 = __experiment_extended_polychromatic_source__(
dict(x0=0, wavelength=w_central))
intensity, u_s, time_proc = extended_polychromatic_source(
__experiment_extended_polychromatic_source__,
x0s,
wavelengths,
spectrum_gauss,
num_processors=num_max_processors,
verbose=True)
plt.figure()
plt.plot(u_s[0].x, abs(u0.u)**2, 'k', lw=1, label='mono')
plt.plot(u_s[0].x, intensity, 'r', lw=2, label='LED')
plt.legend()
save_figure_test(newpath, func_name)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""tests for scalar_fields_X"""
import copyreg
import datetime
import os
import sys
import types
import numpy as np
from diffractio import eps, no_date, plt, um
from diffractio.scalar_fields_X import Scalar_field_X
from diffractio.utils_multiprocessing import _pickle_method, _unpickle_method
from diffractio.utils_tests import comparison, save_figure_test
copyreg.pickle(types.MethodType, _pickle_method, _unpickle_method)
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_fields_X"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_fields_X(object):
def test_add(self):
pass
def test_sub(self):
pass
def test_mul(self):
pass
def test_clear_field(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-50 * um, 50 * um, 128)
wavelength = 1 * um
t1 = Scalar_field_X(x, wavelength)
t1.u = np.ones_like(x, dtype=complex)
t1.save_data(filename=filename+'.npz')
solution = np.zeros_like(t1.u)
t1.clear_field()
proposal = t1.u
assert comparison(proposal, solution, eps), func_name
def test_save_load(self):
"""
Tests save in savez and other functions
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}.'.format(newpath, func_name)
x = np.linspace(-500 * um, 500 * um, 512)
wavelength = .5 * um
t1 = Scalar_field_X(x, wavelength)
t1.u = np.sin(x**2 / 5000)
t1.draw()
save_figure_test(newpath, func_name, add_name='_saved')
t1.save_data(filename=filename+'.npz')
t2 = Scalar_field_X(x, wavelength)
t2.load_data(filename=filename+'.npz')
t2.draw()
save_figure_test(newpath, func_name, add_name='_loaded')
assert True
def test_cut_resample(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x1 = np.linspace(-500 * um, 500 * um, 512)
wavelength = .5 * um
t1 = Scalar_field_X(x1, wavelength)
t1.u = np.sin(2 * np.pi * x1 / 50)
t1.draw()
t1.save_data(filename=filename)
save_figure_test(newpath, func_name, add_name='_1')
t2 = t1.cut_resample(
x_limits=(-250 * um, 250 * um),
num_points=1024,
new_field=True,
interp_kind='quadratic')
t2.draw()
save_figure_test(newpath, func_name, add_name='_2')
t2.save_data(filename=filename + '2'+'.npz')
solution = np.array((512, 1024))
proposal = np.array((len(t1.u), len(t2.u)))
assert comparison(proposal, solution, eps), func_name
def test_insert_mask(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x1 = np.linspace(-500 * um, 500 * um, 512)
wavelength = .5 * um
t1 = Scalar_field_X(x1, wavelength)
t1.clear_field()
x2 = np.linspace(-50 * um, 50 * um, 512)
wavelength = .5 * um
t2 = Scalar_field_X(x2, wavelength)
t2.u = np.sin(2 * np.pi * x2 / 50)
t1.insert_mask(
t2, x0_mask1=-100 * um, clean=False, kind_position='center')
t1.insert_mask(
t2, x0_mask1=100 * um, clean=False, kind_position='center')
t1.draw()
t1.save_data(filename=filename+'.npz')
save_figure_test(newpath, func_name)
assert True, func_name
def test_insert_array_mask(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x1 = np.linspace(-750 * um, 750 * um, 512)
wavelength = .5 * um
t1 = Scalar_field_X(x1, wavelength)
t1.clear_field()
x2 = np.linspace(-50 * um, 50 * um, 512)
wavelength = .5 * um
t2 = Scalar_field_X(x2, wavelength)
t2.u = np.sin(2 * np.pi * x2 / 50)
t1.insert_array_masks(
t2,
x_pos=[-400, -200, 0, 200, 400],
clean=True,
kind_position='center')
t1.draw()
t1.save_data(filename=filename+'.npz')
save_figure_test(newpath, func_name, add_name='_1')
assert True, func_name
def test_transitions(self):
"""
test a binary mask and obtain positions of transitions
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x1 = np.linspace(-750 * um, 750 * um, 4096)
x2 = np.linspace(-50 * um, 50 * um, 4096)
wavelength = .5 * um
t2 = Scalar_field_X(x2, wavelength)
t2.u = np.ones_like(x2, dtype=complex)
t1 = Scalar_field_X(x1, wavelength)
t1.insert_array_masks(
t2,
x_pos=[-400, -200, 0, 200, 400],
clean=True,
kind_position='center')
pos_transitions, type_transitions, raising, falling = t1.get_edges(
kind_transition='amplitude', min_step=.05)
print(pos_transitions)
print(type_transitions)
t1.draw(kind='intensity')
t1.save_data(filename=filename+'.npz')
save_figure_test(newpath, func_name)
solution = np.linspace(-450 * um, 450 * um, 10)
proposal = pos_transitions
assert comparison(proposal, solution, 1), func_name
assert True
def test_fft(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-500 * um, 500 * um, 256)
wavelength = 1 * um
x = np.linspace(-500 * um, 500 * um, 128)
wavelength = .5 * um
t1 = Scalar_field_X(x, wavelength)
t1.u = np.sin(2 * np.pi * x / 100)
t2 = t1.fft(
z=None,
shift=True,
remove0=False,
matrix=False,
new_field=True,
verbose=False)
t2.draw()
save_figure_test(newpath, func_name, add_name='_1')
t2.save_data(filename=filename+'.npz')
assert True
def test_ifft(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-500 * um, 500 * um, 256)
wavelength = 1 * um
x = np.linspace(-500 * um, 500 * um, 128)
wavelength = .5 * um
t1 = Scalar_field_X(x, wavelength)
t1.u = np.sin(2 * np.pi * x / 100)
t1.save_data(filename=filename + '_direct'+'.npz')
t2 = t1.fft(
z=None,
shift=True,
remove0=False,
matrix=False,
new_field=True,
verbose=False)
t2.draw()
save_figure_test(newpath, func_name, add_name='_direct')
t3 = t2.ifft(
z=None,
shift=True,
remove0=False,
matrix=False,
new_field=True,
verbose=False)
t3.draw()
save_figure_test(newpath, func_name, add_name='_ifft')
t3.save_data(filename=filename + '_ifft'+'.npz')
assert True
def test_RS(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 4096
x = np.linspace(-500 * um, 500 * um, num_data)
wavelength = 1 * um
t1 = Scalar_field_X(x, wavelength)
t1.u[np.bitwise_and(x > -200 * um, x < 200 * um)] = 1
t1.draw()
save_figure_test(newpath, func_name, add_name='_mask')
u1 = t1.RS(z=2000 * um, new_field=True)
u1.draw(kind='intensity')
u1.save_data(filename=filename + '2'+'.npz')
save_figure_test(newpath, func_name, add_name='_RS')
assert True
def test_RS_amplification(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 4096
x = np.linspace(-500 * um, 500 * um, num_data)
wavelength = 1 * um
t1 = Scalar_field_X(x, wavelength)
t1.u[np.bitwise_and(x > -200 * um, x < 200 * um)] = 1
t1.draw()
save_figure_test(newpath, func_name, add_name='_mask')
u1 = t1.RS(z=2000 * um, new_field=True, amplification=3)
u1.draw(kind='intensity')
t1.save_data(filename=filename + '2'+'.npz')
save_figure_test(newpath, func_name, add_name='_RS*3')
assert True
def test_BPM(self):
pass
def test_MTF(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024 * 8
x = np.linspace(-50 * um, 50 * um, num_data)
wavelength = 0.6328 * um
# intensidad de una onda plana
u0 = Scalar_field_X(x, wavelength)
u0.u[np.bitwise_and(x > -4 * um, x < 4 * um)] = 1
u0.draw(kind='intensity')
save_figure_test(newpath, func_name, add_name='_mask')
u0.save_data(filename=filename + '_mask'+'.npz')
u0.MTF(kind='mm', has_draw=True)
plt.xlim(-250, 250)
save_figure_test(newpath, func_name, add_name='_mtf')
assert True
def test_intesity(self):
pass
def test_average_intensity(self):
pass
def test_draw(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-500 * um, 500 * um, 4096)
wavelength = .5 * um
t1 = Scalar_field_X(x, wavelength)
t1.u = np.sin(2 * np.pi * x / 100) * np.exp(1j * 2 * np.pi * x / 100)
t1.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amp')
t1.draw(kind='intensity')
save_figure_test(newpath, func_name, add_name='_int')
t1.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
t1.draw(kind='fill')
save_figure_test(newpath, func_name, add_name='_fill')
t1.draw(kind='field')
t1.save_data(filename=filename+'.npz')
save_figure_test(newpath, func_name, add_name='_field')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import os
import sys
import time
from diffractio import degrees, eps, mm, no_date, np, plt, um
from diffractio.scalar_fields_XY import Scalar_field_XY
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.utils_drawing import draw_several_fields
from diffractio.utils_tests import comparison, save_figure_test
try:
import screeninfo
except:
print("screeninfo not imported.")
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_fields_XY"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
def gauss_beam_test():
x0 = np.linspace(-100, 100, 256)
y0 = np.linspace(-100, 100, 256)
wavelength = 0.6328
field = Scalar_source_XY(x0, y0, wavelength)
field.gauss_beam(w0=(50 * um, 50 * um),
r0=(0, 0),
z0=0,
theta=0 * degrees,
phi=0 * degrees)
return field
def gauss_beam_narrow_test():
x0 = np.linspace(-100, 100, 256)
y0 = np.linspace(-100, 100, 256)
wavelength = 0.6328
field = Scalar_source_XY(x0, y0, wavelength)
field.gauss_beam(w0=(5 * um, 5 * um),
r0=(0, 0),
theta=0 * degrees,
z0=0,
phi=0 * degrees)
return field
def plane_wave_test():
x0 = np.linspace(-100, 100, 256)
y0 = np.linspace(-100, 100, 256)
wavelength = 0.6328
field = Scalar_source_XY(x0, y0, wavelength)
field.plane_wave(A=1, theta=0 * degrees, phi=0 * degrees)
return field
def square_test():
x0 = np.linspace(-100, 100, 256)
y0 = np.linspace(-100, 100, 256)
wavelength = 0.6328
t = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t.square(r0=(0 * um, 0 * um), size=(100 * um, 100 * um), angle=0 * degrees)
return t
field_gauss = gauss_beam_test()
field_gauss_narrow = gauss_beam_narrow_test()
square = square_test()
plane_wave = plane_wave_test()
class Test_Scalar_fields_XY(object):
def test_add(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
t1 = field_gauss
t2 = field_gauss
t1.draw(kind='amplitude', has_colorbar='horizontal')
save_figure_test(newpath, func_name, add_name='_1')
t = t1 + t2
t.draw(kind='amplitude', has_colorbar='horizontal')
proposal = 2 * t1.u
solution = t.u
save_figure_test(newpath, func_name, add_name='_2')
assert comparison(proposal, solution, eps)
def test_sub(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
t1 = field_gauss
t2 = field_gauss
t1.draw(kind='amplitude', has_colorbar='horizontal')
save_figure_test(newpath, func_name, add_name='_1')
t = t1 - t2
t.draw(kind='amplitude', has_colorbar='horizontal')
proposal = 0 * t1.u
solution = t.u
save_figure_test(newpath, func_name, add_name='_2')
assert comparison(proposal, solution, eps)
def test_mult(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u0 = field_gauss
t0 = square
u1 = u0 * t0
u1.draw(kind='intensity', has_colorbar='horizontal')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_rotate(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
t0 = square
t0.draw(kind='intensity', has_colorbar='horizontal')
save_figure_test(newpath, func_name, add_name='_00')
t0.rotate(angle=45 * degrees, position=(-50, -50))
t0.draw(kind='intensity', has_colorbar='horizontal')
save_figure_test(newpath, func_name, add_name='_45')
assert True
def test_clear_field(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u0 = field_gauss
proposal = 0 * u0.u
u0.clear_field()
solution = u0.u
u0.draw(kind='intensity', has_colorbar='horizontal')
plt.clim(0, 1)
save_figure_test(newpath, func_name, add_name='')
assert comparison(proposal, solution, eps)
def test_save_load(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-100, 100, 256)
y = np.linspace(-100, 100, 256)
wavelength = 0.6328
t1 = Scalar_source_XY(x, y, wavelength)
t1.gauss_beam(w0=(50 * um, 50 * um),
r0=(0, 0),
z0=0,
theta=0 * degrees,
phi=0 * degrees)
t1.draw()
save_figure_test(newpath, func_name, add_name='_saved')
t1.save_data(filename=filename + '.npz')
time.sleep(1)
t2 = Scalar_field_XY(x, y, wavelength)
t2.load_data(filename=filename + '.npz')
t2.draw()
save_figure_test(newpath, func_name, add_name='_loaded')
assert True
def test_cut_resample(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u0 = field_gauss_narrow
u0.draw(kind='intensity')
save_figure_test(newpath, func_name, add_name='_0before')
u0.cut_resample(x_limits=(-10 * um, 10 * um),
y_limits=(-10 * um, 10 * um),
num_points=(512, 512),
new_field=False)
u0.draw(kind='intensity')
save_figure_test(newpath, func_name, add_name='_1after')
assert True
def test_fft(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
field = field_gauss_narrow
fieldfft1 = field.fft(z=0.1 * mm,
remove0=False,
shift=True,
matrix=False,
new_field=True)
fieldfft1.draw(kind='intensity')
fieldfft1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_RS(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 160 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 1, length / 1, 2 * num_data)
wavelength0 = 0.6238 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
u1.plane_wave(A=1, theta=0 * degrees, phi=0 * degrees)
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength0)
t1.square(r0=(0 * um, 0 * um),
size=(40 * um, 40 * um),
angle=0 * degrees)
u2 = u1 * t1
u2.draw()
u3 = u2.RS(z=4 * mm, new_field=True)
u3.draw(kind='field')
u4 = u3.RS(z=-2 * mm, new_field=True)
u4.draw(kind='field')
u4.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_RS_amplification(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
num_pixels = 256
lengthx = 200 * um
lengthy = 200 * um
wavelength = 0.6238 * um
x0 = np.linspace(-lengthx / 2, lengthx / 2, num_pixels)
y0 = np.linspace(-lengthy / 2, lengthy / 2, num_pixels)
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(r0=(0., 0.), w0=100 * um, z0=0, A=1, theta=0, phi=0)
u2 = u1.RS(amplification=(2, 3), z=1 * mm)
u2.draw('field')
u2.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_profile(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
field = gauss_beam_test()
p1 = [0, 0]
p2 = [field.x[0], field.y[0]]
h, z_profile, point1, point2 = field.profile(point1=p1,
point2=p2,
kind='intensity',
order=1)
field.draw_profile(point1=p1, point2=p2, kind='intensity', order=1)
save_figure_test(newpath, func_name, add_name='_prof')
field.draw()
plt.plot([p1[0], p2[0]], [p1[1], p2[1]], 'r', linewidth=2)
save_figure_test(newpath, func_name, add_name='')
assert True
def test_profile_manual(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
field = gauss_beam_test()
h, z_profile, point1, point2 = field.draw_profile(point1='',
point2='',
kind='intensity',
order=1)
field.draw()
plt.plot([point1[0], point2[0]], [point1[1], point2[1]],
'r',
linewidth=2)
save_figure_test(newpath, func_name, add_name='')
field.draw_profile(point1=point1,
point2=point2,
kind='intensity',
order=1)
save_figure_test(newpath, func_name, add_name='_prof')
assert True
def test_search_focus(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u = gauss_beam_narrow_test()
solution = np.array(u.search_focus())
proposal = np.array([0, 0])
assert comparison(proposal, solution, 2 * um)
def test_MTF(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u = gauss_beam_narrow_test()
u.draw()
save_figure_test(newpath, func_name, add_name='_field')
u.MTF(has_draw=True)
save_figure_test(newpath, func_name, add_name='_mtf')
def test_average_intensity(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
u = gauss_beam_narrow_test()
inten1 = u.average_intensity(verbose=True)
print(inten1)
assert True
def test_send_image_screen(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
screens = screeninfo.get_monitors()
id_screen = 0 # 1
pixel_size_x = 20 * um
pixel_size_y = 20 * um
num_pixels_x = screens[id_screen].width
num_pixels_y = screens[id_screen].height
# Definition of input parameters
x0 = np.linspace(-pixel_size_x * num_pixels_x / 2,
pixel_size_x * num_pixels_x / 2, num_pixels_x)
y0 = np.linspace(-pixel_size_y * num_pixels_y / 2,
pixel_size_y * num_pixels_y / 2, num_pixels_y)
wavelength = 0.6238 * um
t = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t.circle(r0=(0, 0), radius=(500 * um, 500 * um), angle=0 * degrees)
t.lens(r0=(0, 0),
focal=(1000 * mm, 1000 * mm),
radius=(10 * mm, 10 * mm),
angle=0 * degrees)
t.send_image_screen(id_screen, kind='phase')
assert True
def test_get_amplitude(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength = 0.6328 * um
# field total
field = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field.spherical_wave(r0=(0, 0), z0=-1 * mm)
field.draw(kind='field')
real_field = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
real_field.u = field.get_amplitude(matrix=True)
real_field.draw(kind='field')
# Generando fields news
real_fieldNuevo = field.get_amplitude(new_field=True)
real_fieldNuevo.draw(kind='field')
# en el mismo field de entrada
field.get_amplitude()
field.draw(kind='field')
field.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_get_phase(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength = 0.6328 * um
# field total
field = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field.spherical_wave(r0=(0, 0), z0=-1 * mm)
field.draw(kind='field')
fieldImag = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
fieldImag.u = field.get_phase(matrix=True)
fieldImag.draw(kind='field')
fieldImagNuevo = field.get_phase(new_field=True)
fieldImagNuevo.draw(kind='field')
# en el mismo field de entrada
field.get_phase()
field.draw(kind='field')
# no se ve nada, porque se ha quitado la amplitude y la phase
field.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_remove_phase(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength = 0.6 * um
# field total
field = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field.spherical_wave(r0=(0, 0), z0=-1 * mm)
field.draw(kind='field')
field.remove_phase(sign=False)
field.draw(kind='field')
field.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
solution = np.angle(field.u).sum()
proposal = 0
assert comparison(proposal, solution, eps)
assert True
def test_binarizeAmplitud(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength = 0.6 * um
# field total
field = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
field.gray_scale(num_levels=255, levelMin=0, levelMax=1)
field.draw(kind='intensity', normalize=None)
field.binarize(kind="amplitude",
bin_level=0.5,
level0=0,
level1=1,
new_field=False,
matrix=False)
field.draw(kind='intensity', normalize=None)
field.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_binarizeFase(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
wavelength = 0.6 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
# field total
field = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field.spherical_wave(r0=(0, 0), z0=-1 * mm)
field.draw(kind='phase', normalize=None)
field2 = field.binarize(kind="phase",
bin_level=None,
level0=None,
level1=None,
new_field=True,
matrix=False)
field2.draw(kind='phase', normalize=None)
field3 = field.binarize(kind="phase",
bin_level=0,
level0=-np.pi / 2,
level1=np.pi / 2,
new_field=True,
matrix=False)
field3.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_discretize_1(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
# amplitude
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
# field total
field = Scalar_mask_XY(x=x0, y=y0)
field.gray_scale(num_levels=255, levelMin=0, levelMax=1)
field.draw(kind='field')
fieldAmplitud = field.discretize(kind='amplitude',
num_levels=2,
factor=1,
new_field=True,
matrix=False)
fieldAmplitud.draw(kind='field')
fieldAmplitud = field.discretize(kind='amplitude',
num_levels=2,
factor=.5,
new_field=True,
matrix=False)
fieldAmplitud.draw(kind='field')
fieldAmplitud = field.discretize(kind='amplitude',
num_levels=3,
factor=1,
new_field=True,
matrix=False)
fieldAmplitud.draw(kind='field')
fieldAmplitud = field.discretize(kind='amplitude',
num_levels=4,
factor=1,
new_field=True,
matrix=False)
fieldAmplitud.draw(kind='field')
fieldAmplitud = field.discretize(kind='amplitude',
num_levels=4,
factor=.5,
new_field=True,
matrix=False)
fieldAmplitud.draw(kind='field')
fieldAmplitud.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_discretize_2(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
# phase
from diffractio.scalar_masks_XY import Scalar_mask_XY
length = 250 * um
wavelength = 0.6 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
# field total
field = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
field.gray_scale(num_levels=255, levelMin=0, levelMax=1)
field.set_phase(q=1, phase_min=-np.pi, phase_max=np.pi)
field.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=2,
factor=1,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=2,
factor=.5,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=4,
factor=1,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=4,
factor=.5,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_discretize_3(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
# lens
length = 250 * um
wavelength = 0.6 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
# field total
field = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
field.lens(r0=(0 * um, 0 * um),
radius=(150 * um, 150 * um),
focal=(2 * mm, 2 * mm),
angle=0 * degrees)
field.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=2,
factor=1,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
field.lens(r0=(0 * um, 0 * um),
radius=(150 * um, 150 * um),
focal=(2 * mm, 2 * mm),
angle=0 * degrees)
field.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=2,
factor=.5,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=4,
factor=1,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase = field.discretize(kind='phase',
num_levels=4,
factor=.5,
new_field=True,
matrix=False)
fieldFase.draw(kind='field')
fieldFase.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_normalize(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
wavelength = 0.6328 * um
length = 100 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
field1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field1.gauss_beam(r0=(0, 0), w0=(20 * um, 20 * um), z0=0, A=3)
field1.normalize()
field1.draw(kind='intensity', normalize=False)
field1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_several_fields(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}.npz'.format(newpath, func_name)
"""Diversos test para verificar el functionamiento de la
transformada de Fraunhofer"""
length = 500 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength = 0.6328 * um
field1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field1.spherical_wave(r0=(0, 0), z0=-1 * mm)
field2 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field2.gauss_beam(w0=(50 * um, 100 * um),
r0=(0, 0),
z0=0,
theta=0 * degrees,
phi=0 * degrees)
field3 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
field3.laguerre_beam(A=1,
r0=(0, 0),
w0=10 * um,
z=50 * um,
z0=0,
n=1,
l=1)
draw_several_fields(fields=(field1, field2, field3),
titles=('(a)', '(b)', '(c)'))
field3.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for Scalar_mask_XZ"""
import datetime
import os
import sys
import time
from diffractio import (degrees, eps, mm, no_date, np, num_max_processors, plt,
um)
from diffractio.scalar_fields_XZ import Scalar_field_XZ
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.utils_tests import comparison, save_figure_test
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_fields_XZ"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
def _func_polychromatic_RS_(wavelength):
x0 = np.linspace(-100 * um, 100 * um, 512)
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(A=1, x0=0, z0=0 * um, w0=50 * um, theta=0 * degrees)
t1 = Scalar_mask_X(x0, wavelength)
t1.ronchi_grating(period=10 * um, x0=0 * um, fill_factor=0.5)
initial_field = t1
return initial_field
def _func_polychromatic_BPM_(wavelength):
x0 = np.linspace(-200 * um, 200 * um, 512)
t1 = Scalar_mask_X(x0, wavelength)
t1.ronchi_grating(period=15 * um, x0=0 * um, fill_factor=0.5)
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(A=1, x0=0, z0=0 * um, w0=100 * um, theta=0 * degrees)
z = np.linspace(0 * um, 5 * mm, 512)
u1 = Scalar_mask_XZ(x0, z, wavelength, n_background=1)
u1.incident_field(f1 * t1)
u1.rectangle(r0=(-100 * um, 1500 * um),
size=(200 * um, 1000 * um),
angle=0 * degrees,
refraction_index=4)
return u1
def generate_BPM_field():
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 256)
wavelength = .5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.sphere(r0=(0 * um, 0 * um),
radius=(25 * um, 25 * um),
refraction_index=2)
u1.BPM(verbose=False)
return u1
def generate_BPM_gauss():
length = 500 * um
wavelength = .5 * um
x0 = np.linspace(-length / 2, length / 2, 512)
z0 = np.linspace(0 * um, 500 * um, 256)
x_ini = -250 * um * np.tan(30 * degrees)
print("x_ini={}".format(x_ini))
# source
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(A=1, x0=0, z0=250 * um, w0=10 * um, theta=0 * degrees)
u1 = Scalar_field_XZ(x=x0, z=z0, wavelength=wavelength)
u1.clear_refraction_index()
u1.incident_field(f1)
u1.BPM(verbose=False)
return u1
u_focus = generate_BPM_field()
u_gauss = generate_BPM_gauss()
class Test_Scalar_fields_XZ(object):
def test_rotate_field(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-200 * um, 200 * um, 512)
z0 = np.linspace(-100 * um, 600 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.lens_convergent(r0=(0, 100),
aperture=300 * um,
radius=(1000 * um, -250 * um),
thickness=100 * um,
refraction_index=2,
angle=0 * degrees,
mask=(10 * um, 3 + 0.05j))
u1.smooth_refraction_index(type_filter=3,
pixels_filtering=2,
max_diff_filter=0.01,
draw_check=False)
u1.BPM(verbose=False)
u1.draw(logarithm=True,
normalize='maximum',
scale='equal',
draw_borders=True)
save_figure_test(newpath, func_name, add_name='_wo')
u1.draw_refraction_index(draw_borders=True)
save_figure_test(newpath, func_name, add_name='_no')
u1.rotate_field(angle=22.5 * degrees,
center_rotation=(0, 100),
kind='all')
u1.draw_refraction_index(draw_borders=True)
save_figure_test(newpath, func_name, add_name='_n')
u1.draw(logarithm=True, draw_borders=True)
save_figure_test(newpath, func_name, add_name='_wi')
u1.clear_field()
u1.BPM(verbose=False)
u1.draw(logarithm=True, draw_borders=True)
save_figure_test(newpath, func_name, add_name='_recomputed')
assert True
def test_clear_field(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.hkl'.format(newpath, func_name)
u0 = generate_BPM_gauss()
proposal = 0 * u0.u
u0.clear_field()
solution = u0.u
u0.draw(kind='intensity', colorbar_kind='horizontal')
plt.clim(0, 1)
save_figure_test(newpath, func_name, add_name='')
assert comparison(proposal, solution, eps)
def test_save_load(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 256)
wavelength = .5 * um
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.sphere(r0=(0 * um, 0 * um),
radius=(25 * um, 25 * um),
refraction_index=2)
u1.info = """info:
test_save_load():
se graba una máscara para ver si se carga luego bien
Se pueder en nombre, la fecha, etc.
name: prueba
date: 170731
purpose: check testing
"""
u1.save_data(filename=filename + '.npz', add_name='')
time.sleep(0.5)
u2 = Scalar_field_XZ(x0, z0, wavelength)
u2.load_data(filename=filename + '.npz')
u2.draw(logarithm=True, normalize='maximum', draw_borders=True)
save_figure_test(newpath, func_name, add_name='_loaded')
assert True
def test_surface_detection(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 512)
z0 = np.linspace(-5 * um, 200 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(theta=0. * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.biprism(r0=(0, 0),
length=200 * um,
height=50 * um,
refraction_index=1.5,
angle=0)
u1.draw_refraction_index(draw_borders=True, scale='equal')
u1.BPM()
u1.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
scale='equal')
u1.draw(kind='phase', draw_borders=True, scale='equal')
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_cut_resample(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
generates a field and I cut_resample it
"""
x0 = np.linspace(-150 * um, 150 * um, 256)
z0 = np.linspace(-50 * um * um, 300 * um, 256)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=4)
u1.incident_field(u0)
u1.slit(r0=(0 * um, 10 * um),
aperture=40 * um,
depth=10 * um,
refraction_index=1,
refraction_index_center='',
angle=0 * degrees)
u1.BPM(verbose=False)
u1.draw(kind='intensity', draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='_before')
save_figure_test(newpath, func_name, add_name='_before')
u1.draw_refraction_index(draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='_after')
save_figure_test(newpath, func_name, add_name='_n_before')
u1.cut_resample(x_limits=(-75, 75),
z_limits=(0, 30),
num_points=(512, 512),
new_field=False)
u1.draw(kind='intensity', draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='_after')
save_figure_test(newpath, func_name, add_name='_after')
u1.draw_refraction_index(draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='_after')
save_figure_test(newpath, func_name, add_name='_n_after')
assert True
def test_incident_field_1(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-60 * um, 60 * um, 512)
z0 = np.linspace(0 * um, 100 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=10 * um,
theta=0. * degrees)
t0 = Scalar_source_X(x=x0, wavelength=wavelength)
t0.gauss_beam(A=1,
x0=40 * um,
z0=0 * um,
w0=10 * um,
theta=-45. * degrees)
t1 = Scalar_source_X(x=x0, wavelength=wavelength)
t1.gauss_beam(A=1,
x0=-40 * um,
z0=0 * um,
w0=10 * um,
theta=45. * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.BPM()
u1.draw(kind='intensity', logarithm=True)
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_incident_field_n(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-60 * um, 60 * um, 512)
z0 = np.linspace(0 * um, 100 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=10 * um,
theta=0. * degrees)
t0 = Scalar_source_X(x=x0, wavelength=wavelength)
t0.gauss_beam(A=1,
x0=40 * um,
z0=0 * um,
w0=10 * um,
theta=-45. * degrees)
t1 = Scalar_source_X(x=x0, wavelength=wavelength)
t1.gauss_beam(A=1,
x0=-40 * um,
z0=0 * um,
w0=10 * um,
theta=45. * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0, z0=10 * um)
u1.incident_field(t0, z0=25 * um)
u1.incident_field(t1, z0=25 * um)
u1.draw(kind='intensity', logarithm=True)
u1.save_data(filename=filename + '.npz', add_name='_0')
save_figure_test(newpath, func_name, add_name='_0')
u1.BPM()
u1.draw(kind='intensity', logarithm=True)
u1.save_data(filename=filename + '.npz', add_name='_prop')
save_figure_test(newpath, func_name, add_name='_prop')
assert True
def test_final_field(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-150 * um, 150 * um, 512)
z0 = np.linspace(0 * um, 500 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.slit(r0=(10 * um, 0 * um),
aperture=200 * um,
depth=15 * um,
refraction_index=1 + 5j,
refraction_index_center='',
angle=0 * degrees)
u1.biprism(r0=(10 * um, 0 * um),
length=200 * um,
height=15 * um,
refraction_index=1.5,
angle=0 * degrees)
u1.BPM()
u1.draw(kind='intensity', draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='_field')
save_figure_test(newpath, func_name, add_name='_field')
u_final = u1.final_field()
u_final.draw()
u_final.save_data(filename=filename + '.npz', add_name='_final')
save_figure_test(newpath, func_name, add_name='_final')
assert True
def test_RS(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
wavelength = .5 * um
x0 = np.linspace(-200 * um, 200 * um, 512)
z0 = np.linspace(500 * um, 3 * mm, 512)
t1 = Scalar_mask_X(x0, wavelength)
t1.lens(x0=0 * um, radius=100 * um, focal=2 * mm)
# t1.draw(kind='phase')
f1 = Scalar_source_X(x0, wavelength)
f1.plane_wave(A=1, theta=0 * degrees)
# f1.draw()
u1 = Scalar_field_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(f1 * t1)
u1.RS()
u1.draw(logarithm=1, normalize='intensity', draw_borders=False)
x_f, z_f = u1.search_focus()
text = "positions focus: x={:2.2f} um, z={:2.2f} mm".format(
x_f, z_f / mm)
plt.title(text)
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_BPM(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 512)
z0 = np.linspace(0 * um, 200 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=10 * um,
theta=0. * degrees)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.rectangle(r0=(0 * um, 100 * um),
size=(150 * um, 50 * um),
angle=45 * degrees,
refraction_index=1.5 - 0 * .00025j)
u1.draw_refraction_index()
u1.BPM(verbose=False)
u1.draw(logarithm=True, normalize='maximum', draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_WPM(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 512)
z0 = np.linspace(0 * um, 200 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=10 * um,
theta=0. * degrees)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.rectangle(r0=(0 * um, 100 * um),
size=(150 * um, 50 * um),
angle=45 * degrees,
refraction_index=1.5 - 0 * .00025j)
u1.draw_refraction_index()
u1.WPM(verbose=False)
u1.draw(logarithm=True, normalize='maximum', draw_borders=True)
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_compare_methods(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 200 * um
wavelength = 5 * um
x0 = np.linspace(-length / 2, length / 2, 512)
z0 = np.linspace(2 * um, 500 * um, 512)
# source
f1 = Scalar_source_X(x0, wavelength)
f1.gauss_beam(A=1, x0=0 * um, z0=0 * um, w0=10 * um, theta=0 * degrees)
f1.draw(kind='intensity')
# RS
u1 = Scalar_field_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(f1)
u1.RS()
u1.draw(kind='intensity',
logarithm=1,
normalize='intensity',
draw_borders=False)
save_figure_test(newpath, func_name, add_name='_RS')
u1.save_data(filename=filename + '.npz', add_name='_RS')
u_RS = u1.u
u1.clear_field()
u1.incident_field(f1)
u1.BPM(verbose=False)
u1.draw(kind='intensity',
logarithm=1,
normalize='intensity',
draw_borders=False)
save_figure_test(newpath, func_name, add_name='_BPM')
u1.save_data(filename=filename + '.npz', add_name='_BPM')
u_BPM = u1.u
diferencias = np.abs(u_RS)**2 - np.abs(u_BPM)**2
u1.u = diferencias
u1.draw(kind='intensity', logarithm=False, normalize=False)
u1.save_data(filename=filename + '.npz', add_name='_diff')
save_figure_test(newpath, func_name, add_name='_diff')
assert True
def test_draw_profiles(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 200 * um
wavelength = 5 * um
period = 25 * um
z_talbot = 2 * period**2 / wavelength
x0 = np.linspace(-length / 2, length / 2, 512)
z0 = np.linspace(25 * um, 1 * z_talbot, 64)
u0 = Scalar_source_X(x0, wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=-100 * um,
w0=100 * um,
theta=0 * degrees)
t1 = Scalar_mask_X(x0, wavelength)
t1.ronchi_grating(period=25 * um, x0=0 * um, fill_factor=0.5)
u1 = Scalar_field_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(t1 * u0)
u1.RS()
u1.draw(kind='intensity',
logarithm=False,
normalize='maximum',
draw_borders=True,
filename='')
save_figure_test(newpath, func_name, add_name='_int')
filename = '{}{}{}.{}'.format(newpath, func_name, '_video', 'mp4')
seconds = 1
u1.video(kind='intensity',
logarithm=True,
normalize=False,
time_video=10 * seconds,
frames_reduction=5,
filename=filename,
dpi=100)
assert True
def test_BPM_profile_automatico(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 128)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.mask_field(size_edge=5 * um)
u1.sphere(r0=(0 * um, 20 * um),
radius=(20 * um, 20 * um),
refraction_index=1.5)
u1.BPM(verbose=False)
u1.draw_profiles_interactive(kind='intensity',
logarithm=True,
normalize='maximum')
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_BPM_profile_longitudinal(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 512)
wavelength = .5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.mask_field(size_edge=5 * um)
u1.sphere(r0=(0 * um, 0 * um),
radius=(25 * um, 25 * um),
refraction_index=2)
u1.BPM(verbose=False)
u1.draw(logarithm=True, normalize='maximum', draw_borders=True)
save_figure_test(newpath, func_name, add_name='')
u1.profile_longitudinal(x0=0 * um)
save_figure_test(newpath, func_name, add_name='_prof')
assert True
def test_BPM_profile_transversal(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 512)
wavelength = .5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(A=1, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.mask_field(size_edge=5 * um)
u1.sphere(r0=(0 * um, 0 * um),
radius=(25 * um, 25 * um),
refraction_index=2)
u1.BPM(verbose=False)
u1.draw(logarithm=True, normalize='maximum', draw_borders=True)
save_figure_test(newpath, func_name, add_name='')
u1.profile_transversal(z0=46 * um)
save_figure_test(newpath, func_name, add_name='_prof')
assert True
def test_find_focus(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
# dielectrico = 2
# radius_sphere = 8 * um
# x0 = np.linspace(-5 * radius_sphere * um, 5 * radius_sphere * um, 512)
# z0 = np.linspace(0 * um, 4 * radius_sphere, 512)
# wavelength = 5 * um
# u0 = Scalar_source_X(x=x0, wavelength=wavelength)
# u0.gauss_beam(
# A=1,
# x0=0 * um,
# z0=5000 * um,
# w0=radius_sphere / 2,
# theta=0. * degrees)
# u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
# u1.incident_field(u0)
# u1.mask_field(size_edge=5 * um)
#
# u1.sphere(
# r0=(0, 2 * radius_sphere),
# radius=(radius_sphere, radius_sphere),
# refraction_index=dielectrico)
# u1.draw_refraction_index()
# u1.BPM(verbose=False)
u1 = u_focus
u1.draw(logarithm=False, normalize=False, draw_borders=True)
save_figure_test(newpath, func_name, add_name='')
x_max, z_max = u1.search_focus()
u1.profile_transversal(z0=z_max)
save_figure_test(newpath, func_name, add_name='_trans')
u1.profile_longitudinal(x0=x_max)
save_figure_test(newpath, func_name, add_name='_long')
assert True
def test_BPM_inverse(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=0 * um, z0=0 * um, w0=10 * um, theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.rectangle(r0=(0 * um, 45 * um),
size=(25 * um, 25 * um),
angle=0 * degrees,
refraction_index=1.5)
u1.draw_refraction_index(draw_borders=True, min_incr=0.001)
u1.BPM(verbose=False)
u1.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
save_figure_test(newpath, func_name, add_name='_direct')
u2 = u1.BPM_inverse()
u2.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
save_figure_test(newpath, func_name, add_name='_inverse')
differences = u1 - u2
differences.u = np.abs(u1.u) - np.abs(u2.u)
differences.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
save_figure_test(newpath, func_name, add_name='_diff')
assert True
def test_BPM_backpropagation(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
here we do two experiments
1. propagate and after backpropagate the last field
2. backpropagate u0=1
"""
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 75 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(theta=20 * degrees)
u0.gauss_beam(A=1,
x0=-15 * um,
z0=0 * um,
w0=10 * um,
theta=0. * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.rectangle(r0=(0 * um, 45 * um),
size=(25 * um, 25 * um),
angle=0 * degrees,
refraction_index=4)
u1.draw_refraction_index(draw_borders=True, min_incr=0.001)
u1.BPM(verbose=False)
u1.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
save_figure_test(newpath, func_name, add_name='_for')
# Hago la inverse y drawing los resultados
u1.u[:, -1] = 1
u2 = u1.BPM_back_propagation()
# u2.draw_refraction_index(draw_borders=True, min_incr=0.001)
u2.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
u2.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='_back')
assert True
def test_BPM_backpropagation_2(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
we place a field at a certain position and after we backpropagate
"""
x0 = np.linspace(-25 * um, 25 * um, 512)
z0 = np.linspace(0 * um, 100 * um, 512)
wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(theta=20 * degrees)
u0.gauss_beam(A=1,
x0=-5 * um,
z0=0 * um,
w0=5 * um,
theta=15. * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.rectangle(r0=(0 * um, 45 * um),
size=(25 * um, 25 * um),
angle=0 * degrees,
refraction_index=2)
u1.draw_refraction_index(draw_borders=True, min_incr=0.001)
u1.incident_field(u0, z0=80 * um)
# Hago la inverse y drawing los resultados
u2 = u1.BPM_back_propagation()
# u2.draw_incident_field(
# kind='intensity', logarithm=False, normalize=False, filename='')
u2.draw_refraction_index(draw_borders=True, min_incr=0.001)
u2.draw(logarithm=True,
normalize='maximum',
draw_borders=True,
min_incr=0.001)
u2.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_BPM_n_background(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-60 * um, 60 * um, 512)
z0 = np.linspace(0 * um, 120 * um, 512)
wavelength = 4 * um
radius_sphere = 30 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=60 * um,
w0=25 * um,
theta=0 * degrees)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=4)
u1.incident_field(u0)
u1.mask_field(size_edge=5 * um)
u1.sphere(r0=(0, 40 * um),
radius=(radius_sphere, radius_sphere),
refraction_index=1)
u1.smooth_refraction_index(type_filter=3,
pixels_filtering=2,
max_diff_filter=0.01,
draw_check=False)
save_figure_test(newpath, func_name, add_name='_n_diff')
u1.BPM(verbose=False)
u1.draw_refraction_index(scale='scaled')
save_figure_test(newpath, func_name, add_name='_n')
u1.draw(kind='intensity',
logarithm=True,
normalize='maximum',
draw_borders=True,
scale='scaled')
u1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_RS_polychromatic(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
wavelengths = np.linspace(0.4, 0.8, 5)
w_central = 0.6
Dw = 0.15 * um
spectrum = np.exp(-(wavelengths - w_central)**2 / (2 * Dw**2))
initial_field = _func_polychromatic_RS_(wavelengths[0])
x0 = initial_field.x
z0 = np.linspace(250 * um, 1000 * um, 512)
u1 = Scalar_mask_XZ(x0, z0, wavelengths[0], n_background=1)
initial_field = _func_polychromatic_RS_(wavelengths[0])
u1.incident_field(initial_field)
u1.RS()
u1.draw(logarithm=True, normalize='intensity')
u1 = Scalar_mask_XZ(x0, z0, wavelengths[0], n_background=1)
u_poly = u1.RS_polychromatic(_func_polychromatic_RS_,
wavelengths,
spectrum=spectrum,
verbose=False,
num_processors=num_max_processors)
u_poly.draw(logarithm=True, normalize='intensity', draw_borders=True)
save_figure_test(newpath, func_name, add_name='_int')
u_poly.save_data(filename=filename + '.npz', add_name='')
assert True
def test_BPM_polychromatic(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
wavelengths = np.linspace(0.4, 0.8, 11)
spectrum = ''
initial_field = _func_polychromatic_BPM_(wavelengths[0])
z0 = initial_field.z
x0 = initial_field.x
u1 = Scalar_mask_XZ(x0, z0, wavelengths[0], n_background=1)
u_poly = u1.BPM_polychromatic(_func_polychromatic_BPM_,
wavelengths,
spectrum,
verbose=True,
num_processors=num_max_processors)
u_poly.draw(logarithm=True, normalize='intensity', draw_borders=True)
save_figure_test(newpath, func_name, add_name='_int')
u_poly.save_data(filename=filename + '.npz', add_name='')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""tests for scalar_masks_X"""
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, um
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.utils_tests import save_figure_test
from numpy import loadtxt
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_masks_X"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_masks_X(object):
def test_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 128
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.slit(x0=0, size=100 * um)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_double_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 128
length = 25 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.double_slit(x0=0, size=5 * um, separation=15 * um)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_two_levels(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 128
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.two_levels(level1=0, level2=.5, x_edge=0)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gray_scale(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(0, 250 * um, 1024)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.gray_scale(num_levels=16, levelMin=2, levelMax=3)
t1.draw(kind='amplitude')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_prism(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.prism(x0=0, n=1.5, angle=1 * degrees)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_biprism_fresnel(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024
length = 500 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.biprism_fresnel(angle=1 * degrees, x0=100 * um, radius=125)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_biprism_fresnel_nh(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.biprism_fresnel_nh(x0=0, width=100 * um, height=5 * um, n=1.5)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
pass
def test_lens(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 128
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.lens(x0=0 * um, radius=100 * um, focal=5 * mm)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_fresnel_lens(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.fresnel_lens(x0=0 * um,
radius=100 * um,
focal=.25 * mm,
kind='amplitude',
phase=np.pi)
t1.draw(kind='amplitude')
save_figure_test(newpath, func_name, '_amplitude')
t1.fresnel_lens(x0=0 * um,
radius=100 * um,
focal=.25 * mm,
kind='phase',
phase=np.pi)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name, '_phase')
assert True
def test_roughness(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 128
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
t1.roughness(t=15 * um, s=.2 * um)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_dust_different_sizes(self):
# TODO: does not work properly
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
wavelength = 0.6328 * um
x = np.linspace(-500 * um, 500 * um, 2048)
t1 = Scalar_mask_X(x, wavelength)
t1.dust_different_sizes(percentage=0.2, size=20 * um, std=5 * um)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_dust(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
wavelength = 0.6328 * um
x = np.linspace(-500 * um, 500 * um, 2048 * 8)
t1 = Scalar_mask_X(x, wavelength)
t1.dust(percentage=0.9, size=20 * um)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_sine_grating(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 40 * um
red = Scalar_mask_X(x, wavelength)
red.sine_grating(period=period, amp_min=0, amp_max=1, x0=0 * um)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_redRonchi(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
red = Scalar_mask_X(x, wavelength)
red.ronchi_grating(period=50 * um, x0=0 * um, fill_factor=0.75)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_redBinaria_amplitude(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
red = Scalar_mask_X(x, wavelength)
red.binary_grating(period=50 * um,
amin=0.25,
amax=0.5,
phase=np.pi,
x0=25 * um,
fill_factor=0.25)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_redBinaria_phase(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 40 * um
red = Scalar_mask_X(x, wavelength)
red.binary_grating(period=period,
amin=1,
amax=1,
phase=np.pi / 2,
x0=0,
fill_factor=0.5)
red.draw(kind='phase')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_redBlazed(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 125 * um
red = Scalar_mask_X(x, wavelength)
red.blazed_grating(x0=0, period=period, phase_max=2 * np.pi)
red.draw(kind='phase')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_mask_from_function(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
f1 = "R1-h1+np.sqrt(R1**2-(self.x-x0)**2)"
f2 = "R2-h2+np.sqrt(R2**2-(self.x-x0)**2)"
v_globals = {
'R1': 5 * mm,
'R2': 1 * mm,
'x0': 0 * um,
'y0': 0 * um,
'h1': 1 * mm,
'h2': -1 * mm
}
index = 1.5
print(v_globals)
t1 = Scalar_mask_X(x, wavelength)
t1.mask_from_function(x0=0 * um,
index=index,
f1=f1,
f2=f2,
v_globals=v_globals,
radius=100 * um)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_mask_from_array(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 1024 * 8
x = np.linspace(-1 * mm, 1 * mm, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_X(x, wavelength)
script_dir = os.path.dirname(__file__)
rel_path1 = "profile1.txt"
abs_file_path1 = os.path.join(script_dir, rel_path1)
script_dir = os.path.dirname(__file__)
rel_path2 = "profile2.txt"
abs_file_path2 = os.path.join(script_dir, rel_path2)
profile1 = loadtxt(abs_file_path1)
profile2 = loadtxt(abs_file_path2)
t1.mask_from_array(x0=0,
index=1.25,
array1=profile1 * mm,
array2=profile2 * mm,
interp_kind='quadratic',
radius=1.5 * mm)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_chirped_grating_p(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(0 * um, 100 * um, 4096 * 4)
wavelength = 0.6238 * um
red = Scalar_mask_X(x, wavelength)
conds = {
'kind': 'amplitude_binary',
'p0': 20 * um,
'p1': 4 * um,
'amp_min': 0,
'amp_max': 1,
'delta_x': 0,
'phase_max': np.pi,
'length': 0, # equal to length of x
}
red.chirped_grating_p(**conds)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_chirped_grating_q(self):
"""chirped gratings with new definition
'amplitude', 'phase', 'amplitude_binary', 'phase_binary'
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-100 * um, 100 * um, 4096 * 4)
wavelength = 0.6238 * um
red = Scalar_mask_X(x, wavelength)
conds = {
'kind': 'amplitude_binary',
'p0': 20 * um,
'p1': 4 * um,
'amp_min': 0,
'amp_max': 1,
'delta_x': 0,
'phase_max': np.pi,
'length': 0, # equal to length of x
}
red.chirped_grating_q(**conds)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_chirped_grating(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
fx = '10+20*(self.x/length)**2'
red = Scalar_mask_X(x, wavelength)
red.chirped_grating(kind='amplitude_binary',
p_x=fx,
length=500 * um,
x0=0 * um,
amp_max=1,
amp_min=0,
delta_x=0,
phase_max=np.pi)
red.draw(kind='amplitude')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_code(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 2048 * 8
wavelength = 0.85 * um
code = [1, 1, 0, 0, 1, 0, 1, 1, 0, 1]
anchura_bit = 80 * um
x = np.linspace(0, anchura_bit * len(code), num_data)
t1 = Scalar_mask_X(x, wavelength)
t1.binary_code(kind='normal',
code=code,
bit_width=anchura_bit,
x0=0 * um)
t1.draw()
t1.save_data(filename=filename + '-normal' + '.npz')
save_figure_test(newpath, func_name + '-normal')
t2 = Scalar_mask_X(x, wavelength)
t2.binary_code(x0=0 * um,
kind='zeros',
code=code,
bit_width=anchura_bit)
t2.draw()
t2.save_data(filename=filename + '-zeros' + '.npz')
save_figure_test(newpath, func_name + '-zeros')
t3 = Scalar_mask_X(x, wavelength)
t3.binary_code(x0=0, kind='ones', code=code, bit_width=anchura_bit)
t3.draw()
t3.save_data(filename=filename + '-ones' + '.npz')
save_figure_test(newpath, func_name + '-ones')
t4 = Scalar_mask_X(x, wavelength)
t4.binary_code(x0=0, kind='abs_fag', code=code, bit_width=anchura_bit)
t4.draw()
t4.save_data(filename=filename + '-fag' + '.npz')
save_figure_test(newpath, func_name)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests form Scalar_masks_XY"""
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, plt, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.utils_tests import comparison, save_figure_test
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_masks_XY"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_masks_XY(object):
def test_add(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.square(r0=(-50 * um, 0 * um),
size=(50 * um, 50 * um),
angle=0 * degrees)
t1.draw(title='test_square')
t2 = Scalar_mask_XY(x, y, wavelength)
t2.circle(r0=(50 * um, 0 * um),
radius=(25 * um, 25 * um),
angle=0 * degrees)
t2.draw(title='test_square')
t3 = t2 + t1
t3.draw(title='suma')
t1.save_data(filename=filename + '.npz', add_name='_1')
save_figure_test(newpath, func_name, add_name='_1')
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.square(r0=(-50 * um, 0 * um),
size=(150 * um, 150 * um),
angle=0 * degrees)
t1.draw(title='test_square')
t2 = Scalar_mask_XY(x, y, wavelength)
t2.circle(r0=(50 * um, 0 * um),
radius=(125 * um, 125 * um),
angle=0 * degrees)
t2.draw(title='test_square')
t3 = t2 + t1
t3.draw(title='add')
t3.save_data(filename=filename + '.npz', add_name='_2')
save_figure_test(newpath, func_name, add_name='_2')
assert True
def test_substract(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.square(r0=(0 * um, 0 * um),
size=(100 * um, 100 * um),
angle=0 * degrees)
t1.draw(title='test_square')
t2 = Scalar_mask_XY(x, y, wavelength)
t2.circle(r0=(0 * um, 0 * um),
radius=(45 * um, 45 * um),
angle=0 * degrees)
t2.draw(title='test_circle')
t3 = t2 - t1
t3.draw(title='resta')
t3.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_binarize(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
tomamos una mascara de niveles(0,1) y la pasamos a ampitud-fase
"""
num_data = 512
length = 25 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.double_slit(x0=0,
size=5 * um,
separation=15 * um,
angle=0 * degrees)
t1.draw(kind='field')
plt.title('(0,1)-sin binarizar')
t1.save_data(filename=filename + '.npz', add_name='_wo_bin')
save_figure_test(newpath, func_name, '_wo_bin')
t1.binarize(kind='amplitude',
bin_level=None,
level0=0.25,
level1=.75,
new_field=False,
matrix=False)
t1.draw(kind='field')
plt.suptitle('binarizada')
t1.save_data(filename=filename + '.npz', add_name='_wi_bin')
save_figure_test(newpath, func_name, add_name='_wi_bin')
assert True
def test_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.slit(x0=0, size=100 * um, angle=0 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_sinusoidal_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-500 * um, 500 * um, 512)
y = np.linspace(-500 * um, 500 * um, 512)
wavelength = 1 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.sinusoidal_slit(x0=0 * um,
size=90,
amplitude=30 * um,
phase=0 * degrees,
angle=0 * degrees,
period=100 * um)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_slit_series(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 256
length = 1000 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
a_coef1 = np.array([[0, 1, 2], [0, 25, 25]])
a_coef2 = np.array([[0, 1, 2], [0, 25, 25]])
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.slit_series(x0=0,
width=200,
period1=100,
period2=100,
Dy=(0, 0),
a_coef1=a_coef1,
a_coef2=a_coef2,
angle=0 * degrees)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_hiperellipse(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-100 * um, 100 * um, 512)
y = np.linspace(-100 * um, 100 * um, 512)
wavelength = 1 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.super_ellipse(r0=(0, 0),
radius=(20 * um, 40 * um),
angle=0 * degrees,
n=[0.5, 4])
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_crossed_slits(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-100 * um, 100 * um, 512)
y = np.linspace(-100 * um, 100 * um, 512)
wavelength = 1 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.super_ellipse(r0=(0, 0),
radius=(20 * um, 40 * um),
angle=0 * degrees,
n=[0.5, 4])
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_double_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 25 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.double_slit(x0=0,
size=5 * um,
separation=15 * um,
angle=0 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_triangle(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-100 * um, 100 * um, 512)
y = np.linspace(-100 * um, 100 * um, 512)
wavelength = 1 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.triangle(r0=(0, 0), slope=1, height=50 * um, angle=0 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_insert_array_masks(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 1 * um
s = Scalar_mask_XY(x, y, wavelength)
s.cross(r0=(0 * um, 0 * um),
size=(90 * um, 25 * um),
angle=0 * degrees)
t1 = Scalar_mask_XY(x, y, wavelength)
t1.insert_array_masks(t1=s,
space=[100 * um, 100 * um],
margin=50 * um,
angle=90 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_square(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.square(r0=(0 * um, 0 * um),
size=(100 * um, 50 * um),
angle=45 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_circle(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.circle(r0=(0 * um, 0 * um), radius=(100 * um, 100 * um))
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_super_gauss(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.super_gauss(r0=(0 * um, 0 * um),
radius=(length / 3, length / 3),
angle=45 * degrees,
power=22)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_square_circle(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.square_circle(s=.75,
r0=(0 * um, 0 * um),
R1=100 * um,
R2=100 * um,
angle=0 * degrees)
t1.draw(kind='intensity')
# t2 = t1.fft(remove0=False)
# t2.draw(logarithm=True)
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_angular_aperture(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_pixels = 512
length = 200 * um
x0 = np.linspace(-length / 2, length / 2, num_pixels)
y0 = np.linspace(-length / 2, length / 2, num_pixels)
wavelength = 0.6238 * um
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
a_coef = np.array([[0, 4, 8], [50, 25, 25]])
t1.angular_aperture(a_coef=a_coef, angle=0 * degrees)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_ellipse(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(50 * um, 25 * um),
angle=45 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_ring(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.ring(r0=(0 * um, 0 * um),
radius1=(50 * um, 50 * um),
radius2=(100 * um, 150 * um),
angle=45 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_rings(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 60 * um
num_data = 512
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
inner_radius = np.array([5., 10, 15, 20, 25])
outer_radius = np.array([6., 12, 17, 23, 29])
t1 = Scalar_mask_XY(x, y, wavelength)
t1.rings(r0=(0, 0),
inner_radius=inner_radius,
outer_radius=outer_radius)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
num_data = 512
def test_cross(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.cross(r0=(0 * um, 0 * um),
size=(200 * um, 75 * um),
angle=0 * degrees)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_two_levels(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.two_levels(level1=0, level2=.5, x_edge=0)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_edge_series(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_pixels = 512
length = 1000 * um
x0 = np.linspace(-length / 2, length / 2, num_pixels)
y0 = np.linspace(-length / 2, length / 2, num_pixels)
wavelength = 0.06238 * um
a_coef = np.array([[0, 1, 2], [0, 100, 25]])
b_coef = np.array([[0, 3], [0, 25]])
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.edge_series(r0=(0, 0),
period=100,
a_coef=a_coef,
b_coef=b_coef,
angle=0 * degrees,
invert=False)
t1.draw()
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gray_scale(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.gray_scale(num_levels=128, levelMin=0, levelMax=1)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_mask_phase_1(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.mask_from_function(r0=(0 * um, 0 * um),
index=1.5,
f1='1*degrees*self.Y',
f2='1*degrees*self.X',
v_globals=None,
radius=(100 * um, 100 * um))
t1.draw(kind='field')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_mask_phase_2(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
# lens con una surface plana y otra esferica
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
f1 = "R1-h1+np.sqrt(R1**2-(self.X-x0)**2-(self.Y-y0)**2)"
f1 = "1*degrees*self.X"
f1 = "np.zeros_like(self.X,dtype=float)"
f2 = "R2-h2+np.sqrt(R2**2-(self.X-x0)**2-(self.Y-y0)**2)"
# f2="R2-h2+(R2**4-(self.X-x0)**4-(self.Y-y0)**4)**0.25"
v_globals = {
'R1': 5 * mm,
'R2': 1 * mm,
'x0': 0 * um,
'y0': 0 * um,
'h1': 1 * mm,
'h2': -1 * mm,
'np': np,
}
index = 1.5
print(v_globals)
t1 = Scalar_mask_XY(x, y, wavelength)
t1.mask_from_function(r0=(0 * um, 0 * um),
index=index,
f1=f1,
f2=f2,
v_globals=v_globals,
radius=(100 * um, 100 * um))
t1.draw(kind='field')
focal = v_globals['R2'] / (index - 1)
t2 = t1.RS(z=focal)
t2.draw(kind='field', logarithm=True)
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_lens(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t0 = Scalar_mask_XY(x, y, wavelength)
t0.lens(r0=(0 * um, 0 * um),
radius=(100 * um, 100 * um),
focal=(2.5 * mm, 2.5 * mm),
angle=0 * degrees)
t0.draw(kind='phase')
t0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
t1 = Scalar_mask_XY(x, y, wavelength)
t1.lens(r0=(0 * um, 0 * um),
radius=(100 * um, 75 * um),
focal=(5 * mm, 2.5 * mm),
angle=45 * degrees)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz', add_name='_elliptical')
save_figure_test(newpath, func_name, add_name='_elliptical')
assert True
def test_lens_fresnel(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 500 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.fresnel_lens(r0=(0 * um, 0 * um),
radius=(250 * um, 250 * um),
focal=(5 * mm, 5 * mm),
angle=45 * degrees,
kind='amplitude',
phase=np.pi)
t1.draw(kind='intensity')
t1.save_data(filename=filename + '.npz', add_name='_int')
save_figure_test(newpath, func_name, add_name='_int')
t1.fresnel_lens(r0=(0 * um, 0 * um),
radius=(250 * um, 250 * um),
focal=(5 * mm, 5 * mm),
angle=0 * degrees,
kind='phase',
phase=np.pi)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz', add_name='_phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_biprism_fresnel(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.biprism_fresnel(r0=(0 * um, 0 * um),
width=100 * um,
height=5 * um,
n=1.5)
t1.draw(kind='field')
save_figure_test(newpath, func_name)
t1.save_data(filename=filename + '.npz')
assert True
def test_axicon(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.axicon(r0=(0 * um, 0 * um),
radius=100 * um,
angle=2 * degrees,
refraction_index=1.5)
t1.draw(kind='phase')
save_figure_test(newpath, func_name)
t1.save_data(filename=filename + '.npz')
assert True
def test_laguerre_gauss_spiral(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t = Scalar_mask_XY(x, y, wavelength)
t.laguerre_gauss_spiral(kind='intensity',
n=0,
l=4,
r0=(0 * um, 0 * um),
w0=20 * um,
z=100 * um)
t.draw(kind='intensity')
t.save_data(filename=filename + '.npz', add_name='_intensity')
save_figure_test(newpath, func_name, add_name='_intensity')
t2 = Scalar_mask_XY(x, y, wavelength)
t2.laguerre_gauss_spiral(kind='phase',
n=0,
l=16,
r0=(0 * um, 0 * um),
w0=20 * um,
z=4000 * um)
t2.draw(kind='phase')
t2.save_data(filename=filename + '.npz', add_name='_phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_grating_forked(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t = Scalar_mask_XY(x, y, wavelength)
t.forked_grating(r0=(0 * um, 0 * um),
period=20 * um,
l=3,
alpha=2,
kind='amplitude',
angle=0 * degrees)
t.draw(kind='intensity')
t.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_roughness(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.roughness(t=(25 * um, 25 * um), s=1 * um)
t1.draw(kind='phase')
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_sine(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 50 * um
red = Scalar_mask_XY(x, y, wavelength)
red.sine_grating(period=period,
amp_min=0,
amp_max=1,
x0=0 * um,
angle=0 * degrees)
red.draw(kind='intensity')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_Ronchi(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
red = Scalar_mask_XY(x, y, wavelength)
red.ronchi_grating(period=100 * um,
x0=0 * um,
angle=0 * degrees,
fill_factor=0.333)
red.draw(kind='intensity')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_binary_amplitude(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
red = Scalar_mask_XY(x, y, wavelength)
red.binary_grating(period=50 * um,
amin=.5,
amax=.75,
phase=np.pi,
x0=0,
fill_factor=0.25,
angle=0 * degrees)
red.draw(kind='field')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_binary_phase(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
red = Scalar_mask_XY(x, y, wavelength)
red.binary_grating(period=50 * um,
amin=1,
amax=1,
phase=np.pi / 2,
x0=0,
fill_factor=0.5,
angle=0 * degrees)
red.draw(kind='phase')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_blazed(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 125 * um
red = Scalar_mask_XY(x, y, wavelength)
red.blazed_grating(period=period,
phase_max=2 * np.pi,
x0=0,
angle=0 * degrees)
red.draw(kind='phase')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_2D(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 62.5 * um
red = Scalar_mask_XY(x, y, wavelength)
red.grating_2D(r0=(0., 0.),
period=period,
amin=0,
amax=1.,
phase=0 * np.pi / 2,
fill_factor=0.5,
angle=0 * degrees)
red.draw(kind='intensity')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_grating_chess(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 512)
y = np.linspace(-250 * um, 250 * um, 512)
wavelength = 0.6238 * um
period = 125 * um
red = Scalar_mask_XY(x, y, wavelength)
red.grating_2D_chess(r0=(0., 0.),
period=period,
amin=0,
amax=1.,
phase=0 * np.pi / 2,
fill_factor=0.75,
angle=0 * degrees)
red.draw(kind='intensity')
red.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_circle_rough(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6238 * um
t = Scalar_mask_XY(x, y, wavelength)
t.circle_rough(r0=(0, 0),
radius=100 * um,
angle=0 * degrees,
sigma=4 * um)
t.draw(kind='intensity')
t.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_ring_rough(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-250 * um, 250 * um, 1024)
y = np.linspace(-250 * um, 250 * um, 1024)
wavelength = 0.6238 * um
t = Scalar_mask_XY(x, y, wavelength)
t.ring_rough(r0=(0, 0),
radius1=50 * um,
radius2=100 * um,
angle=0 * degrees,
sigma=4 * um)
t.draw(kind='intensity')
t.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_widen(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.ring(r0=(0 * um, 0 * um),
radius1=(50 * um, 50 * um),
radius2=(60 * um, 60 * um),
angle=45 * degrees)
t1.draw()
t1.save_data(filename=filename + '.npz', add_name='_no_widened')
save_figure_test(newpath, func_name, add_name='_no_widened')
t1.widen(radius=50 * um)
# t1.u = np.abs(t1.u)
# t1.u[t1.u < 0.5] = 0
# t1.u[t1.u >= 0.5] = 1
t1.draw()
t1.save_data(filename=filename + '.npz', add_name='_widened')
save_figure_test(newpath, func_name, add_name='_widened')
assert True
def test_compute_area(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
num_data = 512
length = 250 * um
radius = length / 2
x = np.linspace(-radius, radius, num_data)
y = np.linspace(-radius, radius, num_data)
wavelength = 0.6328 * um
t1 = Scalar_mask_XY(x, y, wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(100 * um, 100 * um),
angle=0 * degrees)
t1.draw(title='test_ring')
area = t1.area(percentage=0.001)
text1 = "The area is: {:2.4f} %".format(area * 100)
plt.title(text1)
t1.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test for scalar_sources_XYZ"""
import datetime
import os
import sys
from diffractio import degrees, no_date, np, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_masks_XYZ import Scalar_mask_XYZ
from diffractio.utils_tests import comparison, save_figure_test
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_masks_XYZ"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_masks_XYZ(object):
def test_sphere(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
length = 100 * um
numdataX = 64
numdataZ = 64
longitud = 50 * um
x0 = np.linspace(-length / 2, length / 2, numdataX)
y0 = np.linspace(-length / 2, length / 2, numdataX)
z0 = np.linspace(-longitud, longitud, numdataZ)
wavelength = 0.55 * um
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(20 * um, 20 * um),
angle=0 * degrees)
uxyz = Scalar_mask_XYZ(x=x0,
y=y0,
z=z0,
wavelength=wavelength,
n_background=1.,
info='')
uxyz.sphere(r0=(0 * um, 0 * um, 0 * um),
radius=(10 * um, 30 * um, 50 * um),
refraction_index=2,
angles=(0 * degrees, 0 * degrees, 45 * degrees))
uxyz.incident_field(t1)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for Scalar_mask_XZ"""
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, um
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
from diffractio.utils_tests import comparison, save_figure_test
from numpy import loadtxt
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_masks_XZ"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_masks_XZ(object):
def test_extrude_mask_z_n_var(self):
"""
Here the refraction index is a function of positions z
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = .55 * um
t0 = Scalar_mask_X(x=x0, wavelength=wavelength)
t0.double_slit(x0=0, size=20 * um, separation=50 * um)
t0.draw()
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
z0 = 10 * um
z1 = 50 * um
v_globals = dict(z0=z0, z1=z1)
t1.extrude_mask(t=t0,
z0=z0,
z1=z1,
refraction_index='1+0.25*(z-z0)/(z1-z0)',
v_globals=v_globals)
t1.draw_refraction_index(draw_borders=False, )
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_extrude_mask_z_n_cte(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = .55 * um
t0 = Scalar_mask_X(x=x0, wavelength=wavelength)
t0.double_slit(x0=0, size=20 * um, separation=50 * um)
t0.draw()
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
z0 = 10 * um
z1 = 50 * um
v_globals = dict(z0=z0, z1=z1)
t1.extrude_mask(t=t0,
z0=z0,
z1=z1,
refraction_index=1.5,
v_globals=v_globals)
t1.draw_refraction_index(draw_borders=False, )
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_mask_from_function(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 500 * um, 256)
wavelength = 0.6238 * um
f1 = '50 * um'
f2 = "175*um+np.tan(45*degrees)*(self.X-0*um)"
z_sides = (-75 * um, 75 * um)
v_globals = {'um': 1, 'np': np}
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.mask_from_function(r0=(0, 0),
refraction_index=1.5,
f1=f1,
f2=f2,
z_sides=z_sides,
angle=0 * degrees,
v_globals=v_globals)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_mask_from_array(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x = np.linspace(-15 * mm, 15 * mm, 256)
z = np.linspace(0 * mm, 15 * mm, 256)
wavelength = 0.6328 * um
t1 = Scalar_mask_XZ(x, z, wavelength)
script_dir = os.path.dirname(__file__)
rel_path1 = "profile1.txt"
abs_file_path1 = os.path.join(script_dir, rel_path1)
rel_path2 = "profile2.txt"
abs_file_path2 = os.path.join(script_dir, rel_path2)
profile1 = loadtxt(abs_file_path1)
profile2 = loadtxt(abs_file_path2)
profile1[:, 1] = np.abs(profile1[:, 1])
profile2[:, 1] = np.abs(profile2[:, 1])
t1.mask_from_array(
r0=(0 * um, 0 * um),
refraction_index=1.5,
array1=profile1 * 1000, # pasar a micras
array2=profile2 * 1000, # pasar a micras
x_sides=(-15 * mm, 15 * mm),
angle=0 * degrees,
v_globals={},
interp_kind='nearest')
t1.draw_refraction_index(draw_borders=False)
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_object_by_surfaces(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-20 * um, 20 * um, 256)
z0 = np.linspace(0 * um, 2000 * um, 256)
wavelength = 2 * um
r0 = (0, 0)
refraction_index = 4
Fs = ['Xrot<3*um', 'Xrot>-3*um', 'Zrot>25*um', 'Zrot<1750*um']
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
t1.object_by_surfaces(r0,
refraction_index,
Fs,
angle=0 * degrees,
v_globals={})
t1.draw_refraction_index(draw_borders=True)
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_add_surfaces(self):
assert True
def test_variable_refraction_index_1(self):
"""
Here the refraction index is a function of positions x,z
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
print("Dx={}".format(x0[1] - x0[0]))
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = 50 * um
t0 = Scalar_mask_XZ(x=x0,
z=z0,
wavelength=wavelength,
n_background=1.0)
pn = dict(n_out=1.5,
n_center=4,
cx=0 * um,
cz=100 * um,
radius=75 * um)
center = (pn['cx'], pn['cz'])
radius = pn['radius']
# ref_index = '2*(((X-0)**2+(Z-300)**2)/75**2-0)'
ref_index = "{p[n_out]}+({p[n_center]}-{p[n_out]})*(1-((X-{p[cx]})**2+(Z-{p[cz]})**2)/{p[radius]}**2)".format(
p=pn)
t0.sphere(r0=center,
radius=(radius, radius),
refraction_index=ref_index,
angle=0)
t0.draw_refraction_index(draw_borders=False, scale='equal')
t0.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_variable_refraction_index_2(self):
"""Here the refraction index is a function of positions z"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = .55 * um
t0 = Scalar_mask_X(x=x0, wavelength=wavelength)
t0.double_slit(x0=0, size=20 * um, separation=50 * um)
t0.draw()
z_min = 10 * um
z_max = 50 * um
v_globals = dict(np=np)
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
t1.extrude_mask(t=t0,
z0=z_min,
z1=z_max,
refraction_index='1+0.25*np.abs(x/200)**2',
v_globals=v_globals)
t1.draw_refraction_index(draw_borders=False)
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_discretize_refraction_index(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
print("Dx={}".format(x0[1] - x0[0]))
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = 50 * um
t0 = Scalar_mask_XZ(x=x0,
z=z0,
wavelength=wavelength,
n_background=1.0)
pn = dict(n_out=1.5,
n_center=4,
cx=0 * um,
cz=100 * um,
radius=75 * um)
center = (pn['cx'], pn['cz'])
radius = pn['radius']
# ref_index = '2*(((X-0)**2+(Z-300)**2)/75**2-0)'
ref_index = "{p[n_out]}+({p[n_center]}-{p[n_out]})*(1-((X-{p[cx]})**2+(Z-{p[cz]})**2)/{p[radius]}**2)".format(
p=pn)
t0.sphere(r0=center,
radius=(radius, radius),
refraction_index=ref_index,
angle=0)
t0.discretize_refraction_index(num_layers=6)
t0.draw_refraction_index(draw_borders=False, scale='equal')
t0.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_add_masks(self):
"""
several objects in the same
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = 2 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
t1.sphere(r0=(0, 100 * um),
radius=(40 * um, 40 * um),
refraction_index=2.5,
angle=0)
t1.sphere(r0=(0, 100 * um),
radius=(10 * um, 10 * um),
refraction_index=1,
angle=0)
for pos_slit in [200, 250, 300, 350]:
t1.slit(r0=(0 * um, pos_slit * um),
aperture=100 * um,
depth=10 * um,
refraction_index=1.5 - 1.5j,
refraction_index_center='',
angle=0 * degrees)
t1.draw_refraction_index(draw_borders=False, scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_extrude_mask_simple(self):
"""
takes an refraction index and convert a mask without depth, at one with
depth
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = .55 * um
t0 = Scalar_mask_X(x=x0, wavelength=wavelength)
t0.double_slit(x0=0, size=20 * um, separation=50 * um)
t0.draw()
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
t1.extrude_mask(t=t0,
z0=10 * um,
z1=50 * um,
refraction_index=1.5 - 1.5j)
t1.draw_refraction_index(draw_borders=True)
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_image(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 1024)
z0 = np.linspace(0 * um, 200 * um, 1024)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
script_dir = os.path.dirname(__file__)
rel_path1 = "star_hole.png"
image_name = os.path.join(script_dir, rel_path1)
t1.image(filename=image_name,
n_max=2,
n_min=1,
angle=0 * degrees,
invert=False)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_semi_plane(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-400 * um, 400 * um, 256)
z0 = np.linspace(-100 * um, 100 * um, 256)
wavelength = .5 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.semi_plane(r0=(0, 0),
refraction_index=2,
angle=0 * degrees,
rotation_point=None)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_layer(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-200 * um, 200 * um, 256)
z0 = np.linspace(-100 * um, 100 * um, 256)
wavelength = .5 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.layer(r0=(50, 0),
depth=75 * um,
refraction_index=2,
angle=0 * degrees,
rotation_point=None)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_rectangle(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 200 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.rectangle(r0=(0 * um, 100 * um),
size=(150 * um, 50 * um),
angle=0 * degrees,
refraction_index=1.5)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_slit(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256 * 4)
z0 = np.linspace(0 * um, 250 * um, 256 * 4)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.slit(r0=(0 * um, 50 * um),
aperture=50 * um,
depth=20 * um,
refraction_index=1.5 + 1j,
refraction_index_center='',
angle=0 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_sphere(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 200 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.sphere(r0=(0, 100 * um),
radius=(75 * um, 75 * um),
refraction_index=1.5,
angle=0 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_semi_sphere(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-200 * um, 200 * um, 256)
z0 = np.linspace(-120 * um, 120 * um, 256)
wavelength = .5 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.semi_sphere(r0=(0, 0),
radius=(100, 100),
refraction_index=2,
angle=0 * degrees)
t1.draw_refraction_index(draw_borders=True,
min_incr=0.01,
scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_aspheric_surface_z(self):
assert True
def test_aspheric_lens(self):
assert True
def test_wedge(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(0 * um, 200 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.wedge(r0=(0, 0),
length=100 * um,
refraction_index=1.5,
angle_wedge=22.5 * degrees,
angle=0 * degrees,
rotation_point=None)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_prism(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-150 * um, 150 * um, 256)
z0 = np.linspace(0 * um, 500 * um, 4096)
wavelength = 2 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.prism(r0=(100 * um, 150 * um),
length=200 * um,
refraction_index=2,
angle_prism=60 * degrees,
angle=90 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_biprism(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(-5 * um, 395 * um, 4096)
wavelength = 4 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.biprism(r0=(0, 0),
length=200 * um,
height=50 * um,
refraction_index=1.5,
angle=0)
t1.draw_refraction_index(draw_borders=True, scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_ronchi_grating(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 256)
z0 = np.linspace(0 * um, 1400 * um, 256)
wavelength = 0.5 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.ronchi_grating(period=50 * um,
fill_factor=.5,
length=500 * um,
height=20 * um,
r0=(0 * um, 100 * um),
Dx=2 * um,
refraction_index=1.5 + 0.5j,
heigth_substrate=25 * um,
refraction_index_substrate=1.5,
angle=0 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_ronchi_grating_convert(self):
"""
generate a diffraction grating with substrate
"""
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 256)
z0 = np.linspace(0 * um, 400 * um, 256)
wavelength = .55 * um
t0 = Scalar_mask_X(x=x0, wavelength=wavelength)
t0.slit(x0=0, size=0 * um)
t1 = Scalar_mask_X(x=x0, wavelength=wavelength)
t1.ronchi_grating(period=20 * um, x0=0 * um, fill_factor=0.5)
t1.draw()
t2 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
t2.extrude_mask(t=t0, z0=10 * um, z1=50 * um, refraction_index=1.5)
t2.extrude_mask(t=t1,
z0=50 * um,
z1=55.5 * um,
refraction_index=1.5 - 1.5)
t2.draw_refraction_index(draw_borders=False)
t2.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_sine_grating(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-250 * um, 250 * um, 256)
z0 = np.linspace(0 * um, 1000 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.sine_grating(period=20 * um,
heigth_sine=10 * um,
heigth_substrate=100 * um,
r0=(0 * um, 200 * um),
length=500 * um,
Dx=2 * um,
refraction_index=1.5,
angle=0 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_probe(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-12 * um, 12 * um, 256)
z0 = np.linspace(0 * um, 500 * um, 256)
wavelength = .6 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.probe(r0=(0, 50 * um),
base=10 * um,
length=200 * um,
refraction_index=1.5,
angle=0 * degrees)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_lens_plane_convergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-100 * um, 100 * um, 256)
z0 = np.linspace(-100 * um, 200 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
focal = t1.lens_plane_convergent(r0=(0, -50),
aperture=50 * um,
radius=50 * um,
thickness=50 * um,
refraction_index=1.5,
angle=0 * degrees,
mask=(10 * um, 3 + 0.05j))
print("focus distance f={} um".format(focal))
t1.draw_refraction_index(scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_lens_convergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-200 * um, 200 * um, 256)
z0 = np.linspace(-100 * um, 600 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
focal = t1.lens_convergent(r0=(0, 0),
aperture=300 * um,
radius=(1000 * um, -250 * um),
thickness=100 * um,
refraction_index=2,
angle=0 * degrees,
mask=(10 * um, 3 + 0.05j))
print("focus distance f={} um".format(focal))
t1.draw_refraction_index(scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_lens_plane_divergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-75 * um, 75 * um, 256)
z0 = np.linspace(-100 * um, 200 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
focal = t1.lens_plane_divergent(r0=(0, 0),
aperture=100 * um,
radius=50 * um,
thickness=25 * um,
refraction_index=2,
angle=0 * degrees,
mask=(10 * um, 3 + 0.05j))
print("focus distance f={} um".format(focal))
t1.draw_refraction_index(scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_lens_divergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-75 * um, 75 * um, 256)
z0 = np.linspace(-50 * um, 250 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
focal = t1.lens_divergent(r0=(0, 0),
aperture=100 * um,
radius=(-50 * um, 50 * um),
thickness=25 * um,
refraction_index=1.5,
angle=0 * degrees,
mask=(10 * um, 3 + 0.05j))
print("focus distance f={} um".format(focal))
t1.draw_refraction_index(scale='equal')
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_rough_sheet(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-150 * um, 150 * um, 256)
z0 = np.linspace(-150 * um, 150 * um, 256)
wavelength = 0.6238 * um
t1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
t1.rough_sheet(r0=(0 * um, 0 * um),
size=(200 * um, 25 * um),
t=10 * um,
s=10 * um,
refraction_index=1.5,
angle=0,
rotation_point=None)
t1.draw_refraction_index()
t1.save_data(filename=filename + '.npz', add_name='')
save_figure_test(newpath, func_name, add_name='')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: scalar_sources_X.py
# Purpose: 1D light sources tests
#
# Author: Luis Miguel Sanchez Brea
#
# Created: 2019/01/30
#
# Licence: GPL
# -------------------------------------------------------------------------------
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, um
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.utils_tests import comparison, save_figure_test
from numpy import linspace
# from functools import wraps
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_sources_X"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_sources_X(object):
# def saving_data(f):
# @wraps(f)
# def wrapped(inst, *args, **kwargs):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}'.format(newpath, func_name)
# print(filename)
#
# u0 = f(inst, *args, **kwargs)
# u0.save_data(filename=filename+'.npz')
# save_figure_test(newpath, func_name)
# assert True
#
# assert True
# #return wrapped
def test_plane_wave(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-1000 * um, 1000 * um, 512)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(theta=1 * degrees, z0=0 * um)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gauss_beam(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 2048)
wavelength = .5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1,
x0=0 * um,
z0=-2000 * um,
w0=25 * um,
theta=0 * degrees)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_spherical_wave_convergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.spherical_wave(A=1, x0=0 * um, z0=5 * mm, radius=200 * um)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_spherical_wave_divergent(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.spherical_wave(A=1, x0=0 * um, z0=-5 * mm, radius=200 * um)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_plane_waves_several_inclined(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_waves_several_inclined(A=1,
num_beams=5,
max_angle=5 * degrees)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_plane_waves_dict(self):
assert True
def test_gauss_beams_several_parallel(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beams_several_parallel(A=1,
num_beams=5,
w0=50 * um,
z0=0 * um,
x_central=0 * um,
x_range=750 * um,
theta=0 * degrees)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gauss_beams_several_inclined(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beams_several_inclined(A=1,
num_beams=5,
w0=250 * um,
x0=0 * um,
z0=0 * um,
max_angle=5 * degrees)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_interferences(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 2 * mm
x0 = linspace(-length / 2, length / 2, 1024)
wavelength0 = 0.6238 * um
u1 = Scalar_source_X(x=x0, wavelength=wavelength0)
u2 = Scalar_source_X(x=x0, wavelength=wavelength0)
u1.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=250 * um,
theta=.25 * degrees)
u2.gauss_beam(A=1,
x0=0 * um,
z0=0 * um,
w0=250 * um,
theta=-.25 * degrees)
u0 = u1 + u2
u0.draw(kind='intensity')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test for scalar_sources_XY"""
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, plt, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.utils_math import nearest2
from diffractio.utils_tests import comparison, save_figure_test
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "scalar_sources_XY"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_Scalar_sources_XY(object):
def test_plane_wave(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
# definición de parámetros iniciales
length = 250 * um
npixels = 256
# Generación de la clase
u = Scalar_source_XY(x=np.linspace(-length / 2, length / 2, npixels),
y=np.linspace(-length / 2, length / 2, npixels),
wavelength=0.6328 * um)
# carga de la onda plana
u.plane_wave(phi=2 * degrees, theta=5 * degrees)
# draw y guardar
u.draw(kind='phase')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gauss_beam(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de un haz gaussiano
"""
# definición de parámetros iniciales
length = 100 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# carga del haz gaussiano
u.gauss_beam(A=1,
r0=(0 * um, 0 * um),
z0=0,
w0=(25 * um, 25 * um),
phi=2 * degrees,
theta=5 * degrees)
# draw y guardar
u.draw(kind='field')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_spherical_wave(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de una onda esférica
"""
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# carga de la onda esferica
u.spherical_wave(A=1, r0=(0 * um, 0 * um), z0=-5 * mm, radius=300 * um)
# draw la onda esferica
u.draw(kind='field', normalize='maximum')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_spherical_wave_colimated(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de una onda esférica
"""
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# carga de la onda esferica
u.spherical_wave(A=1,
r0=(0 * um, 0 * um),
z0=-25.0 * mm,
radius=1300 * um)
t = Scalar_mask_XY(x0, y0, wavelength0)
t.lens(r0=(0, 0),
radius=(300 * um, 300 * um),
focal=(25 * mm, 25 * mm),
angle=0)
u_salida = u * t
u.draw(kind='field')
t.draw(kind='field')
# draw la onda esferica
u_salida.draw(kind='field', normalize='maximum')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_vortex_beam(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de un vórtice
"""
# definición del vortex_beam
m = 3
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# carga del vortex_beam
u.vortex_beam(A=1, r0=(0, 0), w0=250 * um, m=m)
# draw el vortex_beam
title = '$m_{vortice}= %d$' % (m)
u.draw(kind='field', title=title)
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_vortices(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
# matrix size
M = 5
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# Dos drawings, uno para la amplitude y otro para phase
plt.figure(figsize=(10, 4.5))
plt.suptitle("$Vortices$", fontsize=20)
for m in range(M):
u.vortex_beam(A=1, r0=(0 * um, 0 * um), w0=100 * um, m=m)
# carga de los drawings
title = "(%d)" % (m)
plt.subplot(2, M, m + 1)
plt.axis('off')
plt.title(title)
h1 = plt.imshow(np.abs(u.u)**2)
h1.set_cmap("gist_heat")
plt.subplot(2, M, m + M + 1)
plt.axis('off')
h2 = plt.imshow(np.angle(u.u))
h2.set_cmap("seismic")
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_1laguerre(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de haz de laguerre_beam
"""
# matrix size
N = 2
K = 2
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# carga del haz de Laguerre
u.laguerre_beam(A=1,
n=N,
l=K,
r0=(0 * um, 0 * um),
w0=100 * um,
z=0.01 * um,
z0=0)
# drawing
title = r'$n=%d, k=%d$' % (N, K)
u.draw(kind='field', title=title)
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_num_data(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de varios haces de num_data = 256
"""
# matrix size
N = 3
K = 3
# definición de parámetros iniciales
length = 750 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# Dos drawings, uno para la amplitude y otro para phase
ID1 = plt.figure()
plt.suptitle("amplitude", fontsize=20)
ID2 = plt.figure()
plt.suptitle("phase", fontsize=20)
# Generación de la clase
for n in range(N + 1):
for k in range(K + 1):
u.laguerre_beam(A=1,
n=n,
l=k,
r0=(0 * um, 0 * um),
w0=100 * um,
z=0.01 * um,
z0=0)
title = "(%d,%d)" % (n, k)
plt.figure(ID1.number)
plt.subplot(N + 1, K + 1, (N + 1) * (k) + n + 1)
plt.axis('off')
plt.title(title, fontsize=14)
h1 = plt.imshow(np.abs(u.u)**2)
h1.set_cmap("gist_heat")
plt.figure(ID2.number)
plt.subplot(N + 1, K + 1, (N + 1) * (k) + n + 1)
plt.axis('off')
plt.title(title, fontsize=14)
h2 = plt.imshow(np.angle(u.u))
h2.set_cmap("seismic")
plt.figure(ID1.number)
plt.figure(ID2.number)
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_Hermite_Gauss(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
# definción del tamaño y parámetros iniciales
length = 250 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
# u.hermite_gauss_beam(I0=1, w=100*um, n = [0,0,1,1,3], m =[0,1,0,1,3], c_mn=[1,1,1,1,1])
u.hermite_gauss_beam(A=1,
r0=(0, 0),
w0=100 * um,
n=1,
m=1,
z=0,
z0=(0, 0))
u.draw(kind='intensity')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_1zernike(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
# parámetros del polinomio de Zernike
N = np.array([1, 1, 2, 2, 2])
M = np.array([-1, 1, -2, 0, 2])
c_nm = np.array([1, 1, 1, 1, 1])
# n=1,2,3,...
# m=-n:-n+2, ...., n-2, n
# definción del tamaño y parámetros iniciales
length = 1000 * um
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# creación del u
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
u.zernike_beam(A=1, r0=(0, 0), radius=length / 2, n=N, m=M, c_nm=c_nm)
u.pupil()
u.draw(kind='field')
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_zernikes(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""
Generación de varios haces de Zernike
"""
# matrix size
N = 4
# definición de parámetros iniciales
length = 2 * mm
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
# Dibujo
plt.figure(figsize=(6, 7))
plt.suptitle(u"polinomios de Zernike (n,m)", fontsize=20)
# Generación de la clase
u = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
for n in range(0, N + 1):
pos = 0
for m in range(-n, n + 1, 2):
pos = pos + 1
u.zernike_beam(A=1,
r0=(0, 0),
radius=length / 2,
n=np.array([n]),
m=np.array([m]),
c_nm=np.array([1]))
u.pupil()
# carga de los drawings
title = "(%d,%d)" % (n, m)
plt.subplot(N + 1, N + 1, n * (N + 1) + pos)
plt.axis('off')
plt.title(title, fontsize=14)
h2 = plt.imshow(np.angle(u.u))
plt.clim(vmin=-np.pi, vmax=np.pi)
h2.set_cmap("seismic")
u.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_plane_waves_several_inclined(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 256)
y0 = np.linspace(-500 * um, 500 * um, 256)
wavelength = 0.6328 * um
u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u0.plane_waves_several_inclined(A=1,
num_beams=(5, 5),
max_angle=(5 * degrees, 180 * degrees))
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_plane_waves_dict(self):
assert True
def test_gauss_beams_several_parallel(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 256)
y0 = np.linspace(-500 * um, 500 * um, 256)
wavelength = 0.6328 * um
u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u0.gauss_beams_several_parallel(A=1,
num_beams=(5, 5),
w0=50 * um,
z0=0 * um,
r0=(0 * um, 0 * um),
r_range=(750 * um, 750 * um),
theta=0 * degrees,
phi=0 * degrees)
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_gauss_beams_several_inclined(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
x0 = np.linspace(-500 * um, 500 * um, 256)
y0 = np.linspace(-500 * um, 500 * um, 256)
wavelength = 0.6328 * um
u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u0.gauss_beams_several_inclined(A=1,
num_beams=(5, 5),
w0=250 * um,
r0=(0 * um, 0 * um),
z0=0 * um,
max_angle=(10 * degrees,
180 * degrees))
u0.draw(kind='field')
u0.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_interferences(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
length = 2 * mm
x0 = np.linspace(-length / 2, length / 2, 256)
y0 = np.linspace(-length / 2, length / 2, 256)
wavelength0 = 0.6238 * um
u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
u2 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength0)
u1.gauss_beam(A=1,
r0=(0 * um, 0 * um),
w0=(500 * um, 500 * um),
z0=0 * um,
phi=2 * degrees,
theta=10 * degrees)
u2.gauss_beam(A=1,
r0=(0 * um, 0 * um),
w0=(500 * um, 500 * um),
z0=0 * um,
phi=2 * degrees,
theta=-10 * degrees)
u3 = u1 + u2
u3.draw(kind='intensity', title="$interferencias$")
u3.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
def test_extent_source(self):
func_name = sys._getframe().f_code.co_name
filename = '{}{}'.format(newpath, func_name)
"""in this test I get a previous mask and then I fill the mask with sperical-waves
"""
# definitions of space and wavelength
num_data = 256
length = 250 * um
x = np.linspace(-length / 2, length / 2, num_data)
y = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328 * um
# location of spherical sources
z0 = -5 * mm
# I define the mask where point sources are defined
t_mask = Scalar_mask_XY(x, y, wavelength)
t_mask.circle(r0=(0 * um, 0 * um), radius=(25 * um, 25 * um))
t_mask.draw()
# distance between point sources (if possible all pixels)
dist_sources_x = 2 * um
dist_sources_y = 2 * um
pos_x = np.arange(x[0], x[-1], dist_sources_x)
pos_y = np.arange(y[0], y[-1], dist_sources_y)
ix, vx, distx = nearest2(x, pos_x + 1)
iy, vy, disty = nearest2(y, pos_y + 1)
u1 = Scalar_source_XY(x, y, wavelength)
x0, y0 = np.meshgrid(ix, iy)
u1.u[x0, y0] = 1
u_mask = u1 * t_mask # I have to extract positions from here
xpos = u_mask.X[u_mask.u > 0.5]
ypos = u_mask.Y[u_mask.u > 0.5]
u_final = Scalar_source_XY(x, y, wavelength)
u_temp = Scalar_source_XY(x, y, wavelength)
for x_i, y_i in zip(xpos, ypos):
u_temp.spherical_wave(A=1, r0=(x_i, y_i), z0=z0, radius=0 * um)
u_final = u_final + u_temp
u_final.draw(kind='field')
u_final.save_data(filename=filename + '.npz')
save_figure_test(newpath, func_name)
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: scalar_fields_XZ.py
# Purpose: tests
#
# Author: Luis Miguel Sanchez Brea
#
# Created: 2017
# Copyright:
# Licence: GPL
# -------------------------------------------------------------------------------
import datetime
import os
import sys
import numpy as np
from diffractio import eps, no_date
from diffractio.utils_math import (amplitude2phase, binarize, distance, ndgrid,
nearest, nearest2, normalize)
from diffractio.utils_tests import comparison
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "utils_math"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
class Test_utils_math(object):
def test_distance(self):
func_name = sys._getframe().f_code.co_name
solution = 1.
x1 = np.array([0, 1, 1])
x2 = np.array([0, 0, 1])
proposal = distance(x1, x2)
assert comparison(proposal, solution, eps), func_name
solution = np.sqrt(3)
x1 = np.array([0, 0, 0])
x2 = np.array([1, 1, 1])
proposal = distance(x1, x2)
assert comparison(proposal, solution, eps), func_name
solution = np.sqrt(2)
x1 = np.array([0, 0, 1j])
x2 = np.array([0, 0, 1])
proposal = distance(x1, x2)
assert comparison(proposal, solution, eps), func_name
def test_nearest(self):
func_name = sys._getframe().f_code.co_name
solution = 10
x = np.linspace(0, 10, 21)
x0 = 5
proposal, _, _ = nearest(x, x0)
assert comparison(proposal, solution, eps), func_name
def test_nearest2(self):
func_name = sys._getframe().f_code.co_name
x = np.linspace(0, 10, 11)
solution = x
proposal, _, _ = nearest2(x, x)
assert comparison(proposal, solution, eps), func_name
def test_ndgrid(self):
func_name = sys._getframe().f_code.co_name
solution = np.array([[0, 0, 0], [1, 1, 1]])
x, y = [0, 1], [2, 3, 4]
X, Y = ndgrid(x, y)
proposal = X
assert comparison(proposal, solution, eps), func_name
def test_binarize(self):
func_name = sys._getframe().f_code.co_name
solution = np.array([0., 0., 0., 1., 1., 1.])
vector = np.linspace(0, 1, 6)
proposal = binarize(vector, min_value=0, max_value=1)
assert comparison(proposal, solution, eps), func_name
solution = np.array([-1., -1., -1., 1., 1., 1.])
vector = np.linspace(-1, 1, 6)
proposal = binarize(vector, min_value=-1, max_value=1)
assert comparison(proposal, solution, eps), func_name
def test_amplitude2phase(self):
func_name = sys._getframe().f_code.co_name
u = np.linspace(0, 2 * np.pi, 6)
solution = np.exp(1j * u)
proposal = amplitude2phase(u)
assert comparison(proposal, solution, eps), func_name
def test_phase2amplitude(self):
# TODO:test
assert True
def test_normalize(self):
func_name = sys._getframe().f_code.co_name
solution = np.array([1, 1]) / np.sqrt(2)
v = np.array([1, 1])
proposal = normalize(v, 2)
assert comparison(proposal, solution, eps), func_name
solution = np.array([1 + 1j, 0]) / np.sqrt(2)
v = np.array([1 + 1j, 0])
proposal = normalize(v, 2)
assert comparison(proposal, solution, eps), func_name
def test_vector_product(self):
# TODO:test
assert True
def test_dot_product(self):
# TODO:test
assert True
def test_divergence(self):
# TODO:test
assert True
def test_curl(self):
# TODO:test
assert True
def test_get_transitions(self):
# TODO:test
assert True
def test_cut_function(self):
# TODO:test
assert True
def test_fft_convolution2d(self):
# TODO:test
assert True
def test_fft_convolution1d(self):
# TODO:test
assert True
def test_fft_correlation1d(self):
# TODO:test
assert True
def test_fft_correlation2d(self):
# TODO:test
assert True
def test_rotate_image(self):
# TODO:test
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: scalar_fields_XZ.py
# Purpose: tests
#
# Author: Luis Miguel Sanchez Brea
#
# Created: 2017
# Copyright:
# Licence: GPL
# -------------------------------------------------------------------------------
import datetime
import os
import time
import numpy as np
from diffractio import no_date
from diffractio.utils_multiprocessing import auxiliar_multiprocessing
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
path_base = "tests_results"
path_class = "utils_math"
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
def function_to_test(iterable, constant):
return iterable**2 * constant
class Test_utils_math(object):
def test_distance(self):
dict_constants = {'x': 3, 'y': 4}
N = 50000
variable_process = np.linspace(0, 1, N)
start = time.time()
sc = auxiliar_multiprocessing()
sc.execute_multiprocessing(function_to_test, variable_process, 1, 8)
# print("{}".format(np.array(sc.result)))
print("8 processes pool took {} seconds".format(time.time() - start))
start = time.time()
res = np.zeros(N)
for ind, val in enumerate(variable_process):
res[ind] = function_to_test(val, 1)
print(
"Single process pool took {} seconds".format(time.time() - start))
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import os
import sys
from diffractio import mm, no_date, np, um
from diffractio.utils_tests import save_figure_test
from diffractio.vector_sources_XY import Vector_source_XY
path_base = "tests_results"
path_class = "Vector_draw_XY"
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
v_lineal = (1, 0)
v_circular = (1, 1j) / np.sqrt(2)
length = 500 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
EM = Vector_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u=1, r0=(0 * um, 0 * um), radius=(length / 5, length / 5))
EM.VRS(z=30 * mm, new_field=False)
Ex, Ey, _ = EM.get()
EM.reduce_matrix = ''
class Test_Vector_fields_XY(object):
def test_draw_intensity(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='intensity')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_intensities(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_phases(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='phases')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_fields(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_stokes(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_draw_param_ellipse(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
EM.draw(kind='param_ellipse')
save_figure_test(newpath, func_name, add_name='')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.utils_tests import save_figure_test
from diffractio.vector_masks_XY import Vector_mask_XY
from diffractio.vector_sources_XY import Vector_source_XY
path_base = "tests_results"
path_class = "Vector_fields_XY"
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
v_lineal = (1, 0, 0)
v_circular = (1, 1j, 0) / np.sqrt(2)
class Test_Vector_fields_XY(object):
def test_save_load(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
assert True
def test_clear_field(self):
# func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
assert True
def test_mul(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
mask = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
mask.fresnel_lens(r0=(0 * um, 0 * um),
radius=(125 * um, 125 * um),
focal=(2 * mm, 2 * mm),
kind='amplitude')
vc = Vector_mask_XY(x0, y0, wavelength)
vc.apply_scalar_mask(u_mask=mask)
vp = Vector_mask_XY(x0, y0, wavelength)
vp.polarizer_linear(azimuth=0 * degrees)
EM = vp
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_vc')
EM2 = vc * vp
EM2.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_vp')
assert True
def test_generar_field_vectorial1(self):
"""
aquí vemos cómo se puede generar el field vectorial a partir
de vueltas sucesivas a los fields E y H
"""
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 512
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328
EM = Vector_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u=1,
r0=(0 * um, 0 * um),
radius=(length / 5, length / 5))
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_0')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_2')
assert True
def test_generar_field_vectorial2(self):
"""
Lo mismo que antes, pero con la operación utils, sin testeo
"""
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2
u0 = Scalar_source_XY(x0, y0, wavelength)
u0.gauss_beam(A=1, z0=0 * um, r0=(0, 0), w0=(25 * um, 25 * um))
EM = Vector_source_XY(x0, y0, wavelength)
EM.constant_polarization(u0, v=[1, 1])
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_0')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_1')
assert True
def test_plane_wave_generacion(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 500 * um
num_data = 16
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328
# con esto definimos el field E
EM = Vector_source_XY(x0, y0, wavelength)
EM.constant_polarization(u=1, v=[1, 0])
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_0')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_1')
t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
t1.circle(r0=(0 * um, 0 * um),
radius=(
length / 2,
length / 2,
),
angle=0 * degrees)
EM.apply_mask(t1)
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_2')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_3')
assert True
def test_RS(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
num_data = 256
length = 150 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
EM = Vector_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_radial(u=1,
r0=(0 * um, 0 * um),
m=1,
fi0=0,
radius=0.)
EM.pupil()
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_1EH')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_2S')
EMz = EM.VRS(z=.5 * mm)
EMz.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_3EH_p')
EMz.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_4S_p')
return True
def test_VRS(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
num_data = 256
length = 150 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
EM = Vector_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_radial(u=1,
r0=(0 * um, 0 * um),
m=1,
fi0=0,
radius=0.)
EM.pupil()
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_1EH')
EM.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_2S')
EMz = EM.VRS(z=.5 * mm)
EMz.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_3EH_p')
EMz.draw(kind='intensities')
save_figure_test(newpath, func_name, add_name='_4S_p')
return True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import os
import sys
from diffractio import degrees, mm, no_date, np, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.utils_tests import save_figure_test
from diffractio.vector_masks_XY import Vector_mask_XY
from py_pol.jones_matrix import Jones_matrix
path_base = "tests_results"
path_class = "vector_masks_XY"
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
polarization_x = [1, 0]
polarization_y = [0, 1]
polarization_right = [1, 1.j] / np.sqrt(2)
polarization_left = [1, -1.j] / np.sqrt(2)
polarization_45 = [1, 1] / np.sqrt(2)
polarization_m45 = [1, -1] / np.sqrt(2)
class Test_vector_masks_XY(object):
def test_equal_mask(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
# mask escalar
mask = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
mask.ring(r0=(0 * um, 0 * um),
radius1=(25 * um, 25 * um),
radius2=(75 * um, 75 * um),
angle=0 * degrees)
# mask vectorial
EM = Vector_mask_XY(x0, y0, wavelength)
EM.apply_scalar_mask(u_mask=mask)
EM.draw(kind='all')
save_figure_test(newpath, func_name, add_name='')
assert True
def test_complementary_mask(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
mask = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)
mask.fresnel_lens(r0=(0 * um, 0 * um),
radius=(125 * um, 125 * um),
focal=(2 * mm, 2 * mm),
angle=0 * degrees,
kind='amplitude')
EM = Vector_mask_XY(x0, y0, wavelength)
EM.complementary_masks(mask=mask,
state_0=np.array([[1, 0], [0, 0]]),
state_1=np.array([[0, 0], [0, 1]]))
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_from_py_pol(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
PL = Jones_matrix('m0')
PL.from_components(components=(0.9, 0, 0, 0.2 * np.exp(1j)))
EM = Vector_mask_XY(x0, y0, wavelength)
EM.from_py_pol(PL)
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_polarizer_linear(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
EM = Vector_mask_XY(x0, y0, wavelength)
EM.polarizer_linear(azimuth=0 * degrees)
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_quarter_wave(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
EM = Vector_mask_XY(x0, y0, wavelength)
EM.quarter_waveplate(azimuth=0 * degrees)
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_half_wave(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
EM = Vector_mask_XY(x0, y0, wavelength)
EM.half_waveplate(azimuth=0 * degrees)
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
def test_polarizer_retarder(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
wavelength = 0.6328 * um
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
EM = Vector_mask_XY(x0, y0, wavelength)
EM.polarizer_retarder(R=90 * degrees,
p1=0.9,
p2=0.1,
azimuth=0 * degrees)
EM.draw(kind='amplitude')
save_figure_test(newpath, func_name, add_name='_amplitude')
EM.draw(kind='phase')
save_figure_test(newpath, func_name, add_name='_phase')
assert True
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import datetime
import os
import sys
from diffractio import degrees, no_date, np, um
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.utils_tests import save_figure_test
from diffractio.vector_sources_XY import Vector_source_XY
path_base = "tests_results"
path_class = "vector_sources_XY"
if no_date is True:
date = '0'
else:
now = datetime.datetime.now()
date = now.strftime("%Y-%m-%d_%H")
newpath = "{}_{}/{}/".format(path_base, date, path_class)
if not os.path.exists(newpath):
os.makedirs(newpath)
polarization_x = [1, 0]
polarization_y = [0, 1]
polarization_right = [1, 1.j] / np.sqrt(2)
polarization_left = [1, -1.j] / np.sqrt(2)
polarization_45 = [1, 1] / np.sqrt(2)
polarization_m45 = [1, -1] / np.sqrt(2)
class Test_vector_sources_XY(object):
def test_constant_polarization(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 25 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 1 * um
EM = Vector_source_XY(x0, y0, wavelength)
EM.constant_polarization(u=1, v=(1, 1j))
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_interferences(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 100 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328
u0 = Scalar_source_XY(x0, y0, wavelength)
u0.plane_wave(A=1, theta=-1 * degrees, phi=0 * degrees)
u1 = Scalar_source_XY(x0, y0, wavelength)
u1.plane_wave(A=1, theta=1 * degrees, phi=0 * degrees)
EM1 = Vector_source_XY(x0, y0, wavelength)
EM1.constant_polarization(u=u0, v=[1, 0])
EM2 = Vector_source_XY(x0, y0, wavelength)
EM1.constant_polarization(u=u1, v=[1, 0])
EM = EM1 + EM2
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_azimuthal_wave(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
EM = Vector_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u=1,
r0=(0 * um, 0 * um),
radius=(length / 2, length / 2))
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_radial_wave(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 250 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
EM = Vector_source_XY(x0, y0, wavelength)
EM.radial_wave(u=1,
r0=(0 * um, 0 * um),
radius=(length / 2, length / 2))
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_gauss(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 75 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
u = Scalar_source_XY(x0, y0, wavelength)
u.gauss_beam(A=1,
r0=(0 * um, 0 * um),
z0=0,
w0=(15 * um, 15 * um),
theta=0. * degrees,
phi=0 * degrees)
EM = Vector_source_XY(x0, y0, wavelength)
EM.constant_polarization(u, v=(1, 1))
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_gauss_radial(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 75 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2 * um
u = Scalar_source_XY(x0, y0, wavelength)
u.gauss_beam(A=1,
r0=(0 * um, 0 * um),
w0=(15 * um, 15 * um),
z0=0,
theta=0. * degrees,
phi=0 * degrees)
EM = Vector_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u)
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_local_polarized_vector_wave(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 500 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2
EM = Vector_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave(u=1,
r0=(0 * um, 0 * um),
m=1.5,
fi0=0 * np.pi)
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_local_polarized_vector_wave_radial(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 500 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2
EM = Vector_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_radial(u=1,
r0=(0 * um, 0 * um),
m=0.5,
fi0=np.pi / 2)
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True
def test_local_polarized_vector_wave_hybrid(self):
func_name = sys._getframe().f_code.co_name
# filename = '{}{}.npz'.format(newpath, func_name)
length = 500 * um
num_data = 256
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 2
EM = Vector_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_hybrid(u=1,
r0=(0 * um, 0 * um),
m=1,
n=3,
fi0=np.pi / 2)
EM.draw(kind='fields')
save_figure_test(newpath, func_name, add_name='_fields')
EM.draw(kind='stokes')
save_figure_test(newpath, func_name, add_name='_stokes')
assert True

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display