diff --git a/eastlake/steps/delete_meds.py b/eastlake/steps/delete_meds.py index f0d5c58..ffb56bb 100644 --- a/eastlake/steps/delete_meds.py +++ b/eastlake/steps/delete_meds.py @@ -26,15 +26,18 @@ def execute(self, stash, new_params=None): if tilename in self.config["save_tilenames"]: continue - # Get meds filenames - meds_files = stash.get_filepaths("meds_files", tilename) - for m in meds_files: - self.logger.error("removing meds file %s" % m) - os.remove(m) - - meds_files = stash.get_filepaths("pizza_cutter_meds_files", tilename) - for m in meds_files: - self.logger.error("removing pizza-cutter meds file %s" % m) - os.remove(m) + meds_files = stash.get_filepaths("meds_files", tilename, keyerror=False) + if meds_files is not None: + for m in meds_files: + if os.path.isfile(m): + self.logger.error("removing meds file %s" % m) + os.remove(m) + + meds_files = stash.get_filepaths("pizza_cutter_meds_files", tilename, keyerror=False) + if meds_files is not None: + for m in meds_files: + if os.path.isfile(m): + self.logger.error("removing pizza-cutter meds file %s" % m) + os.remove(m) return 0, stash diff --git a/eastlake/steps/delete_sources.py b/eastlake/steps/delete_sources.py index ab9a3d1..6e6e97a 100644 --- a/eastlake/steps/delete_sources.py +++ b/eastlake/steps/delete_sources.py @@ -57,6 +57,7 @@ def execute(self, stash, new_params=None): if (seg_file is not None): if os.path.isfile(seg_file): self.logger.error("removing file %s" % seg_file) + os.remove(seg_file) # Also check for bkg and bkg-rms files bkg_file = coadd_file.replace(".fits", "bkg.fits")