Coverage for python/lsst/pipe/tasks/mocks/simpleMapper.py : 89%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008, 2009, 2010, 2011, 2012 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
SimpleMapper inherits directly from Mapper, not CameraMapper. This means we can avoid any problems with paf files at the expense of reimplementing some parts of CameraMapper here. Jim is not sure this was the best possible approach, but it gave him an opportunity to play around with prototyping a future paf-free mapper class, and it does everything it needs to do right now. """
"""Base class of a hierarchy used by SimpleMapper to defined different kinds of types of objects to persist.
PersistenceType objects are never instantiated; only the type objects are used (we needed a simple singleton struct that could be inherited, which is exactly what a Python type is). """
"""Method called by SimpleMapping to implement a map_ method.""" mapper=mapper, storage=storage)
return False
"""Persistence type for things that don't actually use daf_persistence. """
"""Method called by SimpleMapping to implement a map_ method; overridden to not use the path.""" mapper=mapper, storage=storage)
"""Persistence type of Exposure images. """
"""Method called by SimpleMapping to implement a map_ method; overridden to support subimages.""" storage=storage) storage=storage) dataId['imageOrigin'])
"""Mapping object used to implement SimpleMapper, similar in intent to lsst.daf.peristence.Mapping. """
else: storage=storage)
"""Mapping for dataset types that are organized the same way as raw data (i.e. by CCD)."""
dictList = index[dataset][level] results = [list(d.values()) for d in dictList[dataId.get(level, None)]] return results
"""Mapping for dataset types that are organized according to a SkyMap subdivision of the sky."""
"""Mapping for CoaddTempExp datasets."""
"""Mapping for forced_src datasets."""
"""Metaclass for SimpleMapper that creates map_ and query_ methods for everything found in the 'mappings' class variable. """
def _makeQueryClosure(dataset, mapping): return mapping.query(dataset, self.index, level, format, dataId)
MapperMeta._makeMapClosure(dataset, mapping, suffix=suffix))
""" An extremely simple mapper for an imaginary camera for use in integration tests.
As SimpleMapper does not inherit from obs.base.CameraMapper, it does not use a policy file to set mappings or a registry; all the information is here (in the map_* and query_* methods).
The imaginary camera's raw data format has only 'visit' and 'ccd' keys, with two CCDs per visit (by default). """
calexp=RawMapping(ExposurePersistenceType), forced_src=ForcedSrcMapping(SourceCatalogPersistenceType), forced_src_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), truth=SimpleMapping(SimpleCatalogPersistenceType, template="{dataset}-{tract:02d}{ext}", keys={"tract": int}), simsrc=RawMapping(SimpleCatalogPersistenceType, template="{dataset}-{tract:02d}{ext}", keys={"tract": int}), observations=SimpleMapping(ExposureCatalogPersistenceType, template="{dataset}-{tract:02d}{ext}", keys={"tract": int}), ccdExposureId=RawMapping(BypassPersistenceType), ccdExposureId_bits=SimpleMapping(BypassPersistenceType), deepCoaddId=SkyMapping(BypassPersistenceType), deepCoaddId_bits=SimpleMapping(BypassPersistenceType), deepMergedCoaddId=SkyMapping(BypassPersistenceType), deepMergedCoaddId_bits=SimpleMapping(BypassPersistenceType), deepCoadd_skyMap=SimpleMapping(SkyMapPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd=SkyMapping(ExposurePersistenceType), deepCoaddPsfMatched=SkyMapping(ExposurePersistenceType), deepCoadd_calexp=SkyMapping(ExposurePersistenceType), deepCoadd_calexp_background=SkyMapping(CatalogPersistenceType), deepCoadd_icSrc=SkyMapping(SourceCatalogPersistenceType), deepCoadd_icSrc_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_src=SkyMapping(SourceCatalogPersistenceType), deepCoadd_src_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_peak_schema=SimpleMapping(PeakCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_ref=SkyMapping(SourceCatalogPersistenceType), deepCoadd_ref_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_det=SkyMapping(SourceCatalogPersistenceType), deepCoadd_det_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_mergeDet=SkyMapping(SourceCatalogPersistenceType), deepCoadd_mergeDet_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_meas=SkyMapping(SourceCatalogPersistenceType), deepCoadd_meas_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_forced_src=SkyMapping(SourceCatalogPersistenceType), deepCoadd_forced_src_schema=SimpleMapping(SourceCatalogPersistenceType, template="{dataset}{ext}", keys={}), deepCoadd_mock=SkyMapping(ExposurePersistenceType), deepCoaddPsfMatched_mock=SkyMapping(ExposurePersistenceType), deepCoadd_directWarp=TempExpMapping(ExposurePersistenceType), deepCoadd_directWarp_mock=TempExpMapping(ExposurePersistenceType), deepCoadd_psfMatchedWarp=TempExpMapping(ExposurePersistenceType), deepCoadd_psfMatchedWarp_mock=TempExpMapping(ExposurePersistenceType), )
visit=['ccd'], ccd=[], )
return "ccd"
keyDict = self.keyDict else: keyDict = dict(keyDict) for l in self.levels[level]: if l in keyDict: del keyDict[l]
return self.keyDict
"lsst.afw.cameraGeom.Camera", "Camera", None, [], dataId, mapper=self, storage=self.storage )
# Note: for real IDs, we'd want to include filter here, but it doesn't actually matter # for any of the tests we've done so far, which all assume filter='r' raise RuntimeError('tract not in range [0,128)') raise RuntimeError('patch component not in range [0, 8192)')
def splitCcdExposureId(ccdExposureId): return dict(visit=(int(ccdExposureId) // 10), ccd=(int(ccdExposureId) % 10))
nX, nY, sizeX, sizeY, gapX, gapY, pixelSize=1.0, plateScale=20.0, radialDistortion=0.925, ): """Create a camera
@param[in] nx: number of detectors in x @param[in] ny: number of detectors in y @param[in] sizeX: detector size in x (pixels) @param[in] sizeY: detector size in y (pixels) @param[in] gapX: gap between detectors in x (mm) @param[in] gapY: gap between detectors in y (mm) @param[in] pixelSize: pixel size (mm) (a float) @param[in] plateScale: plate scale in arcsec/mm; 20.0 is for LSST @param[in] radialDistortion: radial distortion, in mm/rad^2 (the r^3 coefficient of the radial distortion polynomial that converts FIELD_ANGLE in radians to FOCAL_PLANE in mm); 0.925 is the value Dave Monet measured for lsstSim data
Each detector will have one amplifier (with no raw information). """ lsst.afw.cameraGeom.FIELD_ANGLE: focalPlaneToFieldAngle, }
name=detectorName, id=detectorId, serial=detectorName + " serial", bbox=ccdBBox, ampExtent=ccdBBox.getDimensions(), numAmps=1, pixelSize=lsst.afw.geom.Extent2D(pixelSize, pixelSize), orientation=lsst.afw.cameraGeom.Orientation(fpPos), plateScale=plateScale, radialDistortion=radialDistortion, ).detector)
name="Simple Camera", detectorList=detectorList, transformMap=transformMap, )
""" Create a data repository for SimpleMapper and return a butler for it.
Clobbers anything already in the given path. """ shutil.rmtree(root) |