pyoptics.masks

Masks useful for optical applications.

Functions

annular_mask

Create annular disk.

circular_mask

Create circular disk.

elliptical_mask

Create elliptical mask.

mask_from_polygon

Create masks from interior of a convex or concave polygon.

rectangluar_mask

Create rectangluar mask.

thin_lens

Complex transmission of an ideal thin lens (paraxial).

to_bool

Return a boolean mask from an integer one.

to_int

Return integer mask from an integer one.

pyoptics.masks.circular_mask(x, y, R, x0=0.0, y0=0.0)[source]

Create circular disk.

Parameters:
x, yarrays
Rnumber

Radius of disk.

x0, y0numbers, optional

Center coordinates.

Returns:
maskarray, int
pyoptics.masks.annular_mask(x, y, R_outer, R_inner, x0=0.0, y0=0.0)[source]

Create annular disk.

Parameters:
x, yarrays
R_outer, R_innernumbers

Outer and inner radius of annulus.

x0, y0numbers, optional

Center coordinates.

Returns:
maskarray
pyoptics.masks.rectangluar_mask(x, y, a, b, x0=0.0, y0=0.0, include_1d_output=False)[source]

Create rectangluar mask.

Parameters:
x, yarrays
a, bnumbers

Half side lengths of rectangle.

x0, y0numbers, optional

Center coordinates.

include_1d_outputboolean, optional

If True, return signature is (mask, mask_x, mask_y) with mask being the outer product of mask_y and mask_x.

Returns:
maskarray, int
pyoptics.masks.elliptical_mask(x, y, a, b, x0=0.0, y0=0.0)[source]

Create elliptical mask.

Parameters:
x, yarrays
a, bnumbers

Semi-major axis of ellipse.

x0, y0numbers, optional

Center coordinates.

Returns:
maskarray
pyoptics.masks.to_bool(mask)[source]

Return a boolean mask from an integer one.

Parameters:
maskarray, integer
Returns:
mask_boolarray, boolean
pyoptics.masks.to_int(mask)[source]

Return integer mask from an integer one.

Parameters:
maskarray, bool
Returns:
mask_intarray, integer
pyoptics.masks.mask_from_polygon(x, y, x_poly, y_poly)[source]

Create masks from interior of a convex or concave polygon.

Parameters:
x, yarray

Coordinates of to create mask of.

x_poly, y_polyarrays

Linear arrays of coordinates on polygonal boundaries.

Returns:
maskarray

Integer mask, 1 for all interior points, 0 for all points outisde given polygon.

pyoptics.masks.thin_lens(x, y, f, wavelength, n=1.0, x0=0.0, y0=0.0)[source]

Complex transmission of an ideal thin lens (paraxial).

Parameters:
x, yarrays
fnumber

Focal length. f > 0 for a converging lens.

wavelengthnumber

Vacuum wavelength.

nnumber, optional

Refractive index of the medium behind the lens.

x0, y0numbers, optional

Center coordinates.

Returns:
tarray

exp(-i*k*r**2/(2*f)). With the exp(i(kz - omega*t)) convention, this turns a plane wave into a wave converging towards z = f.