Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nden committed Apr 20, 2021
1 parent 0eae9d1 commit d724473
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 49 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ assign_wcs
validate_open_slits function, so a proper error message is provided to
the user [#5939]

- Added computed ``spectral_region`` to ``model.meta.wcsinfo``. [#5969]

associations
------------

Expand Down
2 changes: 1 addition & 1 deletion jwst/assign_wcs/nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ def nrs_wcs_set_input(input_model, slit_name, wavelength_range=None,
slit_name : int or str
Slit.name of an open slit.
wavelength_range: list
Wavelength range for the combination of fliter and grating.
Wavelength range for the combination of filter and grating.
Returns
-------
Expand Down
82 changes: 41 additions & 41 deletions jwst/assign_wcs/tests/test_nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,49 +881,49 @@ def test_ifu_bbox():
(576.5344359685643, 627.777022204828)),
9: ((149.0259581360621, 1616.7687282225652),
(1386.5118806905086, 1439.843598490326)),
10: ((111.91564190274217, 1574.8351095461135),
(527.229828693075, 578.402894851317)),
11: ((151.3053466801954, 1619.3720722471498),
(1435.423685040875, 1488.917203728964)),
12: ((109.8957204607345, 1572.570246400894),
(477.9699083444277, 529.0782087498488)),
13: ((153.5023503173659, 1621.9005029476564),
(1484.38405923062, 1538.0443479389924)),
14: ((107.98320121613297, 1570.411787034636),
(428.6704834494425, 479.7217241891257)),
15: ((155.77991404913857, 1624.5184927460925),
(1533.169633314481, 1586.9984359105376)),
16: ((106.10212081215678, 1568.286103827344),
(379.3860245240618, 430.3780648366697)),
17: ((158.23149941845386, 1627.305849064835),
(1582.0496119714928, 1636.0513450787032)),
18: ((104.09366374413436, 1566.030231370944),
(330.0822744105267, 381.01974582564395)),
19: ((160.4511021152353, 1629.888830991371),
(1630.7797743277185, 1684.9592727079018)),
20: ((102.25220592881234, 1563.9475099032868),
(280.7233309522168, 331.6093009077988)),
21: ((162.72784286205734, 1632.5257403739463),
(1679.6815760587567, 1734.03692957156)),
22: ((100.40115742738622, 1561.8476640376036),
(231.35443588323855, 282.19575854747006)),
23: ((165.05939163941662, 1635.2270773628682),
(1728.511467615387, 1783.0485841263735)),
24: ((98.45723949658425, 1559.6499479349648),
(182.0417295679079, 232.83530870639865)),
25: ((167.44628840053574, 1637.9923229870349),
(1777.2512197664128, 1831.971115503598)),
26: ((96.56508092457855, 1557.5079027818058),
(132.5285162704088, 183.27350269292484)),
27: ((169.8529496136358, 1640.778485168005),
(1826.028691168028, 1880.9336718824313)),
28: ((94.71390837793813, 1555.4048050512263),
(82.94691422559131, 133.63901517357235)),
29: ((172.3681094850081, 1643.685604697228),
(1874.8184744639657, 1929.9072657798927))}
10: ((111.91564190274217, 1574.8351095461135),
(527.229828693075, 578.402894851317)),
11: ((151.3053466801954, 1619.3720722471498),
(1435.423685040875, 1488.917203728964)),
12: ((109.8957204607345, 1572.570246400894),
(477.9699083444277, 529.0782087498488)),
13: ((153.5023503173659, 1621.9005029476564),
(1484.38405923062, 1538.0443479389924)),
14: ((107.98320121613297, 1570.411787034636),
(428.6704834494425, 479.7217241891257)),
15: ((155.77991404913857, 1624.5184927460925),
(1533.169633314481, 1586.9984359105376)),
16: ((106.10212081215678, 1568.286103827344),
(379.3860245240618, 430.3780648366697)),
17: ((158.23149941845386, 1627.305849064835),
(1582.0496119714928, 1636.0513450787032)),
18: ((104.09366374413436, 1566.030231370944),
(330.0822744105267, 381.01974582564395)),
19: ((160.4511021152353, 1629.888830991371),
(1630.7797743277185, 1684.9592727079018)),
20: ((102.25220592881234, 1563.9475099032868),
(280.7233309522168, 331.6093009077988)),
21: ((162.72784286205734, 1632.5257403739463),
(1679.6815760587567, 1734.03692957156)),
22: ((100.40115742738622, 1561.8476640376036),
(231.35443588323855, 282.19575854747006)),
23: ((165.05939163941662, 1635.2270773628682),
(1728.511467615387, 1783.0485841263735)),
24: ((98.45723949658425, 1559.6499479349648),
(182.0417295679079, 232.83530870639865)),
25: ((167.44628840053574, 1637.9923229870349),
(1777.2512197664128, 1831.971115503598)),
26: ((96.56508092457855, 1557.5079027818058),
(132.5285162704088, 183.27350269292484)),
27: ((169.8529496136358, 1640.778485168005),
(1826.028691168028, 1880.9336718824313)),
28: ((94.71390837793813, 1555.4048050512263),
(82.94691422559131, 133.63901517357235)),
29: ((172.3681094850081, 1643.685604697228),
(1874.8184744639657, 1929.9072657798927))}

