prysm.io#
File readers for various commercial instruments.
- prysm.io.is_mtfvfvf_file(file)#
Read MTF vs Field vs Focus data from a Trioptics .txt dump.
- Parameters
file (str or path_like or file_like) – file to read from, if string of file body, must provide filename
- Returns
boolean (bool) – if the file is an MTFvFvF file
data (str) – contents of the file
- prysm.io.read_trioptics_mtfvfvf(file, filename=None)#
Read MTF vs Field vs Focus data from a Trioptics .txt dump.
- Parameters
file (str or path_like or file_like) – file to read from, if string of file body, must provide filename
filename (str, optional) – name of file; used to select tan/sag if file is given as contents
- Returns
MTF vs Field vs Focus object
- Return type
- prysm.io.read_trioptics_mtf_vs_field(file, metadata=False)#
Read tangential and sagittal MTF data from a Trioptics .mht file.
- Parameters
file (str or path_like or file_like) – contents of a file, path_like to the file, or file object
metadata (bool) – whether to also extract and return metadata
- Returns
dictionary with keys of freq, field, tan, sag
- Return type
dict
- prysm.io.read_trioptics_mtf_vs_field_mtflab_v4(file, metadata=False)#
Read tangential and sagittal MTF data from a Trioptics .mht file. Compatible with MTF-Lab v4.
- Parameters
file (str or path_like or file_like) – contents of a file, path_like to the file, or file object
metadata (bool) – whether to also extract and return metadata
- Returns
dictionary with keys of freq, field, tan, sag
- Return type
dict
- prysm.io.read_trioptics_mtf_vs_field_mtflab_v5(file_contents, metadata=False)#
Read tangential and sagittal MTF data from a Trioptics .mht file. Compatible with MTF-Lab v5.
- Parameters
file_contents (str or path_like or file_like) – contents of a file, path_like to the file, or file object
metadata (bool) – whether to also extract and return metadata
- Returns
dictionary with keys of freq, field, tan, sag
- Return type
dict
- prysm.io.read_trioptics_mtf(file, metadata=False)#
Read MTF data from a Trioptics data file.
- Parameters
file (str or path_like or file_like) – contents of a file, path_like to the file, or file object
metadata (bool) – whether to also extract and return metadata
- Returns
dictionary with keys focus, freq, tan, sag if metadata=True, also has keys in the return of io.parse_trioptics_metadata.
- Return type
dict
- prysm.io.parse_trioptics_metadata(file_contents)#
Read metadata from the contents of a Trioptics .mht file.
- Parameters
file_contents (str) – contents of a .mht file.
- Returns
- dictionary with keys:
operator
time
sample_id
instrument
instrument_sn
collimator
wavelength
efl
obj_angle
focus_pos
azimuth
- Return type
dict
- prysm.io.parse_trioptics_metadata_mtflab_v4(file_contents)#
Read metadata from the contents of a Trioptics .mht file. Compatible with MTF-Lab v4.
- Parameters
file_contents (str) – contents of a .mht file.
- Returns
- dictionary with keys:
operator
time
sample_id
instrument
instrument_sn
collimator
wavelength
efl
obj_angle
focus_pos
azimuth
- Return type
dict
- prysm.io.parse_trioptics_metadata_mtflab_v5(file_contents)#
Read metadata from the contents of a Trioptics .mht file. Compatible with MTF-Lab v5.
- Parameters
file_contents (str) – contents of a .mht file.
- Returns
- dictionary with keys:
operator
time
sample_id
instrument
instrument_sn
collimator
wavelength
efl
obj_angle
focus_pos
azimuth
- Return type
dict
- prysm.io.identify_trioptics_measurement_type(file)#
Identify type of measurement in a Trioptics .mht file.
- Parameters
file (str or path_like or file_like) – contents of a file, path_like to the file, or file object
- Returns
program (str) – measurement type
data (str) – contents of the file
- prysm.io.read_any_trioptics_mht(file, metadata=False)#
Read any Trioptics .mht certificate (MTF vs Field, Distortion, etc).
- Parameters
file (str or path_like or file_like) – contents of a file, path_like to the file, or file object
metadata (bool) – whether to also extract and return metadata
- Returns
dictionary with appropriate keys. If metadata=True, also has keys in the return of io.parse_trioptics_metadata.
- Return type
dict
- 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
numpy.ndarray – spatial_frequencies
numpy.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_ascii(file, phase, dx, wavelength=0.6328, intensity=None)#
Write a Zygo ASCII interferogram file.
- Parameters
file (str) – filename
phase (numpy.ndarray) – array of phase values
dx (numpy.ndarray) – inter-sample spacing, mm
wavelength (float, optional) – wavelength of light, um
intensity (numpy.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.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)