Example #1
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile(self.packageName,
                                                 "ctio0m9Mapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(),
                              **kwargs)
        filter_pairings = [
            'NONE+SEMROCK',  # list of all filter pairings found in data
            'NONE+RONCHI200',
            'RONCHI200+SEMROCK',
            'NONE+NONE',
            'NONE+g',
            'NONE+r',
            'NONE+i',
            'NONE+z',
            'RONCHI200+z',
            'RONCHI200+g',
            'FGB37+RONCHI200',
            'NONE+RONCHI400',
            'FGC715S+RONCHI400',
            'FGC715S+RONCHI200'
        ]

        # default no-filter name used for biases and darks - must appear
        afwImageUtils.defineFilter('NONE', 0.0, alias=[])

        for pairing in filter_pairings:
            afwImageUtils.defineFilter(pairing, 0.0, alias=[])
Example #2
0
 def testMultiPlaneFitsReaders(self):
     """Run tests for MaskedImageFitsReader and ExposureFitsReader.
     """
     metadata = PropertyList()
     metadata.add("FIVE", 5)
     metadata.add("SIX", 6.0)
     wcs = makeSkyWcs(Point2D(2.5, 3.75),
                      SpherePoint(40.0 * degrees, 50.0 * degrees),
                      np.array([[1E-5, 0.0], [0.0, -1E-5]]))
     defineFilter("test_readers_filter", lambdaEff=470.0)
     calib = PhotoCalib(2.5E4)
     psf = GaussianPsf(21, 21, 8.0)
     polygon = Polygon(Box2D(self.bbox))
     apCorrMap = ApCorrMap()
     visitInfo = VisitInfo(exposureTime=5.0)
     transmissionCurve = TransmissionCurve.makeIdentity()
     coaddInputs = CoaddInputs(ExposureTable.makeMinimalSchema(),
                               ExposureTable.makeMinimalSchema())
     detector = DetectorWrapper().detector
     record = coaddInputs.ccds.addNew()
     record.setWcs(wcs)
     record.setPhotoCalib(calib)
     record.setPsf(psf)
     record.setValidPolygon(polygon)
     record.setApCorrMap(apCorrMap)
     record.setVisitInfo(visitInfo)
     record.setTransmissionCurve(transmissionCurve)
     record.setDetector(detector)
     for n, dtypeIn in enumerate(self.dtypes):
         with self.subTest(dtypeIn=dtypeIn):
             exposureIn = Exposure(self.bbox, dtype=dtypeIn)
             shape = exposureIn.image.array.shape
             exposureIn.image.array[:, :] = np.random.randint(low=1,
                                                              high=5,
                                                              size=shape)
             exposureIn.mask.array[:, :] = np.random.randint(low=1,
                                                             high=5,
                                                             size=shape)
             exposureIn.variance.array[:, :] = np.random.randint(low=1,
                                                                 high=5,
                                                                 size=shape)
             exposureIn.setMetadata(metadata)
             exposureIn.setWcs(wcs)
             exposureIn.setFilter(Filter("test_readers_filter"))
             exposureIn.setFilterLabel(
                 FilterLabel(physical="test_readers_filter"))
             exposureIn.setPhotoCalib(calib)
             exposureIn.setPsf(psf)
             exposureIn.getInfo().setValidPolygon(polygon)
             exposureIn.getInfo().setApCorrMap(apCorrMap)
             exposureIn.getInfo().setVisitInfo(visitInfo)
             exposureIn.getInfo().setTransmissionCurve(transmissionCurve)
             exposureIn.getInfo().setCoaddInputs(coaddInputs)
             exposureIn.setDetector(detector)
             with lsst.utils.tests.getTempFilePath(".fits") as fileName:
                 exposureIn.writeFits(fileName)
                 self.checkMaskedImageFitsReader(exposureIn, fileName,
                                                 self.dtypes[n:])
                 self.checkExposureFitsReader(exposureIn, fileName,
                                              self.dtypes[n:])
Example #3
0
 def __init__(self, root, **kwargs):
     self.storage = lsst.daf.persistence.Storage.makeFromURI(root)
     super(SimpleMapper, self).__init__(**kwargs)
     self.root = root
     self.camera = makeSimpleCamera(nX=1, nY=2, sizeX=400, sizeY=200, gapX=2, gapY=2)
     afwImageUtils.defineFilter('r', 619.42)
     self.update()
Example #4
0
    def testCoordinateTransformDcrCalculation(self):
        """Check the DCR calculation using astropy coordinate transformations.

        Astmospheric refraction causes sources to appear closer to zenith than
        they really are. An alternate calculation of the shift due to DCR is to
        transform the pixel coordinates to altitude and azimuth, add the DCR
        amplitude to the altitude, and transform back to pixel coordinates.
        """
        afwImageUtils.defineFilter("gTest", self.lambdaEff,
                                   lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax)
        filterInfo = afwImage.Filter("gTest")
        pixelScale = 0.2*arcseconds
        doFlip = [False, True]

        for testIter in range(self.nRandIter):
            rotAngle = 360.*self.rng.rand()*degrees
            azimuth = 360.*self.rng.rand()*degrees
            elevation = (45. + self.rng.rand()*40.)*degrees  # Restrict to 45 < elevation < 85 degrees
            visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
            for flip in doFlip:
                # Repeat the calculation for both WCS orientations
                wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec(), flipX=flip)
                dcrShifts = calculateDcr(visitInfo, wcs, filterInfo, self.dcrNumSubfilters)
                refShifts = calculateAstropyDcr(visitInfo, wcs, filterInfo, self.dcrNumSubfilters)
                for refShift, dcrShift in zip(refShifts, dcrShifts):
                    # Use a fairly loose tolerance, since 1% of a pixel is good enough agreement.
                    self.assertFloatsAlmostEqual(refShift[1], dcrShift[1], rtol=1e-2, atol=1e-2)
                    self.assertFloatsAlmostEqual(refShift[0], dcrShift[0], rtol=1e-2, atol=1e-2)
    def defineFilter(self,
                     lambdaEff=476.31,
                     lambdaMin=405.,
                     lambdaMax=552.,
                     filterName="gTest"):
        """Construct a `Filter` with sufficient information to calculate DCR.

        Parameters
        ----------
        lambdaEff : `float`, optional
            The effective wavelength of the filter, defaults to LSST g-band value.
        lambdaMin : float, optional
            The minimum wavelength of the filter with greater than 1% transmission,
            defaults to LSST g-band value.
        lambdaMax : `float`, optional
            The maximum wavelength of the filter with greater than 1% transmission,
            defaults to LSST g-band value.
        filterName : `str`, optional
            The simplified name of the filter.

        Returns
        -------
        filterInfo : `lsst.afw.image.Filter`
            The filter definition.
        """
        afwImageUtils.defineFilter(filterName,
                                   lambdaEff,
                                   lambdaMin=lambdaMin,
                                   lambdaMax=lambdaMax)
        return afwImage.Filter(filterName)
    def setUp(self):

        nSources = 10
        # CFHT Filters from the camera mapper.
        afwImageUtils.resetFilters()
        afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
        afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
        afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
        afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
        afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")

        self.bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(1024, 1153))
        dataset = measTests.TestDataset(self.bbox)
        for srcIdx in range(nSources):
            dataset.addSource(100000.0, geom.Point2D(100, 100))
        self.inputCatalogNoFlags, _ = make_input_source_catalog(dataset, False)
        self.inputCatalog, self.exposure = \
            make_input_source_catalog(dataset, True)

        detector = DetectorWrapper(id=23,
                                   bbox=self.exposure.getBBox()).detector
        visit = afwImage.VisitInfo(exposureId=4321,
                                   exposureTime=200.,
                                   date=dafBase.DateTime(nsecs=1400000000 *
                                                         10**9))
        self.exposure.setDetector(detector)
        self.exposure.getInfo().setVisitInfo(visit)
        self.exposure.setFilter(afwImage.Filter('g.MP9401'))
        scale = 2
        scaleErr = 1
        self.photoCalib = afwImage.PhotoCalib(scale, scaleErr)
        self.exposure.setPhotoCalib(self.photoCalib)
 def __init__(self, root, **kwargs):
     self.storage = lsst.daf.persistence.Storage.makeFromURI(root)
     super(SimpleMapper, self).__init__(**kwargs)
     self.root = root
     self.camera = makeSimpleCamera(nX=1, nY=2, sizeX=400, sizeY=200, gapX=2, gapY=2)
     afwImageUtils.defineFilter('r', 619.42)
     self.update()
Example #8
0
    def setUp(self):
        maskedImage = afwImage.MaskedImageF(inFilePathSmall)
        maskedImageMD = readMetadata(inFilePathSmall)

        self.smallExposure = afwImage.ExposureF(inFilePathSmall)
        self.width = maskedImage.getWidth()
        self.height = maskedImage.getHeight()
        self.wcs = afwGeom.makeSkyWcs(maskedImageMD, False)
        self.md = maskedImageMD
        self.psf = DummyPsf(2.0)
        self.detector = DetectorWrapper().detector
        self.extras = {"misc": DummyPsf(3.5)}

        self.exposureBlank = afwImage.ExposureF()
        self.exposureMiOnly = afwImage.makeExposure(maskedImage)
        self.exposureMiWcs = afwImage.makeExposure(maskedImage, self.wcs)
        # n.b. the (100, 100, ...) form
        self.exposureCrWcs = afwImage.ExposureF(100, 100, self.wcs)
        # test with ExtentI(100, 100) too
        self.exposureCrOnly = afwImage.ExposureF(lsst.geom.ExtentI(100, 100))

        afwImage.Filter.reset()
        afwImage.FilterProperty.reset()

        defineFilter("g", 470.0)
