|
6 | 6 |
|
7 | 7 | import copy |
8 | 8 | import logging |
9 | | -import warnings |
10 | 9 |
|
11 | 10 | import gwcs |
12 | 11 | import numpy as np |
|
41 | 40 | Rotation3DToGWA, |
42 | 41 | Slit, |
43 | 42 | Slit2Msa, |
44 | | - Slit2MsaLegacy, |
45 | 43 | Snell, |
46 | 44 | Unitless2DirCos, |
47 | 45 | WavelengthFromGratingEquation, |
@@ -2282,109 +2280,6 @@ def gwa_to_ymsa(msa2gwa_model, lam_cen=None, slit=None, slit_y_range=None): |
2282 | 2280 | return tab |
2283 | 2281 |
|
2284 | 2282 |
|
2285 | | -def _nrs_wcs_set_slit_input_legacy(input_model, slit_name): |
2286 | | - """ |
2287 | | - Return a WCS object for a specific slit, slice or shutter. |
2288 | | -
|
2289 | | - Does not compute the bounding box. |
2290 | | -
|
2291 | | - Parameters |
2292 | | - ---------- |
2293 | | - input_model : JwstDataModel |
2294 | | - A WCS object for the all open slitlets in an observation. |
2295 | | - slit_name : int or str |
2296 | | - Slit.name of an open slit. |
2297 | | -
|
2298 | | - Returns |
2299 | | - ------- |
2300 | | - wcsobj : `~gwcs.wcs.WCS` |
2301 | | - WCS object for this slit. |
2302 | | - """ |
2303 | | - wcsobj = input_model.meta.wcs |
2304 | | - |
2305 | | - slit_wcs = copy.deepcopy(wcsobj) |
2306 | | - slit_wcs.set_transform("sca", "gwa", wcsobj.pipeline[1].transform[1:]) |
2307 | | - g2s = slit_wcs.pipeline[2].transform |
2308 | | - slit_wcs.set_transform("gwa", "slit_frame", g2s.get_model(slit_name)) |
2309 | | - |
2310 | | - exp_type = input_model.meta.exposure.type |
2311 | | - is_nirspec_ifu = is_nrs_ifu_lamp(input_model) or (exp_type.lower() == "nrs_ifu") |
2312 | | - if is_nirspec_ifu: |
2313 | | - slit_wcs.set_transform( |
2314 | | - "slit_frame", "slicer", wcsobj.pipeline[3].transform.get_model(slit_name) & Identity(1) |
2315 | | - ) |
2316 | | - else: |
2317 | | - slit_wcs.set_transform( |
2318 | | - "slit_frame", |
2319 | | - "msa_frame", |
2320 | | - wcsobj.pipeline[3].transform.get_model(slit_name) & Identity(1), |
2321 | | - ) |
2322 | | - return slit_wcs |
2323 | | - |
2324 | | - |
2325 | | -def nrs_wcs_set_input_legacy( |
2326 | | - input_model, slit_name, wavelength_range=None, slit_y_low=None, slit_y_high=None |
2327 | | -): |
2328 | | - """ |
2329 | | - Return a WCS object for a specific slit, slice or shutter. |
2330 | | -
|
2331 | | - This function is intended to work with old-style NIRSpec WCS implementations, |
2332 | | - to support reading in WCS data from existing datamodels. For new datamodels, |
2333 | | - produced after v1.18.0, use `nrs_wcs_set_input`. |
2334 | | -
|
2335 | | - Parameters |
2336 | | - ---------- |
2337 | | - input_model : JwstDataModel |
2338 | | - A WCS object for the all open slitlets in an observation. |
2339 | | - slit_name : int or str |
2340 | | - Slit.name of an open slit. |
2341 | | - wavelength_range : list |
2342 | | - Wavelength range for the combination of filter and grating. |
2343 | | - slit_y_low, slit_y_high : float |
2344 | | - The lower and upper bounds of the slit. Optional. |
2345 | | -
|
2346 | | - Returns |
2347 | | - ------- |
2348 | | - wcsobj : `~gwcs.wcs.WCS` |
2349 | | - WCS object for this slit. |
2350 | | - """ |
2351 | | - warnings.warn( |
2352 | | - "The nrs_wcs_set_input_legacy function is intended for use with an " |
2353 | | - "old-style NIRSpec WCS pipeline. " |
2354 | | - "It will be removed in a future build.", |
2355 | | - DeprecationWarning, |
2356 | | - stacklevel=2, |
2357 | | - ) |
2358 | | - |
2359 | | - def _get_y_range(input_model): |
2360 | | - # get the open slits from the model |
2361 | | - # Need them to get the slit ymin,ymax |
2362 | | - g2s = input_model.meta.wcs.get_transform("gwa", "slit_frame") |
2363 | | - open_slits = g2s.slits |
2364 | | - slit = [s for s in open_slits if s.name == slit_name][0] |
2365 | | - return slit.ymin, slit.ymax |
2366 | | - |
2367 | | - if wavelength_range is None: |
2368 | | - _, wavelength_range = spectral_order_wrange_from_model(input_model) |
2369 | | - |
2370 | | - slit_wcs = _nrs_wcs_set_slit_input_legacy(input_model, slit_name) |
2371 | | - transform = slit_wcs.get_transform("detector", "slit_frame") |
2372 | | - is_nirspec_ifu = ( |
2373 | | - is_nrs_ifu_lamp(input_model) or input_model.meta.exposure.type.lower() == "nrs_ifu" |
2374 | | - ) |
2375 | | - if is_nirspec_ifu: |
2376 | | - bb = compute_bounding_box(transform, None, wavelength_range) |
2377 | | - else: |
2378 | | - if slit_y_low is None or slit_y_high is None: |
2379 | | - slit_y_low, slit_y_high = _get_y_range(input_model) |
2380 | | - bb = compute_bounding_box( |
2381 | | - transform, None, wavelength_range, slit_ymin=slit_y_low, slit_ymax=slit_y_high |
2382 | | - ) |
2383 | | - |
2384 | | - slit_wcs.bounding_box = bb |
2385 | | - return slit_wcs |
2386 | | - |
2387 | | - |
2388 | 2283 | def _fix_slit_name(transform, slit_name): |
2389 | 2284 | """ |
2390 | 2285 | Create a new WCS transform by fixing the slit input to a specific value. |
@@ -2563,13 +2458,6 @@ def nrs_wcs_set_input(input_model, slit_name): |
2563 | 2458 | # Get the full WCS object |
2564 | 2459 | full_wcs = input_model.meta.wcs |
2565 | 2460 |
|
2566 | | - # Check for an old-style WCS that needs different handling |
2567 | | - for step in full_wcs.pipeline: |
2568 | | - if isinstance(step.transform, Slit2MsaLegacy): |
2569 | | - # There is a legacy slit2msa transform somewhere in the pipeline. |
2570 | | - # Use the old deepcopy-and-replace method. |
2571 | | - return nrs_wcs_set_input_legacy(input_model, slit_name) |
2572 | | - |
2573 | 2461 | # Convert FS slit names to numbers |
2574 | 2462 | if str(slit_name).upper() in FIXED_SLIT_NUMS.keys(): |
2575 | 2463 | slit_id = nrs_fs_slit_id(str(slit_name).upper()) |
|
0 commit comments