Esempio n. 1
0
    def setUp(self):
        self.testDir = os.path.dirname(__file__)

        def computeLstHA(data):
            """Return LST, Hour Angle, computed from VisitInfoData."""
            localEra = data.era + data.observatory.getLongitude()
            hourAngle = localEra - data.boresightRaDec[0]
            return localEra, hourAngle

        fields = [
            'exposureId', 'exposureTime', 'darkTime', 'date', 'ut1', 'era',
            'boresightRaDec', 'boresightAzAlt', 'boresightAirmass',
            'boresightRotAngle', 'rotType', 'observatory', 'weather'
        ]
        VisitInfoData = collections.namedtuple("VisitInfoData", fields)
        data1 = VisitInfoData(
            exposureId=10313423,
            exposureTime=10.01,
            darkTime=11.02,
            date=DateTime(65321.1, DateTime.MJD, DateTime.TAI),
            ut1=12345.1,
            era=45.1 * degrees,
            boresightRaDec=IcrsCoord(23.1 * degrees, 73.2 * degrees),
            boresightAzAlt=Coord(134.5 * degrees, 33.3 * degrees),
            boresightAirmass=1.73,
            boresightRotAngle=73.2 * degrees,
            rotType=afwImage.RotType_SKY,
            observatory=Observatory(11.1 * degrees, 22.2 * degrees, 0.333),
            weather=Weather(1.1, 2.2, 34.5),
        )
        self.data1 = data1
        self.localEra1, self.hourAngle1 = computeLstHA(data1)
        data2 = VisitInfoData(
            exposureId=1,
            exposureTime=15.5,
            darkTime=17.8,
            date=DateTime(55321.2, DateTime.MJD, DateTime.TAI),
            ut1=312345.1,
            era=25.1 * degrees,
            boresightRaDec=IcrsCoord(2.1 * degrees, 33.2 * degrees),
            boresightAzAlt=Coord(13.5 * degrees, 83.3 * degrees),
            boresightAirmass=2.05,
            boresightRotAngle=-53.2 * degrees,
            rotType=afwImage.RotType_HORIZON,
            observatory=Observatory(22.2 * degrees, 33.3 * degrees, 0.444),
            weather=Weather(2.2, 3.3, 44.4),
        )
        self.data2 = data2
        self.localEra2, self.hourAngle2 = computeLstHA(data2)
    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)
    def setArgDict(self, md, argDict):
        """Set an argument dict for VisitInfo 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, "AZ"),
            self.altitudeFromZenithDistance(self.popAngle(md, "ZD")),
        )
        argDict["boresightRaDec"] = IcrsCoord(
            self.popAngle(md, "TELRA", units=astropy.units.h),
            self.popAngle(md, "TELDEC"),
        )
        argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
        argDict["observatory"] = Observatory(
            self.popAngle(md, "OBS-LONG"),
            self.popAngle(md, "OBS-LAT"),
            self.popFloat(md, "OBS-ELEV"),
        )
        argDict["weather"] = Weather(
            self.popFloat(md, "OUTTEMP"),
            self.pascalFromMmHg(self.popFloat(md, "PRESSURE")),
            self.popFloat(md, "HUMIDITY"))
        longitude = argDict["observatory"].getLongitude()
        argDict['era'] = self.decamGetEra(md, argDict["boresightRaDec"][0],
                                          longitude)
Esempio n. 4
0
    def setArgDict(self, md, argDict):
        """Set an argument dict for VisitInfo 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"] = -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"),
        )
        # phosim doesn't supply LST, HA, or UT1, and the alt/az/ra/dec/time can be inconsistent.
        # We will leave ERA as NaN until a better answer is available.
        return VisitInfo(**argDict)
    def setUp(self):
        rawPath = os.path.join(testDataDirectory, "hsc", "raw")
        calibPath = os.path.join(testDataDirectory, "hsc", "calib")
        self.repoPath = createDataRepository("lsst.obs.hsc.HscMapper", rawPath)
        self.butler = dafPersist.Butler(root=self.repoPath,
                                        calibRoot=calibPath)

        # The following properties of the provided data are known a priori.
        self.visit = 904024
        self.ccdNum = 50
        self.filter = 'i'
        self.rawSize = (2144, 4241)
        self.ccdSize = (2048, 4176)
        self.exptime = 30.0
        self.darktime = self.exptime  # No explicit darktime
        dateBeg = DateTime(56598.26106374757, DateTime.MJD, DateTime.UTC)
        dateAvgNSec = dateBeg.nsecs() + int(0.5e9 * self.exptime)
        self.dateAvg = DateTime(dateAvgNSec, DateTime.TAI)
        self.boresightRaDec = IcrsCoord('21:22:59.982', '+00:30:00.07')
        self.boresightAzAlt = Coord(226.68922661 * degrees,
                                    63.04359233 * degrees)
        self.boresightAirmass = 1.121626027604189
        self.boresightRotAngle = 270.0 * degrees
        self.rotType = RotType.SKY
        self.obs_longitude = -155.476667 * degrees
        self.obs_latitude = 19.825556 * degrees
        self.obs_elevation = 4139
        self.weath_airTemperature = MakeRawVisitInfo.centigradeFromKelvin(
            272.35)
        self.weath_airPressure = MakeRawVisitInfo.pascalFromMmHg(621.7)
        self.weath_humidity = 33.1
        # NOTE: if we deal with DM-8053 and get UT1 implemented, ERA will change slightly.
        lst = 340.189608333 * degrees
        self.era = lst - self.obs_longitude