hdul = create_nirspec_ifu_file("F290LP", "G140M")
im = datamodels.ImageModel(hdul)
im = datamodels.IFUImageModel(hdul)
im.meta.filename = "test_ifu.fits"
refs = create_reference_files(im)

Expand Down
22 changes: 15 additions & 7 deletions jwst/assign_wcs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,17 @@ def compute_footprint_spectral(model):
[np.nanmax(ra), np.nanmin(dec)],
[np.nanmax(ra), np.nanmax(dec)],
[np.nanmin(ra), np.nanmax(dec)]])
return footprint
lam_min = np.nanmin(lam)
lam_max = np.nanmax(lam)
return footprint, (lam_min, lam_max)


def update_s_region_spectral(model):
""" Update the S_REGION keyword.
"""
footprint = compute_footprint_spectral(model)
footprint, spectral_region = compute_footprint_spectral(model)
update_s_region_keyword(model, footprint)
model.meta.wcsinfo.spectral_region = spectral_region


def compute_footprint_nrs_slit(slit):
Expand All @@ -913,12 +916,16 @@ def compute_footprint_nrs_slit(slit):
ra, dec, lam = slit2world(virtual_corners_x,
virtual_corners_y,
input_lam)
return np.array([ra, dec]).T
footprint = np.array([ra, dec]).T
lam_min = np.nanmin(lam)
lam_max = np.nanmax(lam)
return footprint, (lam_min, lam_max)


def update_s_region_nrs_slit(slit):
footprint = compute_footprint_nrs_slit(slit)
footprint, spectral_region = compute_footprint_nrs_slit(slit)
update_s_region_keyword(slit, footprint)
slit.meta.wcsinfo.spectral_region = spectral_region


def update_s_region_keyword(model, footprint):
Expand Down Expand Up @@ -960,8 +967,8 @@ def compute_footprint_nrs_ifu(dmodel, mod):
-------
footprint : ndarray
The spatial footprint
spctral_region : tuple
The wavwlength range for the observation.
spectral_region : tuple
The wavelength range for the observation.
"""
ra_total = []
dec_total = []
Expand Down Expand Up @@ -1030,8 +1037,9 @@ def update_s_region_mrs(output_model):
output_model : `~jwst.datamodels.IFUImageModel`
The output of assign_wcs.
"""
footprint = compute_footprint_spectral(output_model)
footprint, spectral_region = compute_footprint_spectral(output_model)
update_s_region_keyword(output_model, footprint)
output_model.meta.wcsinfo.spectral_region = spectral_region


def velocity_correction(velosys):
Expand Down

0 comments on commit d724473

Please sign in to comment.