Skip to content

Commit

Permalink
Updates for WL+4 throughput
Browse files Browse the repository at this point in the history
  • Loading branch information
JarronL committed May 29, 2019
1 parent cb8f2a0 commit d66910e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 26 deletions.
57 changes: 41 additions & 16 deletions pynrc/nrc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,
filt_dir = conf.PYNRC_PATH + 'throughputs/'
filt_file = filter + '_nircam_plus_ote_throughput_mod' + m + '_sorted.txt'
bp = S.FileBandpass(filt_dir+filt_file)
bp_name = filter

_log.debug('Reading file: '+filt_file)

Expand Down Expand Up @@ -271,7 +272,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,

# Multiply filter throughput by grism
th_new = th_grism * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
bp = S.ArrayBandpass(bp.wave, th_new)

# spectral resolution in um/pixel
# res is in pixels/um and dw is inverse
Expand All @@ -295,7 +296,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,

# Multiply filter throughput by DHS
th_new = th_dhs * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
bp = S.ArrayBandpass(bp.wave, th_new)

# Mean spectral dispersion (dw/pix)
res = 290.0
Expand Down Expand Up @@ -348,7 +349,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,
# Interpolate substrate transmission onto filter wavelength grid and multiply
th_coron_sub = np.interp(bp.wave/1e4, wtemp, ttemp, left=0, right=0)
th_new = th_coron_sub * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
bp = S.ArrayBandpass(bp.wave, th_new)


# Lyot stop wedge modifications
Expand Down Expand Up @@ -394,23 +395,47 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,
th_wedge = np.interp(bp.wave/1e4, wtemp, ttemp, left=0, right=0)

th_new = th_wedge * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
bp = S.ArrayBandpass(bp.wave, th_new, name=bp.name)


# Weak Lens substrate transmission
if (pupil is not None) and ('WEAK LENS' in pupil):
# Even though this says WL+8, this should work for all lenses
hdulist = fits.open(conf.PYNRC_PATH + 'throughputs/jwst_nircam_wlp8.fits')
if (pupil is not None) and (('WL' in pupil) or ('WEAK LENS' in pupil)):

if 'WL' in pupil:
wl_alt = {'WLP4' :'WEAK LENS +4',
'WLP8' :'WEAK LENS +8',
'WLP12':'WEAK LENS +12 (=4+8)',
'WLM4' :'WEAK LENS -4 (=4-8)',
'WLM8' :'WEAK LENS -8'}
wl_name = wl_alt.get(pupil, pupil)
else:
wl_name = pupil

# Throughput for WL+4
hdulist = fits.open(conf.PYNRC_PATH + 'throughputs/jwst_nircam_wlp4.fits')
wtemp = hdulist[1].data['WAVELENGTH']
ttemp = hdulist[1].data['THROUGHPUT']
th_wl4 = np.interp(bp.wave/1e4, wtemp, ttemp, left=0, right=0)

# If two lenses, then we need to multiply throughput twice
wl_list = ['WEAK LENS +12 (=4+8)', 'WEAK LENS -4 (=4-8)']
pow = 2 if pupil in wl_list else 1

th_wl = np.interp(bp.wave/1e4, wtemp, ttemp, left=0, right=0)
th_new = th_wl**pow * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
# Throughput for WL+/-8
hdulist = fits.open(conf.PYNRC_PATH + 'throughputs/jwst_nircam_wlp8.fits')
wtemp = hdulist[1].data['WAVELENGTH']
ttemp = hdulist[1].data['THROUGHPUT']
th_wl8 = np.interp(bp.wave/1e4, wtemp, ttemp, left=0, right=0)

# If two lenses
wl48_list = ['WEAK LENS +12 (=4+8)', 'WEAK LENS -4 (=4-8)']
if (wl_name in wl48_list):
th_wl = th_wl4 * th_wl8
bp_name = 'F212N'
elif 'WEAK LENS +4' in wl_name:
th_wl = th_wl4
bp_name = 'F212N'
else:
th_wl = th_wl8

th_new = th_wl * bp.throughput
bp = S.ArrayBandpass(bp.wave, th_new)


# Water ice and NVR additions (for LW channel only)
Expand Down Expand Up @@ -446,7 +471,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,
th_new = th_nvr * th_new

# Create new bandpass
bp = S.ArrayBandpass(bp.wave, th_new, name=filter)
bp = S.ArrayBandpass(bp.wave, th_new)


