pyoptools.wavefront.field package

Module contents

class pyoptools.wavefront.field.Field

Bases: object

Class that defines an optical field distribution.

The sampled field uses an regular Cartesian sampling.

ARGUMENTS:

data 2D numpy array containing the complex field information. The number of samples are given by data’s shape.
psize Pixel size of the sample field (resolution)
amp_im Filename of the image containing the amplitude of the field
ph_im Filename of the image containing the phase of the field
amp_n Floating point number used to normalize the amplitude 1/255. by default
ph_n Floating point number used to normalize the phase. 2*pi/255 by default.

The field data can be given as a numpy complex array, or as a set of 2 images, one containing the amplitude of the field, and the other containing the phase of the field. The amp_n, and the ph_n attributes are used to normalize the field. If the images are color images, they are flattened to produce a grayscale image. See: scipy.misc.imread

abs()

Returns an array containing the absolute value of the field

angle

Returns the wrapped phase of the field (mod 2 pi)

check_z()

Given the field characteristics, return the tipical z’s that should be used in the different propagation algorithms.

conj()

Returns the conjugated field

data
field_sample_coord

Returns the 2D arrays X and Y containing the field sampling coordinates

intensity()

Returns an array containing the intensity of the field

l
mask

Return the mask of the data. True indicates masked values (invalid), False indicates valid data.

phase

Returns an array containing the unwrapped phase of the optical field

propagate()

Method that calculates the free space propagation of an optical field.

ARGUMENTS

r Vector that goes from the source plane origin, to the destination plane origin. If r is not a vector but a floating point number, it assumes that the vector is (0,0,r).
n Media refraction index (Not implemented yet assume n=1)
method

Propagation method:

“ae” Angular spectrum propagation method

“rsc” Convolution with the Rayleigh Sommerfeld Kernel

“rsi” Propagate the field using the Rayleigh Sommerfeld
integral

“???”

“auto” Automatically select the best propagation method
given the field conditions.
fix If set to true, the field is re-sampled or resized, so the sampling conditions for the selected propagation method are met.

RETURN VALUE:

Field instance containing the propagated optical field

propagate_ae()

Propagate the field a distance z using angular spectrum method.

Warning

Check if n is implemented and working

propagate_ae_d()

Propagate the field a distance z using angular spectrum method. The observation plane is shifted by x,y units

propagate_fraunhofer()

Propagate the field using the Fraunhofer approximation

ARGUMENT:

z Propagation distance
propagate_fresnel()

Calculate the fresnel transform, using the FFT algorithm.

ARGUMENT:

z Propagation distance
propagate_rs()

Method that calculates the free space propagation of an optical field.

This method calculates the optical propagation of a field, using the Rayleigh Sommerfeld propagation kernel. Depending on the propagation distance, this method selects between the angular spectrum method, and the Rayleigh Sommerfeld convolution method

ARGUMENTS:

z Propagation distance.
n Media refraction index (Not implemented yet assume n=1)
shape Tuple indicating the shape (number of pixels) of the returned field. If shape = None, the field size is preserved.

The other parameters are kept.

RETURN VALUE:

Field instance containing the propagated optical field
propagate_rsc()

Propagate the field a distance z making the convolution with the Rayleigh Sommerfeld kernel.

To avoid noise, the kernel is calculated increasing the size of the matrix.

propagate_rsc_d()

Propagate the field a distance z making the convolution with the Rayleigh Sommerfeld kernel.

To avoid noise, the kernel is calculated increasing the size of the matrix.

propagate_rsc_sc()

Propagate the field a distance z , scaling the output shape by the values given in scale. The resolution remains the same.

propagate_rsi()

Propagate the field a distance z, using the Rayleigh Sommerfeld integral. If dest is not given, the returned field has the same size and discretization of the propagated filed, else the Field class instance (dfield) is filled with propagated values, keeping its size and discretization. The value of the propagated field is returned.

propagate_rsi1()

Propagate the field a distance z, using the Rayleigh Sommerfeld integral. If dest is not given, the returned field has the same size and discretization of the propagated filed, else the Field class instance (dfield) is filled with propagated values, keeping its size and discretization. The value of the propagated field is returned.

propagate_rsi_gpu()
psize
rayrep()

Method to calculate the ray representation of the wavefront.

nx Number of samples to use in the x direction ny Number of samples to use in the Y direction eps Allowed maximum value for lap a/ a (eikonal condition)

Note: This ray representation has only information about the phase.
the intensity, is not yet represented in the ray representation. this needs to be solved.
res

Returns a tuple (dx,dy) containing the resolution(size of each pixel)

resample()

Returns a resampled optical field The size is not modified.

  • res *
    Tuple (rx,ry) indicating the new width and height of the optical field in pixels.

Note: In all resamples, the origin of the optical field is preserved (the origin is always at the center)

resize()

Returns a resized optical field. The resolution is not modified.

  • samples *
    Tuple (nx,ny) indicating the new number of samples of the optical field.

Note: In all resizes, the origin of the optical field is preserved (the origin is always at the center)

shape

Returns the shape of the data contained in the field

size

Returns a tuple containing the size of the area where the field is sampled

tilt()

Rotate around the origin the field observation plane

Idea Taken from:
Free-space beam propagation between arbitrarily oriented planes based on full diffraction theory: a fast Fourier transform approach. The interpolation algorithm suggested in the paper, does not work. This routine is based on a novel interpolation algorithm.
r
Tuple (rx,ry,rz) where rx is the rotation around the x axis, ry is the rotation around the y axis and rz is the rotation around the z axis that must be issued to the object plane, to obtain the image plane.

The rotations are applied first to the z axis, and then to the y axis and finally to the x axis. (need to verify this to check if this is consistent with wxRayTrace).

xsamples

Return the sample points in X

ysamples

Return the sample points in Y

pyoptools.wavefront.field.plane_wave()

Function that returns a plane wave (Field object) that describes a plane wave

** ARGUMENTS **

n Tuple (nx,ny,nz) indicating a vector normal to the plane wave
l Wavelength of the plane wave (usually given in microns)
size Tuple (sx,sy) indicating the physical size of the window used where the field is defined. It must have the same units as l
samples Tuple (nx,ny) indicating the number of samples to be used when creating the plane wave
a Amplitude of the plane wave
ph Phase of the plane wave at the origin (center of the sampling)
pyoptools.wavefront.field.spherical_wave()

Function that returns a spherical wave (Field instance)

The spherical wave returned, is evaluated in the plane Z=0, assuming the source point at the coordinates X,Y,Z, given by ‘’o’’. If o is a number, and not a vector, the source point location is the point (0,0,o)

** Arguments: **

o Location of the point source, assuming that the observation plane is given by Z=0
l Wave length of the spherical wave, usually given in microns
size Tuple (sx,sy) indicating the physical size of the window used where the field is defined. It must have the same units as l
samples Tuple (nx,ny) indicating the number of samples to be used when creating the plane wave
a Amplitude of the plane wave
ph Phase of the spherical wave at the origin (center of the sampling)

Note

If z is positive, the spherical wave generated will be convergent when the wave is propagating in the positive direction of the Z axis. If z is negative, the wave will be divergent.