Example #9
0
    def setUp(self):
        super().setUp()

        afwImage.Filter.reset()
        afwImage.FilterProperty.reset()
        defineFilter("g", 470.0)

        self.wcs = afwGeom.makeSkyWcs(
            lsst.geom.Point2D(0.0, 0.0),
            lsst.geom.SpherePoint(2.0, 34.0, lsst.geom.degrees),
            np.identity(2),
        )
        self.photoCalib = afwImage.PhotoCalib(1.5)
        self.psf = DummyPsf(2.0)
        self.detector = DetectorWrapper().detector
        self.summaryStats = afwImage.ExposureSummaryStats(ra=100.0)
        self.polygon = afwGeom.Polygon(
            lsst.geom.Box2D(lsst.geom.Point2D(0.0, 0.0),
                            lsst.geom.Point2D(25.0, 20.0)))
        self.coaddInputs = afwImage.CoaddInputs()
        self.apCorrMap = afwImage.ApCorrMap()
        self.transmissionCurve = afwImage.TransmissionCurve.makeIdentity()

        self.exposureInfo = afwImage.ExposureInfo()
        gFilter = afwImage.Filter("g")
        gFilterLabel = afwImage.FilterLabel(band="g")
        self.exposureInfo.setFilter(gFilter)
        self.exposureInfo.setFilterLabel(gFilterLabel)
Example #10
0
    def __init__(self, outputRoot=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_sst", "SstMapper.paf",
                                                 "policy")
        policy = pexPolicy.Policy(policyFile)
        super(SstMapper, self).__init__(policy, policyFile.getRepositoryPath(),
                                        **kwargs)

        afwImageUtils.defineFilter('OPEN', lambdaEff=650)
Example #11
0
    def testNullWarpExposure(self, interpLength=10):
        """Test that warpExposure maps an image onto itself.

        Note:
        - NO_DATA and off-CCD pixels must be ignored
        - bad mask pixels get smeared out so we have to excluded all bad mask pixels
          from the output image when comparing masks.
        """
        imageUtils.defineFilter("i", 748.1)

        originalExposure = afwImage.ExposureF(originalExposurePath)
        originalExposure.getInfo().setVisitInfo(makeVisitInfo())
        originalFilter = afwImage.Filter("i")
        originalCalib = afwImage.Calib()
        originalCalib.setFluxMag0(1.0e5, 1.0e3)
        originalExposure.setFilter(originalFilter)
        originalExposure.setCalib(originalCalib)
        afwWarpedExposure = afwImage.ExposureF(originalExposure.getBBox(),
                                               originalExposure.getWcs())
        warpingControl = afwMath.WarpingControl("lanczos4", "", 0,
                                                interpLength)
        afwMath.warpExposure(afwWarpedExposure, originalExposure,
                             warpingControl)
        if SAVE_FITS_FILES:
            afwWarpedExposure.writeFits("afwWarpedExposureNull.fits")

        self.assertEqual(afwWarpedExposure.getFilter().getName(),
                         originalFilter.getName())
        self.assertEqual(afwWarpedExposure.getCalib().getFluxMag0(),
                         originalCalib.getFluxMag0())
        self.assertEqual(afwWarpedExposure.getInfo().getVisitInfo(),
                         originalExposure.getInfo().getVisitInfo())

        afwWarpedMaskedImage = afwWarpedExposure.getMaskedImage()
        afwWarpedMask = afwWarpedMaskedImage.getMask()
        noDataBitMask = afwWarpedMask.getPlaneBitMask("NO_DATA")
        afwWarpedMaskedImageArrSet = afwWarpedMaskedImage.getArrays()
        afwWarpedMaskArr = afwWarpedMaskedImageArrSet[1]

        # compare all non-DATA pixels of image and variance, but relax specs a bit
        # because of minor noise introduced by bad pixels
        noDataMaskArr = afwWarpedMaskArr & noDataBitMask
        msg = "afw null-warped MaskedImage (all pixels, relaxed tolerance)"
        self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage,
                                           originalExposure.getMaskedImage(),
                                           doMask=False,
                                           skipMask=noDataMaskArr,
                                           atol=1e-5,
                                           msg=msg)

        # compare good pixels (mask=0) of image, mask and variance using full
        # tolerance
        msg = "afw null-warped MaskedImage (good pixels, max tolerance)"
        self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage,
                                           originalExposure.getMaskedImage(),
                                           skipMask=afwWarpedMask,
                                           msg=msg)
Example #12
0
 def setUp(self):
     self.size = 512
     self.config = FringeTask.ConfigClass()
     self.config.filters = ['FILTER']
     self.config.num = 5000
     self.config.small = 1
     self.config.large = 128
     self.config.pedestal = False
     afwImageUtils.defineFilter('FILTER', lambdaEff=0)
Example #13
0
 def setUp(self):
     self.size = 512
     self.config = FringeTask.ConfigClass()
     self.config.filters = ['FILTER']
     self.config.num = 5000
     self.config.small = 1
     self.config.large = 128
     self.config.pedestal = False
     afwImageUtils.defineFilter('FILTER', lambdaEff=0)
Example #14
0
def defineSdssFilters(testCase):
    """Initialise filters as used for our tests"""
    imageUtils.resetFilters()
    wavelengths = dict()
    testCase.aliases = dict(u=[], g=[], r=[], i=[], z=['zprime', "z'"])
    for name, lambdaEff in (('u', 355.1), ('g', 468.6), ('r', 616.5),
                            ('i', 748.1), ('z', 893.1)):
        wavelengths[name] = lambdaEff
        imageUtils.defineFilter(name, lambdaEff, alias=testCase.aliases[name])
    return wavelengths
    def setUp(self):
        np.random.seed(1234)
        self.cutoutSize = 35
        self.center = lsst.geom.Point2D(50.1, 49.8)
        self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(-20, -30),
                                    lsst.geom.Extent2I(140, 160))
        self.dataset = lsst.meas.base.tests.TestDataset(self.bbox)
        self.dataset.addSource(100000.0, self.center)
        exposure, catalog = self.dataset.realize(
            10.0, self.dataset.makeMinimalSchema(), randomSeed=0)
        self.exposure = exposure
        detector = DetectorWrapper(id=23, bbox=exposure.getBBox()).detector
        self.exposure.setDetector(detector)

        visit = afwImage.VisitInfo(exposureId=1234,
                                   exposureTime=200.,
                                   date=dafBase.DateTime(
                                       "2014-05-13T17:00:00.000000000",
                                       dafBase.DateTime.Timescale.TAI))
        self.exposure.getInfo().setVisitInfo(visit)

        self.filter_names = ["g"]
        afwImageUtils.resetFilters()
        afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
        self.exposure.setFilter(afwImage.Filter('g'))

        diaObjects = makeDiaObjects(2, self.exposure)
        diaSourceHistory = makeDiaSources(10, diaObjects["diaObjectId"],
                                          self.exposure)
        diaForcedSources = makeDiaForcedSources(10, diaObjects["diaObjectId"],
                                                self.exposure)
        self.diaObjects, diaSourceHistory, self.diaForcedSources = _roundTripThroughApdb(
            diaObjects, diaSourceHistory, diaForcedSources,
            self.exposure.getInfo().getVisitInfo().getDate().toPython())
        self.diaObjects.replace(to_replace=[None], value=np.nan, inplace=True)
        diaSourceHistory.replace(to_replace=[None], value=np.nan, inplace=True)
        self.diaForcedSources.replace(to_replace=[None],
                                      value=np.nan,
                                      inplace=True)
        diaSourceHistory["programId"] = 0

        self.diaSources = diaSourceHistory.loc[[(0, "g", 8), (1, "g", 9)], :]
        self.diaSources["bboxSize"] = self.cutoutSize
        self.diaSourceHistory = diaSourceHistory.drop(labels=[(0, "g",
                                                               8), (1, "g",
                                                                    9)])

        self.cutoutWcs = wcs.WCS(naxis=2)
        self.cutoutWcs.wcs.crpix = [self.center[0], self.center[1]]
        self.cutoutWcs.wcs.crval = [
            self.exposure.getWcs().getSkyOrigin().getRa().asDegrees(),
            self.exposure.getWcs().getSkyOrigin().getDec().asDegrees()
        ]
        self.cutoutWcs.wcs.cd = self.exposure.getWcs().getCdMatrix()
        self.cutoutWcs.wcs.ctype = ["RA---TAN", "DEC--TAN"]
 def __init__(self, root):
     super(SimpleMapper, self).__init__()
     self.root = root
     self.camera = makeSimpleCamera(nX=1,
                                    nY=2,
                                    sizeX=400,
                                    sizeY=200,
                                    gapX=2,
                                    gapY=2)
     afwImageUtils.defineFilter('r', 619.42)
     self.update()
