Coverage for python/lsst/meas/algorithms/ingestIndexReferenceTask.py : 94%

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-2017 AURA/LSST. # # 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 <https://www.lsstcorp.org/LegalNotices/>. #
"""Task runner for the reference catalog ingester
Data IDs are ignored so the runner should just run the task on the parsed command. """
"""Run the task.
Several arguments need to be collected to send on to the task methods.
Parameters ---------- parsedCmd : `argparse.Namespace` Parsed command.
Returns ------- results : `lsst.pipe.base.Struct` or `None` A empty struct if self.doReturnResults, else None """
return pipeBase.Struct()
dtype=str, default='cal_ref_cat', doc='String to pass to the butler to retrieve persisted files.', ) default='HTM', doc='Name of indexer algoritm to use. Default is HTM', )
dtype=DatasetConfig, doc="Configuration for reading the ingested data", ) target=ReadTextCatalogTask, doc='Task to use to read the files. Default is to expect text files.' ) dtype=str, doc="Name of RA column", ) dtype=str, doc="Name of Dec column", ) dtype=str, doc="Name of RA error column", optional=True, ) dtype=str, doc="Name of Dec error column", optional=True, ) dtype=str, doc="The values in the reference catalog are assumed to be in AB magnitudes. " "List of column names to use for photometric information. At least one entry is required." ) keytype=str, itemtype=str, default={}, doc="A map of magnitude column name (key) to magnitude error column (value)." ) dtype=str, optional=True, doc='Name of column stating if satisfactory for photometric calibration (optional).' ) dtype=str, optional=True, doc='Name of column stating if the object is resolved (optional).' ) dtype=str, optional=True, doc='Name of column stating if the object is measured to be variable (optional).' ) dtype=str, optional=True, doc='Name of column to use as an identifier (optional).' ) dtype=str, doc="Name of proper motion RA column", optional=True, ) dtype=str, doc="Name of proper motion Dec column", optional=True, ) dtype=str, doc="Name of proper motion RA error column", optional=True, ) dtype=str, doc="Name of proper motion Dec error column", optional=True, ) dtype=float, doc="Scale factor by which to multiply proper motion values to obtain units of milliarcsec/year", default=1.0, ) dtype=str, doc="Name of parallax column", optional=True, ) dtype=str, doc="Name of parallax error column", optional=True, ) dtype=float, doc="Scale factor by which to multiply parallax values to obtain units of milliarcsec", default=1.0, ) dtype=str, doc="Name of epoch column", optional=True, ) dtype=str, doc="Format of epoch column: any value accepted by astropy.time.Time, e.g. 'iso' or 'unix'", optional=True, ) dtype=str, doc="Scale of epoch column: any value accepted by astropy.time.Time, e.g. 'utc'", optional=True, ) dtype=str, default=[], doc='Extra columns to add to the reference catalog.' )
"""Raise ValueError unless all the named fields are set or are all none (or blank) """ prefix, ", ".join(names), ", ".join(setNames)))
raise ValueError( "ra_name and dec_name and at least one entry in mag_column_list must be supplied.") "mag_err_column_map specified, but keys do not match mag_column_list: {} != {}".format( sorted(self.mag_err_column_map.keys()), sorted(self.mag_column_list))) raise ValueError('"pm_ra/dec_name" must be specified if "pm_ra/dec_err_name" are specified') raise ValueError( '"epoch_name" must be specified if "pm_ra/dec_name" or "parallax_name" are specified')
"""Class for producing and loading indexed reference catalogs.
This implements an indexing scheme based on hierarchical triangular mesh (HTM). The term index really means breaking the catalog into localized chunks called shards. In this case each shard contains the entries from the catalog in a single HTM trixel
For producing catalogs this task makes the following assumptions about the input catalogs: - RA, Dec, RA error and Dec error are all in decimal degrees. - Epoch is available in a column, in a format supported by astropy.time.Time. - There are no off-diagonal covariance terms, such as covariance between RA and Dec, or between PM RA and PM Dec. Gaia is a well known example of a catalog that has such terms, and thus should not be ingested with this task.
Parameters ---------- butler : `lsst.daf.persistence.Butler` Data butler for reading and writing catalogs """
def _makeArgumentParser(cls): """Create an argument parser.
This returns a standard parser with an extra "files" argument. """
self.config.dataset_config.indexer.active)
"""Index a set of files comprising a reference catalog.
Outputs are persisted in the data repository.
Parameters ---------- files : `list` A list of file paths to read. """ # persist empty catalog to hold the master schema self.config.dataset_config.ref_dataset_name) dataId=dataId)
def computeCoord(row, ra_name, dec_name): """Create an ICRS coord. from a row of a catalog being ingested.
Parameters ---------- row : structured `numpy.array` Row from catalog being ingested. ra_name : `str` Name of RA key in catalog being ingested. dec_name : `str` Name of Dec key in catalog being ingested.
Returns ------- coord : `lsst.geom.SpherePoint` ICRS coordinate. """
"""Set coordinate error in a record of an indexed catalog.
The errors are read from the specified columns, and installed in the appropriate columns of the output.
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """
"""Set flags in an output record
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """
"""Set flux fields in a record of an indexed catalog.
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """ fluxErrFromABMagErr(row[error_col_name], row[err_key]))
"""Set proper motion fields in a record of an indexed catalog.
The proper motions are read from the specified columns, scaled appropriately, and installed in the appropriate columns of the output.
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """ return
"""Convert an epoch in native format to TAI MJD (a float). """ scale=self.config.epoch_scale).tai.mjd
"""Set extra data fields in a record of an indexed catalog.
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """ # If data read from a text file contains string like entires, # numpy stores this as its own internal type, a numpy.str_ # object. This seems to be a consequence of how numpy stores # string like objects in fixed column arrays. This checks # if any of the values to be added to the catalog are numpy # string types, and if they are, casts them to a python string # which is what the python c++ records expect
"""Fill a record in an indexed catalog to be persisted.
Parameters ---------- record : `lsst.afw.table.SimpleRecord` Row from indexed catalog to modify. row : structured `numpy.array` Row from catalog being ingested. rec_num : `int` Starting integer to increment for the unique id key_map : `dict` mapping `str` to `lsst.afw.table.Key` Map of catalog keys. """ else:
"""Get a catalog from the butler or create it if it doesn't exist.
Parameters ---------- dataId : `dict` Identifier for catalog to retrieve schema : `lsst.afw.table.Schema` Schema to use in catalog creation if the butler can't get it
Returns ------- catalog : `lsst.afw.table.SimpleCatalog` The catalog specified by `dataId` """
"""Make the schema to use in constructing the persisted catalogs.
Parameters ---------- dtype : `numpy.dtype` Data type describing each entry in ``config.extra_col_names`` for the catalogs being ingested.
Returns ------- schemaAndKeyMap : `tuple` of (`lsst.afw.table.Schema`, `dict`) A tuple containing two items: - The schema for the output source catalog. - A map of catalog keys to use in filling the record """
# make a schema with the standard fields filterNameList=self.config.mag_column_list, addFluxErr=bool(self.config.mag_err_column_map), addCentroid=False, addIsPhotometric=bool(self.config.is_photometric_name), addIsResolved=bool(self.config.is_resolved_name), addIsVariable=bool(self.config.is_variable_name), coordErrDim=2 if bool(self.config.ra_err_name) else 0, addProperMotion=2 if bool(self.config.pm_ra_name) else 0, properMotionErrDim=2 if bool(self.config.pm_ra_err_name) else 0, addParallax=bool(self.config.parallax_name), addParallaxErr=bool(self.config.parallax_err_name), ) if fieldName not in keysToSkip}
# dealing with a string like thing. Need to get type and size. else:
|