Esempio n. 6
0
 def safeOffset(crval, direction, amount):
     try:
         offsetCoord = crval.toIcrs()
         offsetCoord.offset(direction, amount)
         return offsetCoord
     except Exception:
         return IcrsCoord(crval[0] + direction, crval - amount)
    def __init__(self, result):
        """Set exposure information based on a query result from a db connection
        """
        self._ind = -1

        dataId = dict(
            run=result[self._nextInd],
            rerun=result[self._nextInd],
            camcol=result[self._nextInd],
            field=result[self._nextInd],
            filter=result[self._nextInd],
        )
        coordList = []
        for i in range(4):
            coordList.append(
                IcrsCoord(
                    afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
                    afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
                ))
        BaseExposureInfo.__init__(self, dataId, coordList)

        self.strip = result[self._nextInd]
        self.fwhm = result[self._nextInd]
        self.sky = result[self._nextInd]
        self.airmass = result[self._nextInd]
        self.quality = result[self._nextInd]
        self.isBlacklisted = result[self._nextInd]

        # compute RHL quality factors
        self.q = self.sky * (self.fwhm**2)
        self.qscore = None  # not known yet
Esempio n. 8
0
    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["boresightRaDec"] = IcrsCoord(
            self.popAngle(md, "RA2000", units=astropy.units.h),
            self.popAngle(md, "DEC2000"),
        )
        #        argDict["boresightAzAlt"] = Coord(
        #            self.popAngle(md, "AZIMUTH"),
        #            self.popAngle(md, "ALTITUDE"),
        #        )
        argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
        argDict["observatory"] = self.observatory
        argDict["weather"] = Weather(
            self.centigradeFromKelvin(self.popFloat(md, "OUT-TMP")),
            self.pascalFromMmHg(self.popFloat(md, "OUT-PRS")),
            self.popFloat(md, "OUT-HUM"),
        )
        LST = self.popAngle(md, "LST-STR", units=astropy.units.h)
        argDict['era'] = self.eraFromLstAndLongitude(
            LST, self.observatory.getLongitude())
        argDict['darkTime'] = argDict['exposureTime']