Example #17
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_ukirt", "CasuWfcamMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(), **kwargs)

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {
            'project': str,
            'object': str,
            'obsType': str,
            'visit': int,
            'grp': int,
            'dateObs': str,
            'expTime': float,
            'filter': str,
            'date': str,
        }
        for name in ("raw",
                     # processCcd outputs
                     "calexp", "src", "icMatch", "icMatchFull",
                     "srcMatch", "srcMatchFull",
                     # Warp
                     "deepCoadd_tempExp",
                     ):
            self.mappings[name].keyDict.update(keys)

        # The order of these defineFilter commands matters as their IDs are used to generate at least some
        # object IDs (e.g. on coadds) and changing the order will invalidate old objIDs

        afwImageUtils.resetFilters()
        afwImageUtils.defineFilter(name='Z', lambdaEff=950, alias=[])
        afwImageUtils.defineFilter(name='Y', lambdaEff=1100, alias=[])
        afwImageUtils.defineFilter(name='J', lambdaEff=1300, alias=[])
        afwImageUtils.defineFilter(name='H', lambdaEff=1600, alias=[])
        afwImageUtils.defineFilter(name='K', lambdaEff=2000, alias=[])

        self.filters = {}
        for f in "ZYJHK":
            self.filters[f] = f

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        CasuWfcamMapper._nbit_tract = 16
        CasuWfcamMapper._nbit_patch  = 5
        CasuWfcamMapper._nbit_filter = 6
        CasuWfcamMapper._nbit_id = 64 - (CasuWfcamMapper._nbit_tract + 2*CasuWfcamMapper._nbit_patch +
                                         CasuWfcamMapper._nbit_filter)
        if len(afwImage.Filter.getNames()) >= 2**CasuWfcamMapper._nbit_filter:
            raise RuntimeError("You have more filters defined than fit into the %d bits allocated" %
                               CasuWfcamMapper._nbit_filter)
Example #18
0
def defineSdssFilters(testCase):
    """Initialise filters as used for our tests"""
    imageUtils.resetFilters()
    wavelengths = dict()
    testCase.aliases = dict(u=[], g=[], r=[], i=[], z=['zprime', "z'"])
    for name, lambdaEff in (('u', 355.1),
                            ('g', 468.6),
                            ('r', 616.5),
                            ('i', 748.1),
                            ('z', 893.1)):
        wavelengths[name] = lambdaEff
        imageUtils.defineFilter(name, lambdaEff, alias=testCase.aliases[name])
    return wavelengths
Example #19
0
def defineSdssFilters():
    # Initialise filters as used for our tests
    imageUtils.resetFilters()
    wavelengths = dict()
    for name, lambdaEff, aliases in (('u', 355.1, []),
                                     ('g', 468.6, []),
                                     ('r', 616.5, []),
                                     ('i', 748.1, []),
                                     ('z', 893.1, ['zprime', "z'"]),
                                     ):
        wavelengths[name] = lambdaEff
        imageUtils.defineFilter(name, lambdaEff, alias=aliases)
    return wavelengths
Example #20
0
def defineSdssFilters():
    # Initialise filters as used for our tests
    imageUtils.resetFilters()
    wavelengths = dict()
    for name, lambdaEff, aliases in (('u', 355.1, []),
                                     ('g', 468.6, []),
                                     ('r', 616.5, []),
                                     ('i', 748.1, []),
                                     ('z', 893.1, ['zprime', "z'"]),
                                     ):
        wavelengths[name] = lambdaEff
        imageUtils.defineFilter(name, lambdaEff, alias=aliases)
    return wavelengths
Example #21
0
 def testLambdaMinMax(self):
     """Test additional properties for minimum and maximum wavelength for a filter."""
     filt = afwImage.Filter("g")
     # LambdaMin and LambdaMax are undefined for the test SDSS filter, and should return nan
     self.assertTrue(np.isnan(filt.getFilterProperty().getLambdaMin()))
     self.assertTrue(np.isnan(filt.getFilterProperty().getLambdaMax()))
     lambdaEff = 476.31
     lambdaMin = 405
     lambdaMax = 552
     imageUtils.defineFilter("gNew", lambdaEff, lambdaMin=lambdaMin, lambdaMax=lambdaMax)
     filtNew = afwImage.Filter("gNew")
     self.assertEqual(lambdaMin, filtNew.getFilterProperty().getLambdaMin())
     self.assertEqual(lambdaMax, filtNew.getFilterProperty().getLambdaMax())
    def setUp(self):
        # CFHT Filters from the camera mapper.
        afwImageUtils.resetFilters()
        afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
        afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
        afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
        afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
        afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")

        self.metadata = dafBase.PropertySet()

        self.metadata.set("SIMPLE", "T")
        self.metadata.set("BITPIX", -32)
        self.metadata.set("NAXIS", 2)
        self.metadata.set("NAXIS1", 1024)
        self.metadata.set("NAXIS2", 1153)
        self.metadata.set("RADECSYS", 'FK5')
        self.metadata.set("EQUINOX", 2000.)

        self.metadata.setDouble("CRVAL1", 215.604025685476)
        self.metadata.setDouble("CRVAL2", 53.1595451514076)
        self.metadata.setDouble("CRPIX1", 1109.99981456774)
        self.metadata.setDouble("CRPIX2", 560.018167811613)
        self.metadata.set("CTYPE1", 'RA---SIN')
        self.metadata.set("CTYPE2", 'DEC--SIN')

        self.metadata.setDouble("CD1_1", 5.10808596133527E-05)
        self.metadata.setDouble("CD1_2", 1.85579539217196E-07)
        self.metadata.setDouble("CD2_2", -5.10281493481982E-05)
        self.metadata.setDouble("CD2_1", -8.27440751733828E-07)

        self.wcs = afwGeom.makeSkyWcs(self.metadata)
        self.exposure = afwImage.makeExposure(
            afwImage.makeMaskedImageFromArrays(np.ones((1024, 1153))),
            self.wcs)
        detector = DetectorWrapper(id=23,
                                   bbox=self.exposure.getBBox()).detector
        visit = afwImage.VisitInfo(exposureId=4321,
                                   exposureTime=200.,
                                   date=dafBase.DateTime(nsecs=1400000000 *
                                                         10**9))
        self.exposure.setDetector(detector)
        self.exposure.getInfo().setVisitInfo(visit)
        self.exposure.setFilter(afwImage.Filter('g'))
        scale = 2
        scaleErr = 1
        self.photoCalib = afwImage.PhotoCalib(scale, scaleErr)
        self.exposure.setPhotoCalib(self.photoCalib)

        self.inputCatalogNoFlags = make_input_source_catalog(10, False)
        self.inputCatalog = make_input_source_catalog(10, True)
Example #23
0
    def __init__(self, **kwargs):

        #Define the policy file:
        policyFile = Policy.defaultPolicyFile(self.packageName, "GotoMapper.yaml", "policy")
        policy =Policy(policyFile)

        #Change the policy to point to the sim camera description:
        policy["camera"] = "../sim/camera"
        
        #This creates the camera class by calling CameraMapper (i.e., the parent class):
        super(GotoMapper, self).__init__(policy, os.path.dirname(policyFile), **kwargs)

        #Set the filters:
        self.filterIdMap = dict(v=0)
        afwImageUtils.defineFilter(name='R',  lambdaEff=635.9, alias=['R'])
        afwImageUtils.defineFilter(name='G',  lambdaEff=534.9, alias=['G'])
        afwImageUtils.defineFilter(name='B',  lambdaEff=446.6, alias=['B'])
        afwImageUtils.defineFilter(name='L',  lambdaEff=535.5, alias=['L'])
        
        self.filters = {}
        self.filters['R'] = afwImage.Filter('R').getCanonicalName()
        self.filters['G'] = afwImage.Filter('G').getCanonicalName()
        self.filters['B'] = afwImage.Filter('B').getCanonicalName()
        self.filters['L'] = afwImage.Filter('L').getCanonicalName()
        self.defaultFilterName = 'L'
Example #24
0
    def testNullWarpExposure(self, interpLength=10):
        """Test that warpExposure maps an image onto itself.

        Note:
        - NO_DATA and off-CCD pixels must be ignored
        - bad mask pixels get smeared out so we have to excluded all bad mask pixels
          from the output image when comparing masks.
        """
        imageUtils.defineFilter("i", 748.1)

        originalExposure = afwImage.ExposureF(originalExposurePath)
        originalExposure.getInfo().setVisitInfo(makeVisitInfo())
        originalFilter = afwImage.Filter("i")
        originalPhotoCalib = afwImage.PhotoCalib(1.0e5, 1.0e3)
        originalExposure.setFilter(originalFilter)
        originalExposure.setCalib(originalPhotoCalib)
        afwWarpedExposure = afwImage.ExposureF(
            originalExposure.getBBox(),
            originalExposure.getWcs())
        warpingControl = afwMath.WarpingControl(
            "lanczos4", "", 0, interpLength)
        afwMath.warpExposure(
            afwWarpedExposure, originalExposure, warpingControl)
        if SAVE_FITS_FILES:
            afwWarpedExposure.writeFits("afwWarpedExposureNull.fits")

        self.assertEqual(afwWarpedExposure.getFilter().getName(),
                         originalFilter.getName())
        self.assertEqual(afwWarpedExposure.getPhotoCalib(), originalPhotoCalib)
        self.assertEqual(afwWarpedExposure.getInfo().getVisitInfo(),
                         originalExposure.getInfo().getVisitInfo())

        afwWarpedMaskedImage = afwWarpedExposure.getMaskedImage()
        afwWarpedMask = afwWarpedMaskedImage.getMask()
        noDataBitMask = afwWarpedMask.getPlaneBitMask("NO_DATA")
        afwWarpedMaskedImageArrSet = afwWarpedMaskedImage.getArrays()
        afwWarpedMaskArr = afwWarpedMaskedImageArrSet[1]

        # compare all non-DATA pixels of image and variance, but relax specs a bit
        # because of minor noise introduced by bad pixels
        noDataMaskArr = afwWarpedMaskArr & noDataBitMask
        msg = "afw null-warped MaskedImage (all pixels, relaxed tolerance)"
        self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage, originalExposure.getMaskedImage(),
                                           doMask=False, skipMask=noDataMaskArr, atol=1e-5, msg=msg)

        # compare good pixels (mask=0) of image, mask and variance using full
        # tolerance
        msg = "afw null-warped MaskedImage (good pixels, max tolerance)"
        self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage, originalExposure.getMaskedImage(),
                                           skipMask=afwWarpedMask, msg=msg)
