From ef51402b920f11bfa260432a3c4a0604f1a17d92 Mon Sep 17 00:00:00 2001 From: "chown.5" Date: Wed, 4 Jun 2025 12:39:06 -0400 Subject: [PATCH 1/2] added ability to skip skymatch --- pjpipe/lv3/lv3_step.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/pjpipe/lv3/lv3_step.py b/pjpipe/lv3/lv3_step.py index d258700..da85086 100644 --- a/pjpipe/lv3/lv3_step.py +++ b/pjpipe/lv3/lv3_step.py @@ -550,7 +550,15 @@ def run_step( model.meta.observation.exposure_number = str(i) model.meta.group_id = "" - asn_file = skymatch.run(asn_file) + # Add ability to skip skymatch if requested + # By default, skymatch is run + # To do this, set lv3_step.jwst_parameters["skymatch"]["skip"] = True in config.toml + skip_skymatch = False + if self.jwst_parameters and (("skymatch" in self.jwst_parameters) and ("skip" in self.jwst_parameters["skymatch"])): + skip_skymatch = self.jwst_parameters["skymatch"]["skip"] + + if not skip_skymatch: + asn_file = skymatch.run(asn_file) del skymatch gc.collect() @@ -591,14 +599,26 @@ def run_step( # Run the rest of the level 3 pipeline - if use_model_library: - # Re-instantiate the ModelLibrary, to wipe out any weirdness we might have performed - # along the way - asn_file = ModelContainer([models[m] for m in models]) - asn_file = ModelLibrary(asn_file, on_disk=False) - if "name" not in asn_file._asn["products"][0]: - name = f"{self.target.lower()}_{self.band_type}_lv3_{band_short.lower()}{self.bgr_ext}" + # Ensure product name is set correctly whether skymatch is run or not + # This prevents the default "step" name from being used + if isinstance(asn_file, ModelLibrary) and hasattr(asn_file, "_asn"): + name = f"{self.target.lower()}_{self.band_type}_lv3_{self.band.lower()}{self.bgr_ext}" + if "products" in asn_file._asn and len(asn_file._asn["products"]) > 0: asn_file._asn["products"][0]["name"] = copy.deepcopy(name) + log.info(f"Setting product name to {name}") + + # Set the output_dir and output_file for im3 to ensure correct file naming + im3.output_file = f"{self.target.lower()}_{self.band_type}_lv3_{self.band.lower()}{self.bgr_ext}" + log.info(f"Setting output_file to {im3.output_file}") + + # if use_model_library: + # # Re-instantiate the ModelLibrary, to wipe out any weirdness we might have performed + # # along the way + # asn_file = ModelContainer([models[m] for m in models]) + # asn_file = ModelLibrary(asn_file, on_disk=False) + # if "name" not in asn_file._asn["products"][0]: + # name = f"{self.target.lower()}_{self.band_type}_lv3_{band_short.lower()}{self.bgr_ext}" + # asn_file._asn["products"][0]["name"] = copy.deepcopy(name) im3.run(asn_file) From 8743f553c5a047c9b9fec043de6428816ff49e0b Mon Sep 17 00:00:00 2001 From: "chown.5" Date: Mon, 9 Jun 2025 13:39:39 -0400 Subject: [PATCH 2/2] separate bkg and sci skymatch off-switch --- pjpipe/lv3/lv3_step.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pjpipe/lv3/lv3_step.py b/pjpipe/lv3/lv3_step.py index da85086..4a65f65 100644 --- a/pjpipe/lv3/lv3_step.py +++ b/pjpipe/lv3/lv3_step.py @@ -551,11 +551,16 @@ def run_step( model.meta.group_id = "" # Add ability to skip skymatch if requested - # By default, skymatch is run - # To do this, set lv3_step.jwst_parameters["skymatch"]["skip"] = True in config.toml + # By default, skymatch is run on both science and background observations + # To disable skymatch for background observations, + # set lv3_step.jwst_parameters["skymatch"]["skip_bgr"] = True in config.toml + # To disable skymatch for science observations, + # set lv3_step.jwst_parameters["skymatch"]["skip"] = True in config.toml skip_skymatch = False - if self.jwst_parameters and (("skymatch" in self.jwst_parameters) and ("skip" in self.jwst_parameters["skymatch"])): - skip_skymatch = self.jwst_parameters["skymatch"]["skip"] + if self.jwst_parameters: + skymatch_params = self.jwst_parameters.get("skymatch", {}) + key = "skip_bgr" if self.is_bgr else "skip" + skip_skymatch = skymatch_params.get(key, False) if not skip_skymatch: asn_file = skymatch.run(asn_file)