MMTWFS API Documentation

mmtwfs Package

The mmtwfs package is a collection of code that for analyzing Shack-Hartmann wavefront sensor data for the MMTO

mmtwfs.zernike Module

A collection of functions and classes for performing wavefront analysis using Zernike polynomials. Several of these routines were adapted from https://github.com/tvwerkhoven/libtim-py. They have been updated to make them more applicable for MMTO usage and comments added to clarify what they do and how.

Expressions for cartesian derivatives of the Zernike polynomials were adapted from:

http://adsabs.harvard.edu/abs/2014OptLE..52….7N

Functions

cart2pol(arr)

Convert array of [x, y] vectors to [rho, theta]

pol2cart(polarr)

Convert array of [rho, theta] vectors to [x, y]

R_mn(m, n, rho)

Make radial Zernike polynomial on coordinate grid rho.

dR_drho(m, n, rho)

First derivative of Zernike radial polynomial, R(m, n, rho) calculated on coordinate grid rho.

theta_m(m, phi)

Calculate angular Zernike mode on coordinate grid phi

dtheta_dphi(m, phi)

Calculate the first derivative of the m-th Zernike angular mode on coordinate grid phi

zernike(m, n, rho, phi[, norm])

Calculate Zernike mode (m, n) on grid rho and phi.

dZ_dx(m, n, rho, phi[, norm])

Calculate the X slopes of Zernike mode (m, n) on grid rho and phi.

dZ_dy(m, n, rho, phi[, norm])

Calculate the Y slopes of Zernike mode (m, n) on grid rho and phi.

noll_to_zernike(j)

Convert linear Noll index to tuple of Zernike indices.

zernike_noll(j, rho, phi[, norm])

Calculate Noll Zernike mode j on grid rho and phi.

zernike_slope_noll(j, rho, phi[, norm])

Calculate X/Y slopes for Noll Zernike mode j on grid rho and phi.

zernike_slopes(zv, rho, phi[, norm])

Calculate total slope of a set of Zernike modes on a polar coordinate grid, (rho, phi).

noll_normalization_vector([nmodes])

Calculate Noll normalization vector.

norm_coefficient(m, n)

Calculate the normalization coefficient for the (m, n) Zernike mode.

noll_coefficient(ll)

Calculate the Noll coefficent to normalize mode l to unit variance.

Classes

ZernikeVector([coeffs, modestart, ...])

Class to wrap and visualize a vector of Zernike polynomial coefficients.

mmtwfs.telescope Module

Functions

TelescopeFactory([telescope, secondary, config])

Build and return proper Telescope sub-class instance based on the value of 'telescope' and 'secondary'.

Classes

MMT([secondary, config])

Defines configuration and methods that pertain to the MMT's telescope and primary mirror systems

FLWO12([config])

Defines configuration and methods for the FLWO 1.2-meter

mmtwfs.secondary Module

Classes and utilities for optical modeling and controlling the position of the secondary mirrors of the MMTO.

Functions

SecondaryFactory([secondary, config])

Build and return proper Secondary sub-class instance based on the value of 'secondary'.

Classes

F9([config])

Defines configuration and methods specific to the F/9 secondary system

F5([config])

Defines configuration and methods specific to the F/5 secondary system

FLWO12([config])

Secondary mirror configuration for the FLWO 1.2-meter

mmtwfs.wfs Module

Classes and utilities for operating the wavefront sensors of the MMTO and analyzing the data they produce

Functions

WFSFactory([wfs, config])

Build and return proper WFS sub-class instance based on the value of 'wfs'.

wfs_norm(data[, interval, stretch])

Define default image normalization to use for WFS images

check_wfsdata(data[, header])

Utility to validate WFS data

wfsfind(data[, fwhm, threshold, plot, ...])

Use photutils.DAOStarFinder() to find and centroid spots in a Shack-Hartmann WFS image.

grid_spacing(data, apertures)

Measure the WFS grid spacing which changes with telescope focus.

center_pupil(input_data, pup_mask[, ...])

Find the center of the pupil in a WFS image using skimage.feature.match_template().

get_apertures(data, apsize[, fwhm, thresh, ...])

Use wfsfind to locate and centroid spots.

match_apertures(refx, refy, spotx, spoty[, ...])

Given reference aperture and spot X/Y positions, loop through reference apertures and find closest spot.

aperture_distance(refx, refy, spotx, spoty)

Calculate the sum of the distances between each reference aperture and the closest measured spot position.

fit_apertures(pars, ref, spots)

Scale the reference positions by the fit parameters and calculate the total distance between the matches.

get_slopes(data, ref, pup_mask[, fwhm, ...])

Analyze a WFS image and produce pixel offsets between reference and observed spot positions.

make_init_pars([nmodes, modestart, init_zv])

Make a set of initial parameters that can be used with minimize to make a wavefront fit with parameter names that are compatible with ZernikeVectors.

slope_diff(pars, coords, slopes[, norm])

For a given set of wavefront fit parameters, calculate the "distance" between the predicted and measured wavefront slopes.

mk_wfs_mask(data[, thresh_factor, outfile])

Take a WFS image and mask/scale it so that it can be used as a reference for pupil centering

Classes

SH_Reference(data[, fwhm, threshold, plot])

Class to handle Shack-Hartmann reference data

WFS([config, plot])

Defines configuration pattern and methods common to all WFS systems

F9([config, plot])

Defines configuration and methods specific to the F/9 WFS system

NewF9([config, plot])

Defines configuration and methods specific to the F/9 WFS system with the new SBIG CCD

F5([config, plot])

Defines configuration and methods specific to the F/5 WFS systems

Binospec([config, plot])

Defines configuration and methods specific to the Binospec WFS system.

MMIRS([config, plot])

Defines configuration and methods specific to the MMIRS WFS system

mmtwfs.utils Module

Misc. utility routines

Functions

srvlookup(server)

Perform a SRV lookup of 'server' and return its hostname and port.

mmtwfs.custom_exceptions Module

Classes

MMTWFSException([value, results])

Superclass of all custom exceptions

WFSConfigException([value, results])

Raise when an error occurs due to invalid configuration data.

WFSCommandException([value, results])

Raise when an error occurs due to invalid command sent to a WFS system or invalid inputs given to WFS method.

WFSAnalysisFailed([value, results])

Raise when something is wrong with the WFS data that prevents it from being analyzed

ZernikeException([value, results])

Raise when an error occurs in handling or configuring of ZernikeVectors

mmtwfs.config Module

config.py - Configuration data and utility functions

Functions

recursive_subclasses(cls)

The __subclasses__() method only goes one level deep, but various classes can be separated by multiple inheritance layers.

merge_config(*dicts)

This takes a list of python dicts and merges them into a single dict.

Variables

mmtwfs_config