Example #25
0
 def testMultiPlaneFitsReaders(self):
     """Run tests for MaskedImageFitsReader and ExposureFitsReader.
     """
     metadata = PropertyList()
     metadata.add("FIVE", 5)
     metadata.add("SIX", 6.0)
     wcs = makeSkyWcs(Point2D(2.5, 3.75), SpherePoint(40.0*degrees, 50.0*degrees),
                      np.array([[1E-5, 0.0], [0.0, -1E-5]]))
     defineFilter("test_readers_filter", lambdaEff=470.0)
     calib = PhotoCalib(2.5E4)
     psf = GaussianPsf(21, 21, 8.0)
     polygon = Polygon(Box2D(self.bbox))
     apCorrMap = ApCorrMap()
     visitInfo = VisitInfo(exposureTime=5.0)
     transmissionCurve = TransmissionCurve.makeIdentity()
     coaddInputs = CoaddInputs(ExposureTable.makeMinimalSchema(), ExposureTable.makeMinimalSchema())
     detector = DetectorWrapper().detector
     record = coaddInputs.ccds.addNew()
     record.setWcs(wcs)
     record.setCalib(calib)
     record.setPsf(psf)
     record.setValidPolygon(polygon)
     record.setApCorrMap(apCorrMap)
     record.setVisitInfo(visitInfo)
     record.setTransmissionCurve(transmissionCurve)
     record.setDetector(detector)
     for n, dtypeIn in enumerate(self.dtypes):
         with self.subTest(dtypeIn=dtypeIn):
             exposureIn = Exposure(self.bbox, dtype=dtypeIn)
             shape = exposureIn.image.array.shape
             exposureIn.image.array[:, :] = np.random.randint(low=1, high=5, size=shape)
             exposureIn.mask.array[:, :] = np.random.randint(low=1, high=5, size=shape)
             exposureIn.variance.array[:, :] = np.random.randint(low=1, high=5, size=shape)
             exposureIn.setMetadata(metadata)
             exposureIn.setWcs(wcs)
             exposureIn.setFilter(Filter("test_readers_filter"))
             exposureIn.setCalib(calib)
             exposureIn.setPsf(psf)
             exposureIn.getInfo().setValidPolygon(polygon)
             exposureIn.getInfo().setApCorrMap(apCorrMap)
             exposureIn.getInfo().setVisitInfo(visitInfo)
             exposureIn.getInfo().setTransmissionCurve(transmissionCurve)
             exposureIn.getInfo().setCoaddInputs(coaddInputs)
             exposureIn.setDetector(detector)
             with lsst.utils.tests.getTempFilePath(".fits") as fileName:
                 exposureIn.writeFits(fileName)
                 self.checkMaskedImageFitsReader(exposureIn, fileName, self.dtypes[n:])
                 self.checkExposureFitsReader(exposureIn, fileName, self.dtypes[n:])
Example #26
0
 def testLambdaMinMax(self):
     """Test additional properties for minimum and maximum wavelength for a filter."""
     filt = afwImage.Filter("g")
     # LambdaMin and LambdaMax are undefined for the test SDSS filter, and should return nan
     self.assertTrue(np.isnan(filt.getFilterProperty().getLambdaMin()))
     self.assertTrue(np.isnan(filt.getFilterProperty().getLambdaMax()))
     lambdaEff = 476.31
     lambdaMin = 405
     lambdaMax = 552
     imageUtils.defineFilter("gNew",
                             lambdaEff,
                             lambdaMin=lambdaMin,
                             lambdaMax=lambdaMax)
     filtNew = afwImage.Filter("gNew")
     self.assertEqual(lambdaMin, filtNew.getFilterProperty().getLambdaMin())
     self.assertEqual(lambdaMax, filtNew.getFilterProperty().getLambdaMax())
Example #27
0
    def __init__(self, inputPolicy=None, **kwargs):
        """Initialization for the AuxTel Mapper."""
        policyFile = dafPersist.Policy.defaultPolicyFile(self.packageName, "auxTelMapper.yaml", "policy")
        policy = dafPersist.Policy(policyFile)

        CameraMapper.__init__(self, policy, os.path.dirname(policyFile), **kwargs)
        #
        # The composite objects don't seem to set these
        #
        for d in (self.mappings, self.exposures):
            d['raw'] = d['_raw']

        afwImageUtils.defineFilter('NONE', 0.0, alias=['no_filter', 'OPEN', 'empty'])
        afwImageUtils.defineFilter('275CutOn', 0.0, alias=[])
        afwImageUtils.defineFilter('550CutOn', 0.0, alias=[])
        afwImageUtils.defineFilter('green', 0.0, alias=[])
        afwImageUtils.defineFilter('blue', 0.0, alias=[])
