pyoptools.wavefront.field.field module

class pyoptools.wavefront.field.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.field.s()
pyoptools.wavefront.field.field.s2d()