Skip to content

Commit

Permalink
Update code to use lsst.afw.fits.readMetadata
Browse files Browse the repository at this point in the history
instead of the deprecated lsst.afw.image.readMetadata
  • Loading branch information
r-owen committed Jan 9, 2018
1 parent e950157 commit ff517d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions python/lsst/obs/decam/decamMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from lsst.utils import getPackageDir
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
from lsst.afw.fits import readMetadata
from lsst.afw.geom import makeSkyWcs
from lsst.obs.base import CameraMapper, exposureFromImage
from lsst.daf.persistence import ButlerLocation, Storage, Policy
Expand Down Expand Up @@ -209,7 +210,7 @@ def bypass_instcal(self, datasetType, pythonType, butlerLocation, dataId):

# Set the calib by hand; need to grab the zeroth extension
header = re.sub(r'[\[](\d+)[\]]$', "[0]", instcalMap.getLocationsWithRoot()[0])
md0 = afwImage.readMetadata(header)
md0 = readMetadata(header)
calib = afwImage.Calib()
calib.setFluxMag0(10**(0.4 * md0.get("MAGZERO")))
exp.setCalib(calib)
Expand Down Expand Up @@ -239,7 +240,7 @@ def std_raw(self, item, dataId):
md = exp.getMetadata()
rawPath = self.map_raw(dataId).getLocationsWithRoot()[0]
headerPath = re.sub(r'[\[](\d+)[\]]$', "[0]", rawPath)
md0 = afwImage.readMetadata(headerPath)
md0 = readMetadata(headerPath)
# extra keywords to copy to the exposure
for kw in ('DARKTIME', ):
if kw in md0.paramNames() and kw not in md.paramNames():
Expand All @@ -256,7 +257,7 @@ def std_dark(self, item, dataId):
exp = afwImage.makeExposure(afwImage.makeMaskedImage(item))
rawPath = self.map_raw(dataId).getLocations()[0]
headerPath = re.sub(r'[\[](\d+)[\]]$', "[0]", rawPath)
md0 = afwImage.readMetadata(headerPath)
md0 = readMetadata(headerPath)
visitInfo = self.makeRawVisitInfo(md0)
exp.getInfo().setVisitInfo(visitInfo)
return self._standardizeExposure(self.calibrations["dark"], exp, dataId, filter=False)
Expand Down Expand Up @@ -287,7 +288,7 @@ def _standardizeCpMasterCal(self, datasetType, item, dataId, setFilter=False):
masterCalMap = getattr(self, "map_" + datasetType)
masterCalPath = masterCalMap(dataId).getLocationsWithRoot()[0]
headerPath = re.sub(r'[\[](\d+)[\]]$', "[0]", masterCalPath)
md0 = afwImage.readMetadata(headerPath)
md0 = readMetadata(headerPath)
for kw in ('CTYPE1', 'CTYPE2', 'CRVAL1', 'CRVAL2', 'CUNIT1', 'CUNIT2',
'CD1_1', 'CD1_2', 'CD2_1', 'CD2_2'):
if kw in md0.paramNames() and kw not in md.paramNames():
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/decam/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from builtins import zip

import lsst.afw.image as afwImage
from lsst.afw.fits import readMetadata
from lsst.pipe.tasks.ingest import ParseTask, IngestTask, IngestArgumentParser


Expand Down Expand Up @@ -102,7 +102,7 @@ def __init__(self, *args, **kwargs):
def _listdir(self, path, prefix):
for file in os.listdir(path):
fileName = os.path.join(path, file)
md = afwImage.readMetadata(fileName)
md = readMetadata(fileName)
if "EXPNUM" not in md.names():
return
expnum = md.get("EXPNUM")
Expand Down

0 comments on commit ff517d8

Please sign in to comment.