LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
|
Public Member Functions | |
int | catalog_id (self) |
str | __str__ (self) |
IdFactory | make_table_id_factory (self) |
SourceCatalog | make_source_catalog (self, Schema schema) |
np.ndarray | arange (self, *args, **kwargs) |
Callable[[int], tuple[DataCoordinate, int]] | unpacker_from_config (cls, BaseIdGeneratorConfig config, DataCoordinate fixed) |
Callable[[int], tuple[int, DataCoordinate, int]] | unpacker_from_dimension_packer (cls, DimensionPacker dimension_packer, int n_releases=DEFAULT_N_RELEASES) |
A helper class for packing some combination of a data ID, a per-data-ID counter, and a release ID into a single 64-bit integer. As an object frequently passed into code that otherwise has no knowledge of its own data ID, `IdGenerator` also implements ``__str__`` to provide a human-readable representation of the data ID for use in logs and exception messages, with a suitable fallback when no data ID was provided to it. Notes ----- Instances of this class are expected to usually be created via configuration, which will return a derived instance. This pattern starts with one of `DetectorExposureIdGeneratorConfig`, `DetectorVisitIdGeneratorConfig`, and `SkyMapIdGeneratorConfig` (which have the same interface), and looks something this: from lsst.meas.base import DetectorVisitIdGeneratorConfig from lsst.pex.config import Config from lsst.pipe.base import PipelineTask class SomeTaskConfig(PipelineTaskConfig, ...): id_generator = DetectorVisitIdGeneratorConfig.make_field() class SomeTask(PipelineTaskTask): ConfigClass = SomeTaskConfig ... def runQuantum(self, ..., data_id: DataCoordinate): id_generator = self.config.apply(data_id) catalog = id_generator.make_source_catalog(self.schema) ... There is no requirement that `IdGenerator` instances be constructed in `PipelineTask.runQuantum` methods and passed to the ``run`` method, but this is the most common approach. Code that wishes to instead unpack these record IDs to obtain the release ID, data ID and counter value should use the same config (often loaded from the ``Butler``) and pass a fully-expanded data ID identifying only a particular ``skymap`` or ``instrument`` to `unpacker_from_config`:: config = butler.get("some_task_config") catalog = butler.get("some_output_catalog", given_data_id) unpacker = IdGenerator.unpacker_from_config( config.id_generator, butler.registry.expandDataId(skymap="HSC"), ) release_id, embedded_data_id, counter = unpacker(catalog[0]["id"]) assert embedded_data_id == given_data_id This example is a bit contrived, as the ability to reconstruct the data ID is really only useful when you don't have it already, such as when the record ID is obtained from some further-processed version of the original table (such as a SQL database), and in that context the right config to load will not be obvious unless it has been carefully documented. Simple instances of the base class that do not include a data ID may also be constructed by calling the constructor directly:: id_generator = IdGenerator() These IDs may not be unpacked, but they also don't need to be, because they're just the per-catalog "counter" integer already. See Also -------- :ref:`lsst.meas.base-generating-source-and-object-ids`
Definition at line 213 of file _id_generator.py.
str lsst.meas.base._id_generator.IdGenerator.__str__ | ( | self | ) |
Return a human-readable representation of the data ID (or a note about its absence) for use in log and error messages.
Reimplemented in lsst.meas.base._id_generator.FullIdGenerator.
Definition at line 293 of file _id_generator.py.
np.ndarray lsst.meas.base._id_generator.IdGenerator.arange | ( | self, | |
* | args, | ||
** | kwargs ) |
Generate an array of integer IDs for this catalog. All parameters are forwarded to `numpy.arange` to generate an array of per-catalog counter integers. These are then combined with the `catalog_id`` to form the returned array. The IDs generated by `arange` will be equivalent to those generated by `make_table_id_factory` (and by extension, `make_source_catalog`) only if the counter integers start with ``1``, not ``0``, because that's what `~lsst.afw.table.IdFactory` does.
Reimplemented in lsst.meas.base._id_generator.FullIdGenerator.
Definition at line 314 of file _id_generator.py.
int lsst.meas.base._id_generator.IdGenerator.catalog_id | ( | self | ) |
The integer identifier for the full catalog with this data ID, not just one of its rows (`int`). This combines the packed data ID and release ID, but not the counter.
Reimplemented in lsst.meas.base._id_generator.FullIdGenerator.
Definition at line 284 of file _id_generator.py.
SourceCatalog lsst.meas.base._id_generator.IdGenerator.make_source_catalog | ( | self, | |
Schema | schema ) |
Construct a empty catalog object with an ID factory. This is a convenience function for the common pattern of calling `make_table_id_factory`, constructing a `~lsst.afw.table.SourceTable` from that, and then constructing an (empty) `~lsst.afw.table.SourceCatalog` from that.
Definition at line 303 of file _id_generator.py.
IdFactory lsst.meas.base._id_generator.IdGenerator.make_table_id_factory | ( | self | ) |
Construct a new `lsst.afw.table.IdFactory` for this catalog.
Reimplemented in lsst.meas.base._id_generator.FullIdGenerator.
Definition at line 299 of file _id_generator.py.
Callable[[int], tuple[DataCoordinate, int]] lsst.meas.base._id_generator.IdGenerator.unpacker_from_config | ( | cls, | |
BaseIdGeneratorConfig | config, | ||
DataCoordinate | fixed ) |
Return a callable that unpacks the IDs generated by this class, from a config field. Parameters ---------- config : `BaseIdGeneratorConfig` Configuration for an ID generator. fixed : `DataCoordinate` Data ID identifying the dimensions that are considered fixed by the `IdGenerator` that produced the IDs: usually just ``instrument`` or ``skymap``, depending on the configuration. For most configurations this will need to be a fully-expanded data ID. Returns ------- unpacker Callable that takes a single `int` argument (an ID generated by an identically-configured `IdGenerator`) and returns a tuple of: - release_id: the integer that identifies a data release or similar (`int`); - data_id : the data ID used to initialize the original ID generator (`DataCoordinate`); - counter : the counter part of the original ID (`int`). Notes ----- This method cannot be used on IDs generated without a data ID.
Definition at line 329 of file _id_generator.py.
Callable[[int], tuple[int, DataCoordinate, int]] lsst.meas.base._id_generator.IdGenerator.unpacker_from_dimension_packer | ( | cls, | |
DimensionPacker | dimension_packer, | ||
int | n_releases = DEFAULT_N_RELEASES ) |
Return a callable that unpacks the IDs generated by this class, from a `lsst.daf.butler.DimensionPacker` instance. Parameters ---------- dimension_packer : `lsst.daf.butler.DimensionPacker` Dimension packer used to construct the original `DimensionPackerIdGenerator`. n_releases : `int`, optional Number of (contiguous, starting from zero) ``release_id`` values to reserve space for. One (not zero) is used to reserve no space. Returns ------- unpacker Callable that takes a single `int` argument (an ID generated by an identically-constructed `DimensionPackerIdGenerator`) and returns a tuple of: - release_id: the integer that identifies a data release or similar (`int`); - data_id : the data ID used to initialize the original ID generator (`DataCoordinate`); - counter : the counter part of the original ID (`int`). Notes ----- This method cannot be used on IDs generated with no data ID.
Definition at line 367 of file _id_generator.py.