Skip to content

Commit

Permalink
Ask translator class to read additional HDUs
Browse files Browse the repository at this point in the history
This allows CFHT and DECam ingest to happen without a specialist
ingest task.
  • Loading branch information
timj committed Mar 19, 2021
1 parent 08db658 commit 273c76e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from collections import defaultdict
from multiprocessing import Pool

from astro_metadata_translator import ObservationInfo, merge_headers
from astro_metadata_translator import ObservationInfo, merge_headers, MetadataTranslator
from astro_metadata_translator.indexing import process_sidecar_data, process_index_data
from lsst.afw.fits import readMetadata
from lsst.daf.butler import (
Expand Down Expand Up @@ -367,7 +367,14 @@ def extractMetadata(self, filename: ButlerURI) -> RawFileData:
with filename.as_local() as local_file:
phdu = readMetadata(local_file.ospath, 0)
header = merge_headers([phdu, readMetadata(local_file.ospath)], mode="overwrite")
datasets = [self._calculate_dataset_info(header, filename)]

# Try to work out a translator class.
translator_class = MetadataTranslator.determine_translator(header, filename=filename)

# Add each header to the dataset list
datasets = [self._calculate_dataset_info(h, filename)
for h in translator_class.read_all_headers(filename.ospath, header)]

except Exception as e:
self.log.debug("Problem extracting metadata from %s%s: %s", filename, sidecar_fail_msg, e)
# Indicate to the caller that we failed to read.
Expand Down

0 comments on commit 273c76e

Please sign in to comment.