# Resample to common dw to ensure consistency
Expand All @@ -459,7 +484,7 @@ def read_filter(filter, pupil=None, mask=None, module=None, ND_acq=False,
# Need to place zeros at either end so Pysynphot doesn't extrapolate
warr = np.concatenate(([bp.wave.min()-dw],bp.wave,[bp.wave.max()+dw]))
tarr = np.concatenate(([0],bp.throughput,[0]))
bp = S.ArrayBandpass(warr, tarr, name=filter)
bp = S.ArrayBandpass(warr, tarr, name=bp_name)

return bp

Expand Down
29 changes: 19 additions & 10 deletions pynrc/pynrc_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def __init__(self, filter='F210M', pupil=None, mask=None, module='A', ND_acq=Fal
self._grism = ['GRISM0', 'GRISM90']
# Weak lens are only in SW pupil wheel (+4 in filter wheel)
weak_lens = ['+4', '+8', '-8', '+12 (=4+8)', '-4 (=4-8)']
self._weak_lens = ['WEAK LENS '+s for s in weak_lens]
self._weak_lens = ['WEAK LENS '+s for s in weak_lens]

# Specify ice and nvr scalings
self._ice_scale = kwargs['ice_scale'] if 'ice_scale' in kwargs.keys() else None
Expand Down Expand Up @@ -461,7 +461,11 @@ def __init__(self, filter='F210M', pupil=None, mask=None, module='A', ND_acq=Fal
'WLM4' :'WEAK LENS -4 (=4-8)',
'WLM8' :'WEAK LENS -8'}
pupil = wl_alt.get(pupil, pupil)

# Pair F200W throughput with WL+4
# The F212N2 throughput is then handled in read_filter() function
wl_list = ['WEAK LENS +12 (=4+8)', 'WEAK LENS -4 (=4-8)', 'WEAK LENS +4']
if (pupil in wl_list) and (filter!='F200W'):
filter = 'F200W'

# Validate all values, set values, and update bandpass
# Test and set the intrinsic/hidden variables directly rather than through setters
Expand Down Expand Up @@ -875,9 +879,12 @@ def update_detectors(self, verbose=False, det_list=None, **kwargs):
det_list = [485]
elif (self.mask is None) and ('CLEAR' in self.pupil): # SW A Imaging
det_list = [481] #[481,482,483,484]
elif ('WB' in self.mask) or ('WEDGELYOT' in self.pupil): # SW A Bar coronagraph
elif (self.mask is None) and ('WEAK' in self.pupil): # Weak Lens
det_list = [481] #[481,482,483,484]
elif ('WEDGELYOT' in self.pupil) or ((self.mask is not None) and ('WB' in self.mask)):
# SW A Bar coronagraph
det_list = [484]
elif ('210R' in self.mask) or ('335R' in self.mask) or ('CIRCLYOT' in self.pupil):
elif ('CIRCLYOT' in self.pupil) or ((self.mask is not None) and (('210R' in self.mask) or ('335R' in self.mask))):
det_list = [482]
else:
errmsg = 'No detector makes sense here ({} {} {}).'\
Expand All @@ -889,9 +896,11 @@ def update_detectors(self, verbose=False, det_list=None, **kwargs):
det_list = [490]
elif (self.mask is None) and ('CLEAR' in self.pupil):
det_list = [486] #[486,487,488,489]
elif ('WB' in self.mask) or ('WEDGELYOT' in self.pupil):
elif (self.mask is None) and ('WEAK' in self.pupil): # Weak Lens
det_list = [486] #[486,487,488,489]
elif ('WEDGELYOT' in self.pupil) or ((self.mask is not None) and ('WB' in self.mask)):
det_list = [488]
elif ('210R' in self.mask) or ('335R' in self.mask) or ('CIRCLYOT' in self.pupil):
elif ('CIRCLYOT' in self.pupil) or ((self.mask is not None) and (('210R' in self.mask) or ('335R' in self.mask))):
det_list = [486]
else:
errmsg = 'No detector makes sense here ({} {} {}).'\
Expand Down Expand Up @@ -1003,11 +1012,11 @@ def do_warn(wstr):
wstr = '{} mask is no visible in SW module (filter is {})'.format(mask,filter)
do_warn(wstr)

# WEAK LENS +4 only valid with F212N
# Or is is F210M???
# Ned F200W paired with WEAK LENS +4
# The F212N2 filter is handled in the read_filter function
wl_list = ['WEAK LENS +12 (=4+8)', 'WEAK LENS -4 (=4-8)', 'WEAK LENS +4']
if (pupil in wl_list) and (filter!='F212N'):
wstr = '{} is only valid with filter F212N.'.format(pupil)
if (pupil in wl_list) and (filter!='F200W'):
wstr = '{} is only valid with filter F200W.'.format(pupil)
do_warn(wstr)

# Items in the same SW pupil wheel
Expand Down

0 comments on commit d66910e

Please sign in to comment.