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, inputPolicy=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(
            self.packageName, "LsstSimMapper.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(LsstSimMapper,
              self).__init__(policy, os.path.dirname(policyFile), **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.resetFilters()
        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
Beispiel #3
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(self.packageName, "LsstSimMapper.yaml", "policy")
        policy = dafPersist.Policy(policyFile)
        repositoryDir = os.path.join(getPackageDir(self.packageName), 'policy')
        self.defectRegistry = None
        if 'defects' in policy:
            self.defectPath = os.path.join(repositoryDir, policy['defects'])
            defectRegistryLocation = os.path.join(self.defectPath, "defectRegistry.sqlite3")
            self.defectRegistry = dafPersist.Registry.create(defectRegistryLocation)

        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(LsstSimMapper, self).__init__(policy, os.path.dirname(policyFile), **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.resetFilters()
        afwImageUtils.defineFilter('u', lambdaEff=364.59, lambdaMin=324.0, lambdaMax=395.0)
        afwImageUtils.defineFilter('g', lambdaEff=476.31, lambdaMin=405.0, lambdaMax=552.0)
        afwImageUtils.defineFilter('r', lambdaEff=619.42, lambdaMin=552.0, lambdaMax=691.0)
        afwImageUtils.defineFilter('i', lambdaEff=752.06, lambdaMin=818.0, lambdaMax=921.0)
        afwImageUtils.defineFilter('z', lambdaEff=866.85, lambdaMin=922.0, lambdaMax=997.0)
        # official y filter
        afwImageUtils.defineFilter('y', lambdaEff=971.68, lambdaMin=975.0, lambdaMax=1075.0, alias=['y4'])
Beispiel #4
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"]
Beispiel #6
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)
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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
    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)
Beispiel #11
0
 def defineFilters(cls):
     # 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('NONE', 0.0, alias=['no_filter', "OPEN"])
     afwImageUtils.defineFilter('275CutOn', 0.0, alias=[])
     afwImageUtils.defineFilter('550CutOn', 0.0, alias=[])
     # The LSST Filters from L. Jones 04/07/10
     afwImageUtils.defineFilter('u', lambdaEff=364.59, lambdaMin=324.0, lambdaMax=395.0)
     afwImageUtils.defineFilter('g', lambdaEff=476.31, lambdaMin=405.0, lambdaMax=552.0)
     afwImageUtils.defineFilter('r', lambdaEff=619.42, lambdaMin=552.0, lambdaMax=691.0)
     afwImageUtils.defineFilter('i', lambdaEff=752.06, lambdaMin=818.0, lambdaMax=921.0)
     afwImageUtils.defineFilter('z', lambdaEff=866.85, lambdaMin=922.0, lambdaMax=997.0)
     # official y filter
     afwImageUtils.defineFilter('y', lambdaEff=971.68, lambdaMin=975.0, lambdaMax=1075.0, alias=['y4'])
Beispiel #12
0
    def __init__(self, **kwargs):
        policyFile = dafPersistence.Policy.defaultPolicyFile(
            self.packageName, "ztfMapper.yaml", "policy")
        policy = dafPersistence.Policy(policyFile)
        #
        # Look for the calibrations root "root/CALIB" if not supplied
        #
        if kwargs.get('root', None) and not kwargs.get('calibRoot', None):
            calibSearch = [os.path.join(kwargs['root'], 'CALIB')]
            if "repositoryCfg" in kwargs:
                calibSearch += [
                    os.path.join(cfg.root, 'CALIB')
                    for cfg in kwargs["repositoryCfg"].parents
                    if hasattr(cfg, "root")
                ]
                calibSearch += [
                    cfg.root for cfg in kwargs["repositoryCfg"].parents
                    if hasattr(cfg, "root")
                ]
            for calibRoot in calibSearch:
                if os.path.exists(
                        os.path.join(calibRoot, "calibRegistry.sqlite3")):
                    kwargs['calibRoot'] = calibRoot
                    break
            if not kwargs.get('calibRoot', None):
                lsst.log.Log.getLogger("ZtfCamMapper").warn(
                    "Unable to find valid calib root directory")

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

        afwImageUtils.resetFilters()
        afwImageUtils.defineFilter('NONE', 0.0)
        afwImageUtils.defineFilter('ZTF_g', 0.0, alias=['g'])
        afwImageUtils.defineFilter('ZTF_r', 0.0, alias=['r'])
        afwImageUtils.defineFilter('ZTF_i', 0.0, alias=['i'])

        ZtfMapper._nbit_tract = 16
        ZtfMapper._nbit_patch = 5
        ZtfMapper._nbit_filter = 6

        ZtfMapper._nbit_id = 64 - (ZtfMapper._nbit_tract +
                                   2 * ZtfMapper._nbit_patch +
                                   ZtfMapper._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))))
Beispiel #14
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))))
Beispiel #15
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(fileroot=str, )
        for name in ("calexp", "src"):
            self.mappings[name].keyDict = keys

        afwImageUtils.resetFilters()

        afwImageUtils.defineFilter(name='tmp', lambdaEff=0.)
        afwImageUtils.defineFilter(name='J', lambdaEff=1230)  # nm
        afwImageUtils.defineFilter(name='H', lambdaEff=1650)
        afwImageUtils.defineFilter(name='K', lambdaEff=2180)
        afwImageUtils.defineFilter(name='KS', lambdaEff=2180)

        self.filters = {
            "tmp": "tmp",
            "J": "J",
            "H": "H",
            "K": "K",
            "KS": "KS",
        }

        # 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))))
