def setArgDict(self, md, argDict):
        """Set an argument dict for makeVisitInfo and pop associated metadata

        @param[in,out] md  metadata, as an lsst.daf.base.PropertyList or PropertySet
        @param[in,out] argdict  a dict of arguments
        """
        MakeRawVisitInfo.setArgDict(self, md, argDict)
        argDict["darkTime"] = self.popFloat(md, "DARKTIME")
        argDict["boresightAzAlt"] = Coord(
            self.popAngle(md, "AZIMUTH"),
            self.altitudeFromZenithDistance(self.popAngle(md, "ZENITH")),
        )
        argDict["boresightRaDec"] = IcrsCoord(
            self.popAngle(md, "RA_DEG"),
            self.popAngle(md, "DEC_DEG"),
        )
        argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
        argDict["boresightRotAngle"] = 90 * degrees - self.popAngle(
            md, "ROTANG")
        argDict["rotType"] = RotType_SKY
        argDict["observatory"] = self.observatory
        argDict["weather"] = Weather(
            self.popFloat(md, "TEMPERA"),
            self.pascalFromMmHg(self.popFloat(md, "PRESS")),
            float("nan"),
        )
        return makeVisitInfo(**argDict)
Ejemplo n.º 2
0
 def testVisitInfoFitsPersistence(self):
     """Test saving an exposure to FITS and reading it back in preserves (some) VisitInfo fields"""
     exposureId = 5
     exposureTime = 12.3
     boresightRotAngle = 45.6 * afwGeom.degrees
     weather = afwCoord.Weather(1.1, 2.2, 0.3)
     visitInfo = afwImage.makeVisitInfo(
         exposureId = exposureId,
         exposureTime = exposureTime,
         boresightRotAngle = boresightRotAngle,
         weather = weather,
     )
     # Calib used to have exposure time and exposure date, so check for lack of interference
     calib = afwImage.Calib(3.4)
     exposureInfo = afwImage.ExposureInfo()
     exposureInfo.setVisitInfo(visitInfo)
     exposureInfo.setCalib(calib)
     exposureInfo.setDetector(self.detector)
     gFilter = afwImage.Filter("g")
     exposureInfo.setFilter(gFilter)
     maskedImage = afwImage.MaskedImageF(inFilePathSmall)
     exposure = afwImage.ExposureF(maskedImage, exposureInfo)
     with lsst.utils.tests.getTempFilePath(".fits") as tmpFile:
         exposure.writeFits(tmpFile)
         rtExposure = afwImage.ExposureF(tmpFile)
     rtVisitInfo = rtExposure.getInfo().getVisitInfo()
     self.assertEqual(rtVisitInfo.getWeather(), weather)
     self.assertEqual(rtExposure.getCalib(), calib)
     self.assertEqual(rtExposure.getFilter(), gFilter)
Ejemplo n.º 3
0
 def testSetVisitInfoMetadataMissingValues(self):
     """If a value is unknown then it should not be written to the metadata"""
     visitInfo = afwImage.makeVisitInfo()  # only rot type is known
     metadata = PropertyList()
     afwImage.setVisitInfoMetadata(metadata, visitInfo)
     self.assertEqual(metadata.get("ROTTYPE"),
                      RotTypeEnumNameDict[afwImage.RotType_UNKNOWN])
     self.assertEqual(metadata.nameCount(), 1)
Ejemplo n.º 4
0
    def loadExposure(self, sensorRef):
        """Load SDSS data as a post-ISR exposure

        - Image is from fpC
        - Mask is from fpM
        - Wcs is from asTrans
        - PhotoCalib is from tsField
        - Psf is from psField
        """
        originalExp = sensorRef.get("fpC").convertF()
        image = originalExp.getMaskedImage().getImage()
        if self.config.removePedestal:
            image -= self.config.pedestalVal
        mask = sensorRef.get("fpM")
        wcs = sensorRef.get("asTrans")
        tsField = sensorRef.get("tsField")
        photoCalib = tsField.photoCalib
        gain = tsField.gain
        var = afwImage.ImageF(image, True)
        var /= gain

        mi = afwImage.MaskedImageF(image, mask, var)

        if self.config.removeOverlap:
            bbox = mi.getBBox()
            begin = bbox.getBegin()
            extent = bbox.getDimensions()
            extent -= afwGeom.Extent2I(0, self.config.overlapSize)
            tbbox = afwGeom.BoxI(begin, extent)
            mi = afwImage.MaskedImageF(mi, tbbox)

        exposure = afwImage.ExposureF(mi, wcs)
        expInfo = exposure.getInfo()
        expInfo.setPhotoCalib(photoCalib)

        camera = sensorRef.get('camera')
        detector = camera["%(filter)s%(camcol)d" % sensorRef.dataId]
        expInfo.setDetector(detector)
        expInfo.setFilter(afwImage.Filter(sensorRef.dataId['filter']))

        visitInfo = afwImage.makeVisitInfo(
            exposureTime=tsField.exptime,
            date=tsField.dateAvg,
            boresightAirmass=tsField.airmass,
        )
        expInfo.setVisitInfo(visitInfo)

        # Install the SDSS PSF here; if we want to overwrite it later, we can.
        psf = sensorRef.get('psField')
        exposure.setPsf(psf)

        return exposure
