prysm.io#

File readers for various commercial instruments.

prysm.io.read_mtfmapper_sfr_single(file, pixel_pitch=None)#

Read an MTF Mapper SFR (MTF) file generated by the -f flag with –single-roi.

Notes

This reads a “raw_sfr_values.txt” file, not an “edge_sfr_values.txt” file.

Parameters:
  • file (str or path_like or file_like) – contents of a file, path_like to the file, or file object

  • pixel_pitch (float) – center-to-center pixel spacing, in microns

Returns:

  • ndarray – spatial_frequencies

  • ndarray – mtf

prysm.io.read_zygo_datx(file)#

Read a zygo datx file.

Parameters:

file (path_like) – location of a file

Returns:

dictionary with keys phase, intensity, meta

Return type:

dict

Raises:

ImportError – h5py unavailable, required dependency for this

prysm.io.read_zygo_dat(file, multi_intensity_action='first')#

Read the contents of a zygo binary (.dat) file.

Parameters:
  • file (path_like) – path to a file

  • multi_intensity_action (str, {'avg', 'first', 'last'}) – action to take when handling multiple intensitiy frames, only avg is valid at this time

Returns:

dictionary with keys: phase, intensity, meta

Return type:

dict

prysm.io.read_zygo_metadata(file_contents)#

Parse metadata from the contents of a binary Zygo file.

Parameters:

file_contents (bytes) – binary file contents

Returns:

dictionary with a shitload of keys for all of Zygo’s metadata.

Return type:

dict

prysm.io.write_zygo_dat(file, phase, dx, wavelength=0.6328, intensity=None)#

Write a Zygo .DAT interferogram file.

Parameters:
  • file (path_like) – filename

  • phase (ndarray) – array of phase values, nm

  • dx (ndarray) – inter-sample spacing, mm

  • wavelength (float, optional) – wavelength of light, um

  • intensity (ndarray, optional) – intensity data

prysm.io.write_zygo_ascii(file, phase, dx, wavelength=0.6328, intensity=None)#

Write a Zygo ASCII interferogram file.

Parameters:
  • file (path_like) – filename

  • phase (ndarray) – array of phase values, nm

  • dx (ndarray) – inter-sample spacing, mm

  • wavelength (float, optional) – wavelength of light, um

  • intensity (ndarray, optional) – intensity data

prysm.io.read_sigfit_zernikes(file)#

Read Zernikes from a SigFit OUTCOF3 file.

Parameters:

file (str or Path_like) – path to a file

Returns:

  • type | Noll (“Zemax Standard”) or Fringe Zernikes

  • normed | if True, the terms are orthonormalized and have unit standard deviation, else unit amplitude

  • wavelength | wavelength of light in microns

  • rnorm | normalization radius, mm

  • coefs | Zernike mode coefficients, microns

Return type:

dict with keys of surface IDs, which have values of dicts with keys of

prysm.io.read_sigfit_rigidbody(file)#

Read rigid body perturbation data from a SigFit sum1.csv file.

Parameters:

file (str or path_like) – location of a sigfit sum1.csv file

Returns:

all values in mm

Return type:

dict with keys of surface IDs, which have values of dicts with keys of dx, dy, dz, rx, ry, rz, dR

prysm.io.write_codev_gridint(array, filename, comment='CV GRD generated by prysm', typ='SUR', nnb=False)#

Write a Code V INT file in grid sag format.

Parameters:
  • array (ndarray) – array of floats to write if typ is either SUR or WFR, units of nm

  • filename (str) – filename to save to

  • comment (str) – up to 80 character comment

  • typ (str, {'SUR', 'WFR', 'FIL'}) –

    whether the file represents

    SUR surface figure WFR wavefront error FIL intensity apodization

  • nnb (bool, optional) –

    whether Nearest Neighbor interpolation is used.

    When nnb=False, Code V will use bilinear interpolation between points when ray tracing. This can cause failure when ray-tracing when there are high slopes near where the chief ray would intersect the surface. When nnb=False, first order implications due to the interferogram are more accurate, such as pupil positions.

    When nnb=True, nearest neighbor interpolation between points is used when ray tracing. This avoids potential failure modes due to issues finding the chief ray path through the system, but requires higher resolution grid int files be provided to well-represent the deformation.

prysm.io.write_codev_zfr_int(coefs, filename, comment='CV ZFR generated by prysm', SUR=True)#

Write a Code V INT file of ZFR coefficients.

Parameters:
  • coefs (iterable of float) – coefficients, counting from Z1; nanometers

  • filename (file_like) – where to write to

  • comment (string) – file header comment(s)

  • SUR (bool, optional) – if True, specifies surface figure error if False, specifies reflected wavefront error

prysm.io.read_codev_gridint(file)#

Read a Code V INT file containing grid data.

Parameters:

file (str or path_like) – path to a grid int file

Returns:

grid data in array representation, metadata dict

Return type:

tuple of (ndarray, dict)

prysm.io.read_codev_psf(fn, sep=',')#

Read a Code V PSF output.

Parameters:
  • fn (str or path_like) – path to a file containing the buffer dump

  • sep (str) – buffer separator used, typically either ‘,’ or ‘t’

Returns:

  • float – sample spacing in microns

  • ndarray – PSF data from Code V

prysm.io.read_codev_bsp(fn, sep=',')#

Read a Code V BSP output.

Parameters:
  • fn (str or path_like) – path to a file containing the buffer dump

  • sep (str) – buffer separator used, typically either ‘,’ or ‘t’

Returns:

  • float – X sample spacing in microns

  • float – Y sample spacing in microns

  • ndarray – BSP data from Code V