11
11
log .setLevel (logging .DEBUG )
12
12
13
13
14
- def extract2d (input_model ,
15
- slit_names = None ,
16
- source_ids = None ,
17
- reference_files = {},
18
- grism_objects = None ,
19
- tsgrism_extract_height = None ,
20
- wfss_extract_half_height = None ,
21
- extract_orders = None ,
22
- mmag_extract = None ,
23
- nbright = None ):
14
+ def extract2d (
15
+ input_model ,
16
+ slit_names = None ,
17
+ source_ids = None ,
18
+ reference_files = None ,
19
+ grism_objects = None ,
20
+ tsgrism_extract_height = None ,
21
+ wfss_extract_half_height = None ,
22
+ extract_orders = None ,
23
+ mmag_extract = None ,
24
+ nbright = None ,
25
+ ):
24
26
"""
25
- The main extract_2d function
27
+ Extract rectangular cutouts around each spectrum from a spectral dataset.
26
28
27
29
Parameters
28
30
----------
@@ -36,7 +38,7 @@ def extract2d(input_model,
36
38
Reference files.
37
39
grism_objects : list
38
40
A list of grism objects.
39
- tsgrism_extract_height: int
41
+ tsgrism_extract_height : int
40
42
Cross-dispersion extraction height to use for time series grisms.
41
43
This will override the default which for NRC_TSGRISM is a set
42
44
size of 64 pixels.
@@ -54,45 +56,57 @@ def extract2d(input_model,
54
56
-------
55
57
output_model : `~jwst.datamodels.ImageModel` or `~jwst.datamodelsCubeModel`
56
58
A copy of the input_model that has been processed.
57
-
58
59
"""
59
- nrs_modes = ['NRS_FIXEDSLIT' , 'NRS_MSASPEC' , 'NRS_BRIGHTOBJ' ,
60
- 'NRS_LAMP' , 'NRS_AUTOFLAT' , 'NRS_AUTOWAVE' ]
61
- slitless_modes = ['NIS_WFSS' , 'NRC_WFSS' , 'NRC_TSGRISM' ]
60
+ nrs_modes = [
61
+ "NRS_FIXEDSLIT" ,
62
+ "NRS_MSASPEC" ,
63
+ "NRS_BRIGHTOBJ" ,
64
+ "NRS_LAMP" ,
65
+ "NRS_AUTOFLAT" ,
66
+ "NRS_AUTOWAVE" ,
67
+ ]
68
+ slitless_modes = ["NIS_WFSS" , "NRC_WFSS" , "NRC_TSGRISM" ]
62
69
63
70
exp_type = input_model .meta .exposure .type .upper ()
64
- log .info (f'EXP_TYPE is { exp_type } ' )
71
+ log .info (f"EXP_TYPE is { exp_type } " )
72
+
73
+ if reference_files is None :
74
+ reference_files = {}
65
75
66
76
if exp_type in nrs_modes :
67
77
if input_model .meta .instrument .grating .lower () == "mirror" :
68
78
# Catch the case of EXP_TYPE=NRS_LAMP and grating=MIRROR
69
- log .info (f' EXP_TYPE { exp_type } with grating=MIRROR not supported for extract 2D' )
70
- input_model .meta .cal_step .extract_2d = ' SKIPPED'
79
+ log .info (f" EXP_TYPE { exp_type } with grating=MIRROR not supported for extract 2D" )
80
+ input_model .meta .cal_step .extract_2d = " SKIPPED"
71
81
return input_model
72
82
output_model = nrs_extract2d (input_model , slit_names = slit_names , source_ids = source_ids )
73
83
elif exp_type in slitless_modes :
74
- if exp_type == ' NRC_TSGRISM' :
84
+ if exp_type == " NRC_TSGRISM" :
75
85
if tsgrism_extract_height is None :
76
86
tsgrism_extract_height = 64
77
- output_model = extract_tso_object (input_model ,
78
- reference_files = reference_files ,
79
- tsgrism_extract_height = tsgrism_extract_height ,
80
- extract_orders = extract_orders )
87
+ output_model = extract_tso_object (
88
+ input_model ,
89
+ reference_files = reference_files ,
90
+ tsgrism_extract_height = tsgrism_extract_height ,
91
+ extract_orders = extract_orders ,
92
+ )
81
93
else :
82
- output_model = extract_grism_objects (input_model ,
83
- grism_objects = grism_objects ,
84
- reference_files = reference_files ,
85
- extract_orders = extract_orders ,
86
- mmag_extract = mmag_extract ,
87
- wfss_extract_half_height = wfss_extract_half_height ,
88
- nbright = nbright )
94
+ output_model = extract_grism_objects (
95
+ input_model ,
96
+ grism_objects = grism_objects ,
97
+ reference_files = reference_files ,
98
+ extract_orders = extract_orders ,
99
+ mmag_extract = mmag_extract ,
100
+ wfss_extract_half_height = wfss_extract_half_height ,
101
+ nbright = nbright ,
102
+ )
89
103
90
104
else :
91
- log .info (f' EXP_TYPE { exp_type } not supported for extract 2D' )
92
- input_model .meta .cal_step .extract_2d = ' SKIPPED'
105
+ log .info (f" EXP_TYPE { exp_type } not supported for extract 2D" )
106
+ input_model .meta .cal_step .extract_2d = " SKIPPED"
93
107
return input_model
94
108
95
109
# Set the step status to COMPLETE
96
- output_model .meta .cal_step .extract_2d = ' COMPLETE'
110
+ output_model .meta .cal_step .extract_2d = " COMPLETE"
97
111
del input_model
98
112
return output_model
0 commit comments