Skip to content

Commit def30b1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3abb431 commit def30b1

File tree

9 files changed

+64
-57
lines changed

9 files changed

+64
-57
lines changed

jwst/assign_wcs/util.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def create_grism_bbox(
398398
extract_orders = [x[1] for x in ref_extract_orders if x[0] == filter_name].pop()
399399

400400
wavelength_range = f.get_wfss_wavelength_range(filter_name, extract_orders)
401-
print('Wavelength range', wavelength_range)
401+
print("Wavelength range", wavelength_range)
402402
if mmag_extract is None:
403403
mmag_extract = 999.0 # extract all objects, regardless of magnitude
404404
else:
@@ -431,7 +431,7 @@ def _create_grism_bbox(
431431
# this contains the pure information from the catalog with no translations
432432
skyobject_list = get_object_info(input_model.meta.source_catalog)
433433

434-
print('sky object list', skyobject_list)
434+
print("sky object list", skyobject_list)
435435
# get the imaging transform to record the center of the object in the image
436436
# here, image is in the imaging reference frame, before going through the
437437
# dispersion coefficients
@@ -451,9 +451,16 @@ def _create_grism_bbox(
451451
# takes in ra, dec, wavelength, order but wave and order
452452
# don't get used until the detector->grism_detector transform
453453
xcenter, ycenter, _, _ = sky_to_detector(
454-
obj.sky_centroid.icrs.ra.value, obj.sky_centroid.icrs.dec.value, 1, 1)
454+
obj.sky_centroid.icrs.ra.value, obj.sky_centroid.icrs.dec.value, 1, 1
455+
)
455456

456-
print('X and Y center', xcenter, ycenter, obj.sky_centroid.icrs.ra.value, obj.sky_centroid.icrs.dec.value)
457+
print(
458+
"X and Y center",
459+
xcenter,
460+
ycenter,
461+
obj.sky_centroid.icrs.ra.value,
462+
obj.sky_centroid.icrs.dec.value,
463+
)
457464
order_bounding = {}
458465
waverange = {}
459466
partial_order = {}
@@ -483,11 +490,11 @@ def _create_grism_bbox(
483490
]
484491
)
485492
if input_model.meta.exposure.type.upper() == "MIR_WFSS":
486-
print('lmin lmax order', lmin,lmax,order)
487-
x1, y1, _, _, _ = sky_to_grism(ra, dec, [lmin] , [order] )
488-
x2, y2,_, _ , _ = sky_to_grism(ra, dec, [lmax] , [order] )
489-
#y1 = ycenter + y1
490-
#y2 = ycenter + y2
493+
print("lmin lmax order", lmin, lmax, order)
494+
x1, y1, _, _, _ = sky_to_grism(ra, dec, [lmin], [order])
495+
x2, y2, _, _, _ = sky_to_grism(ra, dec, [lmax], [order])
496+
# y1 = ycenter + y1
497+
# y2 = ycenter + y2
491498
print("+++++++++++++++++++++++++assign_wcs util.py x1,y1,x2,y2", x1, y1, x2, y2)
492499
else:
493500
x1, y1, _, _, _ = sky_to_grism(ra, dec, [lmin] * 4, [order] * 4)
@@ -520,17 +527,17 @@ def _create_grism_bbox(
520527
input_model.meta.wcsinfo.dispersion_direction,
521528
)
522529

523-
print('object is extended', obj.is_extended)
524-
530+
print("object is extended", obj.is_extended)
531+
525532
if wfss_extract_half_height is not None and not obj.is_extended:
526533
if input_model.meta.wcsinfo.dispersion_direction == 2:
527534
ra_center, dec_center = (
528535
obj.sky_centroid.ra.value,
529536
obj.sky_centroid.dec.value,
530537
)
531538
center, _, _, _, _ = sky_to_grism(
532-
ra_center, dec_center, (lmin + lmax) / 2, order
533-
)
539+
ra_center, dec_center, (lmin + lmax) / 2, order
540+
)
534541
xmin = center - wfss_extract_half_height
535542
xmax = center + wfss_extract_half_height
536543
elif input_model.meta.wcsinfo.dispersion_direction == 1:
@@ -546,13 +553,13 @@ def _create_grism_bbox(
546553
else:
547554
raise ValueError("Cannot determine dispersion direction.")
548555

549-
print('xmin xmax', xmin, xmax)
556+
print("xmin xmax", xmin, xmax)
550557
# Convert floating-point corner values to whole pixel indexes
551558
xmin = gwutils._toindex(xmin) # noqa: SLF001
552559
xmax = gwutils._toindex(xmax) # noqa: SLF001
553560
ymin = gwutils._toindex(ymin) # noqa: SLF001
554561
ymax = gwutils._toindex(ymax) # noqa: SLF001
555-
print('ymin ymax', ymin, ymax)
562+
print("ymin ymax", ymin, ymax)
556563
# Don't add objects and orders that are entirely off the detector.
557564
# "partial_order" marks objects that are near enough to the detector
558565
# edge to have some spectrum on the detector.

jwst/extract_1d/extract.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,10 @@ def define_aperture(input_model, slit, extract_params, exp_type):
11871187
data_shape = data_model.data.shape[-2:]
11881188

11891189
# Get a wavelength array for the data
1190-
1190+
11911191
wl_array = get_wavelengths(data_model, exp_type, extract_params["spectral_order"])
11921192

1193-
print('result of get_wavelengths', wl_array)
1193+
print("result of get_wavelengths", wl_array)
11941194
# Shift aperture definitions by source position if needed
11951195
# Extract parameters are updated in place
11961196
if extract_params["use_source_posn"]:
@@ -1620,7 +1620,7 @@ def create_extraction(
16201620
extract_params = get_extract_parameters(
16211621
extract_ref_dict, data_model, slitname, sp_order, input_model.meta, **kwargs
16221622
)
1623-
print('in extract.py extraction parameters', extract_params["match"])
1623+
print("in extract.py extraction parameters", extract_params["match"])
16241624

16251625
if extract_params["match"] == NO_MATCH:
16261626
log.critical("Missing extraction parameters.")
@@ -1630,8 +1630,8 @@ def create_extraction(
16301630
raise ContinueError()
16311631

16321632
extract_params["dispaxis"] = data_model.meta.wcsinfo.dispersion_direction
1633-
print('extract params', extract_params["dispaxis"])
1634-
1633+
print("extract params", extract_params["dispaxis"])
1634+
16351635
if extract_params["dispaxis"] is None:
16361636
log.warning("The dispersion direction information is missing, so skipping ...")
16371637
raise ContinueError()
@@ -1645,7 +1645,7 @@ def create_extraction(
16451645

16461646
valid = np.isfinite(wavelength)
16471647
wavelength = wavelength[valid]
1648-
print('wavelength',wavelength)
1648+
print("wavelength", wavelength)
16491649
if np.sum(valid) == 0:
16501650
log.error("Spectrum is empty; no valid data.")
16511651
raise ContinueError()
@@ -1663,7 +1663,7 @@ def create_extraction(
16631663

16641664
# Set up aperture correction, to be used for every integration
16651665
apcorr_available = False
1666-
print('Source type', source_type)
1666+
print("Source type", source_type)
16671667
if source_type is not None and source_type.upper() == "POINT" and apcorr_ref_model is not None:
16681668
log.info("Creating aperture correction.")
16691669
# NIRSpec needs to use a wavelength in the middle of the
@@ -1687,7 +1687,7 @@ def create_extraction(
16871687
)
16881688
else:
16891689
apcorr = None
1690-
print('in extract.py apcorr',apcorr)
1690+
print("in extract.py apcorr", apcorr)
16911691

16921692
# Log the parameters before extracting
16931693
log_initial_parameters(extract_params)
@@ -1726,7 +1726,7 @@ def create_extraction(
17261726

17271727
# Extract each integration
17281728
spec_list = []
1729-
print('integrations', integrations)
1729+
print("integrations", integrations)
17301730
for integ in integrations:
17311731
(
17321732
sum_flux,
@@ -1741,8 +1741,8 @@ def create_extraction(
17411741
scene_model_2d,
17421742
residual_2d,
17431743
) = extract_one_slit(data_model, integ, profile, bg_profile, nod_profile, extract_params)
1744-
print('Got here')
1745-
1744+
print("Got here")
1745+
17461746
# Save the scene model and residual
17471747
if save_scene_model:
17481748
if isinstance(scene_model, datamodels.CubeModel):
@@ -1808,7 +1808,7 @@ def create_extraction(
18081808

18091809
del sum_flux
18101810

1811-
print('flux', flux)
1811+
print("flux", flux)
18121812
error = np.sqrt(f_var_poisson + f_var_rnoise + f_var_flat)
18131813
sb_error = np.sqrt(sb_var_poisson + sb_var_rnoise + sb_var_flat)
18141814
berror = np.sqrt(b_var_poisson + b_var_rnoise + b_var_flat)
@@ -1886,7 +1886,7 @@ def create_extraction(
18861886

18871887
if exp_type in WFSS_EXPTYPES:
18881888
spectral_order = data_model.meta.wcsinfo.spectral_order
1889-
print('spectral order', spectral_order)
1889+
print("spectral order", spectral_order)
18901890
if hasattr(data_model.meta, "filename"):
18911891
# calwebb_spec3 case: no separate slit input to function
18921892
spec.meta.filename = data_model.meta.filename
@@ -2143,8 +2143,8 @@ def run_extract1d(
21432143
else:
21442144
apcorr_ref_model = read_apcorr_ref(apcorr_ref_name, exp_type)
21452145

2146-
print('in extract.py', apcorr_ref_model)
2147-
2146+
print("in extract.py", apcorr_ref_model)
2147+
21482148
# This will be relevant if we're asked to extract a spectrum
21492149
# and the spectral order is zero.
21502150
# That's only OK if the disperser is a prism.
@@ -2154,7 +2154,7 @@ def run_extract1d(
21542154
profile_model = None
21552155
scene_model = None
21562156
residual = None
2157-
print('is this true', isinstance(input_model, (ModelContainer, datamodels.MultiSlitModel)))
2157+
print("is this true", isinstance(input_model, (ModelContainer, datamodels.MultiSlitModel)))
21582158
if isinstance(input_model, (ModelContainer, datamodels.MultiSlitModel)):
21592159
if isinstance(input_model, ModelContainer):
21602160
slits = input_model
@@ -2176,7 +2176,7 @@ def run_extract1d(
21762176
# Set up the output model
21772177
output_model = _make_output_model(slits[0], meta_source)
21782178

2179-
print('in extract.py number of slits', len(slits))
2179+
print("in extract.py number of slits", len(slits))
21802180
for slit in slits: # Loop over the slits in the input model
21812181
log.info(f"Working on slit {slit.name}")
21822182
log.debug(f"Slit is of type {type(slit)}")

jwst/extract_1d/extract_1d_step.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def _get_extract_reference_files_by_mode(self, model, exp_type):
9494
if apcorr_ref != "N/A":
9595
self.log.info(f"Using APCORR file {apcorr_ref}")
9696

97-
print('************************',apcorr_ref)
98-
97+
print("************************", apcorr_ref)
98+
9999
try:
100100
psf_ref = self.get_reference_file(model, "psf")
101101
except crds.core.exceptions.CrdsLookupError:
@@ -416,8 +416,8 @@ def process(self, input_data):
416416
profile = None
417417
scene_model = None
418418
residual = None
419-
print('The returned reference files', extract_ref, apcorr_ref, psf_ref)
420-
419+
print("The returned reference files", extract_ref, apcorr_ref, psf_ref)
420+
421421
if isinstance(model, datamodels.IFUCubeModel):
422422
# Call the IFU specific extraction routine
423423
extracted = self._extract_ifu(model, exp_type, extract_ref, apcorr_ref)

jwst/extract_2d/extract_2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from jwst.extract_2d.grisms import extract_grism_objects, extract_tso_object
88
from jwst.extract_2d.nirspec import nrs_extract2d
99

10-
#from jwst.miri import extract_wfss_objects
10+
# from jwst.miri import extract_wfss_objects
1111

1212
log = logging.getLogger(__name__)
1313

@@ -98,7 +98,7 @@ def extract2d(
9898
extract_orders=extract_orders,
9999
)
100100

101-
#elif exp_type == "MIR_WFSS":
101+
# elif exp_type == "MIR_WFSS":
102102
# print("extract 2d WFSS")
103103
# output_model = extract_grism_objects(
104104
# input_model,

jwst/extract_2d/extract_2d_step.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def process(self, input_model):
4242
reference_file_names = {}
4343

4444
if input_model.meta.exposure.type in extract_2d.slitless_modes:
45-
print('Going to read in wavelength reference file')
45+
print("Going to read in wavelength reference file")
4646
# The wavelengthrange file is used only by the WFSS modes.
4747
# If retrieved by a Nirspec mode, it would override the name of
4848
# the file in meta.ref_file if a custom file was used.
4949
for reftype in self.reference_file_types:
5050
reffile = self.get_reference_file(input_model, reftype)
5151
reference_file_names[reftype] = reffile if reffile else ""
52-
print('refrence file names',reference_file_names)
52+
print("reference file names", reference_file_names)
5353
with datamodels.open(input_model) as dm:
5454
output_model = extract_2d.extract2d(
5555
dm,

jwst/extract_2d/grisms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def extract_grism_objects(
394394
]:
395395
raise ValueError("Expected name of wavelengthrange reference file")
396396
else:
397-
print(' mag limits', mmag_extract, nbright)
397+
print(" mag limits", mmag_extract, nbright)
398398
grism_objects = util.create_grism_bbox(
399399
input_model,
400400
reference_files,
@@ -479,7 +479,7 @@ def extract_grism_objects(
479479
order_model = Const1D(order)
480480
order_model.inverse = Const1D(order)
481481

482-
print('WHAT ARE THESE', xmin, ymin, xcenter_model, ycenter_model, order_model)
482+
print("WHAT ARE THESE", xmin, ymin, xcenter_model, ycenter_model, order_model)
483483
if input_model.meta.exposure.type.upper() == "MIR_WFSS":
484484
tr = inwcs.get_transform("dispersed_detector", "detector")
485485
else:

jwst/lib/dispaxis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_dispersion_direction(exposure_type, grating="ANY", filter_wh="ANY", pupi
7676
"MIR_IMAGE": None,
7777
"MIR_LRS-FIXEDSLIT": 2,
7878
"MIR_LRS-SLITLESS": 2,
79-
"MIR_WFSS":2,
79+
"MIR_WFSS": 2,
8080
"MIR_LYOT": None,
8181
"MIR_MRS": 2,
8282
"MIR_TACQ": None,

jwst/lib/wcs_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_wavelengths(model, exp_type="", order=None, use_wavecorr=None):
4040
else:
4141
wl_array = None
4242

43-
print(' lib wcs_utils', wl_array)
43+
print(" lib wcs_utils", wl_array)
4444
# Check for a present but empty wavelength array
4545
with warnings.catch_warnings():
4646
warnings.filterwarnings("ignore", message="All-NaN slice", category=RuntimeWarning)

jwst/pipeline/calwebb_spec2.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
EXP_TYPES_USING_REFBKGDS = WFSS_TYPES + ["NIS_SOSS"]
4949

5050
WFSS_TYPES = WFSS_TYPES + ["MIR_WFSS"]
51+
52+
5153
class Spec2Pipeline(Pipeline):
5254
"""
5355
Process JWST spectroscopic exposures from Level 2a to 2b.
@@ -223,9 +225,9 @@ def process_exposure_product(
223225

224226
# Check the datamodel to see if it's a grism image/direct image, if so get the catalog
225227
# name from the asn and record it to the meta
226-
print('WFSS_TYPES', WFSS_TYPES, exp_type)
228+
print("WFSS_TYPES", WFSS_TYPES, exp_type)
227229
if exp_type in WFSS_TYPES:
228-
print('In calwebb_spec2 we are in WFSS_TYPES')
230+
print("In calwebb_spec2 we are in WFSS_TYPES")
229231
try:
230232
science.meta.source_catalog = Path(members_by_type["sourcecat"][0]).name
231233
self.log.info(f"Using sourcecat file {science.meta.source_catalog}")
@@ -348,7 +350,7 @@ def process_exposure_product(
348350
elif exp_type == "NRS_MSASPEC":
349351
calibrated = self._process_nirspec_msa_slits(calibrated)
350352
elif exp_type == "MIR_WFSS":
351-
print('in calspec2 Calling process_miri_wfss')
353+
print("in calspec2 Calling process_miri_wfss")
352354
calibrated = self._process_miri_wfss(calibrated)
353355
elif exp_type in NRS_SLIT_TYPES:
354356
calibrated = self._process_nirspec_slits(calibrated)
@@ -588,9 +590,8 @@ def _step_verification(self, exp_type, science, members_by_type, multi_int):
588590
'Science data does not allow WFSS contamination correction. Skipping "wfss_contam".'
589591
)
590592
self.wfss_contam.skip = True
591-
if exp_type == 'MIR_WFSS':
593+
if exp_type == "MIR_WFSS":
592594
self.wfss_contam.skip = True
593-
594595

595596
def _process_grism(self, data):
596597
"""
@@ -659,7 +660,6 @@ def _process_grism(self, data):
659660
calibrated = self.photom.run(calibrated)
660661
return calibrated
661662

662-
663663
def _process_miri_wfss(self, data):
664664
"""
665665
Calibrate MIRI WFSS data.
@@ -716,15 +716,15 @@ def _process_miri_wfss(self, data):
716716

717717
# Continue with remaining calibration steps, using the original
718718
# DN/sec image
719-
print('*** run extracted_2d')
719+
print("*** run extracted_2d")
720720
calibrated = self.extract_2d.run(calibrated)
721-
print('*** src type')
721+
print("*** src type")
722722
calibrated = self.srctype.run(calibrated)
723-
#calibrated = self.straylight.run(calibrated)
724-
#calibrated = self.fringe.run(calibrated)
725-
#calibrated = self.pathloss.run(calibrated)
726-
#calibrated = self.barshadow.run(calibrated)
727-
#calibrated = self.wfss_contam.run(calibrated)
723+
# calibrated = self.straylight.run(calibrated)
724+
# calibrated = self.fringe.run(calibrated)
725+
# calibrated = self.pathloss.run(calibrated)
726+
# calibrated = self.barshadow.run(calibrated)
727+
# calibrated = self.wfss_contam.run(calibrated)
728728
calibrated = self.photom.run(calibrated)
729729
return calibrated
730730

0 commit comments

Comments
 (0)