Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Aug 7, 2023
1 parent b73cc7d commit e2ff232
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions jdaviz/configs/imviz/plugins/footprints/preset_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
"jwst_footprint"
]

_instruments = {'NIRspec': 'NIRSpec',
'NIRcam:short': 'NIRCam',
'NIRcam:long': 'NIRCam',
_instruments = {'NIRSpec': 'NIRSpec',
'NIRCam:short': 'NIRCam',
'NIRCam:long': 'NIRCam',
'NIRISS': 'NIRISS',
'MIRI': 'MIRI',
'FGS': 'FGS'
}

_full_apertures = {'NIRspec': 'NRS_FULL_MSA',
'NIRcam:short': 'NRCALL_FULL',
'NIRcam:long': 'NRCALL_FULL',
_full_apertures = {'NIRSpec': 'NRS_FULL_MSA',
'NIRCam:short': 'NRCALL_FULL',
'NIRCam:long': 'NRCALL_FULL',
'NIRISS': 'NIS_AMIFULL',
'MIRI': 'MIRIM_FULL',
'FGS': 'FGS1_FULL'
}

_all_apertures = {'NIRspec': ["NRS_FULL_MSA1",
_all_apertures = {'NIRSpec': ["NRS_FULL_MSA1",
"NRS_FULL_MSA2",
"NRS_FULL_MSA3",
"NRS_FULL_MSA4",
Expand All @@ -45,15 +45,15 @@
"NRS_S400A1_SLIT",
"NRS_S1600A1_SLIT",
"NRS_S200B1_SLIT"],
'NIRcam:short': ["NRCA1_FULL",
'NIRCam:short': ["NRCA1_FULL",
"NRCA2_FULL",
"NRCA3_FULL",
"NRCA4_FULL",
"NRCB1_FULL",
"NRCB2_FULL",
"NRCB3_FULL",
"NRCB4_FULL",],
'NIRcam:long': ["NRCA5_FULL", "NRCB5_FULL"],
'NIRCam:long': ["NRCA5_FULL", "NRCB5_FULL"],
'NIRISS': ['NIS_AMIFULL'],
'MIRI': ['MIRIM_FULL'],
'FGS': ['FGS1_FULL', 'FGS2_FULL']
Expand Down Expand Up @@ -98,27 +98,27 @@ def jwst_footprint(instrument, ra, dec, pa, v2_offset=0.0, v3_offset=0.0, apertu
siaf_interface = pysiaf.Siaf(_instruments.get(instrument))

# Get center and PA offset from full aperture
nrc_full = siaf_interface.apertures[_full_apertures.get(instrument)]
nrc_corners = nrc_full.corners("tel", rederive=False)
nrc_v2 = np.mean(nrc_corners[0]) - v2_offset
nrc_v3 = np.mean(nrc_corners[1]) + v3_offset
pa_offset = nrc_full.V3IdlYAngle
full = siaf_interface.apertures[_full_apertures.get(instrument)]
corners = full.corners("tel", rederive=False)
v2 = np.mean(corners[0]) - v2_offset
v3 = np.mean(corners[1]) + v3_offset
pa_offset = full.V3IdlYAngle

# Attitude matrix for sky coordinates
attmat = pysiaf.utils.rotations.attitude(nrc_v2, nrc_v3, ra, dec, pa - pa_offset)
attmat = pysiaf.utils.rotations.attitude(v2, v3, ra, dec, pa - pa_offset)

if apertures is None:
apertures = _all_apertures.get(instrument)

# Aperture regions
nrc_regions = []
ap_regions = []
for aperture_name in apertures:
aperture = siaf_interface.apertures[aperture_name]
aperture.set_attitude_matrix(attmat)
poly_points = aperture.closed_polygon_points("sky")

sky_coord = coordinates.SkyCoord(*poly_points, unit="deg")
reg = regions.PolygonSkyRegion(sky_coord)
nrc_regions.append(reg)
ap_regions.append(reg)

return regions.Regions(nrc_regions)
return regions.Regions(ap_regions)

0 comments on commit e2ff232

Please sign in to comment.