Esempio n. 9
0
 def setUp(self):
     datadir = self.getTestDataDir()
     self.repoPath = os.path.join(datadir, "DATA")
     self.calibPath = os.path.join(datadir, "CALIB")
     self.butler = dafPersist.Butler(root=self.repoPath,
                                     calibRoot=self.calibPath)
     self.size = (2112, 4644)
     self.dataId = {'visit': 1038843}
     self.filter = "i2"
     self.exposureTime = 615.037
     self.darkTime = 615.0
     dateObs = DateTime(54771.6066250, DateTime.MJD, DateTime.UTC)
     self.dateAvg = DateTime(
         dateObs.nsecs(DateTime.TAI) + int(0.5e9 * self.exposureTime),
         DateTime.TAI)
     self.boresightRaDec = IcrsCoord(135.409417 * degrees,
                                     -2.400000 * degrees)
     self.boresightAzAlt = Coord(122.34 * degrees, 52.02 * degrees)
     self.boresightAirmass = 1.269
     self.rotType = RotType.UNKNOWN
     self.obs_longitude = -155.468876 * degrees
     self.obs_latitude = 19.825252 * degrees
     self.obs_elevation = 4204
     self.weath_airTemperature = 0.90
     self.weath_airPressure = 617.65 * 100  # 100 Pascal/millibar
     self.weath_humidity = 39.77
     # NOTE: if we deal with DM-8053 and get UT1 implemented, ERA will change slightly.
     lst = 104.16591666666666 * degrees
     self.era = lst - self.obs_longitude
Esempio n. 10
0
    def testGetCatalog(self, logLevel=Log.TRACE):
        astrom = ANetBasicAstrometryTask(self.conf, andConfig=self.andConfig)
        astrom.log.setLevel(logLevel)

        ctrCoord = IcrsCoord(
            215.6 * afwGeom.degrees,
            53.0 * afwGeom.degrees,
        )
        cat = astrom.refObjLoader.loadSkyCircle(
            ctrCoord=ctrCoord,
            radius=0.1 * afwGeom.degrees,
            filterName='z',
        ).refCat
        print('Got', len(cat), 'reference sources')

        ids = set(s.getId() for s in cat)
        print(len(ids), 'unique IDs')

        ids = set()
        for src in cat:
            sid = src.getId()
            if sid in ids:
                print('Source id', sid, 'is duplicated')
            self.assertNotIn(sid, ids)
            ids.add(sid)
    def setArgDict(self, md, argDict):
        """Set an argument dict for VisitInfo 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["boresightRaDec"] = IcrsCoord(
            self.popAngle(md, "RA2000", units=astropy.units.h),
            self.popAngle(md, "DEC2000"),
        )
        argDict["boresightAzAlt"] = Coord(
            self.popAngle(md, "AZIMUTH"),
            self.popAngle(md, "ALTITUDE"),
        )
        argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
        argDict["observatory"] = self.observatory
        argDict["weather"] = Weather(
            self.centigradeFromKelvin(self.popFloat(md, "OUT-TMP")),
            self.pascalFromMmHg(self.popFloat(md, "OUT-PRS")),
            self.popFloat(md, "OUT-HUM"),
        )
        LST = self.popAngle(md, "LST-STR", units=astropy.units.h)
        argDict['era'] = self.eraFromLstAndLongitude(
            LST, self.observatory.getLongitude())
        argDict['darkTime'] = argDict['exposureTime']

        # Rotation angle formula determined empirically from visual inspection
        # of HSC images.  See DM-9111.
        rotAngle = (270.0 * degrees - self.popAngle(md, "INST-PA")).wrap()
        argDict['boresightRotAngle'] = rotAngle
        argDict['rotType'] = RotType.SKY
Esempio n. 12
0
    def setArgDict(self, md, argDict):
        """Set an argument dict for VisitInfo 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, "TELAZ"),
            self.popAngle(md, "TELALT"),
        )
        argDict["boresightRaDec"] = IcrsCoord(
            self.popAngle(
                md,
                "RA_DEG",
            ),
            self.popAngle(md, "DEC_DEG"),
        )
        argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
        argDict["observatory"] = Observatory(
            self.popAngle(md, "LONGITUD"),
            self.popAngle(md, "LATITUDE"),
            4204,  # from Wikipedia
        )
        argDict["weather"] = Weather(
            self.popFloat(md, "TEMPERAT"),
            self.popFloat(md, "PRESSURE") * 100.0,  # 100 Pascal per millibar
            self.popFloat(md, "RELHUMID"),
        )
        # Using LST to compute ERA until we get UT1 (see: DM-8053)
        LST = self.popAngle(md, "LST-OBS", units=astropy.units.h)
        argDict['era'] = self.eraFromLstAndLongitude(
            LST, argDict["observatory"].getLongitude())