Beispiel #16
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(self.packageName, "LsstSimMapper.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(LsstSimMapper, self).__init__(policy, os.path.dirname(policyFile), **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.resetFilters()
        afwImageUtils.defineFilter('u', lambdaEff=364.59, lambdaMin=324.0, lambdaMax=395.0)
        afwImageUtils.defineFilter('g', lambdaEff=476.31, lambdaMin=405.0, lambdaMax=552.0)
        afwImageUtils.defineFilter('r', lambdaEff=619.42, lambdaMin=552.0, lambdaMax=691.0)
        afwImageUtils.defineFilter('i', lambdaEff=752.06, lambdaMin=818.0, lambdaMax=921.0)
        afwImageUtils.defineFilter('z', lambdaEff=866.85, lambdaMin=922.0, lambdaMax=997.0)
        # official y filter
        afwImageUtils.defineFilter('y', lambdaEff=971.68, lambdaMin=975.0, lambdaMax=1075.0, alias=['y4'])
    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))))
    def setUp(self):
        # CFHT Filters from the camera mapper.
        self.filter_names = ["u", "g", "r", "i", "z"]
        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")

        # metadata taken from CFHT data
        # v695856-e0/v695856-e0-c000-a00.sci_img.fits
        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.calibration = 10000
        self.calibrationErr = 100
        self.exposureId = 1234
        self.exposureTime = 200.
        self.imageSize = [1024, 1153]
        self.dateTime = "2014-05-13T17:00:00.000000000"

        # Make images  with one source in them and distinct values and
        # variance for each image.
        # Direct Image
        source_image = afwImage.MaskedImageF(
            lsst.geom.ExtentI(self.imageSize[0] + 1, self.imageSize[1] + 1))
        source_image.image[100, 100, afwImage.LOCAL] = 10
        source_image.getVariance().set(1)
        bbox = lsst.geom.BoxI(
            lsst.geom.PointI(1, 1),
            lsst.geom.ExtentI(self.imageSize[0], self.imageSize[1]))
        masked_image = afwImage.MaskedImageF(source_image, bbox,
                                             afwImage.LOCAL)
        self.exposure = afwImage.makeExposure(masked_image, self.wcs)

        detector = DetectorWrapper(id=23,
                                   bbox=self.exposure.getBBox()).detector
        visit = afwImage.VisitInfo(exposureId=self.exposureId,
                                   exposureTime=self.exposureTime,
                                   date=dafBase.DateTime(
                                       self.dateTime,
                                       dafBase.DateTime.Timescale.TAI))
        self.exposure.setDetector(detector)
        self.exposure.getInfo().setVisitInfo(visit)
        self.exposure.setFilter(afwImage.Filter('g'))
        self.exposure.setPhotoCalib(
            afwImage.PhotoCalib(self.calibration, self.calibrationErr))

        # Difference Image
        source_image = afwImage.MaskedImageF(
            lsst.geom.ExtentI(self.imageSize[0] + 1, self.imageSize[1] + 1))
        source_image.image[100, 100, afwImage.LOCAL] = 20
        source_image.getVariance().set(2)
        bbox = lsst.geom.BoxI(
            lsst.geom.PointI(1, 1),
            lsst.geom.ExtentI(self.imageSize[0], self.imageSize[1]))
        masked_image = afwImage.MaskedImageF(source_image, bbox,
                                             afwImage.LOCAL)
        self.diffim = afwImage.makeExposure(masked_image, self.wcs)
        self.diffim.setDetector(detector)
        self.diffim.getInfo().setVisitInfo(visit)
        self.diffim.setFilter(afwImage.Filter('g'))
        self.diffim.setPhotoCalib(
            afwImage.PhotoCalib(self.calibration, self.calibrationErr))

        self.expIdBits = 16

        FWHM = 5
        psf = measAlg.DoubleGaussianPsf(15, 15,
                                        FWHM / (2 * np.sqrt(2 * np.log(2))))
        self.exposure.setPsf(psf)
        self.diffim.setPsf(psf)

        self.testDiaObjects = create_test_dia_objects(5, self.wcs)
        # Add additional diaObjects that are outside of the above difference
        # and calexp visit images.
        # xy outside
        src = self.testDiaObjects.addNew()
        src['id'] = 10000000
        src.setCoord(self.wcs.pixelToSky(-100000, -100000))
        # y outside
        src = self.testDiaObjects.addNew()
        src['id'] = 10000001
        src.setCoord(self.wcs.pixelToSky(100, -100000))
        # x outside
        src = self.testDiaObjects.addNew()
        src['id'] = 10000002
        src.setCoord(self.wcs.pixelToSky(-100000, 100))
        # Ids of objects that were "updated" during "ap_association"
        # processing.
        self.updatedTestIds = np.array([1, 2, 3, 4, 10000001], dtype=np.uint64)
        # Expecdted number of sources is the number of updated ids plus
        # any that are within the CCD footprint but are not in the
        # above list of ids.
        self.expectedDiaForcedSources = 6

        self.expected_n_columns = 11
    def setUp(self):
        """Create a sqlite3 database with default tables and schemas.
        """
        # CFHT Filters from the camera mapper.
        self.filter_names = ["u", "g", "r", "i", "z"]
        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.dia_object_schema = make_dia_object_schema()

        # metadata taken from CFHT data
        # v695856-e0/v695856-e0-c000-a00.sci_img.fits

        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=1234,
            exposureTime=200.,
            date=dafBase.DateTime("2014-05-13T17:00:00.000000000",
                                  dafBase.DateTime.Timescale.TAI))
        self.exposure.setDetector(detector)
        self.exposure.getInfo().setVisitInfo(visit)
        self.exposure.setFilter(afwImage.Filter('g'))
        self.flux0 = 10000
        self.flux0_err = 100
        self.exposure.setPhotoCalib(
            afwImage.PhotoCalib(self.flux0, self.flux0_err))

        bbox = geom.Box2D(self.exposure.getBBox())
        wcs = self.exposure.getWcs()

        self.pixelator = sphgeom.HtmPixelization(20)
        region = sphgeom.ConvexPolygon([wcs.pixelToSky(pp).getVector()
                                        for pp in bbox.getCorners()])

        indices = self.pixelator.envelope(region, 64)
        # Index types must be cast to int to work with dax_apdb.
        self.index_ranges = indices.ranges()
