API reference

This page gives an overview of all public functions, modules, and objects included in Lentil. All classes and functions exposed in the lentil namespace are public.

Some subpackages are public including lentil.radiometry and lentil.detector.

Planes

lentil.Plane([amplitude, phase, mask, ...])

Base class for representing a finite geometric plane.

lentil.Pupil([focal_length, pixelscale, ...])

Class for representing a pupil plane.

lentil.Image([amplitude, phase, mask, ...])

Class for representing an image plane.

lentil.Detector([amplitude, phase, mask, ...])

Class for representing an image plane that returns intensity.

lentil.Grism(trace, dispersion[, ...])

Class for representing a grism.

lentil.Tilt(x, y)

Object for representing tilt in terms of an angle

lentil.Rotate([angle, unit, order])

Rotate a Wavefront by a specified angle

lentil.Flip([axis])

Flip a wavefront along specified axis

Wavefront

lentil.Wavefront(wavelength[, pixelscale, ...])

A class representing a monochromatic wavefront.

Zernike polynomials

lentil.zernike(mask, index[, normalize, ...])

Compute the circular Zernike polynomial for a given mask.

lentil.zernike_basis(mask, modes[, ...])

Compute a Zernike basis set for a given mask.

lentil.zernike_compose(mask, coeffs[, ...])

Create an OPD based on the supplied Zernike coefficients.

lentil.zernike_coordinates(mask[, shift, rotate])

Compute the Zernike coordinate system for a given mask.

lentil.zernike_fit(opd, mask, modes[, ...])

Fit a Zernike basis set to an OPD.

lentil.zernike_remove(opd, mask, modes[, ...])

Fit and remove a Zernike basis set from an OPD.

Wavefront errors

lentil.power_spectrum(mask, pixelscale, rms, ...)

Wavefront error defined by a Power Spectral Density (PSD) function.

lentil.translation_defocus(mask, f_number, ...)

Defocus error characterized by a axial translation.

Imaging artifacts

lentil.jitter(img, scale[, pixelscale, ...])

Apply image jitter via convolution.

lentil.smear(img, distance[, angle, ...])

Apply image smear via convolution.

Utilities

Shapes

lentil.circle(shape, radius[, shift])

Compute a circle with anti-aliasing.

lentil.circlemask(shape, radius[, shift])

Compute a circular mask.

lentil.hexagon(shape, radius[, rotate])

Compute a hexagon mask.

lentil.slit(shape, width)

Compute a slit mask.

Array manipulation

lentil.boundary(x[, threshold])

Find bounding row and column indices of data within an array.

lentil.centroid(img)

Compute image centroid location.

lentil.pad(array, shape)

Zero-pad an array.

lentil.window(img[, shape, slice])

Extract an appropriately sized, potentially windowed array

lentil.rebin(img, factor)

Rebin an image by an integer factor.

lentil.rescale(img, scale[, shape, mask, ...])

Rescale an image by interpolation.

Miscellaneous

lentil.min_sampling(wave, z, du, npix, min_q)

lentil.pixelscale_nyquist(wave, f_number)

Compute the output plane sampling which is Nyquist sampled for intensity.

lentil.normalize_power(array[, power])

Normalizie the power in an array.

lentil.sanitize_shape(shape)

lentil.sanitize_bandpass(vec)

Detector module

Charge collection

lentil.detector.collect_charge(img, wave, qe)

Convert photon count (or flux) to electron count (or flux) by applying the detector's wavelength-dependent quantum efficiency.

lentil.detector.collect_charge_bayer(img, ...)

Convert photon count (or flux) to electron count (or flux) by applying the detector's wavelength-dependent quantum efficiency.

Pixel effects

lentil.detector.pixel(img[, oversample])

Apply the aperture effects of a square pixel on a discretely sampled image.

lentil.detector.pixelate(img, oversample)

Convolve an image with the pixel MTF and rescale the result to native sampling

Noise

lentil.detector.shot_noise(img[, method, seed])

Apply shot noise to an image

lentil.detector.read_noise(img, electrons[, ...])

Apply read noise to a frame

lentil.detector.charge_diffusion(img, sigma)

Apply charge diffusion represented by a Gaussian blur

lentil.detector.dark_current(rate[, shape, ...])

Create dark current frame

lentil.detector.rule07_dark_current(...[, ...])

Create dark current frame for HgCdTe infrared detectors using Rule 07

Readout

lentil.detector.adc(img, gain[, ...])

Analog to digital conversion

Cosmic rays

lentil.detector.cosmic_rays(shape, ...[, ...])

Cosmic ray generator for simulating cosmic ray hits on a detector.

Radiometry module

lentil.radiometry.Spectrum(wave, value[, ...])

Class for representing spectral quantities.

lentil.radiometry.Blackbody(wave, temp[, ...])

Class for representing a blackbody emitter.

lentil.radiometry.Material([transmission, ...])

Class for representing a material with radiometric properties.

lentil.radiometry.planck_radiance(wave, temp)

Compute the Planck law spectral radiance from a blackbody radiator at the given temperature.

lentil.radiometry.planck_exitance(wave, temp)

Compute the Planck law spectral exitance from a blackbody radiator at the given temperature.

lentil.radiometry.vegaflux(band[, waveunit, ...])

Get the flux of Vega in a desired observing band.

lentil.radiometry.path_transmission(iterable)

Construct a common transmission from an iterable of Spectrum or Material objects or numeric types

lentil.radiometry.path_emission(iterable[, ...])

Construct a common emission from an iterable of Material objects

Internals

Warning

The lentil.field, lentil.fourier, and lentil.helper top-level modules are intended for internal use. Stable functionality in these modules is not guaranteed.

Field

lentil.field.Field(data[, pixelscale, ...])

Two-dimensional discretely sampled complex field.

lentil.field.NDField(field)

lentil.field.extent(shape, offset)

Compute shifted array extent

lentil.field.overlap(a, b)

True if two Fields overlap, otherwise False

lentil.field.boundary(*fields)

Compute the bounding extents around a number of Field objects.

lentil.field.insert(field, out[, intensity, ...])

param field

Field to insert into out

lentil.field.merge(a, b[, check_overlap])

Merge two Fields

lentil.field.multiply(x1, x2)

Multiply fields element-wise.

lentil.field.reduce(*fields)

Reduce a number of disjoint Fields into a potentially smaller set where overlapping Fields are merged.

Fourier transforms

lentil.fourier.dft2(f, alpha[, npix, shift, ...])

Compute the 2-dimensional discrete Fourier Transform.

lentil.fourier.idft2(F, alpha[, npix, ...])

Compute the 2-dimensional inverse discrete Fourier Transform.

Helper functions

lentil.helper.boundary_slice(x[, threshold, pad])

Find bounding row and column indices of data within an array and return the results as slice objects.

lentil.helper.gaussian2d(size, sigma)

2D Gaussian kernel.

lentil.helper.mesh(shape[, shift])

Generate a standard mesh.

lentil.helper.slice_offset(slice, shape)

Compute the offset of the center of a 2D slice relative to the center of a larger array.