diff --git a/romancal/flatfield/flat_field.py b/romancal/flatfield/flat_field.py index e1dc38fcb..a1388b99e 100644 --- a/romancal/flatfield/flat_field.py +++ b/romancal/flatfield/flat_field.py @@ -68,8 +68,7 @@ def do_flat_field(output_model, flat_model, include_var_flat=False): log.info("Skipping flat field - no flat reference file.") output_model.meta.cal_step.flat_field = "SKIPPED" else: - apply_flat_field(output_model, flat_model, - include_var_flat=include_var_flat) + apply_flat_field(output_model, flat_model, include_var_flat=include_var_flat) output_model.meta.cal_step.flat_field = "COMPLETE" @@ -130,10 +129,8 @@ def apply_flat_field(science, flat, include_var_flat=False): try: science.var_flat = science.data**2 / flat_data_squared * flat_err**2 except AttributeError: - science["var_flat"] = np.zeros( - shape=science.data.shape, dtype=np.float32) - science.var_flat = (science.data**2 - / flat_data_squared * flat_err**2) + science["var_flat"] = np.zeros(shape=science.data.shape, dtype=np.float32) + science.var_flat = science.data**2 / flat_data_squared * flat_err**2 total_var += science.var_flat science.err = np.sqrt(total_var) diff --git a/romancal/flatfield/flat_field_step.py b/romancal/flatfield/flat_field_step.py index d14dded63..f7e8a9e14 100644 --- a/romancal/flatfield/flat_field_step.py +++ b/romancal/flatfield/flat_field_step.py @@ -40,9 +40,7 @@ def process(self, input_model): # Do the flat-field correction output_model = flat_field.do_correction( - input_model, - reference_file_model, - include_var_flat=self.include_var_flat + input_model, reference_file_model, include_var_flat=self.include_var_flat ) # Close reference file diff --git a/romancal/flatfield/tests/test_flatfield.py b/romancal/flatfield/tests/test_flatfield.py index 9a9afdba6..5fe08ceb9 100644 --- a/romancal/flatfield/tests/test_flatfield.py +++ b/romancal/flatfield/tests/test_flatfield.py @@ -102,14 +102,14 @@ def test_skip_var_flat(): wfi_image1 = maker_utils.mk_level2_image() wfi_image2 = maker_utils.mk_level2_image() - del wfi_image1['var_flat'] - del wfi_image2['var_flat'] + del wfi_image1["var_flat"] + del wfi_image2["var_flat"] wfi_image_model1 = ImageModel(wfi_image1) wfi_image_model2 = ImageModel(wfi_image2) result1 = FlatFieldStep.call(wfi_image_model1, include_var_flat=False) result2 = FlatFieldStep.call(wfi_image_model2, include_var_flat=True) - assert not hasattr(result1, 'var_flat') - assert hasattr(result2, 'var_flat') + assert not hasattr(result1, "var_flat") + assert hasattr(result2, "var_flat") @pytest.mark.parametrize( diff --git a/romancal/regtest/test_resample.py b/romancal/regtest/test_resample.py index 2d5dd167e..7757b8370 100644 --- a/romancal/regtest/test_resample.py +++ b/romancal/regtest/test_resample.py @@ -64,8 +64,7 @@ def test_resample_single_file(rtdata, ignore_asdf_paths): }""" ) assert all( - hasattr(resample_out, x) - for x in ["data", "err", "var_poisson", "var_rnoise"] + hasattr(resample_out, x) for x in ["data", "err", "var_poisson", "var_rnoise"] ) step.log.info( diff --git a/romancal/resample/resample.py b/romancal/resample/resample.py index b7901ed1d..9f2bc4133 100644 --- a/romancal/resample/resample.py +++ b/romancal/resample/resample.py @@ -165,8 +165,9 @@ def __init__( with self.input_models: models = list(self.input_models) - self.all_have_var_flat = np.all([ - hasattr(model, 'var_flat') for model in models]) + self.all_have_var_flat = np.all( + [hasattr(model, "var_flat") for model in models] + ) # update meta.basic populate_mosaic_basic(self.blank_output, models) @@ -191,7 +192,7 @@ def __init__( self.input_models.shelve(m, i, modify=False) if not self.all_have_var_flat: - del self.blank_output._instance['var_flat'] + del self.blank_output._instance["var_flat"] def do_drizzle(self): """Pick the correct drizzling mode based on ``self.single``.""" diff --git a/romancal/resample/tests/test_resample.py b/romancal/resample/tests/test_resample.py index caeec6d69..bbf921ab6 100644 --- a/romancal/resample/tests/test_resample.py +++ b/romancal/resample/tests/test_resample.py @@ -608,7 +608,7 @@ def test_var_flat_presence(exposure_1, include_var_flat): if not include_var_flat: exposure_1 = [e.copy() for e in exposure_1] for e in exposure_1: - del e._instance['var_flat'] + del e._instance["var_flat"] input_models = ModelLibrary(exposure_1) resample_data = ResampleData(input_models) @@ -617,9 +617,9 @@ def test_var_flat_presence(exposure_1, include_var_flat): output_model = output_models.borrow(0) if not include_var_flat: - assert not hasattr(output_model, 'var_flat') + assert not hasattr(output_model, "var_flat") else: - assert hasattr(output_model, 'var_flat') + assert hasattr(output_model, "var_flat") output_models.shelve(output_model, 0, modify=False)