12
12
13
13
14
14
# FGS guide star mode exposure types
15
- guider_list = ['FGS_ID-IMAGE' , 'FGS_ID-STACK' , 'FGS_ACQ1' , 'FGS_ACQ2' ,
16
- 'FGS_TRACK' , 'FGS_FINEGUIDE' ]
15
+ guider_list = ["FGS_ID-IMAGE" , "FGS_ID-STACK" , "FGS_ACQ1" , "FGS_ACQ2" , "FGS_TRACK" , "FGS_FINEGUIDE" ]
17
16
18
17
19
18
def correct_model (input_model , mask_model ):
20
- """Perform the dq_init step on a JWST datamodel
19
+ """
20
+ Perform the dq_init step on a JWST datamodel.
21
21
22
22
Parameters
23
23
----------
24
24
input_model : input JWST datamodel
25
25
The jwst datamodel to be corrected
26
-
27
26
mask_model : mask datamodel
28
27
The mask model to use in the correction
29
28
@@ -32,20 +31,19 @@ def correct_model(input_model, mask_model):
32
31
output_model : JWST datamodel
33
32
The corrected JWST datamodel
34
33
"""
35
-
36
34
output_model = do_dqinit (input_model , mask_model )
37
35
38
36
return output_model
39
37
40
38
41
39
def do_dqinit (output_model , mask_model ):
42
- """Perform the dq_init step on a JWST datamodel
40
+ """
41
+ Perform the dq_init step on a JWST datamodel.
43
42
44
43
Parameters
45
44
----------
46
45
output_model : input JWST datamodel
47
46
The jwst datamodel to be corrected
48
-
49
47
mask_model : mask datamodel
50
48
The mask model to use in the correction
51
49
@@ -54,17 +52,15 @@ def do_dqinit(output_model, mask_model):
54
52
output_model : JWST datamodel
55
53
The corrected JWST datamodel
56
54
"""
57
-
58
55
# Inflate empty DQ array, if necessary
59
56
check_dimensions (output_model )
60
57
61
58
# Extract subarray from reference data, if necessary
62
59
if reffile_utils .ref_matches_sci (output_model , mask_model ):
63
60
mask_array = mask_model .dq
64
61
else :
65
- log .info ('Extracting mask subarray to match science data' )
66
- mask_sub_model = reffile_utils .get_subarray_model (output_model ,
67
- mask_model )
62
+ log .info ("Extracting mask subarray to match science data" )
63
+ mask_sub_model = reffile_utils .get_subarray_model (output_model , mask_model )
68
64
mask_array = mask_sub_model .dq .copy ()
69
65
mask_sub_model .close ()
70
66
@@ -77,15 +73,20 @@ def do_dqinit(output_model, mask_model):
77
73
output_model .pixeldq = dq
78
74
# Additionally, propagate mask DO_NOT_USE flags to groupdq to
79
75
# ensure no ramps are fit to bad pixels.
80
- output_model .groupdq = np .bitwise_or (output_model .groupdq , mask_array & dqflags .group ['DO_NOT_USE' ])
76
+ output_model .groupdq = np .bitwise_or (
77
+ output_model .groupdq , mask_array & dqflags .group ["DO_NOT_USE" ]
78
+ )
81
79
82
- output_model .meta .cal_step .dq_init = ' COMPLETE'
80
+ output_model .meta .cal_step .dq_init = " COMPLETE"
83
81
84
82
return output_model
85
83
86
84
87
85
def check_dimensions (input_model ):
88
- """Check that the input model pixeldq attribute has the same dimensions as
86
+ """
87
+ Check the input model pixeldq dimensions.
88
+
89
+ The pixeldq attribute should have the same dimensions as
89
90
the image plane of the input model science data
90
91
If it has dimensions (0,0), create an array of zeros with the same shape
91
92
as the image plane of the input model. For the FGS modes, the
@@ -94,45 +95,34 @@ def check_dimensions(input_model):
94
95
Parameters
95
96
----------
96
97
input_model : JWST datamodel
97
- input datamodel
98
-
99
- Returns
100
- -------
101
- None
98
+ Input datamodel.
102
99
"""
103
-
104
100
input_shape = input_model .data .shape
105
101
106
102
if isinstance (input_model , datamodels .GuiderRawModel ):
107
103
if input_model .dq .shape != input_shape [- 2 :]:
108
-
109
104
# If the shape is different, then the mask model should have
110
105
# a shape of (0,0).
111
106
# If that's the case, create the array
112
107
if input_model .dq .shape == (0 , 0 ):
113
- input_model .dq = np .zeros (( input_shape [- 2 :])) .astype (' uint32' )
108
+ input_model .dq = np .zeros (input_shape [- 2 :]).astype (" uint32" )
114
109
else :
115
- log .error ("DQ array has the wrong shape: (%d, %d)" %
116
- input_model .dq .shape )
110
+ log .error (f"DQ array has the wrong shape: { input_model .dq .shape } " )
117
111
118
- else : # RampModel
112
+ else : # RampModel
119
113
if input_model .pixeldq .shape != input_shape [- 2 :]:
120
-
121
114
# If the shape is different, then the mask model should have
122
115
# a shape of (0,0).
123
116
# If that's the case, create the array
124
117
if input_model .pixeldq .shape == (0 , 0 ):
125
- input_model .pixeldq = \
126
- np .zeros ((input_shape [- 2 :])).astype ('uint32' )
118
+ input_model .pixeldq = np .zeros (input_shape [- 2 :]).astype ("uint32" )
127
119
else :
128
- log .error ("Pixeldq array has the wrong shape: (%d, %d)" %
129
- input_model .pixeldq .shape )
120
+ log .error (f"Pixeldq array has the wrong shape: { input_model .pixeldq .shape } " )
130
121
131
122
# Perform the same check for the input model groupdq array
132
123
if input_model .groupdq .shape != input_shape :
133
124
if input_model .groupdq .shape == (0 , 0 , 0 , 0 ):
134
- input_model .groupdq = np .zeros (( input_shape )) .astype (' uint8' )
125
+ input_model .groupdq = np .zeros (input_shape ).astype (" uint8" )
135
126
else :
136
- log .error ("Groupdq array has wrong shape: (%d, %d, %d, %d)" %
137
- input_model .groupdq .shape )
127
+ log .error (f"Groupdq array has wrong shape: { input_model .groupdq .shape } " )
138
128
return
0 commit comments