|
1 | 1 | """Flag pixels affected by open MSA shutters in NIRSpec exposures."""
|
2 | 2 |
|
3 | 3 | import json
|
4 |
| -import numpy as np |
5 | 4 | import logging
|
| 5 | +import warnings |
6 | 6 | from pathlib import Path
|
7 | 7 |
|
| 8 | +import numpy as np |
8 | 9 | from gwcs.wcs import WCS
|
9 |
| - |
10 | 10 | from stdatamodels.jwst import datamodels
|
11 | 11 | from stdatamodels.jwst.transforms.models import Slit
|
12 | 12 |
|
13 |
| -from ..assign_wcs.nirspec import slitlets_wcs, _nrs_wcs_set_input_lite, _get_transforms |
| 13 | +from jwst.assign_wcs.nirspec import ( |
| 14 | + slitlets_wcs, |
| 15 | + _nrs_wcs_set_input_lite, |
| 16 | + _get_transforms, |
| 17 | + log as nirspec_log, |
| 18 | +) |
| 19 | +from jwst.lib.basic_utils import LoggingContext |
14 | 20 |
|
15 | 21 | log = logging.getLogger(__name__)
|
16 | 22 | log.setLevel(logging.DEBUG)
|
@@ -43,9 +49,12 @@ def do_correction(input_model, shutter_refname, wcs_refnames):
|
43 | 49 | """
|
44 | 50 | # Create a list of failed open slitlets from the msaoper reference file
|
45 | 51 | failed_slitlets = create_slitlets(shutter_refname)
|
| 52 | + log.info("%d failed open shutters", len(failed_slitlets)) |
46 | 53 |
|
47 | 54 | # Flag the stuck open shutters
|
48 |
| - output_model = flag(input_model, failed_slitlets, wcs_refnames) |
| 55 | + with warnings.catch_warnings(): |
| 56 | + warnings.filterwarnings("ignore", category=RuntimeWarning, message="Invalid interval") |
| 57 | + output_model = flag(input_model, failed_slitlets, wcs_refnames) |
49 | 58 | output_model.meta.cal_step.msa_flagging = "COMPLETE"
|
50 | 59 |
|
51 | 60 | return output_model
|
@@ -79,7 +88,8 @@ def flag(input_datamodel, failed_slitlets, wcs_refnames):
|
79 | 88 | Science data with DQ flags modified.
|
80 | 89 | """
|
81 | 90 | # Use the machinery in assign_wcs to create a WCS object for the bad shutters
|
82 |
| - pipeline = slitlets_wcs(input_datamodel, wcs_refnames, failed_slitlets) |
| 91 | + with LoggingContext(nirspec_log, level=logging.WARNING): |
| 92 | + pipeline = slitlets_wcs(input_datamodel, wcs_refnames, failed_slitlets) |
83 | 93 | wcs = WCS(pipeline)
|
84 | 94 |
|
85 | 95 | # Create output as a copy of the input science data model so we can overwrite
|
|
0 commit comments