def _createDataIdsAndRefcats(self, filenames, htmLevel, name): """Create mock dataIds and refcat handles. Parameters ---------- filenames : `list` [`str`] Names of files to use. htmLevel : `int` HTM level to use for the loader. name : `str` Name of reference catalog (for logging). Returns ------- dataIds : `list` [`MockRefcatDataId`] List of mock dataIds. refCats : `list` [`MockRefcatDeferredDatasetHandle`] List of mock deferred dataset handles. Raises ------ RuntimeError if any file contains sources that cover more than one HTM pixel at level ``htmLevel``. """ pixelization = sphgeom.HtmPixelization(htmLevel) htm = esutil.htm.HTM(htmLevel) dataIds = [] refCats = [] for filename in filenames: cat = afwTable.BaseCatalog.readFits(filename) ids = htm.lookup_id(np.rad2deg(cat['coord_ra']), np.rad2deg(cat['coord_dec'])) if len(np.unique(ids)) != 1: raise RuntimeError(f"File {filename} contains more than one pixel at level {htmLevel}") dataIds.append(MockRefcatDataId(pixelization, ids[0])) refCats.append(MockRefcatDeferredDatasetHandle(cat, name)) return dataIds, refCats
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()
def __init__(self, config, name, metadata): DiaObjectCalculationPlugin.__init__(self, config, name, metadata) self.pixelator = sphgeom.HtmPixelization(self.config.htmLevel)
def __init__(self, **kwargs): pipeBase.Task.__init__(self, **kwargs) self.pixelator = sphgeom.HtmPixelization(self.config.htmLevel)