Esempio n. 13
0
 def generateTract(self, index):
     """Generate the TractInfo for a particular index"""
     center = IcrsCoord(self.config.raList[index] * afwGeom.degrees,
                        self.config.decList[index] * afwGeom.degrees)
     radius = self.config.radiusList[index]
     wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0), crValCoord=center)
     return ExplicitTractInfo(index, self.config.patchInnerDimensions, self.config.patchBorder, center,
                              radius * afwGeom.degrees, self.config.tractOverlap * afwGeom.degrees, wcs)
Esempio n. 14
0
def angToCoord(thetaphi):
    """Convert healpy's ang to an afw Coord

    The ang is provided as a single object, thetaphi, so the output
    of healpy functions can be directed to this function without
    additional translation.
    """
    return IcrsCoord(float(thetaphi[1])*afwGeom.radians, float(thetaphi[0] - 0.5*numpy.pi)*afwGeom.radians)
Esempio n. 15
0
 def makeWcs():
     wcs = lsst.afw.image.makeWcs(
         IcrsCoord(10 * lsst.afw.geom.degrees, 45 * lsst.afw.geom.degrees),
         lsst.afw.geom.Point2D(5, 5),
         5.1e-5,
         0,
         0,
         -5.1e-5,  # CD: 11, 12, 21, 22
     )
     return wcs
Esempio n. 16
0
 def setUp(self):
     TransformTestBaseClass.setUp(self)
     self.crpix = Point2D(100, 100)
     self.crvalList = [
         IcrsCoord(0 * degrees, 45 * degrees),
         IcrsCoord(0.00001 * degrees, 45 * degrees),
         IcrsCoord(359.99999 * degrees, 45 * degrees),
         IcrsCoord(30 * degrees, 89.99999 * degrees),
         IcrsCoord(30 * degrees, -89.99999 * degrees),
     ]
     self.orientationList = [
         0 * degrees,
         0.00001 * degrees,
         -0.00001 * degrees,
         -45 * degrees,
         90 * degrees,
     ]
     self.scale = 1.0 * arcseconds
     self.tinyPixels = 10 * sys.float_info.epsilon
     self.tinyAngle = 10 * sys.float_info.epsilon * radians
Esempio n. 17
0
    def testGetDR7(self):
        obsSdssDir = lsst.utils.getPackageDir('obs_sdss')
        butler = dafPersist.Butler(
            root=os.path.join(obsSdssDir, "tests", "data", "dr7", "runs"))
        sub = butler.subset("fpC", run=5754, camcol=3, field=280, filter="r")
        self.assertEqual(len(sub), 1)
        for ref in sub:
            im = ref.get("fpC")
            w, h = im.getWidth(), im.getHeight()
            self.assertEqual(im.__class__, lsst.afw.image.ImageU)
            self.assertEqual(w, 2048)
            self.assertEqual(h, 1489)

            im_md = ref.get("fpC_md")
            self.assertEqual(im_md.get("RUN"), 5754)
            self.assertEqual(im_md.get("FRAME"), 280)
            self.assertEqual(im_md.get("STRIPE"), 82)

            msk = ref.get("fpM")
            w, h = msk.getWidth(), msk.getHeight()
            self.assertEqual(msk.__class__,
                             lsst.afw.image.Mask[lsst.afw.image.MaskPixel])
            self.assertEqual(w, 2048)
            self.assertEqual(h, 1489)

            psf = ref.get("psField")
            k = psf.getKernel()
            w, h = k.getWidth(), k.getHeight()
            self.assertEqual(psf.__class__, lsst.meas.algorithms.PcaPsf)
            self.assertEqual(w, 31)
            self.assertEqual(h, 31)

            wcs = ref.get("asTrans")
            self.assertIsInstance(wcs, SkyWcs)
            self.assertFalse(wcs.isFlipped)
            # comparison is to results from lsst.afw.image.TanWcs class
            self.assertCoordsAlmostEqual(
                wcs.pixelToSky(700, 1000),
                IcrsCoord(343.6507738304687 * degrees,
                          -0.3509870420713227 * degrees))

            tsField = ref.get("tsField")
            self.assertAlmostEqual(tsField.gain, 4.72, 2)
            self.assertAlmostEqual(tsField.airmass, 1.2815132857671601)
            self.assertAlmostEqual(tsField.exptime, 53.907456)
            predDateStart = DateTime(53664.226070589997, DateTime.MJD,
                                     DateTime.TAI)
            predDateAvg = DateTime(
                predDateStart.nsecs(DateTime.TAI) +
                int(0.5e9 * tsField.exptime), DateTime.TAI)
            self.assertAlmostEqual(tsField.dateAvg.get(), predDateAvg.get())
