Speckle Noise Tools

Disclaimer

These tools were created for investigations into speckle maps during development of pynrc. Documentation is relatively sparse and functions may not be maintained very well with respect to updated versions of Python and webbpsf. They are provided here for completeness, and may even prove useful to someone in the future, present, or past(?).

Class Summary

OPD_extract(opd, header[, seg_terms, verbose])

Decompose OPD to Zernike/Hexike coefficients

Functions Summary

opd_extract_mp(opds, header[, nproc])

Generate multiple OPD_extract objects

opd_sci_gen(opd)

OPD image for science observation

opd_sci_gen_mp(opds_all[, nproc])

Multiple OPD images for science observations

opd_ref_gen(args[, verbose])

Generate a drifted OPD image

ODP_drift_all(wfe_drift, opds_all, …)

Drift list of OPDs

get_psf(opd, header[, filter, mask, pupil, …])

Generate PSF

gen_psf_ref_all(opd_ref_list_all, …[, verbose])

Calculate a series of reference PSFs

get_contrast(speckle_noise_image, planet_psf)

Output single contrast curve

residual_speckle_image(psf_star_all, psf_ref_all)

Create residual speckle images

speckle_noise_image(psf_star_all, psf_ref_all)

Create a speckle noise image map

read_opd_file(opd_file[, opd_path, header])

Read in the OPD file data and header (optional)

read_opd_slice(pupilopd[, opd_path, header])

Get only a specified OPD slice from file.

Documentation

class pynrc.speckle_noise.OPD_extract(opd, header, seg_terms=30, verbose=False)[source]

Bases: object

Decompose OPD to Zernike/Hexike coefficients

For a given JWST OPD image and header, extract the Zernike/Hexike components for the overall pupil and each mirror segment. Makes use of functions in webbpsf.

Parameters
  • opd (ndarray) – OPD image map.

  • header (obj) – Header extracted from OPD FITS files.

  • seg_terms (int) – Number of Hexike terms to fit to each mirror segment.

  • verbose (bool) – Print information as fittings are performed.

Attributes Summary

mask_pupil

Tricontagon mask

mask_opd

Mask generated from OPD map

coeff_pupil

Zernike coefficients for overall pupil

coeff_segs

Hexike coefficients for each segment

Methods Summary

mask_seg(i)

Return a sampled subsection of the analytic segment mask

opd_seg(i[, opd_pupil])

Return a subsection of some OPD image for the provided segment index

combine_opd_segs([opd_segs])

Combine list of OPD segments into a single image

Methods Documentation

mask_seg(i)[source]

Return a sampled subsection of the analytic segment mask

Parameters

i (int) – Segment index

opd_seg(i, opd_pupil=None)[source]

Return a subsection of some OPD image for the provided segment index

Parameters
  • i (int) – Segment index

  • opd_pupil (mask) – Optional pupil mask to modify resulting segment OPD

combine_opd_segs(opd_segs=None)[source]

Combine list of OPD segments into a single image

pynrc.speckle_noise.opd_extract_mp(opds, header, nproc=None)[source]

Generate multiple OPD_extract objects

If you have multiple opd maps to perform Zernike/Hexike extractions on, this function calls Python’s multiprocessor routines to perform calculations in parallel.

Parameters
  • opds (ndarray) – Data cube of size (nopds, ny, nx)

  • header (obj) – Header information

  • nproc (int, None) – Number of simultaneous processes to perform. If not set, then:

    >>> nproc = int(np.min([nopd,mp.cpu_count()*0.75]))
    
pynrc.speckle_noise.opd_sci_gen(opd)[source]

OPD image for science observation

Function to go through an OPD class and generate a science OPD image.

Parameters

opd (obj) – OPD_extract object

pynrc.speckle_noise.opd_sci_gen_mp(opds_all, nproc=None)[source]

Multiple OPD images for science observations

Function to go through multiple OPD classes and generate science OPD images.

Parameters
  • opds_all (obj list) – List of OPD_extract objects

  • nproc (int, None) – Number of simultaneous processes to perform. If not set, then:

    >>> nproc = int(np.min([nopd,mp.cpu_count()*0.75]))
    
pynrc.speckle_noise.opd_ref_gen(args, verbose=False)[source]

Generate a drifted OPD image

pynrc.speckle_noise.ODP_drift_all(wfe_drift, opds_all, pup_cf_std, seg_cf_std, opd_resid_list)[source]

Drift list of OPDs

Drift a list of OPDs by some RMS WFE (multiprocess function).

Parameters
  • wfe_drift (float) – Single value in nm

  • opds_all (list) – List of OPD objects (usually 10 from RevV OPDs)

  • pup_cf_std (float) – Zernike sigma for overall pupil

  • seg_cf_std (float) – Hexike sigma for segments

  • opd_resid_list (list) – List of residual images (from opd_sci_gen) for each OPD

pynrc.speckle_noise.get_psf(opd, header, filter='F410M', mask=None, pupil=None, jitter=False, njit=10, jitter_sigma=0.005, r=None, theta=None, **kwargs)[source]

Generate PSF

Create a NIRCam PSF based on the input opd, header, and other info.

The jitter model recomputes the PSF at random positional offsets with a standard deviation equal to jitter_sigma. It does this njit times and averages the resulting PSFs.

pynrc.speckle_noise.gen_psf_ref_all(opd_ref_list_all, opd_header, filt, mask, pupil, verbose=False, **kwargs)[source]

Calculate a series of reference PSFs

Given a list of reference OPD, calculate a series of PSFs. Assume that opd_ref_list_all is a nested list of drifted OPDs. For instance:

[[10 OPDs with 1nm drift], [10 OPDs with 5nm drift], [10 OPDs with 10nm drift]]
pynrc.speckle_noise.get_contrast(speckle_noise_image, planet_psf)[source]

Output single contrast curve

Return the contrast for curve for a speckle noise map. Both inputs are HDULists.

pynrc.speckle_noise.residual_speckle_image(psf_star_all, psf_ref_all)[source]

Create residual speckle images

For a list of science and reference PSFs, create residual speckle images

pynrc.speckle_noise.speckle_noise_image(psf_star_all, psf_ref_all)[source]

Create a speckle noise image map

For a list of science and reference PSFs, create a speckle noise image map

pynrc.speckle_noise.read_opd_file(opd_file, opd_path=None, header=True)[source]

Read in the OPD file data and header (optional)

pynrc.speckle_noise.read_opd_slice(pupilopd, opd_path=None, header=True)[source]

Get only a specified OPD slice from file.

pupilopd is a tuple of form (filename, slice)