Ejemplo n.º 5
0
    def loadExposure(self, sensorRef):
        """Load SDSS data as a post-ISR exposure

        - Image is from fpC
        - Mask is from fpM
        - Wcs is from asTrans
        - PhotoCalib is from tsField
        - Psf is from psField
        """
        originalExp = sensorRef.get("fpC").convertF()
        image = originalExp.getMaskedImage().getImage()
        if self.config.removePedestal:
            image -= self.config.pedestalVal
        mask = sensorRef.get("fpM")
        wcs = sensorRef.get("asTrans")
        tsField = sensorRef.get("tsField")
        photoCalib = tsField.photoCalib
        gain = tsField.gain
        var = afwImage.ImageF(image, True)
        var /= gain

        mi = afwImage.MaskedImageF(image, mask, var)

        if self.config.removeOverlap:
            bbox = mi.getBBox()
            begin = bbox.getBegin()
            extent = bbox.getDimensions()
            extent -= afwGeom.Extent2I(0, self.config.overlapSize)
            tbbox = afwGeom.BoxI(begin, extent)
            mi = afwImage.MaskedImageF(mi, tbbox)

        exposure = afwImage.ExposureF(mi, wcs)
        expInfo = exposure.getInfo()
        expInfo.setPhotoCalib(photoCalib)

        camera = sensorRef.get('camera')
        detector = camera["%(filter)s%(camcol)d" % sensorRef.dataId]
        expInfo.setDetector(detector)
        expInfo.setFilter(afwImage.Filter(sensorRef.dataId['filter']))

        visitInfo = afwImage.makeVisitInfo(
            exposureTime=tsField.exptime,
            date=tsField.dateAvg,
            boresightAirmass=tsField.airmass,
        )
        expInfo.setVisitInfo(visitInfo)

        # Install the SDSS PSF here; if we want to overwrite it later, we can.
        psf = sensorRef.get('psField')
        exposure.setPsf(psf)

        return exposure
Ejemplo n.º 6
0
    def updateMetadata(self,
                       calibImage,
                       exposureTime,
                       darkTime=None,
                       **kwargs):
        """!Update the metadata from the VisitInfo

        \param calibImage       The image whose metadata is to be set
        \param exposureTime     The exposure time for the image
        \param darkTime         The time since the last read (default: exposureTime)
        """

        if darkTime is None:
            darkTime = exposureTime  # avoid warning messages when using calibration products

        visitInfo = afwImage.makeVisitInfo(exposureTime=exposureTime,
                                           darkTime=darkTime,
                                           **kwargs)
        md = calibImage.getMetadata()

        afwImage.setVisitInfoMetadata(md, visitInfo)
Ejemplo n.º 7
0
 def std_dark(self, item, dataId):
     exp = self._standardizeExposure(self.calibrations['dark'], \
                                     item, dataId, trimmed=False, filter=False)
     visitInfo = afwImage.makeVisitInfo(exposureTime=1.0, darkTime=1.0)
     exp.getInfo().setVisitInfo(visitInfo)
     return exp
Ejemplo n.º 8
0
    def testMakeVisitInfo(self):
        """Test the makeVisitInfo factory function"""
        data = self.data1

        visitInfo = afwImage.makeVisitInfo()
        self._testIsEmpty(visitInfo)

        visitInfo = afwImage.makeVisitInfo(exposureId=data.exposureId)
        self.assertEqual(visitInfo.getExposureId(), data.exposureId)
        self.assertTrue(math.isnan(visitInfo.getExposureTime()))

        visitInfo = afwImage.makeVisitInfo(exposureTime=data.exposureTime)
        self.assertEqual(visitInfo.getExposureTime(), data.exposureTime)

        visitInfo = afwImage.makeVisitInfo(darkTime=data.darkTime)
        self.assertEqual(visitInfo.getDarkTime(), data.darkTime)

        visitInfo = afwImage.makeVisitInfo(date=data.date)
        self.assertEqual(visitInfo.getDate(), data.date)

        visitInfo = afwImage.makeVisitInfo(ut1=data.ut1)
        self.assertEqual(visitInfo.getUt1(), data.ut1)

        visitInfo = afwImage.makeVisitInfo(era=data.era)
        self.assertEqual(visitInfo.getEra(), data.era)

        visitInfo = afwImage.makeVisitInfo(boresightRaDec=data.boresightRaDec)
        self.assertEqual(visitInfo.getBoresightRaDec(), data.boresightRaDec)

        visitInfo = afwImage.makeVisitInfo(boresightAzAlt=data.boresightAzAlt)
        self.assertEqual(visitInfo.getBoresightAzAlt(), data.boresightAzAlt)

        visitInfo = afwImage.makeVisitInfo(
            boresightAirmass=data.boresightAirmass)
        self.assertEqual(visitInfo.getBoresightAirmass(),
                         data.boresightAirmass)

        visitInfo = afwImage.makeVisitInfo(
            boresightRotAngle=data.boresightRotAngle)
        self.assertEqual(visitInfo.getBoresightRotAngle(),
                         data.boresightRotAngle)

        visitInfo = afwImage.makeVisitInfo(rotType=data.rotType)
        self.assertEqual(visitInfo.getRotType(), data.rotType)

        visitInfo = afwImage.makeVisitInfo(observatory=data.observatory)
        self.assertEqual(visitInfo.getObservatory(), data.observatory)

        visitInfo = afwImage.makeVisitInfo(weather=data.weather)
        self.assertEqual(visitInfo.getWeather(), data.weather)