Esempio n. 18
0
    def setUp(self):
        # Set up a Coadd with CoaddInputs tables that have blank filter columns to be filled
        # in by later test code.
        self.coadd = ExposureF(30, 90)
        # WCS is arbitrary, since it'll be the same for all images
        wcs = makeSkyWcs(crpix=Point2D(0, 0),
                         crval=IcrsCoord(45.0 * degrees, 45.0 * degrees),
                         cdMatrix=makeCdMatrix(scale=0.17 * degrees))
        self.coadd.setWcs(wcs)
        schema = ExposureCatalog.Table.makeMinimalSchema()
        self.filterKey = schema.addField("filter", type=str, doc="", size=16)
        weightKey = schema.addField("weight", type=float, doc="")
        # First input image covers the first 2/3, second covers the last 2/3, so they
        # overlap in the middle 1/3.
        inputs = ExposureCatalog(schema)
        self.input1 = inputs.addNew()
        self.input1.setId(1)
        self.input1.setBBox(Box2I(Point2I(0, 0), Point2I(29, 59)))
        self.input1.setWcs(wcs)
        self.input1.set(weightKey, 2.0)
        self.input2 = inputs.addNew()
        self.input2.setId(2)
        self.input2.setBBox(Box2I(Point2I(0, 30), Point2I(29, 89)))
        self.input2.setWcs(wcs)
        self.input2.set(weightKey, 3.0)
        # Use the same catalog for visits and CCDs since the algorithm we're testing only cares
        # about CCDs.
        self.coadd.getInfo().setCoaddInputs(CoaddInputs(inputs, inputs))

        # Set up a catalog with centroids and a FilterFraction plugin.
        # We have one record in each region (first input only, both inputs, second input only)
        schema = SourceCatalog.Table.makeMinimalSchema()
        centroidKey = Point2DKey.addFields(schema,
                                           "centroid",
                                           doc="position",
                                           unit="pixel")
        schema.getAliasMap().set("slot_Centroid", "centroid")
        self.plugin = FilterFractionPlugin(
            config=FilterFractionPlugin.ConfigClass(),
            schema=schema,
            name="subaru_FilterFraction",
            metadata=PropertyList())
        catalog = SourceCatalog(schema)
        self.record1 = catalog.addNew()
        self.record1.set(centroidKey, Point2D(14.0, 14.0))
        self.record12 = catalog.addNew()
        self.record12.set(centroidKey, Point2D(14.0, 44.0))
        self.record2 = catalog.addNew()
        self.record2.set(centroidKey, Point2D(14.0, 74.0))
Esempio n. 19
0
    def __init__(self, result):
        """Set exposure information based on a query result from a db connection
        """
        result = list(result)
        dataId = dict(
            run=result.pop(0),
            camcol=result.pop(0),
            field=result.pop(0),
            filter=result.pop(0),
        )
        coordList = [IcrsCoord(afwGeom.Angle(result.pop(0), afwGeom.degrees),
                               afwGeom.Angle(result.pop(0), afwGeom.degrees)) for i in range(4)]

        BaseExposureInfo.__init__(self, dataId=dataId, coordList=coordList)
        self.fluxMag0 = result.pop(0)
        self.fluxMag0Sigma = result.pop(0)