Example #28
0
    def __init__(self, outputRoot=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_wiyn", "WhircMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
#        print policyFile.getRepositoryPath()
        super(WhircMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        afwImageUtils.defineFilter('OPEN', lambdaEff=1750)  # nm
        afwImageUtils.defineFilter('J' , lambdaEff=1250)
        afwImageUtils.defineFilter('H' , lambdaEff=1650)
        afwImageUtils.defineFilter('KS', lambdaEff=2175, alias=['Ks'])
Example #29
0
    def testBBox(self):
        """Test that the default bounding box includes all warped pixels
        """
        kernelName = "lanczos2"
        warper = afwMath.Warper(kernelName)
        originalExposure, swarpedImage, swarpedWcs = self.getSwarpedImage(
            kernelName=kernelName, useSubregion=True, useDeepCopy=False)

        imageUtils.defineFilter("i", 748.1)

        originalFilter = afwImage.Filter("i")
        originalCalib = afwImage.Calib()
        originalCalib.setFluxMag0(1.0e5, 1.0e3)
        originalExposure.setFilter(originalFilter)
        originalExposure.setCalib(originalCalib)

        warpedExposure1 = warper.warpExposure(destWcs=swarpedWcs,
                                              srcExposure=originalExposure)
        # the default size must include all good pixels, so growing the bbox
        # should not add any
        warpedExposure2 = warper.warpExposure(destWcs=swarpedWcs,
                                              srcExposure=originalExposure,
                                              border=1)
        # a bit of excess border is allowed, but surely not as much as 10 (in
        # fact it is approx. 5)
        warpedExposure3 = warper.warpExposure(destWcs=swarpedWcs,
                                              srcExposure=originalExposure,
                                              border=-10)
        # assert that warpedExposure and warpedExposure2 have the same number of non-no_data pixels
        # and that warpedExposure3 has fewer
        noDataBitMask = afwImage.Mask.getPlaneBitMask("NO_DATA")
        mask1Arr = warpedExposure1.getMaskedImage().getMask().getArray()
        mask2Arr = warpedExposure2.getMaskedImage().getMask().getArray()
        mask3Arr = warpedExposure3.getMaskedImage().getMask().getArray()
        nGood1 = (mask1Arr & noDataBitMask == 0).sum()
        nGood2 = (mask2Arr & noDataBitMask == 0).sum()
        nGood3 = (mask3Arr & noDataBitMask == 0).sum()
        self.assertEqual(nGood1, nGood2)
        self.assertLess(nGood3, nGood1)

        self.assertEqual(warpedExposure1.getFilter().getName(),
                         originalFilter.getName())
        self.assertEqual(warpedExposure1.getCalib().getFluxMag0(),
                         originalCalib.getFluxMag0())
Example #30
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile(self.packageName,
                                                 "ts3Mapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(),
                              **kwargs)

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {
            'visit': int,
            'ccd': int,
            'filter': str,
            'date': str,
            'expTime': float,
            'object': str,
            'imageType': str,
        }
        for name in (
                "raw",
                "raw_amp",
                # processCcd outputs
                "postISRCCD",
                "calexp",
                "postISRCCD",
                "src",
                "icSrc",
                "srcMatch",
        ):
            self.mappings[name].keyDict.update(keys)

        # @merlin, you should swap these out for the filters you actually intend to use.
        self.filterIdMap = {'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5}

        # The LSST Filters from L. Jones 04/07/10
        # afwImageUtils.defineFilter('u', 364.59)
        # afwImageUtils.defineFilter('g', 476.31, alias=["SDSSG"])
        # afwImageUtils.defineFilter('r', 619.42, alias=["SDSSR"])
        # afwImageUtils.defineFilter('i', 752.06, alias=["SDSSI"])
        # afwImageUtils.defineFilter('z', 866.85, alias=["SDSSZ"])
        # afwImageUtils.defineFilter('y', 971.68, alias=['y4'])  # official y filter
        afwImageUtils.defineFilter('550CutOn', 550.0)
        afwImageUtils.defineFilter('NONE', 0.0, alias=['no_filter', "OPEN"])
Example #31
0
    def __init__(self, outputRoot=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(
            self.packageName, "WhircMapper.yaml", "policy")
        policy = dafPersist.Policy(policyFile)

        CameraMapper.__init__(self, policy, os.path.dirname(policyFile),
                              **kwargs)

        afwImageUtils.defineFilter('OPAQUE', lambdaEff=0)  # nm
        afwImageUtils.defineFilter('OPEN', lambdaEff=1750)  # nm
        afwImageUtils.defineFilter('J', lambdaEff=1250)
        afwImageUtils.defineFilter('H', lambdaEff=1650)
        afwImageUtils.defineFilter('KS', lambdaEff=2175, alias=['Ks'])

        self._nbit_tract = 8
        self._nbit_patch = 8
        self._nbit_filter = 8

        self._nbit_id = 64 - (self._nbit_tract + 2*self._nbit_patch + self._nbit_filter)
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_file", "FileMapper.paf",
                                                 "policy")
        policy = pexPolicy.Policy(policyFile)
        if False:
            if not kwargs.get('root', None):
                raise RuntimeError("Please specify a root")
            if not kwargs.get('calibRoot', None):
                kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

        super(FileMapper,
              self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = dict(calexp=str, )
        for name in ("calexp", "src"):
            self.mappings[name].keyDict = keys

        # SDSS g': http://www.naoj.org/Observing/Instruments/SCam/txt/g.txt
        # SDSS r': http://www.naoj.org/Observing/Instruments/SCam/txt/r.txt
        # SDSS i': http://www.naoj.org/Observing/Instruments/SCam/txt/i.txt
        # SDSS z': http://www.naoj.org/Observing/Instruments/SCam/txt/z.txt
        # y-band: Shimasaku et al., 2005, PASJ, 57, 447

        afwImageUtils.resetFilters()

        afwImageUtils.defineFilter(name='g', lambdaEff=477, alias=['W-S-G+'])
        afwImageUtils.defineFilter(name='r', lambdaEff=623, alias=['W-S-R+'])
        afwImageUtils.defineFilter(name='i', lambdaEff=775, alias=['W-S-I+'])
        afwImageUtils.defineFilter(name='z', lambdaEff=925, alias=['W-S-Z+'])
        afwImageUtils.defineFilter(name='y', lambdaEff=990, alias=['W-S-ZR'])

        self.filters = {
            "W-S-G+": "g",
            "W-S-R+": "r",
            "W-S-I+": "i",
            "W-S-Z+": "z",
            "W-S-ZR": "y",
        }

        # next line makes a dict that maps filter names to sequential integers (arbitrarily sorted),
        # for use in generating unique IDs for sources.
        self.filterIdMap = dict(zip(self.filters, range(len(self.filters))))
Example #33
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_file", "FileMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        if False:
            if not kwargs.get('root', None):
                raise RuntimeError("Please specify a root")
            if not kwargs.get('calibRoot', None):
                kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

        super(FileMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)
        
        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = dict(calexp=str,
                )
        for name in ("calexp", "src"):
            self.mappings[name].keyDict = keys

        # SDSS g': http://www.naoj.org/Observing/Instruments/SCam/txt/g.txt
        # SDSS r': http://www.naoj.org/Observing/Instruments/SCam/txt/r.txt
        # SDSS i': http://www.naoj.org/Observing/Instruments/SCam/txt/i.txt
        # SDSS z': http://www.naoj.org/Observing/Instruments/SCam/txt/z.txt
        # y-band: Shimasaku et al., 2005, PASJ, 57, 447

        afwImageUtils.resetFilters()

        afwImageUtils.defineFilter(name='g', lambdaEff=477, alias=['W-S-G+'])
        afwImageUtils.defineFilter(name='r', lambdaEff=623, alias=['W-S-R+'])
        afwImageUtils.defineFilter(name='i', lambdaEff=775, alias=['W-S-I+'])
        afwImageUtils.defineFilter(name='z', lambdaEff=925, alias=['W-S-Z+'])
        afwImageUtils.defineFilter(name='y', lambdaEff=990, alias=['W-S-ZR'])
        
        self.filters = {
            "W-S-G+"  : "g",
            "W-S-R+"  : "r",
            "W-S-I+"  : "i",
            "W-S-Z+"  : "z",
            "W-S-ZR"  : "y",
            }

        # next line makes a dict that maps filter names to sequential integers (arbitrarily sorted),
        # for use in generating unique IDs for sources.
        self.filterIdMap = dict(zip(self.filters, range(len(self.filters))))
    def testFilters(self):
        """Test that the coadd filter is set correctly
        """
        imageUtils.defineFilter("g", 468.6)
        imageUtils.defineFilter("r", 616.5)

        unkFilter = afwImage.Filter()
        gFilter = afwImage.Filter("g")
        rFilter = afwImage.Filter("r")

        imShape = (150, 150)
        imSigma = 1.0
        imVariance = 1.0

        badMaskPlanes = ["EDGE"]

        np.random.seed(0)

        coadd = None
        maskedImage = afwTestUtils.makeGaussianNoiseMaskedImage(
            dimensions=imShape, sigma=imSigma, variance=imVariance)
        inExp = afwImage.ExposureF(maskedImage)

        coadd = coaddChiSq.Coadd(
            bbox=inExp.getBBox(),
            wcs=inExp.getWcs(),
            badMaskPlanes=badMaskPlanes,
        )

        inExp.setFilter(gFilter)
        coadd.addExposure(inExp)
        self.assertEqualFilters(coadd.getCoadd().getFilter(), gFilter)
        self.assertEqualFilterSets(coadd.getFilters(), (gFilter, ))
        coadd.addExposure(inExp)
        self.assertEqualFilters(coadd.getCoadd().getFilter(), gFilter)
        self.assertEqualFilterSets(coadd.getFilters(), (gFilter, ))

        inExp.setFilter(rFilter)
        coadd.addExposure(inExp)
        self.assertEqualFilters(coadd.getCoadd().getFilter(), unkFilter)
        self.assertEqualFilterSets(coadd.getFilters(), (gFilter, rFilter))
Example #35
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(self.packageName, "SdssMapper.yaml", "policy")
        policy = dafPersist.Policy(policyFile)

        self.doFootprints = False
        if inputPolicy is not None:
            for kw in inputPolicy.paramNames(True):
                if kw == "doFootprints":
                    self.doFootprints = True
                else:
                    kwargs[kw] = inputPolicy.get(kw)

        super(SdssMapper, self).__init__(policy, os.path.dirname(policyFile), **kwargs)
        # define filters?
        self.filterIdMap = dict(u=0, g=1, r=2, i=3, z=4)

        afwImageUtils.defineFilter('u', lambdaEff=380)
        afwImageUtils.defineFilter('g', lambdaEff=450)
        afwImageUtils.defineFilter('r', lambdaEff=600)
        afwImageUtils.defineFilter('i', lambdaEff=770)
        afwImageUtils.defineFilter('z', lambdaEff=900)
Example #36
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_sofi", "SOFIMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        super(SofiMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        # The "ccd" provided by the user is translated through the registry into an extension name for the "raw"
        # template.  The template therefore doesn't include "ccd", so we need to ensure it's explicitly included
        # so the ArgumentParser can recognise and accept it.

        self.exposures['raw'].keyDict['ccd'] = int

        afwImageUtils.defineFilter('Ks', lambdaEff=2175, alias=['KS'])
        self.filterIdMap = dict(Ks=0)

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {'pointing': str,
                'dateObs': str,
                'expTime': float,
                }
        for name in ("raw", "calexp", "postISRCCD", "src", "icSrc", "icMatch"):
            self.mappings[name].keyDict.update(keys)
Example #37
0
    def testBBox(self):
        """Test that the default bounding box includes all warped pixels
        """
        kernelName = "lanczos2"
        warper = afwMath.Warper(kernelName)
        originalExposure, swarpedImage, swarpedWcs = self.getSwarpedImage(
            kernelName=kernelName, useSubregion=True, useDeepCopy=False)

        imageUtils.defineFilter("i", 748.1)

        originalFilter = afwImage.Filter("i")
        originalPhotoCalib = afwImage.PhotoCalib(1.0e5, 1.0e3)
        originalExposure.setFilter(originalFilter)
        originalExposure.setCalib(originalPhotoCalib)

        warpedExposure1 = warper.warpExposure(
            destWcs=swarpedWcs, srcExposure=originalExposure)
        # the default size must include all good pixels, so growing the bbox
        # should not add any
        warpedExposure2 = warper.warpExposure(
            destWcs=swarpedWcs, srcExposure=originalExposure, border=1)
        # a bit of excess border is allowed, but surely not as much as 10 (in
        # fact it is approx. 5)
        warpedExposure3 = warper.warpExposure(
            destWcs=swarpedWcs, srcExposure=originalExposure, border=-10)
        # assert that warpedExposure and warpedExposure2 have the same number of non-no_data pixels
        # and that warpedExposure3 has fewer
        noDataBitMask = afwImage.Mask.getPlaneBitMask("NO_DATA")
        mask1Arr = warpedExposure1.getMaskedImage().getMask().getArray()
        mask2Arr = warpedExposure2.getMaskedImage().getMask().getArray()
        mask3Arr = warpedExposure3.getMaskedImage().getMask().getArray()
        nGood1 = (mask1Arr & noDataBitMask == 0).sum()
        nGood2 = (mask2Arr & noDataBitMask == 0).sum()
        nGood3 = (mask3Arr & noDataBitMask == 0).sum()
        self.assertEqual(nGood1, nGood2)
        self.assertLess(nGood3, nGood1)

        self.assertEqual(warpedExposure1.getFilter().getName(),
                         originalFilter.getName())
        self.assertEqual(warpedExposure1.getPhotoCalib(), originalPhotoCalib)
Example #38
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = Policy.defaultPolicyFile(self.packageName,
                                              "CtmoMapper.yaml", "policy")
        policy = Policy(policyFile)
        # ...and add it to the mapper:
        super(CtmoCamMapper,
              self).__init__(policy, os.path.dirname(policyFile), **kwargs)

        # Define your filter set
        # Create a dict of filters:
        self.filters = {}

        # Define your set of filters; you can have as many filters as you like...
        afwImageUtils.defineFilter(name="Clear",
                                   lambdaEff=535.5,
                                   alias=["Clear"])

        # ...add them to your filter dict...
        self.filters["Clear"] = afwImage.Filter("Clear").getCanonicalName()

        # ...and set your default filter.
        self.defaultFilterName = "Clear"
Example #39
0
    def testDcrCalculation(self):
        """Test that the shift in pixels due to DCR is consistently computed.

        The shift is compared to pre-computed values.
        """
        dcrNumSubfilters = 3
        afwImageUtils.defineFilter("gTest", self.lambdaEff,
                                   lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax)
        filterInfo = afwImage.Filter("gTest")
        rotAngle = 0.*degrees
        azimuth = 30.*degrees
        elevation = 65.*degrees
        pixelScale = 0.2*arcseconds
        visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
        wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec())
        dcrShift = calculateDcr(visitInfo, wcs, filterInfo, dcrNumSubfilters)
        # Compare to precomputed values.
        refShift = [(-0.5575567724366292, -0.2704095599533037),
                    (0.001961910992342903, 0.000951507567181944),
                    (0.40402552599550073, 0.19594841296051665)]
        for shiftOld, shiftNew in zip(refShift, dcrShift):
            self.assertFloatsAlmostEqual(shiftOld[1], shiftNew[1], rtol=1e-6, atol=1e-8)
            self.assertFloatsAlmostEqual(shiftOld[0], shiftNew[0], rtol=1e-6, atol=1e-8)
 def testDcrSubfilterOrder(self):
     """Test that the bluest subfilter always has the largest DCR amplitude.
     """
     dcrNumSubfilters = 3
     afwImageUtils.defineFilter("gTest", self.lambdaEff,
                                lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax)
     filterInfo = afwImage.Filter("gTest")
     pixelScale = 0.2*arcseconds
     for testIter in range(self.nRandIter):
         rotAngle = 360.*self.rng.rand()*degrees
         azimuth = 360.*self.rng.rand()*degrees
         elevation = (45. + self.rng.rand()*40.)*degrees  # Restrict to 45 < elevation < 85 degrees
         visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
         wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec())
         dcrShift = calculateDcr(visitInfo, wcs, filterInfo, dcrNumSubfilters)
         # First check that the blue subfilter amplitude is greater than the red subfilter
         rotation = calculateImageParallacticAngle(visitInfo, wcs).asRadians()
         ampShift = [dcr[1]*np.sin(rotation) + dcr[0]*np.cos(rotation) for dcr in dcrShift]
         self.assertGreater(ampShift[0], 0.)  # The blue subfilter should be shifted towards zenith
         self.assertLess(ampShift[2], 0.)  # The red subfilter should be shifted away from zenith
         # The absolute amplitude of the blue subfilter should also
         # be greater than that of the red subfilter
         self.assertGreater(np.abs(ampShift[0]), np.abs(ampShift[2]))
    def testDcrCalculation(self):
        """Test that the shift in pixels due to DCR is consistently computed.

        The shift is compared to pre-computed values.
        """
        dcrNumSubfilters = 3
        afwImageUtils.defineFilter("gTest", self.lambdaEff,
                                   lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax)
        filterInfo = afwImage.Filter("gTest")
        rotAngle = 0.*degrees
        azimuth = 30.*degrees
        elevation = 65.*degrees
        pixelScale = 0.2*arcseconds
        visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
        wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec())
        dcrShift = calculateDcr(visitInfo, wcs, filterInfo, dcrNumSubfilters)
        # Compare to precomputed values.
        refShift = [(-0.5363512808, -0.3103517169),
                    (0.001887293861, 0.001092054612),
                    (0.3886592703, 0.2248919247)]
        for shiftOld, shiftNew in zip(refShift, dcrShift):
            self.assertFloatsAlmostEqual(shiftOld[1], shiftNew[1], rtol=1e-6, atol=1e-8)
            self.assertFloatsAlmostEqual(shiftOld[0], shiftNew[0], rtol=1e-6, atol=1e-8)
Example #42
0
 def testDcrSubfilterOrder(self):
     """Test that the bluest subfilter always has the largest DCR amplitude.
     """
     dcrNumSubfilters = 3
     afwImageUtils.defineFilter("gTest", self.lambdaEff,
                                lambdaMin=self.lambdaMin, lambdaMax=self.lambdaMax)
     filterInfo = afwImage.Filter("gTest")
     pixelScale = 0.2*arcseconds
     for testIter in range(self.nRandIter):
         rotAngle = 360.*self.rng.rand()*degrees
         azimuth = 360.*self.rng.rand()*degrees
         elevation = (45. + self.rng.rand()*40.)*degrees  # Restrict to 45 < elevation < 85 degrees
         visitInfo = self.makeDummyVisitInfo(azimuth, elevation)
         wcs = self.makeDummyWcs(rotAngle, pixelScale, crval=visitInfo.getBoresightRaDec())
         dcrShift = calculateDcr(visitInfo, wcs, filterInfo, dcrNumSubfilters)
         # First check that the blue subfilter amplitude is greater than the red subfilter
         rotation = calculateImageParallacticAngle(visitInfo, wcs).asRadians()
         ampShift = [dcr[1]*np.sin(rotation) + dcr[0]*np.cos(rotation) for dcr in dcrShift]
         self.assertGreater(ampShift[0], 0.)  # The blue subfilter should be shifted towards zenith
         self.assertLess(ampShift[2], 0.)  # The red subfilter should be shifted away from zenith
         # The absolute amplitude of the blue subfilter should also
         # be greater than that of the red subfilter
         self.assertGreater(np.abs(ampShift[0]), np.abs(ampShift[2]))
Example #43
0
    def __init__(self, inputPolicy=None, **kwargs):

        #Define the policy file:
        policyFile = Policy.defaultPolicyFile(self.packageName,
                                              "GotoMapper.yaml", "policy")
        policy = Policy(policyFile)

        #This creates the camera class by calling CameraMapper (i.e., the parent class):
        super(GotoMapper, self).__init__(policy, os.path.dirname(policyFile),
                                         **kwargs)

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {
            'visit': int,
            'ccd': int,
            'filter': str,
            'dataType': str,
            'expTime': float,
            'dateObs': str,
            'taiObs': str,
            'mjd': int,
            'field': str,
            'survey': str
        }
        for name in (
                "raw",
                "postISRCCD",
                "calexp",
                "src",
                "icSrc",
                "srcMatch",
        ):
            self.mappings[name].keyDict.update(keys)

        #Set the filters:
        self.filterIdMap = dict(v=0)
        afwImageUtils.defineFilter(name='R', lambdaEff=635.9, alias=['R'])
        afwImageUtils.defineFilter(name='G', lambdaEff=534.9, alias=['G'])
        afwImageUtils.defineFilter(name='B', lambdaEff=446.6, alias=['B'])
        afwImageUtils.defineFilter(name='L', lambdaEff=535.5, alias=['L'])

        self.filters = {}
        self.filters['R'] = afwImage.Filter('R').getCanonicalName()
        self.filters['G'] = afwImage.Filter('G').getCanonicalName()
        self.filters['B'] = afwImage.Filter('B').getCanonicalName()
        self.filters['L'] = afwImage.Filter('L').getCanonicalName()
        self.defaultFilterName = 'L'
Example #44
0
    def setUp(self):
        maskedImage = afwImage.MaskedImageF(inFilePathSmall)
        maskedImageMD = readMetadata(inFilePathSmall)

        self.smallExposure = afwImage.ExposureF(inFilePathSmall)
        self.width = maskedImage.getWidth()
        self.height = maskedImage.getHeight()
        self.wcs = afwGeom.makeSkyWcs(maskedImageMD, False)
        self.md = maskedImageMD
        self.psf = DummyPsf(2.0)
        self.detector = DetectorWrapper().detector

        self.exposureBlank = afwImage.ExposureF()
        self.exposureMiOnly = afwImage.makeExposure(maskedImage)
        self.exposureMiWcs = afwImage.makeExposure(maskedImage, self.wcs)
        # n.b. the (100, 100, ...) form
        self.exposureCrWcs = afwImage.ExposureF(100, 100, self.wcs)
        # test with ExtentI(100, 100) too
        self.exposureCrOnly = afwImage.ExposureF(lsst.geom.ExtentI(100, 100))

        afwImage.Filter.reset()
        afwImage.FilterProperty.reset()

        defineFilter("g", 470.0)
Example #45
0
    def defineFilters(self):
        afwImageUtils.resetFilters()
        
        afwImageUtils.defineFilter('NONE', lambdaEff=0)

        # Johnson filters
        afwImageUtils.defineFilter('U',  lambdaEff=300,  alias=['W-J-U'])
        afwImageUtils.defineFilter('B',  lambdaEff=400,  alias=['W-J-B'])
        afwImageUtils.defineFilter('V',  lambdaEff=550,  alias=['W-J-V'])
        afwImageUtils.defineFilter('VR', lambdaEff=600,  alias=['W-J-VR'])

        # Cousins filters
        afwImageUtils.defineFilter('R',  lambdaEff=650,  alias=['W-C-RC'])
        afwImageUtils.defineFilter('I',  lambdaEff=800,  alias=['W-C-IC'])

        # Sloan filters
        afwImageUtils.defineFilter('g',  lambdaEff=450,  alias=['W-S-G+'])
        afwImageUtils.defineFilter('r',  lambdaEff=600,  alias=['W-S-R+'])
        afwImageUtils.defineFilter('i',  lambdaEff=770,  alias=['W-S-I+'])
        afwImageUtils.defineFilter('z',  lambdaEff=900,  alias=['W-S-Z+'])
        afwImageUtils.defineFilter('y',  lambdaEff=1000, alias=['W-S-ZR'])

        # Narrow-band filters
        afwImageUtils.defineFilter("NA503", lambdaEff=503, alias=['N-A-L503'])
        afwImageUtils.defineFilter("NA651", lambdaEff=651, alias=['N-A-L651'])
        afwImageUtils.defineFilter("NA656", lambdaEff=656, alias=['N-A-L656'])
        afwImageUtils.defineFilter("NA659", lambdaEff=659, alias=['N-A-L659'])
        afwImageUtils.defineFilter("NA671", lambdaEff=671, alias=['N-A-L671'])

        afwImageUtils.defineFilter('NB1006', lambdaEff=1006, alias=['N-B-1006'])
        afwImageUtils.defineFilter('NB1010', lambdaEff=1010, alias=['N-B-1010'])
        afwImageUtils.defineFilter('NB100',  lambdaEff=100,  alias=['N-B-L100'])
        afwImageUtils.defineFilter('NB359',  lambdaEff=359,  alias=['N-B-L359'])
        afwImageUtils.defineFilter('NB387',  lambdaEff=387,  alias=['N-B-L387'])
        afwImageUtils.defineFilter('NB413',  lambdaEff=413,  alias=['N-B-L413'])
        afwImageUtils.defineFilter('NB497',  lambdaEff=497,  alias=['N-B-L497'])
        afwImageUtils.defineFilter('NB515',  lambdaEff=515,  alias=['N-B-L515'])
        afwImageUtils.defineFilter('NB570',  lambdaEff=570,  alias=['N-B-L570'])
        afwImageUtils.defineFilter('NB704',  lambdaEff=704,  alias=['N-B-L704'])
        afwImageUtils.defineFilter('NB711',  lambdaEff=711,  alias=['N-B-L711'])
        afwImageUtils.defineFilter('NB816',  lambdaEff=816,  alias=['N-B-L816'])
        afwImageUtils.defineFilter('NB818',  lambdaEff=818,  alias=['N-B-L818'])
        afwImageUtils.defineFilter('NB912',  lambdaEff=912,  alias=['N-B-L912'])
        afwImageUtils.defineFilter('NB921',  lambdaEff=921,  alias=['N-B-L921'])
        afwImageUtils.defineFilter('NB973',  lambdaEff=973,  alias=['N-B-L973'])

        # Intermediate-band filters
        afwImageUtils.defineFilter("L427", lambdaEff=427, alias=['I-A-L427'])
        afwImageUtils.defineFilter("L445", lambdaEff=445, alias=['I-A-L445'])
        afwImageUtils.defineFilter("L464", lambdaEff=464, alias=['I-A-L464'])
        afwImageUtils.defineFilter("L484", lambdaEff=484, alias=['I-A-L484'])
        afwImageUtils.defineFilter("L505", lambdaEff=505, alias=['I-A-L505'])
        afwImageUtils.defineFilter("L527", lambdaEff=527, alias=['I-A-L527'])
        afwImageUtils.defineFilter("L550", lambdaEff=550, alias=['I-A-L550'])
        afwImageUtils.defineFilter("L574", lambdaEff=574, alias=['I-A-L574'])
        afwImageUtils.defineFilter("L598", lambdaEff=598, alias=['I-A-L598'])
        afwImageUtils.defineFilter("L624", lambdaEff=624, alias=['I-A-L624'])
        afwImageUtils.defineFilter("L651", lambdaEff=651, alias=['I-A-L651'])
        afwImageUtils.defineFilter("L679", lambdaEff=679, alias=['I-A-L679'])
        afwImageUtils.defineFilter("L709", lambdaEff=709, alias=['I-A-L709'])
        afwImageUtils.defineFilter("L738", lambdaEff=738, alias=['I-A-L738'])
        afwImageUtils.defineFilter("L767", lambdaEff=767, alias=['I-A-L767'])
        afwImageUtils.defineFilter("L797", lambdaEff=797, alias=['I-A-L797'])
        afwImageUtils.defineFilter("L827", lambdaEff=827, alias=['I-A-L827'])
        afwImageUtils.defineFilter("L856", lambdaEff=856, alias=['I-A-L856'])
        afwImageUtils.defineFilter("L856", lambdaEff=856, alias=['I-A-L856'])

        # Unknown/custom filters
        afwImageUtils.defineFilter("B030", lambdaEff=0, alias=['G-A-B030'])
        afwImageUtils.defineFilter("R030", lambdaEff=0, alias=['G-A-R030'])
        afwImageUtils.defineFilter("P550", lambdaEff=0, alias=['P-A-L550'])
        afwImageUtils.defineFilter("SN01", lambdaEff=0, alias=['S-A-SN01'])
        afwImageUtils.defineFilter("SN02", lambdaEff=0, alias=['S-A-SN02'])
        afwImageUtils.defineFilter("Y",    lambdaEff=0, alias=['W-A-Y'])
        afwImageUtils.defineFilter("ZB",   lambdaEff=0, alias=['W-S-ZB'])


        self.filters = {
            "W-J-U"   : "U",
            "W-J-B"   : "B",
            "W-J-V"   : "V",
            "W-J-VR"  : "VR",
            "W-C-RC"  : "R",
            "W-C-IC"  : "I",
            "W-S-G+"  : "g",
            "W-S-R+"  : "r",
            "W-S-I+"  : "i",
            "W-S-Z+"  : "z",
            "W-S-ZR"  : "y",
            'N-A-L503': "NA503",
            'N-A-L651': "NA651",
            'N-A-L656': "NA656",
            'N-A-L659': "NA659",
            'N-A-L671': "NA671",
            'N-B-1006': 'NB1006',
            'N-B-1010': 'NB1010',
            'N-B-L100': 'NB100',
            'N-B-L359': 'NB359',
            'N-B-L387': 'NB387',
            'N-B-L413': 'NB413',
            'N-B-L497': 'NB497',
            'N-B-L515': 'NB515',
            'N-B-L570': 'NB570',
            'N-B-L704': 'NB704',
            'N-B-L711': 'NB711',
            'N-B-L816': 'NB816',
            'N-B-L818': 'NB818',
            'N-B-L912': 'NB912',
            'N-B-L921': 'NB921',
            'N-B-L973': 'NB973',
            "I-A-L427": "L427",
            "I-A-L445": "L445",
            "I-A-L464": "L464",
            "I-A-L484": "L484",
            "I-A-L505": "L505",
            "I-A-L527": "L527",
            "I-A-L550": "L550",
            "I-A-L574": "L574",
            "I-A-L598": "L598",
            "I-A-L624": "L624",
            "I-A-L651": "L651",
            "I-A-L679": "L679",
            "I-A-L709": "L709",
            "I-A-L738": "L738",
            "I-A-L767": "L767",
            "I-A-L797": "L797",
            "I-A-L827": "L827",
            "I-A-L856": "L856",
            'G-A-B030': "B030",
            'G-A-R030': "R030",
            'P-A-L550': "P550",
            'S-A-SN01': "SN01",
            'S-A-SN02': "SN02",
            'W-A-Y'   : "Y",
            'W-S-ZB'  : "ZB",
            }


        # next line makes a dict that maps filter names to sequential integers (arbitrarily sorted),
        # for use in generating unique IDs for sources.
        self.filterIdMap = dict(zip(self.filters, range(len(self.filters))))
Example #46
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "DecamMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        super(DecamMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        afwImageUtils.defineFilter('u', lambdaEff=350, alias=['u DECam c0006 3500.0 1000.0'])
        afwImageUtils.defineFilter('g', lambdaEff=450, alias=['g DECam SDSS c0001 4720.0 1520.0'])
        afwImageUtils.defineFilter('r', lambdaEff=600, alias=['r DECam SDSS c0002 6415.0 1480.0'])
        afwImageUtils.defineFilter('i', lambdaEff=750, alias=['i DECam SDSS c0003 7835.0 1470.0'])
        afwImageUtils.defineFilter('z', lambdaEff=900, alias=['z DECam SDSS c0004 9260.0 1520.0'])
        afwImageUtils.defineFilter('y', lambdaEff=1000, alias=['Y DECam c0005 10095.0 1130.0'])

        # The data ID key ccdnum is not directly used in the current policy
        # template of the raw dataset, so is not in its keyDict automatically.
        # Add it so raw dataset know about the data ID key ccdnum.
        self.mappings["raw"].keyDict.update({'ccdnum': int})

        # The number of bits allocated for fields in object IDs
        # TODO: This needs to be updated; also see Trac #2797
        DecamMapper._nbit_tract = 10
        DecamMapper._nbit_patch = 10
        DecamMapper._nbit_filter = 4
        DecamMapper._nbit_id = 64 - (DecamMapper._nbit_tract +
                                     2*DecamMapper._nbit_patch +
                                     DecamMapper._nbit_filter)
Example #47
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "DecamMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        super(DecamMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        afwImageUtils.defineFilter('u', lambdaEff=350, alias=['u DECam c0006 3500.0 1000.0'])
        afwImageUtils.defineFilter('g', lambdaEff=450, alias=['g DECam SDSS c0001 4720.0 1520.0'])
        afwImageUtils.defineFilter('r', lambdaEff=600, alias=['r DECam SDSS c0002 6415.0 1480.0'])
        afwImageUtils.defineFilter('i', lambdaEff=750, alias=['i DECam SDSS c0003 7835.0 1470.0'])
        afwImageUtils.defineFilter('z', lambdaEff=900, alias=['z DECam SDSS c0004 9260.0 1520.0'])
        afwImageUtils.defineFilter('y', lambdaEff=1000, alias=['Y DECam c0005 10095.0 1130.0'])
import pdb
import unittest

import lsst.utils.tests as utilsTests
import lsst.daf.base as dafBase
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
import lsst.afw.geom as afwGeom
import lsst.afw.geom.ellipses as afwGeomEllipses
import lsst.afw.table as afwTable
import lsst.ap.cluster as apCluster
import lsst.ap.match as apMatch


# Usually defined by lsst.obs.lsstSim.LsstSimMapper
afwImageUtils.defineFilter('u', 364.59)
afwImageUtils.defineFilter('g', 476.31)
afwImageUtils.defineFilter('r', 619.42)
afwImageUtils.defineFilter('i', 752.06)
afwImageUtils.defineFilter('z', 866.85)
afwImageUtils.defineFilter('y', 971.68)

class SourceClusterAttributesTestCase(unittest.TestCase):
    """Test case for source cluster attribute computation.
    """
    def setUp(self):
        # Setup bogus exposure information
        self.exposures = apMatch.ExposureInfoMap()
        for filter in "ugrizy":
            filterId = afwImage.Filter(filter).getId()
            ps = dafBase.PropertySet()
Example #49
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_decam", "DecamMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        super(DecamMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        afwImageUtils.defineFilter('u', lambdaEff=350)
        afwImageUtils.defineFilter('g', lambdaEff=450)
        afwImageUtils.defineFilter('r', lambdaEff=600)
        afwImageUtils.defineFilter('i', lambdaEff=750)
        afwImageUtils.defineFilter('z', lambdaEff=900)
        afwImageUtils.defineFilter('y', lambdaEff=1000, alias='Y') # Urgh!
Example #50
0
nx = 10
ny = 10
exp = lsst.afw.image.ExposureF(nx, ny)

# Fill the maskedImage
exp.maskedImage.image.array = np.arange(nx*ny, dtype='f').reshape(nx, ny)
exp.maskedImage.variance.array = np.ones((nx, ny), dtype='f')
exp.maskedImage.mask.array[5, 5] = 5  # make one pixel non-zero

# Fill the detector
detectorWrapper = DetectorWrapper(bbox=exp.getBBox())
exp.setDetector(detectorWrapper.detector)

# Fill the filter
resetFilters()
defineFilter('ha', 656.28)
filt = lsst.afw.image.Filter('ha')
exp.setFilter(filt)

# Fill the PhotoCalib
photoCalib = lsst.afw.image.PhotoCalib(1e6, 2e4)
exp.setPhotoCalib(photoCalib)

# Fill the SkyWcs
ra = 30.0 * lsst.geom.degrees
dec = 40.0 * lsst.geom.degrees
cdMatrix = lsst.afw.geom.makeCdMatrix(scale=0.2*lsst.geom.arcseconds, orientation=45*lsst.geom.degrees)
crpix = lsst.geom.Point2D(4, 4)
crval = lsst.geom.SpherePoint(ra, dec)
skyWcs = lsst.afw.geom.makeSkyWcs(crpix=crpix, crval=crval, cdMatrix=cdMatrix)
exp.setWcs(skyWcs)
Example #51
0
 def addFilters(cls):
     afwImageUtils.resetFilters()
     for kwds in HSC_FILTER_DEFINITIONS:
         afwImageUtils.defineFilter(**kwds)
Example #52
0
#!/usr/bin/env python

from lsst.afw.image.utils import defineFilter

# Effective wavelengths from Fukugita et al., 1996AJ....111.1748F
# Table 2a (1.2 airmass, first row)
defineFilter("u'", 355.7)
defineFilter("g'", 482.5)
defineFilter("r'", 626.1)
defineFilter("i'", 767.2)
defineFilter("z'", 909.7)
Example #53
0
 def __init__(self, root, parentRegistry=None, repositoryCfg=None):
     policyFilePath = dafPersist.Policy.defaultPolicyFile(
         self.packageName, "testCalexpMetadataObjects.yaml", "policy")
     policy = dafPersist.Policy(policyFilePath)
     super(MapperForTestCalexpMetadataObjects, self).__init__(
         policy, repositoryDir=root, root=root, parentRegistry=None, repositoryCfg=None)
     self.filterIdMap = {
         'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}
     # The LSST Filters from L. Jones 04/07/10
     afwImageUtils.defineFilter('u', 364.59)
     afwImageUtils.defineFilter('g', 476.31)
     afwImageUtils.defineFilter('r', 619.42)
     afwImageUtils.defineFilter('i', 752.06)
     afwImageUtils.defineFilter('z', 866.85)
     afwImageUtils.defineFilter('y', 971.68, alias=['y4'])  # official y filter
Example #54
0
    def __init__(self, outputRoot=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_sst", "SstMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        super(SstMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        afwImageUtils.defineFilter('OPEN', lambdaEff=650)
Example #55
0
 def __init__(self, root):
     super(SimpleMapper, self).__init__()
     self.root = root
     self.camera = makeSimpleCamera(nX=1, nY=2, sizeX=400, sizeY=200, gapX=2, gapY=2)
     afwImageUtils.defineFilter('r', 619.42)
     self.update()
Example #56
0
    def __init__(self, **kwargs):
        policyFile = Policy.defaultPolicyFile("obs_cfht", "MegacamMapper.yaml", "policy")
        policy = Policy(policyFile)
        super(MegacamMapper, self).__init__(policy, os.path.dirname(policyFile), **kwargs)

        # The "ccd" provided by the user is translated through the registry
        # into an extension name for the "raw" template.  The template
        # therefore doesn't include "ccd", so we need to ensure it's
        # explicitly included so the ArgumentParser can recognise and accept
        # it.

        self.exposures['raw'].keyDict['ccd'] = int

        afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
        afwImageUtils.defineFilter('u2', lambdaEff=354, alias="u.MP9302")
        afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
        afwImageUtils.defineFilter('g2', lambdaEff=472, alias="g.MP9402")
        afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
        afwImageUtils.defineFilter('r2', lambdaEff=640, alias="r.MP9602")
        afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
        afwImageUtils.defineFilter('i2', lambdaEff=764, alias="i.MP9702")
        afwImageUtils.defineFilter('i3', lambdaEff=776, alias="i.MP9703")
        afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")
        afwImageUtils.defineFilter('z2', lambdaEff=926, alias="z.MP9901")

        # define filters?
        self.filterIdMap = dict(u=0, g=1, r=2, i=3, z=4, i2=5, u2=6, g2=7, r2=8, i3=9, z2=10)

        # Ensure each dataset type of interest knows about the full range of
        # keys available from the registry
        keys = {'runId': str,
                'object': str,
                'visit': int,
                'ccd': int,
                'extension': int,
                'state': str,
                'filter': str,
                'date': str,
                'taiObs': str,
                'expTime': float,
                }
        for name in ("raw", "calexp", "postISRCCD", "src", "icSrc", "icMatch"):
            self.mappings[name].keyDict.update(keys)
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "testMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)

        self.doFootprints = False
        if inputPolicy is not None:
            for kw in inputPolicy.paramNames(True):
                if kw == "doFootprints":
                    self.doFootprints = True
                else:
                    kwargs[kw] = inputPolicy.get(kw)

        CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(), **kwargs)
        self.filterIdMap = {
                'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5}

        # The LSST Filters from L. Jones 04/07/10
        afwImageUtils.defineFilter('u', 364.59)
        afwImageUtils.defineFilter('g', 476.31)
        afwImageUtils.defineFilter('r', 619.42)
        afwImageUtils.defineFilter('i', 752.06)
        afwImageUtils.defineFilter('z', 866.85)
        afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
Example #58
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_cfht", "MegacamMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        super(MegacamMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs)

        # The "ccd" provided by the user is translated through the registry into an extension name for the "raw"
        # template.  The template therefore doesn't include "ccd", so we need to ensure it's explicitly included
        # so the ArgumentParser can recognise and accept it.
        for mapping in self.exposures.values():
            if 'visit' in mapping.keyDict:
                mapping.keyDict['ccd'] = int

        afwImageUtils.defineFilter('u', lambdaEff=350, alias="u.MP9301")
        afwImageUtils.defineFilter('g', lambdaEff=450, alias="g.MP9401")
        afwImageUtils.defineFilter('r', lambdaEff=600, alias="r.MP9601")
        afwImageUtils.defineFilter('i', lambdaEff=750, alias="i.MP9701")
        afwImageUtils.defineFilter('i2', lambdaEff=750, alias="i.MP9702")
        afwImageUtils.defineFilter('z', lambdaEff=900, alias="z.MP9801")

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {'runId': str,
                'object': str,
                'visit': int,
                'ccd': int,
                'extension': int,
                'state': str,
                'filter': str,
                'date': str,
                'taiObs': str,
                'expTime': float,
                }
        for name in ("raw", "calexp", "postISRCCD", "src"):
            self.mappings[name].keyDict.update(keys)