Skip to content

Commit

Permalink
include_si_wfe in NIRCam() coeff function
Browse files Browse the repository at this point in the history
  • Loading branch information
JarronL committed Feb 2, 2019
1 parent e1624b9 commit 3f6d7a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions pynrc/nrc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def _wrap_coeff_for_mp(args):
# current exception being handled.
traceback.print_exc()

print()
print('')
#raise e
poppy.conf.use_multiprocessing = mp_prev
return None
Expand Down Expand Up @@ -1206,7 +1206,10 @@ def psf_coeff(filter_or_bp, pupil=None, mask=None, module='A',
# Pass arguments to the helper function
hdu_arr = []
for wa in worker_arguments:
hdu_arr.append(_wrap_coeff_for_mp(wa))
hdu = _wrap_coeff_for_mp(wa)
if hdu is None:
raise RuntimeError('Returned None values. Issue with multiprocess or WebbPSF??')
hdu_arr.append(hdu)
t1 = time.time()

# Reset to original log levels
Expand Down
25 changes: 17 additions & 8 deletions pynrc/pynrc_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ class NIRCam(object):
Updates :attr:`wfe_drift` attribute.
opd : tuple or HDUList
Tuple (file, slice) or filename or HDUList specifying OPD.
include_si_wfe : bool
Include SI WFE measurements? Default=True.
tel_pupil : str
File name or HDUList specifying telescope entrance pupil.
jitter : str or None
Expand Down Expand Up @@ -1517,7 +1519,7 @@ def bar_offset(self, value):

def update_psf_coeff(self, fov_pix=None, oversample=None,
offset_r=None, offset_theta=None, tel_pupil=None, opd=None,
wfe_drift=None, jitter='gaussian', jitter_sigma=0.007,
wfe_drift=None, include_si_wfe=None, jitter='gaussian', jitter_sigma=0.007,
bar_offset=None, save=None, force=False, **kwargs):
"""Create new PSF coefficients.
Expand Down Expand Up @@ -1562,10 +1564,12 @@ def update_psf_coeff(self, fov_pix=None, oversample=None,
Updates :attr:`wfe_drift` attribute and coefficients appropriately.
opd : tuple, str, or HDUList
Tuple (file, slice) or filename or HDUList specifying OPD.
tel_pupil : str
include_si_wfe : bool
Include SI WFE measurements? Default=True.
tel_pupil : str or HDUList
File name or HDUList specifying telescope entrance pupil.
jitter : str or None
Currently either 'gaussian' or None.
jitter : str
Either 'gaussian' or 'none'.
jitter_sigma : float
If ``jitter = 'gaussian'``, then this is the size of the blurring effect.
save : bool
Expand Down Expand Up @@ -1626,9 +1630,12 @@ def update_psf_coeff(self, fov_pix=None, oversample=None,
if tel_pupil is None:
try: tel_pupil = self._psf_info['tel_pupil']
except (AttributeError, KeyError): tel_pupil = None
if include_si_wfe is None:
try: include_si_wfe = self._psf_info['include_si_wfe']
except (AttributeError, KeyError): include_si_wfe = True
if jitter is None:
try: jitter = self._psf_info['jitter']
except (AttributeError, KeyError): jitter = None
except (AttributeError, KeyError): jitter = 'gaussian'
if jitter_sigma is None:
try: jitter_sigma = self._psf_info['jitter_sigma']
except (AttributeError, KeyError): jitter_sigma = 0.007
Expand All @@ -1638,12 +1645,15 @@ def update_psf_coeff(self, fov_pix=None, oversample=None,
if save is None:
try: save = self._psf_info['save']
except (AttributeError, KeyError): save = True

if jitter=='none':
jitter = None

#print(opd)
self._psf_info={'fov_pix':fov_pix, 'oversample':oversample,
'offset_r':offset_r, 'offset_theta':offset_theta,
'tel_pupil':tel_pupil, 'save':save, 'force':force,
'opd':opd, 'jitter':jitter, 'jitter_sigma':jitter_sigma}
'include_si_wfe':include_si_wfe, 'opd':opd, 'jitter':jitter, 'jitter_sigma':jitter_sigma}
self._psf_coeff = psf_coeff(self.bandpass, self.pupil, self.mask, self.module,
**self._psf_info)

Expand Down Expand Up @@ -1674,7 +1684,6 @@ def update_psf_coeff(self, fov_pix=None, oversample=None,
self._psf_coeff += cf_mod
else:
self._bar_offset = 0


# WFE Drift is handled differently than the rest of the parameters
# This is because we use wfed_coeff() to determine the resid values
Expand Down Expand Up @@ -1711,7 +1720,7 @@ def update_psf_coeff(self, fov_pix=None, oversample=None,
self._psf_info_bg = {'fov_pix':self._fov_pix_bg, 'oversample':oversample,
'offset_r':0, 'offset_theta':0, 'tel_pupil':tel_pupil,
'opd':opd, 'jitter':jitter, 'jitter_sigma':jitter_sigma,
'save':True, 'force':False}
'include_si_wfe':include_si_wfe, 'save':True, 'force':False}
self._psf_coeff_bg = psf_coeff(self.bandpass, self.pupil, None, self.module,
**self._psf_info_bg)

Expand Down

0 comments on commit 3f6d7a4

Please sign in to comment.