Skip to content

Commit

Permalink
Deprecate specialist gen3 raw ingest task
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Mar 23, 2021
1 parent e90fcdd commit 4012841
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
47 changes: 6 additions & 41 deletions python/lsst/obs/cfht/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@

import re

from lsst.daf.butler import ButlerURI, Formatter
from deprecated.sphinx import deprecated

import lsst.obs.base
from lsst.obs.base.ingest import RawFileData
from astro_metadata_translator import fix_header

from lsst.pipe.tasks.ingest import ParseTask
import lsst.pex.exceptions
Expand All @@ -46,47 +45,13 @@
}


@deprecated(reason="MegaPrime no longer requires a specialist gen3 ingest task. Please use the default."
" Will be removed after v23.",
category=FutureWarning,
version="22.0")
class MegaPrimeRawIngestTask(lsst.obs.base.RawIngestTask):
"""Task for ingesting raw MegaPrime multi-extension FITS data into Gen3.
"""
def extractMetadata(self, filename: ButlerURI) -> RawFileData:
datasets = []

try:
with filename.as_local() as local_file:
fitsData = lsst.afw.fits.Fits(local_file.ospath, "r")

# NOTE: The primary header (HDU=0) does not contain detector
# data.
for i in range(1, fitsData.countHdus()):
fitsData.setHdu(i)
header = fitsData.readMetadata()
if not header["EXTNAME"].startswith("ccd"):
continue
fix_header(header)
datasets.append(self._calculate_dataset_info(header, filename))
except Exception as e:
self.log.debug("Problem extracting metadata from %s: %s", filename, e)
# Indicate to the caller that we failed to read.
# Do not try to ingest partial contents of file.
datasets = []
formatterClass = Formatter
instrument = None
self._on_metadata_failure(filename, e)
if self.config.failFast:
raise RuntimeError(f"Problem extracting metadata for file {filename}") from e
else:
# The data model currently assumes that whilst multiple datasets
# can be associated with a single file, they must all share the
# same formatter.
instrument, formatterClass = self._determine_instrument_formatter(datasets[0].dataId, filename)
if instrument is None:
datasets = []

self.log.info(f"Found images for {len(datasets)} detectors in {filename}")
return RawFileData(datasets=datasets, filename=filename,
FormatterClass=formatterClass,
instrumentClass=type(instrument))


class MegacamParseTask(ParseTask):
Expand Down
1 change: 0 additions & 1 deletion tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class MegaPrimeIngestTestCase(IngestTestBase, lsst.utils.tests.TestCase):
curatedCalibrationDatasetTypes = ()
ingestDir = os.path.dirname(__file__)
instrumentClassName = "lsst.obs.cfht.MegaPrime"
rawIngestTask = "lsst.obs.cfht.MegaPrimeRawIngestTask"
filterLabel = lsst.afw.image.FilterLabel(physical="i.MP9702", band="i")

@property
Expand Down

0 comments on commit 4012841

Please sign in to comment.