Skip to content

Commit

Permalink
Merge pull request #509 from kammerje/develop
Browse files Browse the repository at this point in the history
Updating bar mask offsets directly from pySIAF
  • Loading branch information
mperrin authored Dec 9, 2021
2 parents f0223f5 + f2a123a commit e5cd611
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions webbpsf/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

_log = logging.getLogger('webbpsf')

import pysiaf


####### Classes for modeling aspects of JWST's segmented active primary #####

Expand Down Expand Up @@ -706,31 +708,6 @@ class NIRCam_BandLimitedCoron(poppy.BandLimitedCoron):
allowable_kinds = ['nircamcircular', 'nircamwedge']
""" Allowable types of BLC supported by this class"""

# Offsets along the bar occulters are based on
# outputs from John Stansberry's filt_baroffset.pro
# See https://github.com/mperrin/webbpsf/issues/63
offset_swb = {"F182M": -1.856,
"F187N": -1.571,
"F210M": -0.071,
"F212N": 0.143,
"F200W": 0.232,
'narrow': -8.00}
""" Offsets per filter along SWB occulter for module A, in arcsec"""

offset_lwb = {"F250M": 6.846,
"F300M": 5.249,
"F277W": 5.078,
"F335M": 4.075,
"F360M": 3.195,
"F356W": 2.455,
"F410M": 1.663,
"F430M": 1.043,
"F460M": -0.098,
"F480M": -0.619,
"F444W": -0.768,
'narrow': 8.0}
""" Offsets per filter along LWB occulter for module A, in arcsec"""

def __init__(self, name="unnamed BLC", kind='nircamcircular', module='A', nd_squares=True,
bar_offset=None, auto_offset=None, **kwargs):
super(NIRCam_BandLimitedCoron, self).__init__(name=name, kind=kind, **kwargs)
Expand All @@ -757,6 +734,13 @@ def __init__(self, name="unnamed BLC", kind='nircamcircular', module='A', nd_squ
else:
raise NotImplementedError("invalid name for NIRCam occulter: " + self.name)

# EDIT: updated on 8 Dec 2021 to grab offsets directly from pySIAF
self.siaf = pysiaf.Siaf('NIRCAM')
self.offset_swb = {filt: self.get_bar_offset_from_siaf(filt, channel='SW')
for filt in ["F182M", "F187N", "F210M", "F212N", "F200W", 'narrow']}
self.offset_lwb = {filt: self.get_bar_offset_from_siaf(filt, channel='LW')
for filt in ["F250M", "F300M", "F277W", "F335M", "F360M", "F356W", "F410M", "F430M", "F460M", "F480M", "F444W", 'narrow']}

if bar_offset is None and auto_offset is not None:
offsets = self.offset_swb if self.name.lower() == 'maskswb' else self.offset_lwb
try:
Expand All @@ -773,6 +757,22 @@ def __init__(self, name="unnamed BLC", kind='nircamcircular', module='A', nd_squ
else:
self.bar_offset = None

def get_bar_offset_from_siaf(self, filt, channel='LW'):
""" Get bar offset directly from SIAF.
"""

if channel == 'SW':
refapername = 'NRCA4_MASKSWB'
apername = 'NRCA4_MASKSWB_' + filt.upper()
else: # otherwise default to LW
refapername = 'NRCA5_MASKLWB'
apername = 'NRCA5_MASKLWB_' + filt.upper()
offset_arcsec = np.sqrt((self.siaf.apertures[refapername].V2Ref - self.siaf.apertures[apername].V2Ref)**2 + (self.siaf.apertures[refapername].V3Ref - self.siaf.apertures[apername].V3Ref)**2)
sign = np.sign(self.siaf.apertures[refapername].V2Ref - self.siaf.apertures[apername].V2Ref)

return sign * offset_arcsec

def get_transmission(self, wave):
""" Compute the amplitude transmission appropriate for a BLC for some given pixel spacing
corresponding to the supplied Wavefront.
Expand Down

0 comments on commit e5cd611

Please sign in to comment.