LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Public Member Functions | |
def | __init__ |
def | backup |
def | keys |
def | getKeys |
def | getDefaultLevel |
def | getDefaultSubLevel |
def | getCameraName |
def | getPackageName |
def | map_camera |
def | bypass_camera |
def | map_defects |
def | bypass_defects |
def | std_raw |
def | map_skypolicy |
def | std_skypolicy |
Public Member Functions inherited from lsst.daf.persistence.mapper.Mapper | |
def | __new__ |
def | __init__ |
def | __getstate__ |
def | __setstate__ |
def | keys |
def | queryMetadata |
def | getDatasetTypes |
def | map |
def | canStandardize |
def | standardize |
def | validate |
def | backup |
Static Public Member Functions | |
def | getShortCcdName |
Public Attributes | |
log | |
levels | |
defaultLevel | |
defaultSubLevels | |
root | |
registry | |
keyDict | |
mappings | |
cameraDataLocation | |
camera | |
defectRegistry | |
defectPath | |
filters | |
skypolicy | |
Static Public Attributes | |
packageName = None | |
Private Member Functions | |
def | _parentSearch |
def | _getCcdKeyVal |
Utility functions. More... | |
def | _setupRegistry |
def | _transformId |
def | _mapActualToPath |
def | _extractDetectorName |
def | _extractAmpId |
def | _setAmpDetector |
def | _setCcdDetector |
def | _setFilter |
def | _setTimes |
def | _standardizeExposure |
def | _defectLookup |
def | _makeCamera |
CameraMapper is a base class for mappers that handle images from a camera and products derived from them. This provides an abstraction layer between the data on disk and the code. Public methods: keys, queryMetadata, getDatasetTypes, map, canStandardize, standardize Mappers for specific data sources (e.g., CFHT Megacam, LSST simulations, etc.) should inherit this class. The CameraMapper manages datasets within a "root" directory. It can also be given an "outputRoot". If so, the input root is linked into the outputRoot directory using a symlink named "_parent"; writes go into the outputRoot while reads can come from either the root or outputRoot. As outputRoots are used as inputs for further processing, the chain of _parent links allows any dataset to be retrieved. Note that writing to a dataset present in the input root will hide the existing dataset but not overwrite it. See #2160 for design discussion. A camera is assumed to consist of one or more rafts, each composed of multiple CCDs. Each CCD is in turn composed of one or more amplifiers (amps). A camera is also assumed to have a camera geometry description (CameraGeom object) as a policy file, a filter description (Filter class static configuration) as another policy file, and an optional defects description directory. Information from the camera geometry and defects are inserted into all Exposure objects returned. The mapper uses one or two registries to retrieve metadata about the images. The first is a registry of all raw exposures. This must contain the time of the observation. One or more tables (or the equivalent) within the registry are used to look up data identifier components that are not specified by the user (e.g. filter) and to return results for metadata queries. The second is an optional registry of all calibration data. This should contain validity start and end entries for each calibration dataset in the same timescale as the observation time. The following method must be provided by the subclass: _extractDetectorName(self, dataId): returns the detector name for a CCD (e.g., "CFHT 21", "R:1,2 S:3,4") as used in the AFW CameraGeom class given a dataset identifier referring to that CCD or a subcomponent of it. Other methods that the subclass may wish to override include: _transformId(self, dataId): transformation of a data identifier from colloquial usage (e.g., "ccdname") to proper/actual usage (e.g., "ccd"), including making suitable for path expansion (e.g. removing commas). The default implementation does nothing. Note that this method should not modify its input parameter. getShortCcdName(self, ccdName): a static method that returns a shortened name suitable for use as a filename. The default version converts spaces to underscores. _getCcdKeyVal(self, dataId): return a CCD key and value by which to look up defects in the defects registry. The default value returns ("ccd", detector name) _mapActualToPath(self, template, actualId): convert a template path to an actual path, using the actual dataset identifier. The mapper's behaviors are largely specified by the policy file. See the MapperDictionary.paf for descriptions of the available items. The 'exposures', 'calibrations', and 'datasets' subpolicies configure mappings (see Mappings class). Functions to map (provide a path to the data given a dataset identifier dictionary) and standardize (convert data into some standard format or type) may be provided in the subclass as "map_{dataset type}" and "std_{dataset type}", respectively. If non-Exposure datasets cannot be retrieved using standard daf_persistence methods alone, a "bypass_{dataset type}" function may be provided in the subclass to return the dataset instead of using the "datasets" subpolicy. Implementations of map_camera and bypass_camera that should typically be sufficient are provided in this base class. @todo * Handle defects the same was as all other calibration products, using the calibration registry * Instead of auto-loading the camera at construction time, load it from the calibration registry * Rewrite defects as AFW tables so we don't need pyfits to unpersist them; then remove all mention of pyfits from this package.
Definition at line 40 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.__init__ | ( | self, | |
policy, | |||
repositoryDir, | |||
root = None , |
|||
registry = None , |
|||
calibRoot = None , |
|||
calibRegistry = None , |
|||
provided = None , |
|||
outputRoot = None |
|||
) |
Initialize the CameraMapper. @param policy (pexPolicy.Policy) Policy with per-camera defaults already merged @param repositoryDir (string) Policy repository for the subclassing module (obtained with getRepositoryPath() on the per-camera default dictionary) @param root (string) Root directory for data @param registry (string) Path to registry with data's metadata @param calibRoot (string) Root directory for calibrations @param calibRegistry (string) Path to registry with calibrations' metadata @param provided (list of strings) Keys provided by the mapper @param outputRoot (string) Root directory for output data
Definition at line 133 of file cameraMapper.py.
|
private |
Find the defects for a given CCD. @param dataId (dict) Dataset identifier @return (string) path to the defects file or None if not available
Definition at line 784 of file cameraMapper.py.
|
private |
Extract the amplifier identifer from a dataset identifier. @warning this is deprecated; DO NOT USE IT amplifier identifier has two parts: the detector name for the CCD containing the amplifier and index of the amplifier in the detector. @param dataId (dict) Dataset identifer @return (tuple) Amplifier identifier
Definition at line 685 of file cameraMapper.py.
|
private |
Extract the detector (CCD) name from the dataset identifier. The name in question is the detector name used by lsst.afw.cameraGeom. @param dataId (dict) Dataset identifier @return (string) Detector name
Definition at line 675 of file cameraMapper.py.
|
private |
Utility functions.
Return CCD key and value used to look a defect in the defect registry The default implementation simply returns ("ccd", full detector name)
Definition at line 583 of file cameraMapper.py.
|
private |
Make a camera (instance of lsst.afw.cameraGeom.Camera) describing the camera geometry Also set self.cameraDataLocation, if relevant (else it can be left None). This implementation assumes that policy contains an entry "camera" that points to the subdirectory in this package of camera data; specifically, that subdirectory must contain: - a file named `camera.py` that contains persisted camera config - ampInfo table FITS files, as required by lsst.afw.cameraGeom.makeCameraFromPath @param policy (pexPolicy.Policy) Policy with per-camera defaults already merged @param repositoryDir (string) Policy repository for the subclassing module (obtained with getRepositoryPath() on the per-camera default dictionary)
Definition at line 816 of file cameraMapper.py.
|
private |
Convert a template path to an actual path, using the actual data identifier. This implementation is usually sufficient but can be overridden by the subclass. @param template (string) Template path @param actualId (dict) Dataset identifier @return (string) Pathname
Definition at line 657 of file cameraMapper.py.
|
private |
Look for the given path in the current root or any of its parents by following "_parent" symlinks; return None if it can't be found. A little tricky because the path may be in an alias of the root (e.g. ".") and because the "_parent" links go between the root and the rest of the path.
Definition at line 374 of file cameraMapper.py.
|
private |
Set the detector object in an Exposure for an amplifier. Defects are also added to the Exposure based on the detector object. @param[in,out] item (lsst.afw.image.Exposure) @param dataId (dict) Dataset identifier @param trimmed (bool) Should detector be marked as trimmed? (ignored)
Definition at line 698 of file cameraMapper.py.
|
private |
Set the detector object in an Exposure for a CCD. @param[in,out] item (lsst.afw.image.Exposure) @param dataId (dict) Dataset identifier @param trimmed (bool) Should detector be marked as trimmed? (ignored)
Definition at line 707 of file cameraMapper.py.
|
private |
Set the filter object in an Exposure. If the Exposure had a FILTER keyword, this was already processed during load. But if it didn't, use the filter from the registry. @param mapping (lsst.daf.butlerUtils.Mapping) @param[in,out] item (lsst.afw.image.Exposure) @param dataId (dict) Dataset identifier
Definition at line 717 of file cameraMapper.py.
|
private |
Set the exposure time and exposure midpoint in the calib object in an Exposure. Use the EXPTIME and MJD-OBS keywords (and strip out EXPTIME). @param mapping (lsst.daf.butlerUtils.Mapping) @param[in,out] item (lsst.afw.image.Exposure) @param dataId (dict) Dataset identifier
Definition at line 735 of file cameraMapper.py.
|
private |
Set up a registry (usually SQLite3), trying a number of possible paths. @param name (string) Name of registry @param path (string) Path for registry @param policyKey (string) Key in policy for registry path @param root (string) Root directory to look in @return (lsst.daf.butlerUtils.Registry) Registry object
Definition at line 590 of file cameraMapper.py.
|
private |
Default standardization function for images. @param mapping (lsst.daf.butlerUtils.Mapping) @param[in,out] item (lsst.afw.image.Exposure) @param dataId (dict) Dataset identifier @param filter (bool) Set filter? @param trimmed (bool) Should detector be marked as trimmed? @return (lsst.afw.image.Exposure) the standardized Exposure
Definition at line 760 of file cameraMapper.py.
|
private |
Generate a standard ID dict from a camera-specific ID dict. Canonical keys include: - amp: amplifier name - ccd: CCD name (in LSST this is a combination of raft and sensor) The default implementation returns a copy of its input. @param dataId[in] (dict) Dataset identifier; this must not be modified @return (dict) Transformed dataset identifier
Definition at line 644 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.backup | ( | self, | |
datasetType, | |||
dataId | |||
) |
Rename any existing object with the given type and dataId. The CameraMapper implementation saves objects in a sequence of e.g.: foo.fits foo.fits~1 foo.fits~2 All of the backups will be placed in the output repo, however, and will not be removed if they are found elsewhere in the _parent chain. This means that the same file will be stored twice if the previous version was found in an input repo.
Definition at line 428 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.bypass_camera | ( | self, | |
datasetType, | |||
pythonType, | |||
butlerLocation, | |||
dataId | |||
) |
Return the (preloaded) camera object.
Definition at line 516 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.bypass_defects | ( | self, | |
datasetType, | |||
pythonType, | |||
butlerLocation, | |||
dataId | |||
) |
Return a defect based on the butler location returned by map_defects @param[in] butlerLocation: a ButlerLocation with locationList = path to defects FITS file @param[in] dataId: the usual data ID; "ccd" must be set Note: the name "bypass_XXX" means the butler makes no attempt to convert the ButlerLocation into an object, which is what we want for now, since that conversion is a bit tricky.
Definition at line 535 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.getCameraName | ( | cls | ) |
Return the name of the camera that this CameraMapper is for.
Definition at line 487 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.getDefaultLevel | ( | self | ) |
Definition at line 478 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.getDefaultSubLevel | ( | self, | |
level | |||
) |
Definition at line 481 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.getKeys | ( | self, | |
datasetType, | |||
level | |||
) |
Return supported keys and their value types for a given dataset type at a given level of the key hierarchy. @param datasetType (str) dataset type or None for all keys @param level (str) level or None for all levels @return (iterable) Set of keys usable in a dataset identifier
Definition at line 460 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.getPackageName | ( | cls | ) |
Return the name of the package containing this CameraMapper.
Definition at line 497 of file cameraMapper.py.
|
static |
Convert a CCD name to a form useful as a filename The default implementation converts spaces to underscores.
Definition at line 668 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.keys | ( | self | ) |
Return supported keys. @return (iterable) List of keys usable in a dataset identifier
Definition at line 455 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.map_camera | ( | self, | |
dataId, | |||
write = False |
|||
) |
Map a camera dataset.
Definition at line 503 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.map_defects | ( | self, | |
dataId, | |||
write = False |
|||
) |
Map defects dataset. @return a very minimal ButlerLocation containing just the locationList field (just enough information that bypass_defects can use it).
Definition at line 523 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.map_skypolicy | ( | self, | |
dataId | |||
) |
Map a sky policy.
Definition at line 568 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.std_raw | ( | self, | |
item, | |||
dataId | |||
) |
Standardize a raw dataset by converting it to an Exposure instead of an Image
Definition at line 562 of file cameraMapper.py.
def lsst.daf.butlerUtils.cameraMapper.CameraMapper.std_skypolicy | ( | self, | |
item, | |||
dataId | |||
) |
Standardize a sky policy by returning the one we use.
Definition at line 573 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.camera |
Definition at line 351 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.cameraDataLocation |
Definition at line 350 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.defaultLevel |
Definition at line 166 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.defaultSubLevels |
Definition at line 167 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.defectPath |
Definition at line 356 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.defectRegistry |
Definition at line 354 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.filters |
Definition at line 364 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.keyDict |
Definition at line 256 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.levels |
Definition at line 161 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.log |
Definition at line 151 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.mappings |
Definition at line 265 of file cameraMapper.py.
|
static |
Definition at line 129 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.registry |
Definition at line 227 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.root |
Definition at line 224 of file cameraMapper.py.
lsst.daf.butlerUtils.cameraMapper.CameraMapper.skypolicy |
Definition at line 367 of file cameraMapper.py.