Esempio n. 20
0
 def makeVisitInfo():
     return lsst.afw.image.VisitInfo(
         10313423,
         10.01,
         11.02,
         DateTime(65321.1, DateTime.MJD, DateTime.TAI),
         12345.1,
         45.1 * lsst.afw.geom.degrees,
         IcrsCoord(23.1 * degrees, 73.2 * degrees),
         Coord(134.5 * degrees, 33.3 * degrees),
         1.73,
         73.2 * degrees,
         lsst.afw.image.RotType.SKY,
         lsst.afw.coord.Observatory(11.1 * degrees, 22.2 * degrees, 0.333),
         lsst.afw.coord.Weather(1.1, 2.2, 34.5),
     )
Esempio n. 21
0
 def __init__(self, result):
     """Set exposure information based on a query result from a db connection
     """
     self._ind = -1
     dataId = dict(raft=result[self._nextInd],
                   visit=result[self._nextInd],
                   sensor=result[self._nextInd],
                   filter=result[self._nextInd])
     coordList = []
     for i in range(4):
         coordList.append(
             IcrsCoord(
                 afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
                 afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
             ))
     self.fwhm = result[self._nextInd]
     BaseExposureInfo.__init__(self, dataId, coordList)
Esempio n. 22
0
    def setUp(self):
        crval = IcrsCoord(afwGeom.PointD(44., 45.))
        crpix = afwGeom.PointD(0, 0)

        arcsecPerPixel = 1 / 3600.0
        CD11 = arcsecPerPixel
        CD12 = 0
        CD21 = 0
        CD22 = arcsecPerPixel

        self.tanWcs = makeWcs(crval, crpix, CD11, CD12, CD21, CD22)

        S = 300
        N = 5

        if self.MatchClass == afwTable.ReferenceMatch:
            refSchema = LoadReferenceObjectsTask.makeMinimalSchema(
                filterNameList=["r"], addFluxSigma=True, addIsPhotometric=True)
            self.refCat = afwTable.SimpleCatalog(refSchema)
        elif self.MatchClass == afwTable.SourceMatch:
            refSchema = afwTable.SourceTable.makeMinimalSchema()
            self.refCat = afwTable.SourceCatalog(refSchema)
        else:
            raise RuntimeError("Unsupported MatchClass=%r" %
                               (self.MatchClass, ))
        srcSchema = afwTable.SourceTable.makeMinimalSchema()
        SingleFrameMeasurementTask(schema=srcSchema)
        self.refCoordKey = afwTable.CoordKey(refSchema["coord"])
        self.srcCoordKey = afwTable.CoordKey(srcSchema["coord"])
        self.srcCentroidKey = afwTable.Point2DKey(srcSchema["slot_Centroid"])
        self.sourceCat = afwTable.SourceCatalog(srcSchema)
        self.origSourceCat = afwTable.SourceCatalog(
            srcSchema)  # undistorted copy
        self.matches = []

        for i in np.linspace(0., S, N):
            for j in np.linspace(0., S, N):
                src = self.sourceCat.addNew()
                refObj = self.refCat.addNew()

                src.set(self.srcCentroidKey, afwGeom.Point2D(i, j))

                c = self.tanWcs.pixelToSky(afwGeom.Point2D(i, j))
                refObj.setCoord(c)

                self.matches.append(self.MatchClass(refObj, src, 0.0))
    def setArgDict(self, md, argDict):
        """Set an argument dict for VisitInfo 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"] = -self.popAngle(md, "ROTANG")
        argDict["rotType"] = RotType.SKY
        argDict["observatory"] = self.observatory
        weather = defaultWeather(self.observatory.getElevation())
        temperature = self.defaultMetadata(self.popFloat(md, "TEMPERA"),
                                           weather.getAirTemperature(),
                                           minimum=-10,
                                           maximum=40.)
        pressure = self.defaultMetadata(self.pascalFromMmHg(
            self.popFloat(md, "PRESS")),
                                        weather.getAirPressure(),
                                        minimum=50000.,
                                        maximum=90000.)
        humidity = 40.  # Not currently supplied by phosim, so set to a typical value.
        argDict["weather"] = Weather(temperature, pressure, humidity)
        longitude = argDict["observatory"].getLongitude()
        RA = argDict["boresightRaDec"][0]
        # phosim doesn't supply LST, HA, or UT1, and the alt/az/ra/dec/time can be inconsistent.
        # We will leave ERA as NaN until a better answer is available.
        try:
            # Other simulation tools don't have the same problem, and need hour angle if it is available.
            HA = self.popAngle(md, "HA", units=astropy.units.h)
            argDict['era'] = HA + RA - longitude
        except:
            self.log.warn("Hour angle missing from metadata, will be NAN")
        return VisitInfo(**argDict)
Esempio n. 24
0
    def makeExposure(self, universalId):
        """Make a tiny exposure with exposure info set, but no pixels

        In particular, exposure info is set as a record in a table, so it can be recorded in a coadd
        """
        inputRecorder = self.coaddInputRecorder.makeCoaddTempExpRecorder(
            universalId, self.numExp)
        bbox = lsst.afw.geom.Box2I(lsst.afw.geom.Point2I(100, 100),
                                   lsst.afw.geom.Extent2I(10, 10))

        detectorName = "detector {}".format(universalId)
        detector = lsst.afw.cameraGeom.testUtils.DetectorWrapper(
            name=detectorName, id=universalId).detector

        exp = lsst.afw.image.ExposureF(bbox)
        exp.setDetector(detector)

        expInfo = exp.getInfo()
        wcs = lsst.afw.image.makeWcs(
            IcrsCoord(10 * lsst.afw.geom.degrees, 45 * lsst.afw.geom.degrees),
            lsst.afw.geom.Point2D(5, 5),
            5.1e-5,
            0,
            0,
            -5.1e-5,  # CD: 11, 12, 21, 22
        )
        expInfo.setWcs(wcs)
        expInfo.setPsf(GaussianPsf(5, 5, 2.5))
        calib = lsst.afw.image.Calib()
        calib.setFluxMag0(1.1e12, 2.2e10)
        expInfo.setCalib(calib)
        expInfo.setApCorrMap(self.makeApCorrMap())
        expInfo.setValidPolygon(Polygon(
            lsst.afw.geom.Box2D(bbox).getCorners()))
        if self.version > 1:
            expInfo.setVisitInfo(self.makeVisitInfo())

        inputRecorder.addCalExp(calExp=exp, ccdId=universalId, nGoodPix=100)
        inputRecorder.finish(coaddTempExp=exp, nGoodPix=100)

        return exp
Esempio n. 25
0
    def generateTract(self, index):
        """Generate the TractInfo for this index"""
        ringNum, tractNum = self.getRingIndices(index)
        if ringNum == -1:  # South polar cap
            ra, dec = 0, -0.5 * math.pi
        elif ringNum == self.config.numRings:  # North polar cap
            ra, dec = 0, 0.5 * math.pi
        else:
            dec = self._ringSize * (ringNum + 1) - 0.5 * math.pi
            ra = math.fmod(
                self.config.raStart +
                2 * math.pi * tractNum / self._ringNums[ringNum], 2 * math.pi)

        center = IcrsCoord(ra * afwGeom.radians, dec * afwGeom.radians)
        wcs = self._wcsFactory.makeWcs(crPixPos=afwGeom.Point2D(0, 0),
                                       crValCoord=center)
        return ExplicitTractInfo(index, self.config.patchInnerDimensions,
                                 self.config.patchBorder, center,
                                 0.5 * self._ringSize * afwGeom.radians,
                                 self.config.tractOverlap * afwGeom.degrees,
                                 wcs)
Esempio n. 26
0
 def setUp(self):
     self.butler = dafPersist.Butler(
         root=os.path.join(os.path.dirname(__file__), "data"))
     self.exposureTime = 15.0
     self.darkTime = 15.0
     dateObs = DateTime(49552.28496, DateTime.MJD, DateTime.TAI)
     self.dateAvg = DateTime(
         dateObs.nsecs(DateTime.TAI) + int(0.5e9 * self.exposureTime),
         DateTime.TAI)
     self.boresightRaDec = IcrsCoord(359.936019771151 * degrees,
                                     -2.3356222648145 * degrees)
     self.boresightAzAlt = Coord(127.158246182602 * degrees,
                                 (90 - 40.6736117075876) * degrees)
     self.boresightAirmass = 1.31849492005496
     self.boresightRotAngle = (90 - 3.43228) * degrees
     self.rotType = RotType_SKY
     self.obs_longitude = -70.749417 * degrees
     self.obs_latitude = -30.244633 * degrees
     self.obs_elevation = 2663.0
     self.weath_airTemperature = 5.0
     self.weath_airPressure = MakeRawVisitInfo.pascalFromMmHg(520.0)
Esempio n. 27
0
 def test_getBoresightRaDec(self):
     coord = IcrsCoord(afwGeom.Point2D(53.0091385, -27.4389488), afwGeom.degrees)
     self.assertEqual(coord, self.visit_info.getBoresightRaDec())
Esempio n. 28
0
from lsst.daf.base import DateTime
import lsst.afw.image as afwImage
import lsst.utils.tests
from lsst.utils import getPackageDir

import lsst.pex.exceptions as pexExcept
import lsst.daf.persistence as dafPersist
from lsst.obs.base import MakeRawVisitInfo
from lsst.afw.image import RotType
from lsst.afw.coord import IcrsCoord, Coord
from lsst.afw.geom import degrees

# Desired VisitInfo values for visit 229388, shared between testGetRaw.py and
# testGetInstcal.py

boresightRaDec = IcrsCoord('02:51:16.790', '-00:00:05.699')
# NOTE: if we deal with DM-8053 and implement UT1, ERA will not come from HA, so this will change.
HA = -42.505291666666665 * degrees
era = HA + boresightRaDec[0] - 70.81489000000001 * degrees
visit229388_info = {
    "dateAvg": DateTime("2013-09-01T06:05:10.753848", DateTime.TAI),
    "exposureTime": 200.0,
    "darkTime": 201.15662,
    "era": era,
    "boresightRaDec": boresightRaDec,
    "boresightAzAlt": Coord(61.24 * degrees, (90 - 50.46) * degrees),
    "boresightAirmass": 1.57,
    "boresightRotAngle": float("nan") * degrees,
    "rotType": RotType.UNKNOWN,
    "obs_longitude": 70.81489000000001 * degrees,
    "obs_latitude": -30.16606 * degrees,
Esempio n. 29
0
        cursor.execute(queryStr, dataTuple)
        exposureInfoList = [ExposureInfo(result) for result in cursor]

        return pipeBase.Struct(exposureInfoList=exposureInfoList, )

    def _runArgDictFromDataId(self, dataId):
        """Extract keyword arguments for run (other than coordList) from a data ID

        @return keyword arguments for run (other than coordList), as a dict
        """
        return dict(filter=dataId["filter"])


if __name__ == "__main__":
    # example of use
    selectTask = SelectLsstImagesTask()
    minRa = afwGeom.Angle(1, afwGeom.degrees)
    maxRa = afwGeom.Angle(2, afwGeom.degrees)
    minDec = afwGeom.Angle(5, afwGeom.degrees)
    maxDec = afwGeom.Angle(6, afwGeom.degrees)
    coordList = [
        IcrsCoord(minRa, minDec),
        IcrsCoord(maxRa, minDec),
        IcrsCoord(maxRa, maxDec),
        IcrsCoord(minRa, maxDec),
    ]
    results = selectTask.run(coordList=coordList, filter='r')
    for ccdInfo in results.exposureInfoList:
        print "dataId=%s, fwhm=%s" % (ccdInfo.dataId, ccdInfo.fwhm)
Esempio n. 30
0
 def setUp(self):
     # arbitrary values
     self.crpix = Point2D(100, 100)
     self.crval = IcrsCoord(30 * degrees, 45 * degrees)
     self.scale = 1.0 * arcseconds