Beispiel #20
0
    def __init__(self, **kwargs):
        policyFile = Policy.defaultPolicyFile("obs_pfs", "PfsMapper.yaml",
                                              "policy")
        policy = Policy(policyFile)
        if not kwargs.get('root', None):
            pfsDataDir = os.environ.get('PFS_DATA_DIR')
            if pfsDataDir is None:
                raise RuntimeError(
                    "Either $PFS_DATA_DIR or root= must be specified")
            kwargs['root'] = os.path.join(pfsDataDir, 'PFS')
        if not kwargs.get('calibRoot', None):
            kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

        super(PfsMapper, 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 = {
            'site': str,
            'category': str,
            'field': str,
            'visit': int,
            'ccd': int,
            'filter': str,
            'arm': str,
            'spectrograph': int,
            'dateObs': str,
            'expTime': float,
            'dataType': str,
            'taiObs': str,
            'pfsDesignId': int,
            'slitOffset': float,
        }
        for name in ("raw", "pfsArm", "wlFitData", "arcLines"):
            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="UNRECOGNISED",
                                   lambdaEff=0,
                                   alias=[
                                       "NONE",
                                       "None",
                                       "Unrecognised",
                                       "UNRECOGNISED",
                                       "Unrecognized",
                                       "UNRECOGNIZED",
                                       "NOTSET",
                                   ])
        afwImageUtils.defineFilter(name='b',
                                   lambdaEff=477,
                                   alias=['blue', 'PFS-B'])
        afwImageUtils.defineFilter(name='r',
                                   lambdaEff=623,
                                   alias=['red', 'PFS-R'])
        afwImageUtils.defineFilter(name='n',
                                   lambdaEff=623,
                                   alias=['nearInfraRed', 'PFS-N'])
        afwImageUtils.defineFilter(name='m',
                                   lambdaEff=775,
                                   alias=['mediumResolutionRed', 'PFS-M'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        self.filters = {}
        for f in ["b", "r", "n", "m", "NONE", "UNRECOGNISED"]:
            # Get the canonical name -- see #2113
            self.filters[f] = afwImage.Filter(
                afwImage.Filter(f).getId()).getName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        PfsMapper._nbit_id = 64
Beispiel #21
0
    def __init__(self, inputPolicy=None, **kwargs):
        policyFile = dafPersist.Policy.defaultPolicyFile(
            self.packageName, "LsstSimMapper.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(LsstSimMapper,
              self).__init__(policy, os.path.dirname(policyFile), **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.resetFilters()
        afwImageUtils.defineFilter('u',
                                   lambdaEff=364.59,
                                   lambdaMin=324.0,
                                   lambdaMax=395.0)
        afwImageUtils.defineFilter('g',
                                   lambdaEff=476.31,
                                   lambdaMin=405.0,
                                   lambdaMax=552.0)
        afwImageUtils.defineFilter('r',
                                   lambdaEff=619.42,
                                   lambdaMin=552.0,
                                   lambdaMax=691.0)
        afwImageUtils.defineFilter('i',
                                   lambdaEff=752.06,
                                   lambdaMin=818.0,
                                   lambdaMax=921.0)
        afwImageUtils.defineFilter('z',
                                   lambdaEff=866.85,
                                   lambdaMin=922.0,
                                   lambdaMax=997.0)
        # official y filter
        afwImageUtils.defineFilter('y',
                                   lambdaEff=971.68,
                                   lambdaMin=975.0,
                                   lambdaMax=1075.0,
                                   alias=['y4'])
        # If/when y3 sim data becomes available, uncomment this and
        # modify the schema appropriately
        # afwImageUtils.defineFilter('y3', 1002.44) # candidate y-band

        # FTaken from hscMapper.py
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.
        LsstSimMapper._nbit_tract = 16
        LsstSimMapper._nbit_patch = 5
        LsstSimMapper._nbit_filter = 6
        LsstSimMapper._nbit_id = 64 - (LsstSimMapper._nbit_tract +
                                       2 * LsstSimMapper._nbit_patch +
                                       LsstSimMapper._nbit_filter)
Beispiel #22
0
    def __init__(self, **kwargs):
        policyFile = Policy.defaultPolicyFile("obs_pfs", "PfsMapper.yaml", "policy")
        policy = Policy(policyFile)
        if not kwargs.get('root', None):
            try:
                kwargs['root'] = os.path.join(os.environ.get('PFS_DATA_DIR'), 'PFS')
            except:
                raise RuntimeError("Either $PFS_DATA_DIR or root= must be specified")
        if not kwargs.get('calibRoot', None):
            kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

        super(PfsMapper, 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 = {'site': str,
                'category': str,
                'field': str,
                'expId': int,
                'visit': int,
                'ccd': int,
                'filter': str,
                'arm': str,
                'spectrograph': int,
                'dateObs': str,
                'expTime': float,
                'dataType': str,
                'taiObs': str,
                'pfiDesignId': int,
                'slitOffset': float,
                }
        for name in ("raw", "pfsArm", "pfsMerged"):
            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="UNRECOGNISED", lambdaEff=0,
                                   alias=["NONE", "None", "Unrecognised", "UNRECOGNISED",
                                          "Unrecognized", "UNRECOGNIZED", "NOTSET",])
        afwImageUtils.defineFilter(name='b', lambdaEff=477, alias=['blue', 'PFS-B'])
        afwImageUtils.defineFilter(name='r', lambdaEff=623, alias=['red', 'PFS-R'])
        afwImageUtils.defineFilter(name='n', lambdaEff=623, alias=['nearInfraRed', 'PFS-N'])
        afwImageUtils.defineFilter(name='m', lambdaEff=775, alias=['mediumResolutionRed', 'PFS-M'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        self.filters = {}
        for f in ["b",
                  "r",
                  "n",
                  "m",
                  "NONE",
                  "UNRECOGNISED"
                  ]:
            # Get the canonical name -- see #2113
            self.filters[f] = afwImage.Filter(afwImage.Filter(f).getId()).getName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        PfsMapper._nbit_id = 64
Beispiel #23
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_pfs", "PfsMapper.paf",
                                                 "policy")
        policy = pexPolicy.Policy(policyFile)
        if not kwargs.get('root', None):
            try:
                kwargs['root'] = os.path.join(
                    os.environ.get('SUPRIME_DATA_DIR'), 'PFS')
            except:
                raise RuntimeError(
                    "Either $SUPRIME_DATA_DIR or root= must be specified")
        if not kwargs.get('calibRoot', None):
            kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

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

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {
            'field': str,
            'visit': int,
            'ccd': int,  # for compatibility with HSC: serial no of ccd
            'spectrograph':
            int,  # [0,1,2,3] for each arm in [blue, red, nir, medred]
            'dateObs': str,
            'taiObs': str,
            'filter': str,  # 'arm' called filter for compatibility
            'site': str,
            'category': str,
        }
        for name in (
                "raw",
                # processCcd outputs
                "calexp",
                "postISRCCD",
        ):
            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="UNRECOGNISED",
                                   lambdaEff=0,
                                   alias=[
                                       "NONE",
                                       "None",
                                       "Unrecognised",
                                       "UNRECOGNISED",
                                       "Unrecognized",
                                       "UNRECOGNIZED",
                                       "NOTSET",
                                   ])
        afwImageUtils.defineFilter(name='b',
                                   lambdaEff=477,
                                   alias=['blue', 'PFS-B'])
        afwImageUtils.defineFilter(name='r',
                                   lambdaEff=623,
                                   alias=['red', 'PFS-R'])
        afwImageUtils.defineFilter(name='n',
                                   lambdaEff=623,
                                   alias=['nearInfraRed', 'PFS-N'])
        afwImageUtils.defineFilter(name='m',
                                   lambdaEff=775,
                                   alias=['mediumResolutionRed', 'PFS-M'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        # It's a bit hard to initialise self.filters properly until #2113 is resolved,
        # including the part that makes it possible to get all aliases
        #
        self.filters = {}
        for f in ["b", "r", "n", "m", "NONE", "UNRECOGNISED"]:
            # Get the canonical name -- see #2113
            self.filters[f] = afwImage.Filter(
                afwImage.Filter(f).getId()).getName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        PfsMapper._nbit_id = 64  # - (PfsMapper._nbit_tract + 2*PfsMapper._nbit_patch + PfsMapper._nbit_filter)
Beispiel #24
0
    def __init__(self, **kwargs):
        policyFile = Policy.defaultPolicyFile("obs_subaru", "HscMapper.yaml",
                                              "policy")
        policy = Policy(policyFile)
        if not kwargs.get('root', None):
            try:
                kwargs['root'] = os.path.join(
                    os.environ.get('SUPRIME_DATA_DIR'), 'HSC')
            except:
                raise RuntimeError(
                    "Either $SUPRIME_DATA_DIR or root= must be specified")
        if not kwargs.get('calibRoot', None):
            calibSearch = [os.path.join(kwargs['root'], 'CALIB')]
            if "repositoryCfg" in kwargs:
                calibSearch += [
                    os.path.join(cfg.root, 'CALIB')
                    for cfg in kwargs["repositoryCfg"].parents
                    if hasattr(cfg, "root")
                ]
                calibSearch += [
                    cfg.root for cfg in kwargs["repositoryCfg"].parents
                    if hasattr(cfg, "root")
                ]
            for calibRoot in calibSearch:
                if os.path.exists(
                        os.path.join(calibRoot, "calibRegistry.sqlite3")):
                    kwargs['calibRoot'] = calibRoot
                    break
            if not kwargs.get('calibRoot', None):
                lsst.log.Log.getLogger("HscMapper").warn(
                    "Unable to find calib root directory")

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

        self._linearize = LinearizeSquared()

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {
            'field': str,
            'visit': int,
            'filter': str,
            'ccd': int,
            'dateObs': str,
            'taiObs': str,
            'expTime': float,
            'pointing': int,
        }
        for name in (
                "raw",
                # processCcd outputs
                "postISRCCD",
                "calexp",
                "postISRCCD",
                "src",
                "icSrc",
                "icMatch",
                "srcMatch",
                # mosaic outputs
                "wcs",
                "fcr",
                # processCcd QA
                "ossThumb",
                "flattenedThumb",
                "calexpThumb",
                "plotMagHist",
                "plotSeeingRough",
                "plotSeeingRobust",
                "plotSeeingMap",
                "plotEllipseMap",
                "plotEllipticityMap",
                "plotFwhmGrid",
                "plotEllipseGrid",
                "plotEllipticityGrid",
                "plotPsfSrcGrid",
                "plotPsfModelGrid",
                "fitsFwhmGrid",
                "fitsEllipticityGrid",
                "fitsEllPaGrid",
                "fitsPsfSrcGrid",
                "fitsPsfModelGrid",
                "tableSeeingMap",
                "tableSeeingGrid",
                # forcedPhot outputs
                "forced_src",
        ):
            self.mappings[name].keyDict.update(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

        # 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="UNRECOGNISED",
                                   lambdaEff=0,
                                   alias=[
                                       "NONE",
                                       "None",
                                       "Unrecognised",
                                       "UNRECOGNISED",
                                       "Unrecognized",
                                       "UNRECOGNIZED",
                                       "NOTSET",
                                   ])
        afwImageUtils.defineFilter(name='g',
                                   lambdaEff=477,
                                   alias=['W-S-G+', 'HSC-G'])
        afwImageUtils.defineFilter(name='r',
                                   lambdaEff=623,
                                   alias=['W-S-R+', 'HSC-R'])
        afwImageUtils.defineFilter(name='r1',
                                   lambdaEff=623,
                                   alias=['109', 'ENG-R1'])
        afwImageUtils.defineFilter(name='i',
                                   lambdaEff=775,
                                   alias=['W-S-I+', 'HSC-I'])
        afwImageUtils.defineFilter(name='z',
                                   lambdaEff=925,
                                   alias=['W-S-Z+', 'HSC-Z'])
        afwImageUtils.defineFilter(name='y',
                                   lambdaEff=990,
                                   alias=['W-S-ZR', 'HSC-Y'])
        afwImageUtils.defineFilter(name='N387',
                                   lambdaEff=387,
                                   alias=['NB0387'])
        afwImageUtils.defineFilter(name='N515',
                                   lambdaEff=515,
                                   alias=['NB0515'])
        afwImageUtils.defineFilter(name='N656',
                                   lambdaEff=656,
                                   alias=['NB0656'])
        afwImageUtils.defineFilter(name='N816',
                                   lambdaEff=816,
                                   alias=['NB0816'])
        afwImageUtils.defineFilter(name='N921',
                                   lambdaEff=921,
                                   alias=['NB0921'])
        afwImageUtils.defineFilter(name='N1010',
                                   lambdaEff=1010,
                                   alias=['NB1010'])
        afwImageUtils.defineFilter(name='SH', lambdaEff=0, alias=[
            'SH',
        ])
        afwImageUtils.defineFilter(name='PH', lambdaEff=0, alias=[
            'PH',
        ])
        afwImageUtils.defineFilter(name='N527',
                                   lambdaEff=527,
                                   alias=['NB0527'])
        afwImageUtils.defineFilter(name='N718',
                                   lambdaEff=718,
                                   alias=['NB0718'])
        afwImageUtils.defineFilter(name='I945',
                                   lambdaEff=945,
                                   alias=['IB0945'])
        afwImageUtils.defineFilter(name='N973',
                                   lambdaEff=973,
                                   alias=['NB0973'])
        afwImageUtils.defineFilter(name='i2', lambdaEff=775, alias=['HSC-I2'])
        afwImageUtils.defineFilter(name='r2', lambdaEff=623, alias=['HSC-R2'])
        afwImageUtils.defineFilter(name='N468',
                                   lambdaEff=468,
                                   alias=['NB0468'])
        afwImageUtils.defineFilter(name='N926',
                                   lambdaEff=926,
                                   alias=['NB0926'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        # It's a bit hard to initialise self.filters properly until #2113 is resolved,
        # including the part that makes it possible to get all aliases
        #
        self.filters = {}
        for f in [
                "HSC-G", "HSC-R", "HSC-R2", "HSC-I", "HSC-I2", "HSC-Z",
                "HSC-Y", "ENG-R1", "NB0387", "NB0468", "NB0515", "NB0527",
                "NB0656", "NB0718", "NB0816", "NB0921", "NB0926", "IB0945",
                "NB0973", "NB1010", "SH", "PH", "NONE", "UNRECOGNISED"
        ]:
            self.filters[f] = afwImage.Filter(f).getCanonicalName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        HscMapper._nbit_tract = 16
        HscMapper._nbit_patch = 5
        HscMapper._nbit_filter = 6

        HscMapper._nbit_id = 64 - (HscMapper._nbit_tract +
                                   2 * HscMapper._nbit_patch +
                                   HscMapper._nbit_filter)

        if len(afwImage.Filter.getNames()) >= 2**HscMapper._nbit_filter:
            raise RuntimeError(
                "You have more filters defined than fit into the %d bits allocated"
                % HscMapper._nbit_filter)
    def setUp(self):
        # CFHT Filters from the camera mapper.
        self.filter_names = ["u", "g", "r", "i", "z"]
        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")

        # metadata taken from CFHT data
        # v695856-e0/v695856-e0-c000-a00.sci_img.fits
        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.calibration = 10000
        self.calibrationErr = 100
        self.exposureId = 1234
        self.exposureTime = 200.
        self.imageSize = [1024, 1153]
        self.dateTime = "2014-05-13T17:00:00.000000000"

        # Make images  with one source in them and distinct values and
        # variance for each image.
        # Direct Image
        source_image = afwImage.MaskedImageF(
            lsst.geom.ExtentI(self.imageSize[0] + 1, self.imageSize[1] + 1))
        source_image.image[100, 100, afwImage.LOCAL] = 10
        source_image.getVariance().set(1)
        bbox = lsst.geom.BoxI(
            lsst.geom.PointI(1, 1),
            lsst.geom.ExtentI(self.imageSize[0],
                              self.imageSize[1]))
        masked_image = afwImage.MaskedImageF(source_image, bbox, afwImage.LOCAL)
        self.exposure = afwImage.makeExposure(masked_image, self.wcs)

        detector = DetectorWrapper(
            id=23, bbox=self.exposure.getBBox()).detector
        visit = afwImage.VisitInfo(
            exposureId=self.exposureId,
            exposureTime=self.exposureTime,
            date=dafBase.DateTime(self.dateTime,
                                  dafBase.DateTime.Timescale.TAI))
        self.exposure.setDetector(detector)
        self.exposure.getInfo().setVisitInfo(visit)
        self.exposure.setFilter(afwImage.Filter('g'))
        self.exposure.setPhotoCalib(afwImage.PhotoCalib(self.calibration, self.calibrationErr))

        # Difference Image
        source_image = afwImage.MaskedImageF(
            lsst.geom.ExtentI(self.imageSize[0] + 1, self.imageSize[1] + 1))
        source_image.image[100, 100, afwImage.LOCAL] = 20
        source_image.getVariance().set(2)
        bbox = lsst.geom.BoxI(
            lsst.geom.PointI(1, 1),
            lsst.geom.ExtentI(self.imageSize[0],
                              self.imageSize[1]))
        masked_image = afwImage.MaskedImageF(source_image, bbox, afwImage.LOCAL)
        self.diffim = afwImage.makeExposure(masked_image, self.wcs)
        self.diffim.setDetector(detector)
        self.diffim.getInfo().setVisitInfo(visit)
        self.diffim.setFilter(afwImage.Filter('g'))
        self.diffim.setPhotoCalib(afwImage.PhotoCalib(self.calibration, self.calibrationErr))

        self.expIdBits = 16

        FWHM = 5
        psf = measAlg.DoubleGaussianPsf(15, 15, FWHM/(2*np.sqrt(2*np.log(2))))
        self.exposure.setPsf(psf)
        self.diffim.setPsf(psf)

        self.testDiaObjects = create_test_dia_objects(5, self.wcs)
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)
Beispiel #27
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)
 def addFilters(cls):
     afwImageUtils.resetFilters()
     for kwds in HSC_FILTER_DEFINITIONS:
         afwImageUtils.defineFilter(**kwds)
Beispiel #29
0
 def tearDown(self):
     afwImageUtils.resetFilters()
Beispiel #30
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_subaru", "HscMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        if not kwargs.get('root', None):
            try:
                kwargs['root'] = os.path.join(os.environ.get('SUPRIME_DATA_DIR'), 'HSC')
            except:
                raise RuntimeError("Either $SUPRIME_DATA_DIR or root= must be specified")
        if not kwargs.get('calibRoot', None):
            kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

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

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {'field': str,
                'visit': int,
                'filter': str,
                'ccd': int,
                'dateObs': str,
                'taiObs': str,
                'expTime': float,
                'pointing': int,
                }
        for name in ("raw",
                     # processCcd outputs
                     "postISRCCD", "calexp", "postISRCCD", "src", "icSrc", "icMatch", "icMatchFull",
                     "srcMatch", "srcMatchFull",
                     # processCcd QA
                     "ossThumb", "flattenedThumb", "calexpThumb", "plotMagHist", "plotSeeingRough",
                     "plotSeeingRobust", "plotSeeingMap", "plotEllipseMap", "plotEllipticityMap",
                     "plotFwhmGrid", "plotEllipseGrid", "plotEllipticityGrid", "plotPsfSrcGrid",
                     "plotPsfModelGrid", "fitsFwhmGrid", "fitsEllipticityGrid", "fitsEllPaGrid",
                     "fitsPsfSrcGrid", "fitsPsfModelGrid", "tableSeeingMap", "tableSeeingGrid",
                     # forcedPhot outputs
                     "forced_src",
                     # Warp
                     "coaddTempExp",
                     ):
            self.mappings[name].keyDict.update(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

        # 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="UNRECOGNISED", lambdaEff=0,
                                   alias=["NONE", "None", "Unrecognised", "UNRECOGNISED",
                                          "Unrecognized", "UNRECOGNIZED", "NOTSET",])
        afwImageUtils.defineFilter(name='g', lambdaEff=477, alias=['W-S-G+', 'HSC-G'])
        afwImageUtils.defineFilter(name='r', lambdaEff=623, alias=['W-S-R+', 'HSC-R'])
        afwImageUtils.defineFilter(name='r1', lambdaEff=623, alias=['109', 'ENG-R1'])
        afwImageUtils.defineFilter(name='i', lambdaEff=775, alias=['W-S-I+', 'HSC-I'])
        afwImageUtils.defineFilter(name='z', lambdaEff=925, alias=['W-S-Z+', 'HSC-Z'])
        afwImageUtils.defineFilter(name='y', lambdaEff=990, alias=['W-S-ZR', 'HSC-Y'])
        afwImageUtils.defineFilter(name='N515', lambdaEff=515, alias=['NB0515'])
        afwImageUtils.defineFilter(name='N656', lambdaEff=656, alias=['NB0656'])
        afwImageUtils.defineFilter(name='N816', lambdaEff=816, alias=['NB0816'])
        afwImageUtils.defineFilter(name='N921', lambdaEff=921, alias=['NB0921'])
        afwImageUtils.defineFilter(name='SH', lambdaEff=0, alias=['SH',])
        afwImageUtils.defineFilter(name='PH', lambdaEff=0, alias=['PH',])
        afwImageUtils.defineFilter(name='N527', lambdaEff=527, alias=['NB0527'])
        afwImageUtils.defineFilter(name='N718', lambdaEff=718, alias=['NB0718'])
        afwImageUtils.defineFilter(name='I945', lambdaEff=945, alias=['IB0945'])
        afwImageUtils.defineFilter(name='N973', lambdaEff=973, alias=['NB0973'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        # It's a bit hard to initialise self.filters properly until #2113 is resolved,
        # including the part that makes it possible to get all aliases
        #
        self.filters = {}
        for f in [
            "HSC-G",
            "HSC-R",
            "HSC-I",
            "HSC-Z",
            "HSC-Y",
            "ENG-R1",
            "NB0515",
            "NB0527",
            "NB0656",
            "NB0718",
            "NB0816",
            "NB0921",
            "IB0945",
            "NB0973",
            "SH",
            "PH",
            "NONE",
            "UNRECOGNISED"]:
            # Get the canonical name -- see #2113
            self.filters[f] = afwImage.Filter(afwImage.Filter(f).getId()).getName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        HscMapper._nbit_tract = 16
        HscMapper._nbit_patch  = 5
        HscMapper._nbit_filter = 6

        HscMapper._nbit_id = 64 - (HscMapper._nbit_tract + 2*HscMapper._nbit_patch + HscMapper._nbit_filter)

        if len(afwImage.Filter.getNames()) >= 2**HscMapper._nbit_filter:
            raise RuntimeError("You have more filters defined than fit into the %d bits allocated" %
                               HscMapper._nbit_filter)
Beispiel #31
0
    def __init__(self, **kwargs):
        policyFile = pexPolicy.DefaultPolicyFile("obs_pfs", "PfsMapper.paf", "policy")
        policy = pexPolicy.Policy(policyFile)
        if not kwargs.get('root', None):
            try:
                kwargs['root'] = os.path.join(os.environ.get('SUPRIME_DATA_DIR'), 'PFS')
            except:
                raise RuntimeError("Either $SUPRIME_DATA_DIR or root= must be specified")
        if not kwargs.get('calibRoot', None):
            kwargs['calibRoot'] = os.path.join(kwargs['root'], 'CALIB')

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

        # Ensure each dataset type of interest knows about the full range of keys available from the registry
        keys = {'field': str,
                'visit': int,
                'ccd': int, # for compatibility with HSC: serial no of ccd
                'spectrograph': int, # [0,1,2,3] for each arm in [blue, red, nir, medred]
                'dateObs': str,
                'taiObs': str,
                'filter': str, # 'arm' called filter for compatibility
                'site': str,
                'category': str,
                }
        for name in ("raw",
                     # processCcd outputs
                     "calexp", 
                     "postISRCCD", 
                     ):
            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="UNRECOGNISED", lambdaEff=0,
                                   alias=["NONE", "None", "Unrecognised", "UNRECOGNISED",
                                          "Unrecognized", "UNRECOGNIZED", "NOTSET",])
        afwImageUtils.defineFilter(name='b', lambdaEff=477, alias=['blue','PFS-B'])
        afwImageUtils.defineFilter(name='r', lambdaEff=623, alias=['red','PFS-R'])
        afwImageUtils.defineFilter(name='n', lambdaEff=623, alias=['nearInfraRed','PFS-N'])
        afwImageUtils.defineFilter(name='m', lambdaEff=775, alias=['mediumResolutionRed','PFS-M'])
        #
        # self.filters is used elsewhere, and for now we'll set it
        #
        # It's a bit hard to initialise self.filters properly until #2113 is resolved,
        # including the part that makes it possible to get all aliases
        #
        self.filters = {}
        for f in [
            "b",
            "r",
            "n",
            "m",
            "NONE",
            "UNRECOGNISED"]:
            # Get the canonical name -- see #2113
            self.filters[f] = afwImage.Filter(afwImage.Filter(f).getId()).getName()
        self.defaultFilterName = "UNRECOGNISED"

        #
        # The number of bits allocated for fields in object IDs, appropriate for
        # the default-configured Rings skymap.
        #
        # This shouldn't be the mapper's job at all; see #2797.

        PfsMapper._nbit_id = 64# - (PfsMapper._nbit_tract + 2*PfsMapper._nbit_patch + PfsMapper._nbit_filter)
Beispiel #32
0
    def addFilters(cls):
        # 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

        # 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="UNRECOGNISED",
                                   lambdaEff=0,
                                   alias=[
                                       "NONE",
                                       "None",
                                       "Unrecognised",
                                       "UNRECOGNISED",
                                       "Unrecognized",
                                       "UNRECOGNIZED",
                                       "NOTSET",
                                   ])
        afwImageUtils.defineFilter(name='g',
                                   lambdaEff=477,
                                   alias=['W-S-G+', 'HSC-G'])
        afwImageUtils.defineFilter(name='r',
                                   lambdaEff=623,
                                   alias=['W-S-R+', 'HSC-R'])
        afwImageUtils.defineFilter(name='r1',
                                   lambdaEff=623,
                                   alias=['109', 'ENG-R1'])
        afwImageUtils.defineFilter(name='i',
                                   lambdaEff=775,
                                   alias=['W-S-I+', 'HSC-I'])
        afwImageUtils.defineFilter(name='z',
                                   lambdaEff=925,
                                   alias=['W-S-Z+', 'HSC-Z'])
        afwImageUtils.defineFilter(name='y',
                                   lambdaEff=990,
                                   alias=['W-S-ZR', 'HSC-Y'])
        afwImageUtils.defineFilter(name='N387',
                                   lambdaEff=387,
                                   alias=['NB0387'])
        afwImageUtils.defineFilter(name='N515',
                                   lambdaEff=515,
                                   alias=['NB0515'])
        afwImageUtils.defineFilter(name='N656',
                                   lambdaEff=656,
                                   alias=['NB0656'])
        afwImageUtils.defineFilter(name='N816',
                                   lambdaEff=816,
                                   alias=['NB0816'])
        afwImageUtils.defineFilter(name='N921',
                                   lambdaEff=921,
                                   alias=['NB0921'])
        afwImageUtils.defineFilter(name='N1010',
                                   lambdaEff=1010,
                                   alias=['NB1010'])
        afwImageUtils.defineFilter(name='SH', lambdaEff=0, alias=[
            'SH',
        ])
        afwImageUtils.defineFilter(name='PH', lambdaEff=0, alias=[
            'PH',
        ])
        afwImageUtils.defineFilter(name='N527',
                                   lambdaEff=527,
                                   alias=['NB0527'])
        afwImageUtils.defineFilter(name='N718',
                                   lambdaEff=718,
                                   alias=['NB0718'])
        afwImageUtils.defineFilter(name='I945',
                                   lambdaEff=945,
                                   alias=['IB0945'])
        afwImageUtils.defineFilter(name='N973',
                                   lambdaEff=973,
                                   alias=['NB0973'])
        afwImageUtils.defineFilter(name='i2', lambdaEff=775, alias=['HSC-I2'])
        afwImageUtils.defineFilter(name='r2', lambdaEff=623, alias=['HSC-R2'])
        afwImageUtils.defineFilter(name='N468',
                                   lambdaEff=468,
                                   alias=['NB0468'])
        afwImageUtils.defineFilter(name='N926',
                                   lambdaEff=926,
                                   alias=['NB0926'])
Beispiel #33
0
 def postHook(self, **kwargs):
     afwIU.resetFilters()  # So other cameras may be run
 def postHook(self, **kwargs):
     afwIU.resetFilters() # So other cameras may be run
Beispiel #35
0
 def tearDown(self):
     afwImageUtils.resetFilters()
Beispiel #36
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))))