diff --git a/romancal/assign_wcs/assign_wcs_step.py b/romancal/assign_wcs/assign_wcs_step.py index b84b9ad09..5dcbf0cb2 100644 --- a/romancal/assign_wcs/assign_wcs_step.py +++ b/romancal/assign_wcs/assign_wcs_step.py @@ -2,6 +2,7 @@ Assign a gWCS object to a science image. """ + import logging import gwcs.coordinate_frames as cf diff --git a/romancal/associations/__init__.py b/romancal/associations/__init__.py index 3eeaf4bd3..17e97a23a 100644 --- a/romancal/associations/__init__.py +++ b/romancal/associations/__init__.py @@ -7,6 +7,7 @@ For more, see the :ref:`documentation overview `. """ + # flake8: noqa: F401, F402, F403 # Take version from the upstream package diff --git a/romancal/associations/asn_from_list.py b/romancal/associations/asn_from_list.py index dcd1c90dc..5e9a65284 100644 --- a/romancal/associations/asn_from_list.py +++ b/romancal/associations/asn_from_list.py @@ -1,4 +1,5 @@ """Create an association from a list""" + import argparse import sys diff --git a/romancal/associations/association_io.py b/romancal/associations/association_io.py index 397f77fbe..fee54da5c 100644 --- a/romancal/associations/association_io.py +++ b/romancal/associations/association_io.py @@ -1,6 +1,7 @@ """ Define the I/O methods for Level 3 associations """ + import json as json_lib import logging diff --git a/romancal/associations/lib/acid.py b/romancal/associations/lib/acid.py index 813c7ed76..42414d671 100644 --- a/romancal/associations/lib/acid.py +++ b/romancal/associations/lib/acid.py @@ -1,4 +1,5 @@ """Association Candidate Identifier""" + import re from ast import literal_eval diff --git a/romancal/associations/lib/association_rules.py b/romancal/associations/lib/association_rules.py index d8a7d4e96..b78ef28f9 100644 --- a/romancal/associations/lib/association_rules.py +++ b/romancal/associations/lib/association_rules.py @@ -4,6 +4,7 @@ ----- These associations are specifically defined for use in DMS. """ + from romancal.associations.lib import rules_level2 from romancal.associations.registry import RegistryMarker diff --git a/romancal/associations/lib/constraint.py b/romancal/associations/lib/constraint.py index 114c97e67..285a23a95 100644 --- a/romancal/associations/lib/constraint.py +++ b/romancal/associations/lib/constraint.py @@ -1,5 +1,6 @@ """Constraints """ + import abc import collections import logging diff --git a/romancal/associations/lib/decorators.py b/romancal/associations/lib/decorators.py index 66d8d11af..59ef60e1f 100644 --- a/romancal/associations/lib/decorators.py +++ b/romancal/associations/lib/decorators.py @@ -7,6 +7,7 @@ .. _glue-viz: https://github.com/glue-viz/glue """ + from functools import wraps __all__ = ["memoize", "singleton", "memoize_attr_check"] diff --git a/romancal/associations/lib/member.py b/romancal/associations/lib/member.py index 0ff107a73..524415296 100644 --- a/romancal/associations/lib/member.py +++ b/romancal/associations/lib/member.py @@ -1,4 +1,5 @@ """Association Member""" + from collections import UserDict from copy import copy diff --git a/romancal/associations/lib/process_list.py b/romancal/associations/lib/process_list.py index c183804f3..148a9b80f 100644 --- a/romancal/associations/lib/process_list.py +++ b/romancal/associations/lib/process_list.py @@ -1,4 +1,5 @@ """Reprocessing List""" + from collections import deque from enum import Enum from functools import reduce diff --git a/romancal/associations/lib/rules_level2.py b/romancal/associations/lib/rules_level2.py index 80a324909..91eef529f 100644 --- a/romancal/associations/lib/rules_level2.py +++ b/romancal/associations/lib/rules_level2.py @@ -1,5 +1,6 @@ """Association Definitions: DMS Level2b product associations """ + import logging from romancal.associations.lib.constraint import Constraint diff --git a/romancal/associations/lib/update_path.py b/romancal/associations/lib/update_path.py index b596deee7..90ff09374 100644 --- a/romancal/associations/lib/update_path.py +++ b/romancal/associations/lib/update_path.py @@ -1,4 +1,5 @@ """Update path of members in an association""" + from os.path import basename, join diff --git a/romancal/associations/lib/utilities.py b/romancal/associations/lib/utilities.py index 727cffc4c..c1bfa4b36 100644 --- a/romancal/associations/lib/utilities.py +++ b/romancal/associations/lib/utilities.py @@ -1,4 +1,5 @@ """General Utilities""" + import logging from ast import literal_eval from functools import wraps diff --git a/romancal/associations/load_asn.py b/romancal/associations/load_asn.py index 43ef01874..f168cf922 100644 --- a/romancal/associations/load_asn.py +++ b/romancal/associations/load_asn.py @@ -1,4 +1,5 @@ """Load an Association from a file or object""" + from inspect import isclass from .association import Association diff --git a/romancal/associations/main.py b/romancal/associations/main.py index 8c1249eab..9d6e2ccf2 100644 --- a/romancal/associations/main.py +++ b/romancal/associations/main.py @@ -1,4 +1,5 @@ """Main entry for the association generator""" + import argparse import logging import os diff --git a/romancal/associations/registry.py b/romancal/associations/registry.py index 1c02bc66e..c1f8c12ec 100644 --- a/romancal/associations/registry.py +++ b/romancal/associations/registry.py @@ -1,4 +1,5 @@ """Association Registry""" + import importlib.util import logging from inspect import getmembers, isclass, isfunction, ismethod, ismodule diff --git a/romancal/associations/tests/helpers.py b/romancal/associations/tests/helpers.py index b886db206..00d2418f9 100644 --- a/romancal/associations/tests/helpers.py +++ b/romancal/associations/tests/helpers.py @@ -1,4 +1,5 @@ """Helpers for tests.""" + # ruff: noqa import os import re diff --git a/romancal/associations/tests/test_constraints.py b/romancal/associations/tests/test_constraints.py index 6d86195ed..e4606b453 100644 --- a/romancal/associations/tests/test_constraints.py +++ b/romancal/associations/tests/test_constraints.py @@ -1,4 +1,5 @@ """Constraint Tests""" + import pytest from romancal.associations.lib.constraint import ( diff --git a/romancal/associations/tests/test_level2_candidates.py b/romancal/associations/tests/test_level2_candidates.py index bb85000a5..76007ce05 100644 --- a/romancal/associations/tests/test_level2_candidates.py +++ b/romancal/associations/tests/test_level2_candidates.py @@ -1,4 +1,5 @@ """Test Level2 candidate operation""" + import pytest from romancal.associations.main import Main diff --git a/romancal/associations/tests/test_registry.py b/romancal/associations/tests/test_registry.py index 9ffbec069..fefae0ef5 100644 --- a/romancal/associations/tests/test_registry.py +++ b/romancal/associations/tests/test_registry.py @@ -1,4 +1,5 @@ """Test the Registry""" + import pytest from romancal.associations.lib.keyvalue_registry import KeyValueRegistry diff --git a/romancal/associations/tests/test_update_path.py b/romancal/associations/tests/test_update_path.py index 31420a532..d28a47fe3 100644 --- a/romancal/associations/tests/test_update_path.py +++ b/romancal/associations/tests/test_update_path.py @@ -1,4 +1,5 @@ """Test utility update_path""" + from romancal.associations.asn_from_list import asn_from_list from romancal.associations.lib.rules_elpp_base import DMS_ELPP_Base from romancal.associations.lib.update_path import update_path diff --git a/romancal/conftest.py b/romancal/conftest.py index 1ce516e02..69a1ff954 100644 --- a/romancal/conftest.py +++ b/romancal/conftest.py @@ -1,4 +1,5 @@ """Project default for pytest""" + import inspect import json import os diff --git a/romancal/dark_current/dark_current_step.py b/romancal/dark_current/dark_current_step.py index 034913e5f..acc4f01d9 100755 --- a/romancal/dark_current/dark_current_step.py +++ b/romancal/dark_current/dark_current_step.py @@ -44,9 +44,9 @@ def process(self, input): if "nframes" not in dark_model.meta.exposure: dark_model.meta.exposure["nframes"] = input_model.meta.exposure.nframes if "groupgap" not in dark_model.meta.exposure: - dark_model.meta.exposure[ - "groupgap" - ] = input_model.meta.exposure.groupgap + dark_model.meta.exposure["groupgap"] = ( + input_model.meta.exposure.groupgap + ) # Do the dark correction out_model = input_model diff --git a/romancal/dark_current/tests/test_dark.py b/romancal/dark_current/tests/test_dark.py index fe0def0ca..98dc9684d 100755 --- a/romancal/dark_current/tests/test_dark.py +++ b/romancal/dark_current/tests/test_dark.py @@ -2,7 +2,6 @@ Unit tests for dark current correction """ - import numpy as np import pytest import roman_datamodels as rdm diff --git a/romancal/datamodels/container.py b/romancal/datamodels/container.py index 65affce76..624618b65 100644 --- a/romancal/datamodels/container.py +++ b/romancal/datamodels/container.py @@ -198,9 +198,11 @@ def __getitem__(self, index): step = index.step m = self._models[start:stop:step] m = [ - rdm.open(item, memmap=self._memmap) - if (not isinstance(item, rdm.DataModel) and self._return_open) - else item + ( + rdm.open(item, memmap=self._memmap) + if (not isinstance(item, rdm.DataModel) and self._return_open) + else item + ) for item in m ] else: diff --git a/romancal/jump/tests/test_jump_step.py b/romancal/jump/tests/test_jump_step.py index 0ebb28e4b..1955b9ecd 100644 --- a/romancal/jump/tests/test_jump_step.py +++ b/romancal/jump/tests/test_jump_step.py @@ -1,6 +1,7 @@ """ Unit tests for the Roman jump step code """ + from itertools import cycle import numpy as np diff --git a/romancal/lib/dms.py b/romancal/lib/dms.py index 840c59f6d..20ecaaa06 100644 --- a/romancal/lib/dms.py +++ b/romancal/lib/dms.py @@ -3,6 +3,7 @@ Example: Certain tests are required by DMS to log in a specific way. The decorator for this is defined in this module. """ + from stpipe import log as stpipe_log diff --git a/romancal/lib/dqflags.py b/romancal/lib/dqflags.py index 50b3f0837..df61ee34c 100644 --- a/romancal/lib/dqflags.py +++ b/romancal/lib/dqflags.py @@ -18,6 +18,7 @@ which provides 32 bits. Bits of an integer are most easily referred to using the formula `2**bit_number` where `bit_number` is the 0-index bit of interest. """ + # for this file drop E241 (multiple spaces after :, for readability) # flake8: noqa: E241 # Pixel-specific flags diff --git a/romancal/lib/progress.py b/romancal/lib/progress.py index 89027d307..6ba8bbbd0 100644 --- a/romancal/lib/progress.py +++ b/romancal/lib/progress.py @@ -6,6 +6,7 @@ If the module is not available, then stub it out. """ + import logging __all__ = ["Bar"] diff --git a/romancal/lib/signal_slot.py b/romancal/lib/signal_slot.py index 472e727b2..5894d8e4d 100644 --- a/romancal/lib/signal_slot.py +++ b/romancal/lib/signal_slot.py @@ -1,5 +1,6 @@ """ A signal/slot implementation """ + import inspect import logging from collections import namedtuple diff --git a/romancal/lib/suffix.py b/romancal/lib/suffix.py index 9a17b53b1..3a0001f88 100644 --- a/romancal/lib/suffix.py +++ b/romancal/lib/suffix.py @@ -20,6 +20,7 @@ `SUFFIXES_TO_DISCARD` as necessary, then use the output of `find_suffixes`. """ + import itertools import logging import re diff --git a/romancal/linearity/tests/test_linearity.py b/romancal/linearity/tests/test_linearity.py index feb35ea06..b137069fd 100644 --- a/romancal/linearity/tests/test_linearity.py +++ b/romancal/linearity/tests/test_linearity.py @@ -3,6 +3,7 @@ Unit tests for linearity correction """ + import numpy as np import pytest from astropy import units as u diff --git a/romancal/pipeline/__init__.py b/romancal/pipeline/__init__.py index 19fbf04a7..b5414f1cd 100644 --- a/romancal/pipeline/__init__.py +++ b/romancal/pipeline/__init__.py @@ -2,6 +2,7 @@ This module collects all of the stpipe.Pipeline subclasses made available by this package. """ + from .exposure_pipeline import ExposurePipeline from .highlevel_pipeline import HighLevelPipeline diff --git a/romancal/ramp_fitting/ramp_fit_step.py b/romancal/ramp_fitting/ramp_fit_step.py index 3d75dab4c..7e37549a3 100644 --- a/romancal/ramp_fitting/ramp_fit_step.py +++ b/romancal/ramp_fitting/ramp_fit_step.py @@ -20,7 +20,6 @@ class RampFitStep(RomanStep): - """ This step fits a straight line to the value of counts vs. time to determine the mean count rate for each pixel. @@ -262,9 +261,7 @@ def create_image_model(input_model, image_info): var_poisson = u.Quantity( var_poisson, u.electron**2 / u.s**2, dtype=var_poisson.dtype ) - var_rnoise = u.Quantity( - var_rnoise, u.electron**2 / u.s**2, dtype=var_rnoise.dtype - ) + var_rnoise = u.Quantity(var_rnoise, u.electron**2 / u.s**2, dtype=var_rnoise.dtype) err = u.Quantity(err, u.electron / u.s, dtype=err.dtype) if dq is None: dq = np.zeros(data.shape, dtype="u4") diff --git a/romancal/refpix/data.py b/romancal/refpix/data.py index 73d87ff38..383305e48 100644 --- a/romancal/refpix/data.py +++ b/romancal/refpix/data.py @@ -466,9 +466,9 @@ def fft_interpolate(self, num: int = 3) -> ChannelView: # Mask all the data columns mask = np.ones((rows, columns), dtype=bool) - mask[ - :, : -Const.PAD - ] = False # this maybe different for the left/right channels + mask[:, : -Const.PAD] = ( + False # this maybe different for the left/right channels + ) mask = mask.flatten() # Find the indices of the padded columns diff --git a/romancal/refpix/tests/reference_utils.py b/romancal/refpix/tests/reference_utils.py index 17bc2cc3d..cebe5939b 100644 --- a/romancal/refpix/tests/reference_utils.py +++ b/romancal/refpix/tests/reference_utils.py @@ -14,6 +14,7 @@ provided reference code and this implementation contained within the git history. of the project itself. """ + import threading import numpy as np @@ -308,7 +309,7 @@ def fft_interp( # meaningfully chanFrameData_Flat = spfft.irfft( fftResult * chanFrameData_Flat.size, - workers=1 + workers=1, # ) ).astype(chanFrameData_Flat.dtype) # Return read only pixels diff --git a/romancal/regtest/regtestdata.py b/romancal/regtest/regtestdata.py index 3040b3476..4ade328de 100644 --- a/romancal/regtest/regtestdata.py +++ b/romancal/regtest/regtestdata.py @@ -726,9 +726,10 @@ def compare_asdf(result, truth, ignore=None, rtol=1e-05, atol=1e-08, equal_nan=T "lazy_load": False, "copy_arrays": True, } - with asdf.open(result, **open_kwargs) as af0, asdf.open( - truth, **open_kwargs - ) as af1: + with ( + asdf.open(result, **open_kwargs) as af0, + asdf.open(truth, **open_kwargs) as af1, + ): # swap the inputs here so DeepDiff(truth, result) # this will create output with 'new_value' referring to # the value in the result and 'old_value' referring to the truth diff --git a/romancal/regtest/test_dark_current.py b/romancal/regtest/test_dark_current.py index 67fcfc9dd..3e31501a4 100644 --- a/romancal/regtest/test_dark_current.py +++ b/romancal/regtest/test_dark_current.py @@ -1,4 +1,5 @@ """Regression test for the Dark current subtraction step.""" + import pytest from romancal.stpipe import RomanStep diff --git a/romancal/regtest/test_jump_det.py b/romancal/regtest/test_jump_det.py index fbb6f512f..7d892de1f 100644 --- a/romancal/regtest/test_jump_det.py +++ b/romancal/regtest/test_jump_det.py @@ -1,4 +1,5 @@ """Regression test for the Jump detection step.""" + import pytest from romancal.stpipe import RomanStep diff --git a/romancal/regtest/test_linearity.py b/romancal/regtest/test_linearity.py index cf9837048..aad0a88a2 100644 --- a/romancal/regtest/test_linearity.py +++ b/romancal/regtest/test_linearity.py @@ -1,4 +1,5 @@ """Regression test for the linearity correction step.""" + import pytest from romancal.stpipe import RomanStep diff --git a/romancal/regtest/test_ramp_fitting.py b/romancal/regtest/test_ramp_fitting.py index 3ff9a508d..cf82316c9 100644 --- a/romancal/regtest/test_ramp_fitting.py +++ b/romancal/regtest/test_ramp_fitting.py @@ -5,6 +5,7 @@ A requirement for the larger mission verification project is to have tests tied to reqirements. """ + from pathlib import Path import pytest diff --git a/romancal/regtest/test_refpix.py b/romancal/regtest/test_refpix.py index 52bbcb853..ec87d0cbc 100644 --- a/romancal/regtest/test_refpix.py +++ b/romancal/regtest/test_refpix.py @@ -1,4 +1,5 @@ """Regression tests for the Reference Pixel Correction step""" + import pytest from romancal.stpipe import RomanStep diff --git a/romancal/regtest/test_wfi_dq_init.py b/romancal/regtest/test_wfi_dq_init.py index 722022b52..0e7c8481d 100644 --- a/romancal/regtest/test_wfi_dq_init.py +++ b/romancal/regtest/test_wfi_dq_init.py @@ -1,4 +1,5 @@ """Tests for the DQ Init module and DMS 25 and DMS 26 requirements""" + import os import pytest diff --git a/romancal/regtest/test_wfi_photom.py b/romancal/regtest/test_wfi_photom.py index 48916d4e7..fa9fc5e84 100644 --- a/romancal/regtest/test_wfi_photom.py +++ b/romancal/regtest/test_wfi_photom.py @@ -1,4 +1,5 @@ """Regression tests for the photom step of the Roman pipeline""" + import math import pytest diff --git a/romancal/regtest/test_wfi_pipeline.py b/romancal/regtest/test_wfi_pipeline.py index dbb71ab32..0781e460a 100644 --- a/romancal/regtest/test_wfi_pipeline.py +++ b/romancal/regtest/test_wfi_pipeline.py @@ -1,4 +1,5 @@ """ Roman tests for flat field correction """ + import copy import numpy as np diff --git a/romancal/regtest/test_wfi_saturation.py b/romancal/regtest/test_wfi_saturation.py index a45969371..d84c932f0 100644 --- a/romancal/regtest/test_wfi_saturation.py +++ b/romancal/regtest/test_wfi_saturation.py @@ -1,4 +1,5 @@ """ Tests for the saturation step""" + import os import pytest diff --git a/romancal/skymatch/skymatch.py b/romancal/skymatch/skymatch.py index 8ac63e16d..80a41a3ff 100644 --- a/romancal/skymatch/skymatch.py +++ b/romancal/skymatch/skymatch.py @@ -1,6 +1,7 @@ """ A module that provides functions for matching sky in overlapping images. """ + import logging from datetime import datetime diff --git a/romancal/skymatch/skystatistics.py b/romancal/skymatch/skystatistics.py index 6a9851589..a61aca7f3 100644 --- a/romancal/skymatch/skystatistics.py +++ b/romancal/skymatch/skystatistics.py @@ -3,6 +3,7 @@ :py:func:`~romancal.skymatch.skymatch.match` and :py:class:`~romancal.skymatch.skyimage.SkyImage`. """ + from copy import deepcopy # THIRD PARTY diff --git a/romancal/source_detection/source_detection_step.py b/romancal/source_detection/source_detection_step.py index 6c9b0ae4b..664d97251 100644 --- a/romancal/source_detection/source_detection_step.py +++ b/romancal/source_detection/source_detection_step.py @@ -2,7 +2,6 @@ Create a source catalog for tweakreg """ - import logging import astropy.units as u @@ -210,9 +209,9 @@ def process(self, input): else: catalog.write(cat_filename, format="ascii.ecsv", overwrite=True) - input_model.meta.source_detection[ - "tweakreg_catalog_name" - ] = cat_filename + input_model.meta.source_detection["tweakreg_catalog_name"] = ( + cat_filename + ) else: if self.fit_psf: # PSF photometry centroid results are stored in an astropy table @@ -231,9 +230,9 @@ def process(self, input): else: # only attach catalog to file if its being passed to the next step # and save_catalogs is false, since it is not in the schema - input_model.meta.source_detection[ - "tweakreg_catalog" - ] = catalog_as_recarray + input_model.meta.source_detection["tweakreg_catalog"] = ( + catalog_as_recarray + ) input_model.meta.cal_step["source_detection"] = "COMPLETE" # just pass input model to next step - catalog is stored in meta diff --git a/romancal/step.py b/romancal/step.py index 91bf7ff32..9dd5ecd11 100644 --- a/romancal/step.py +++ b/romancal/step.py @@ -2,6 +2,7 @@ This module collects all of the stpipe.Step subclasses made available by this package. """ + from .assign_wcs.assign_wcs_step import AssignWcsStep from .dark_current.dark_current_step import DarkCurrentStep from .dq_init.dq_init_step import DQInitStep diff --git a/romancal/stpipe/core.py b/romancal/stpipe/core.py index c379b354a..aaee7fa63 100644 --- a/romancal/stpipe/core.py +++ b/romancal/stpipe/core.py @@ -1,6 +1,7 @@ """ Roman Calibration Pipeline base class """ + import logging import time diff --git a/romancal/stpipe/utilities.py b/romancal/stpipe/utilities.py index b64a2bed0..b595d4dd5 100644 --- a/romancal/stpipe/utilities.py +++ b/romancal/stpipe/utilities.py @@ -1,6 +1,7 @@ """ Utilities """ + import inspect import logging from importlib import import_module diff --git a/romancal/tests/base_classes.py b/romancal/tests/base_classes.py index fc34b3c82..fded0fe55 100644 --- a/romancal/tests/base_classes.py +++ b/romancal/tests/base_classes.py @@ -1,4 +1,5 @@ """Base classes for Roman tests""" + import os import sys from glob import glob as _sys_glob diff --git a/romancal/tweakreg/tweakreg_step.py b/romancal/tweakreg/tweakreg_step.py index df8fdfa8e..b79492cf2 100644 --- a/romancal/tweakreg/tweakreg_step.py +++ b/romancal/tweakreg/tweakreg_step.py @@ -1,6 +1,7 @@ """ Roman pipeline step for image alignment. """ + import os from pathlib import Path