|
LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
Public Member Functions | |
| def | __iter__ (self) |
| def | keys (self) |
| def | values (self) |
| def | items (self) |
| def | iteritems (self) |
| def | itervalues (self) |
| def | iterkeys (self) |
| def | __contains__ (self, name) |
| Return True if the specified field exists in this config. More... | |
| def | __new__ (cls, *args, **kw) |
| def | __reduce__ (self) |
| def | setDefaults (self) |
| def | update (self, **kw) |
| def | load (self, filename, root="config") |
| def | loadFromStream (self, stream, root="config", filename=None) |
| def | save (self, filename, root="config") |
| def | saveToStream (self, outfile, root="config", skipImports=False) |
| def | freeze (self) |
| def | toDict (self) |
| def | names (self) |
| def | validate (self) |
| def | formatHistory (self, name, **kwargs) |
| def | __setattr__ (self, attr, value, at=None, label="assignment") |
| def | __delattr__ (self, attr, at=None, label="deletion") |
| def | __eq__ (self, other) |
| def | __ne__ (self, other) |
| def | __str__ (self) |
| def | __repr__ (self) |
| def | compare (self, other, shortcut=True, rtol=1E-8, atol=1E-8, output=None) |
| def | __init_subclass__ (cls, **kwargs) |
| def | __setattr__ (cls, name, value) |
Properties | |
| history = property(lambda x: x._history) | |
Base class for configuration (*config*) objects.
Notes
-----
A ``Config`` object will usually have several `~lsst.pex.config.Field`
instances as class attributes. These are used to define most of the base
class behavior.
``Config`` implements a mapping API that provides many `dict`-like methods,
such as `keys`, `values`, `items`, `iteritems`, `iterkeys`, and
`itervalues`. ``Config`` instances also support the ``in`` operator to
test if a field is in the config. Unlike a `dict`, ``Config`` classes are
not subscriptable. Instead, access individual fields as attributes of the
configuration instance.
Examples
--------
Config classes are subclasses of ``Config`` that have
`~lsst.pex.config.Field` instances (or instances of
`~lsst.pex.config.Field` subclasses) as class attributes:
>>> from lsst.pex.config import Config, Field, ListField
>>> class DemoConfig(Config):
... intField = Field(doc="An integer field", dtype=int, default=42)
... listField = ListField(doc="List of favorite beverages.", dtype=str,
... default=['coffee', 'green tea', 'water'])
...
>>> config = DemoConfig()
Configs support many `dict`-like APIs:
>>> config.keys()
['intField', 'listField']
>>> 'intField' in config
True
Individual fields can be accessed as attributes of the configuration:
>>> config.intField
42
>>> config.listField.append('earl grey tea')
>>> print(config.listField)
['coffee', 'green tea', 'water', 'earl grey tea']
| def lsst.pex.config.config.Config.__contains__ | ( | self, | |
| name | |||
| ) |
Return True if the specified field exists in this config.
@param[in] name field name to test for
| def lsst.pex.config.config.Config.__delattr__ | ( | self, | |
| attr, | |||
at = None, |
|||
label = "deletion" |
|||
| ) |
| def lsst.pex.config.config.Config.__init_subclass__ | ( | cls, | |
| ** | kwargs | ||
| ) |
Run initialization for every subclass. Specifically registers the subclass with a YAML representer and YAML constructor (if pyyaml is available)
Reimplemented in lsst.pipe.tasks.dataFrameActions._baseDataFrameActions.DataFrameAction.
Definition at line 1447 of file config.py.
| def lsst.pex.config.config.Config.__iter__ | ( | self | ) |
| def lsst.pex.config.config.Config.__ne__ | ( | self, | |
| other | |||
| ) |
| def lsst.pex.config.config.Config.__new__ | ( | cls, | |
| * | args, | ||
| ** | kw | ||
| ) |
Allocate a new `lsst.pex.config.Config` object. In order to ensure that all Config object are always in a proper state when handed to users or to derived `~lsst.pex.config.Config` classes, some attributes are handled at allocation time rather than at initialization. This ensures that even if a derived `~lsst.pex.config.Config` class implements ``__init__``, its author does not need to be concerned about when or even the base ``Config.__init__`` should be called.
Definition at line 893 of file config.py.
| def lsst.pex.config.config.Config.__reduce__ | ( | self | ) |
Reduction for pickling (function with arguments to reproduce). We need to condense and reconstitute the `~lsst.pex.config.Config`, since it may contain lambdas (as the ``check`` elements) that cannot be pickled.
Definition at line 926 of file config.py.
|
inherited |
| def lsst.pex.config.config.Config.__setattr__ | ( | self, | |
| attr, | |||
| value, | |||
at = None, |
|||
label = "assignment" |
|||
| ) |
Set an attribute (such as a field's value). Notes ----- Unlike normal Python objects, `~lsst.pex.config.Config` objects are locked such that no additional attributes nor properties may be added to them dynamically. Although this is not the standard Python behavior, it helps to protect users from accidentally mispelling a field name, or trying to set a non-existent field.
| def lsst.pex.config.config.Config.__str__ | ( | self | ) |
| def lsst.pex.config.config.Config.compare | ( | self, | |
| other, | |||
shortcut = True, |
|||
rtol = 1E-8, |
|||
atol = 1E-8, |
|||
output = None |
|||
| ) |
Compare this configuration to another `~lsst.pex.config.Config` for
equality.
Parameters
----------
other : `lsst.pex.config.Config`
Other `~lsst.pex.config.Config` object to compare against this
config.
shortcut : `bool`, optional
If `True`, return as soon as an inequality is found. Default is
`True`.
rtol : `float`, optional
Relative tolerance for floating point comparisons.
atol : `float`, optional
Absolute tolerance for floating point comparisons.
output : callable, optional
A callable that takes a string, used (possibly repeatedly) to
report inequalities.
Returns
-------
isEqual : `bool`
`True` when the two `lsst.pex.config.Config` instances are equal.
`False` if there is an inequality.
See also
--------
lsst.pex.config.compareConfigs
Notes
-----
Unselected targets of `~lsst.pex.config.RegistryField` fields and
unselected choices of `~lsst.pex.config.ConfigChoiceField` fields
are not considered by this method.
Floating point comparisons are performed by `numpy.allclose`.
Definition at line 1402 of file config.py.
| def lsst.pex.config.config.Config.formatHistory | ( | self, | |
| name, | |||
| ** | kwargs | ||
| ) |
Format a configuration field's history to a human-readable format.
Parameters
----------
name : `str`
Name of a `~lsst.pex.config.Field` in this config.
kwargs
Keyword arguments passed to `lsst.pex.config.history.format`.
Returns
-------
history : `str`
A string containing the formatted history.
See also
--------
lsst.pex.config.history.format
Definition at line 1311 of file config.py.
| def lsst.pex.config.config.Config.freeze | ( | self | ) |
| def lsst.pex.config.config.Config.items | ( | self | ) |
| def lsst.pex.config.config.Config.iteritems | ( | self | ) |
| def lsst.pex.config.config.Config.iterkeys | ( | self | ) |
| def lsst.pex.config.config.Config.itervalues | ( | self | ) |
| def lsst.pex.config.config.Config.keys | ( | self | ) |
Get field names.
Returns
-------
names : `list`
List of `lsst.pex.config.Field` names.
See also
--------
lsst.pex.config.Config.iterkeys
| def lsst.pex.config.config.Config.load | ( | self, | |
| filename, | |||
root = "config" |
|||
| ) |
Modify this config in place by executing the Python code in a
configuration file.
Parameters
----------
filename : `str`
Name of the configuration file. A configuration file is Python
module.
root : `str`, optional
Name of the variable in file that refers to the config being
overridden.
For example, the value of root is ``"config"`` and the file
contains::
config.myField = 5
Then this config's field ``myField`` is set to ``5``.
**Deprecated:** For backwards compatibility, older config files
that use ``root="root"`` instead of ``root="config"`` will be
loaded with a warning printed to `sys.stderr`. This feature will be
removed at some point.
See also
--------
lsst.pex.config.Config.loadFromStream
lsst.pex.config.Config.save
lsst.pex.config.Config.saveFromStream
Definition at line 1012 of file config.py.
| def lsst.pex.config.config.Config.loadFromStream | ( | self, | |
| stream, | |||
root = "config", |
|||
filename = None |
|||
| ) |
Modify this Config in place by executing the Python code in the
provided stream.
Parameters
----------
stream : file-like object, `str`, or compiled string
Stream containing configuration override code.
root : `str`, optional
Name of the variable in file that refers to the config being
overridden.
For example, the value of root is ``"config"`` and the file
contains::
config.myField = 5
Then this config's field ``myField`` is set to ``5``.
**Deprecated:** For backwards compatibility, older config files
that use ``root="root"`` instead of ``root="config"`` will be
loaded with a warning printed to `sys.stderr`. This feature will be
removed at some point.
filename : `str`, optional
Name of the configuration file, or `None` if unknown or contained
in the stream. Used for error reporting.
See also
--------
lsst.pex.config.Config.load
lsst.pex.config.Config.save
lsst.pex.config.Config.saveFromStream
Definition at line 1047 of file config.py.
| def lsst.pex.config.config.Config.names | ( | self | ) |
| def lsst.pex.config.config.Config.save | ( | self, | |
| filename, | |||
root = "config" |
|||
| ) |
Save a Python script to the named file, which, when loaded,
reproduces this config.
Parameters
----------
filename : `str`
Desination filename of this configuration.
root : `str`, optional
Name to use for the root config variable. The same value must be
used when loading (see `lsst.pex.config.Config.load`).
See also
--------
lsst.pex.config.Config.saveToStream
lsst.pex.config.Config.load
lsst.pex.config.Config.loadFromStream
Definition at line 1103 of file config.py.
| def lsst.pex.config.config.Config.saveToStream | ( | self, | |
| outfile, | |||
root = "config", |
|||
skipImports = False |
|||
| ) |
Save a configuration file to a stream, which, when loaded,
reproduces this config.
Parameters
----------
outfile : file-like object
Destination file object write the config into. Accepts strings not
bytes.
root
Name to use for the root config variable. The same value must be
used when loading (see `lsst.pex.config.Config.load`).
skipImports : `bool`, optional
If `True` then do not include ``import`` statements in output,
this is to support human-oriented output from ``pipetask`` where
additional clutter is not useful.
See also
--------
lsst.pex.config.Config.save
lsst.pex.config.Config.load
lsst.pex.config.Config.loadFromStream
Definition at line 1135 of file config.py.
| def lsst.pex.config.config.Config.setDefaults | ( | self | ) |
Subclass hook for computing defaults. Notes ----- Derived `~lsst.pex.config.Config` classes that must compute defaults rather than using the `~lsst.pex.config.Field` instances's defaults should do so here. To correctly use inherited defaults, implementations of ``setDefaults`` must call their base class's ``setDefaults``.
Reimplemented in lsst.pipe.tasks.scaleVariance.ScaleVarianceConfig, lsst.pipe.tasks.mocks.mockCoadd.MockCoaddConfig, lsst.pipe.tasks.ingestCuratedCalibs.IngestCuratedCalibsConfig, lsst.pipe.tasks.dataFrameActions._actions.NanoJansky, lsst.pipe.drivers.multiBandDriver.MultiBandDriverConfig, lsst.pipe.drivers.constructCalibs.FringeConfig, lsst.pipe.drivers.constructCalibs.DarkConfig, lsst.pipe.drivers.constructCalibs.CalibConfig, lsst.pipe.drivers.coaddDriver.CoaddDriverConfig, lsst.pipe.drivers.background.MaskObjectsConfig, lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedConfig, lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFrameConfig, lsst.meas.modelfit.cmodel.cmodelContinued.CModelForcedConfig, lsst.meas.modelfit.cmodel.cmodelContinued.CModelSingleFrameConfig, lsst.meas.base.forcedMeasurement.ForcedMeasurementConfig, and lsst.ip.diffim.dipoleMeasurement.DipoleMeasurementConfig.
Definition at line 939 of file config.py.
| def lsst.pex.config.config.Config.toDict | ( | self | ) |
Make a dictionary of field names and their values.
Returns
-------
dict_ : `dict`
Dictionary with keys that are `~lsst.pex.config.Field` names.
Values are `~lsst.pex.config.Field` values.
See also
--------
lsst.pex.config.Field.toDict
Notes
-----
This method uses the `~lsst.pex.config.Field.toDict` method of
individual fields. Subclasses of `~lsst.pex.config.Field` may need to
implement a ``toDict`` method for *this* method to work.
Definition at line 1208 of file config.py.
| def lsst.pex.config.config.Config.update | ( | self, | |
| ** | kw | ||
| ) |
Update values of fields specified by the keyword arguments.
Parameters
----------
kw
Keywords are configuration field names. Values are configuration
field values.
Notes
-----
The ``__at`` and ``__label`` keyword arguments are special internal
keywords. They are used to strip out any internal steps from the
history tracebacks of the config. Do not modify these keywords to
subvert a `~lsst.pex.config.Config` instance's history.
Examples
--------
This is a config with three fields:
>>> from lsst.pex.config import Config, Field
>>> class DemoConfig(Config):
... fieldA = Field(doc='Field A', dtype=int, default=42)
... fieldB = Field(doc='Field B', dtype=bool, default=True)
... fieldC = Field(doc='Field C', dtype=str, default='Hello world')
...
>>> config = DemoConfig()
These are the default values of each field:
>>> for name, value in config.iteritems():
... print(f"{name}: {value}")
...
fieldA: 42
fieldB: True
fieldC: 'Hello world'
Using this method to update ``fieldA`` and ``fieldC``:
>>> config.update(fieldA=13, fieldC='Updated!')
Now the values of each field are:
>>> for name, value in config.iteritems():
... print(f"{name}: {value}")
...
fieldA: 13
fieldB: True
fieldC: 'Updated!'
Definition at line 952 of file config.py.
| def lsst.pex.config.config.Config.validate | ( | self | ) |
Validate the Config, raising an exception if invalid.
Raises
------
lsst.pex.config.FieldValidationError
Raised if verification fails.
Notes
-----
The base class implementation performs type checks on all fields by
calling their `~lsst.pex.config.Field.validate` methods.
Complex single-field validation can be defined by deriving new Field
types. For convenience, some derived `lsst.pex.config.Field`-types
(`~lsst.pex.config.ConfigField` and
`~lsst.pex.config.ConfigChoiceField`) are defined in `lsst.pex.config`
that handle recursing into subconfigs.
Inter-field relationships should only be checked in derived
`~lsst.pex.config.Config` classes after calling this method, and base
validation is complete.
Reimplemented in lsst.pipe.drivers.multiBandDriver.MultiBandDriverConfig, lsst.pipe.drivers.coaddDriver.CoaddDriverConfig, lsst.pipe.drivers.background.MaskObjectsConfig, lsst.meas.base.baseMeasurement.BaseMeasurementConfig, lsst.meas.algorithms.measureApCorr.MeasureApCorrConfig, lsst.meas.algorithms.gaussianPsfFactory.GaussianPsfFactory, lsst.fgcmcal.sedterms.Sedterm, lsst.dax.apdb.apdbSql.ApdbSqlConfig, and lsst.afw.geom.transformConfig.RadialTransformConfig.
Definition at line 1285 of file config.py.
| def lsst.pex.config.config.Config.values | ( | self | ) |
|
static |