DcrAssembleCoaddConnections

class lsst.pipe.tasks.dcrAssembleCoadd.DcrAssembleCoaddConnections(*, config: PipelineTaskConfig | None = None)

Bases: AssembleCoaddConnections

Attributes Summary

allConnections

Mapping holding all connection attributes.

brightObjectMask

Class used for declaring PipelineTask prerequisite connections.

coaddExposure

Connection for output dataset.

dcrCoadds

Connection for output dataset.

dcrNImages

Connection for output dataset.

defaultTemplates

deprecatedTemplates

dimensions

Set of dimension names that define the unit of work for this task.

initInputs

Set with the names of all InitInput connection attributes.

initOutputs

Set with the names of all InitOutput connection attributes.

inputMap

Connection for output dataset.

inputWarps

Class used for declaring PipelineTask input connections

inputs

Set with the names of all connectionTypes.Input connection attributes.

nImage

Connection for output dataset.

outputs

Set with the names of all Output connection attributes.

prerequisiteInputs

Set with the names of all PrerequisiteInput connection attributes.

selectedVisits

Class used for declaring PipelineTask input connections

skyMap

Class used for declaring PipelineTask input connections

templateExposure

Class used for declaring PipelineTask input connections

Methods Summary

adjustQuantum(inputs, outputs, label, data_id)

Override to make adjustments to lsst.daf.butler.DatasetRef objects in the lsst.daf.butler.core.Quantum during the graph generation stage of the activator.

buildDatasetRefs(quantum)

Build QuantizedConnection corresponding to input Quantum.

getSpatialBoundsConnections()

Return the names of regular input and output connections whose data IDs should be used to compute the spatial bounds of this task's quanta.

getTemporalBoundsConnections()

Return the names of regular input and output connections whose data IDs should be used to compute the temporal bounds of this task's quanta.

Attributes Documentation

allConnections: Mapping[str, BaseConnection] = {'brightObjectMask': PrerequisiteInput(name='brightObjectMask', storageClass='ObjectMaskCatalog', doc='Input Bright Object Mask mask produced with external catalogs to be applied to the mask plane BRIGHT_OBJECT.', multiple=False, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band'), isCalibration=False, deferLoad=False, minimum=0, lookupFunction=None), 'coaddExposure': Output(name='{outputCoaddName}Coadd{warpTypeSuffix}', storageClass='ExposureF', doc='Output coadded exposure, produced by stacking input warps', multiple=False, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band'), isCalibration=False), 'dcrCoadds': Output(name='{fakesType}{outputCoaddName}Coadd{warpTypeSuffix}', storageClass='ExposureF', doc='Output coadded exposure, produced by stacking input warps', multiple=True, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band', 'subfilter'), isCalibration=False), 'dcrNImages': Output(name='{outputCoaddName}Coadd_nImage', storageClass='ImageU', doc='Output image of number of input images per pixel', multiple=True, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band', 'subfilter'), isCalibration=False), 'inputMap': Output(name='{outputCoaddName}Coadd_inputMap', storageClass='HealSparseMap', doc='Output healsparse map of input images', multiple=False, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band'), isCalibration=False), 'inputWarps': Input(name='{inputWarpName}Coadd_{warpType}Warp', storageClass='ExposureF', doc='Input list of warps to be assembled i.e. stacked.Note that this will often be different than the inputCoaddName.WarpType (e.g. direct, psfMatched) is controlled by the warpType config parameter', multiple=True, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'visit', 'instrument'), isCalibration=False, deferLoad=True, minimum=1, deferGraphConstraint=False), 'nImage': Output(name='{outputCoaddName}Coadd_nImage', storageClass='ImageU', doc='Output image of number of input images per pixel', multiple=False, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band'), isCalibration=False), 'selectedVisits': Input(name='{outputCoaddName}Visits', storageClass='StructuredDataDict', doc='Selected visits to be coadded.', multiple=False, deprecated=None, _deprecation_context='', dimensions=('instrument', 'tract', 'patch', 'skymap', 'band'), isCalibration=False, deferLoad=False, minimum=1, deferGraphConstraint=False), 'skyMap': Input(name='skyMap', storageClass='SkyMap', doc='Input definition of geometry/bbox and projection/wcs for coadded exposures', multiple=False, deprecated=None, _deprecation_context='', dimensions=('skymap',), isCalibration=False, deferLoad=False, minimum=1, deferGraphConstraint=False), 'templateExposure': Input(name='{fakesType}{inputCoaddName}Coadd{warpTypeSuffix}', storageClass='ExposureF', doc='Input coadded exposure, produced by previous call to AssembleCoadd', multiple=False, deprecated=None, _deprecation_context='', dimensions=('tract', 'patch', 'skymap', 'band'), isCalibration=False, deferLoad=False, minimum=1, deferGraphConstraint=False)}

Mapping holding all connection attributes.

This is a read-only view that is automatically updated when connection attributes are added, removed, or replaced in __init__. It is also updated after __init__ completes to reflect changes in inputs, prerequisiteInputs, outputs, initInputs, and initOutputs.

brightObjectMask

Class used for declaring PipelineTask prerequisite connections.

Parameters:
namestr

The default name used to identify the dataset type

storageClassstr

The storage class used when (un)/persisting the dataset type

multiplebool

Indicates if this connection should expect to contain multiple objects of the given dataset type. Tasks with more than one connection with multiple=True with the same dimensions may want to implement PipelineTaskConnections.adjustQuantum to ensure those datasets are consistent (i.e. zip-iterable) in PipelineTask.runQuantum and notify the execution system as early as possible of outputs that will not be produced because the corresponding input is missing.

dimensionsiterable of str

The lsst.daf.butler.Butler lsst.daf.butler.Registry dimensions used to identify the dataset type identified by the specified name

minimumbool

Minimum number of datasets required for this connection, per quantum. This is checked in the base implementation of PipelineTaskConnections.adjustQuantum, which raises FileNotFoundError (causing QuantumGraph generation to fail). PipelineTask implementations may provide custom adjustQuantum implementations for more fine-grained or configuration-driven constraints, as long as they are compatible with this minium.

lookupFunction: `typing.Callable`, optional

An optional callable function that will look up PrerequisiteInputs using the DatasetType, registry, quantum dataId, and input collections passed to it. If no function is specified, the default temporal spatial lookup will be used.

Raises:
TypeError

Raised if minimum is greater than one but multiple=False.

Notes

Prerequisite inputs are used for datasets that must exist in the data repository before a pipeline including this is run; they cannot be produced by another task in the same pipeline.

In exchange for this limitation, they have a number of advantages relative to regular Input connections:

  • The query used to find them then during QuantumGraph generation can be fully customized by providing a lookupFunction.

  • Failed searches for prerequisites during QuantumGraph generation will usually generate more helpful diagnostics than those for regular Input connections.

  • The default query for prerequisite inputs relates the quantum dimensions directly to the dimensions of its dataset type, without being constrained by any of the other dimensions in the pipeline. This allows them to be used for temporal calibration lookups (which regular Input connections cannot do at present) and to work around QuantumGraph generation limitations involving cases where naive spatial overlap relationships between dimensions are not desired (e.g. a task that wants all detectors in each visit for which the visit overlaps a tract, not just those where that detector+visit combination overlaps the tract).

  • Prerequisite inputs may be optional (regular inputs are never optional).

coaddExposure

Connection for output dataset.

dcrCoadds

Connection for output dataset.

dcrNImages

Connection for output dataset.

defaultTemplates = {'fakesType': '', 'inputCoaddName': 'deep', 'inputWarpName': 'deep', 'outputCoaddName': 'dcr', 'warpType': 'direct', 'warpTypeSuffix': ''}
deprecatedTemplates = {}
dimensions: set[str] = {'band', 'patch', 'skymap', 'tract'}

Set of dimension names that define the unit of work for this task.

Required and implied dependencies will automatically be expanded later and need not be provided.

This may be replaced or modified in __init__ to change the dimensions of the task. After __init__ it will be a frozenset and may not be replaced.

initInputs: set[str] = frozenset({})

Set with the names of all InitInput connection attributes.

See inputs for additional information.

initOutputs: set[str] = frozenset({})

Set with the names of all InitOutput connection attributes.

See inputs for additional information.

inputMap

Connection for output dataset.

inputWarps

Class used for declaring PipelineTask input connections

Parameters:
namestr

The default name used to identify the dataset type

storageClassstr

The storage class used when (un)/persisting the dataset type

multiplebool

Indicates if this connection should expect to contain multiple objects of the given dataset type. Tasks with more than one connection with multiple=True with the same dimensions may want to implement PipelineTaskConnections.adjustQuantum to ensure those datasets are consistent (i.e. zip-iterable) in PipelineTask.runQuantum and notify the execution system as early as possible of outputs that will not be produced because the corresponding input is missing.

dimensionsiterable of str

The lsst.daf.butler.Butler lsst.daf.butler.Registry dimensions used to identify the dataset type identified by the specified name

deferLoadbool

Indicates that this dataset type will be loaded as a lsst.daf.butler.DeferredDatasetHandle. PipelineTasks can use this object to load the object at a later time.

minimumbool

Minimum number of datasets required for this connection, per quantum. This is checked in the base implementation of PipelineTaskConnections.adjustQuantum, which raises NoWorkFound if the minimum is not met for Input connections (causing the quantum to be pruned, skipped, or never created, depending on the context), and FileNotFoundError for PrerequisiteInput connections (causing QuantumGraph generation to fail). PipelineTask implementations may provide custom adjustQuantum implementations for more fine-grained or configuration-driven constraints, as long as they are compatible with this minium.

deferGraphConstraint: `bool`, optional

If True, do not include this dataset type’s existence in the initial query that starts the QuantumGraph generation process. This can be used to make QuantumGraph generation faster by avoiding redundant datasets, and in certain cases it can (along with careful attention to which tasks are included in the same QuantumGraph) be used to work around the QuantumGraph generation algorithm’s inflexible handling of spatial overlaps. This option has no effect when the connection is not an overall input of the pipeline (or subset thereof) for which a graph is being created, and it never affects the ordering of quanta.

Raises:
TypeError

Raised if minimum is greater than one but multiple=False.

NotImplementedError

Raised if minimum is zero for a regular Input connection; this is not currently supported by our QuantumGraph generation algorithm.

inputs: set[str] = frozenset({'inputWarps', 'selectedVisits', 'skyMap', 'templateExposure'})

Set with the names of all connectionTypes.Input connection attributes.

This is updated automatically as class attributes are added, removed, or replaced in __init__. Removing entries from this set will cause those connections to be removed after __init__ completes, but this is supported only for backwards compatibility; new code should instead just delete the collection attributed directly. After __init__ this will be a frozenset and may not be replaced.

nImage

Connection for output dataset.

outputs: set[str] = frozenset({'coaddExposure', 'dcrCoadds', 'dcrNImages', 'inputMap', 'nImage'})

Set with the names of all Output connection attributes.

See inputs for additional information.

prerequisiteInputs: set[str] = frozenset({'brightObjectMask'})

Set with the names of all PrerequisiteInput connection attributes.

See inputs for additional information.

selectedVisits

Class used for declaring PipelineTask input connections

Parameters:
namestr

The default name used to identify the dataset type

storageClassstr

The storage class used when (un)/persisting the dataset type

multiplebool

Indicates if this connection should expect to contain multiple objects of the given dataset type. Tasks with more than one connection with multiple=True with the same dimensions may want to implement PipelineTaskConnections.adjustQuantum to ensure those datasets are consistent (i.e. zip-iterable) in PipelineTask.runQuantum and notify the execution system as early as possible of outputs that will not be produced because the corresponding input is missing.

dimensionsiterable of str

The lsst.daf.butler.Butler lsst.daf.butler.Registry dimensions used to identify the dataset type identified by the specified name

deferLoadbool

Indicates that this dataset type will be loaded as a lsst.daf.butler.DeferredDatasetHandle. PipelineTasks can use this object to load the object at a later time.

minimumbool

Minimum number of datasets required for this connection, per quantum. This is checked in the base implementation of PipelineTaskConnections.adjustQuantum, which raises NoWorkFound if the minimum is not met for Input connections (causing the quantum to be pruned, skipped, or never created, depending on the context), and FileNotFoundError for PrerequisiteInput connections (causing QuantumGraph generation to fail). PipelineTask implementations may provide custom adjustQuantum implementations for more fine-grained or configuration-driven constraints, as long as they are compatible with this minium.

deferGraphConstraint: `bool`, optional

If True, do not include this dataset type’s existence in the initial query that starts the QuantumGraph generation process. This can be used to make QuantumGraph generation faster by avoiding redundant datasets, and in certain cases it can (along with careful attention to which tasks are included in the same QuantumGraph) be used to work around the QuantumGraph generation algorithm’s inflexible handling of spatial overlaps. This option has no effect when the connection is not an overall input of the pipeline (or subset thereof) for which a graph is being created, and it never affects the ordering of quanta.

Raises:
TypeError

Raised if minimum is greater than one but multiple=False.

NotImplementedError

Raised if minimum is zero for a regular Input connection; this is not currently supported by our QuantumGraph generation algorithm.

skyMap

Class used for declaring PipelineTask input connections

Parameters:
namestr

The default name used to identify the dataset type

storageClassstr

The storage class used when (un)/persisting the dataset type

multiplebool

Indicates if this connection should expect to contain multiple objects of the given dataset type. Tasks with more than one connection with multiple=True with the same dimensions may want to implement PipelineTaskConnections.adjustQuantum to ensure those datasets are consistent (i.e. zip-iterable) in PipelineTask.runQuantum and notify the execution system as early as possible of outputs that will not be produced because the corresponding input is missing.

dimensionsiterable of str

The lsst.daf.butler.Butler lsst.daf.butler.Registry dimensions used to identify the dataset type identified by the specified name

deferLoadbool

Indicates that this dataset type will be loaded as a lsst.daf.butler.DeferredDatasetHandle. PipelineTasks can use this object to load the object at a later time.

minimumbool

Minimum number of datasets required for this connection, per quantum. This is checked in the base implementation of PipelineTaskConnections.adjustQuantum, which raises NoWorkFound if the minimum is not met for Input connections (causing the quantum to be pruned, skipped, or never created, depending on the context), and FileNotFoundError for PrerequisiteInput connections (causing QuantumGraph generation to fail). PipelineTask implementations may provide custom adjustQuantum implementations for more fine-grained or configuration-driven constraints, as long as they are compatible with this minium.

deferGraphConstraint: `bool`, optional

If True, do not include this dataset type’s existence in the initial query that starts the QuantumGraph generation process. This can be used to make QuantumGraph generation faster by avoiding redundant datasets, and in certain cases it can (along with careful attention to which tasks are included in the same QuantumGraph) be used to work around the QuantumGraph generation algorithm’s inflexible handling of spatial overlaps. This option has no effect when the connection is not an overall input of the pipeline (or subset thereof) for which a graph is being created, and it never affects the ordering of quanta.

Raises:
TypeError

Raised if minimum is greater than one but multiple=False.

NotImplementedError

Raised if minimum is zero for a regular Input connection; this is not currently supported by our QuantumGraph generation algorithm.

templateExposure

Class used for declaring PipelineTask input connections

Parameters:
namestr

The default name used to identify the dataset type

storageClassstr

The storage class used when (un)/persisting the dataset type

multiplebool

Indicates if this connection should expect to contain multiple objects of the given dataset type. Tasks with more than one connection with multiple=True with the same dimensions may want to implement PipelineTaskConnections.adjustQuantum to ensure those datasets are consistent (i.e. zip-iterable) in PipelineTask.runQuantum and notify the execution system as early as possible of outputs that will not be produced because the corresponding input is missing.

dimensionsiterable of str

The lsst.daf.butler.Butler lsst.daf.butler.Registry dimensions used to identify the dataset type identified by the specified name

deferLoadbool

Indicates that this dataset type will be loaded as a lsst.daf.butler.DeferredDatasetHandle. PipelineTasks can use this object to load the object at a later time.

minimumbool

Minimum number of datasets required for this connection, per quantum. This is checked in the base implementation of PipelineTaskConnections.adjustQuantum, which raises NoWorkFound if the minimum is not met for Input connections (causing the quantum to be pruned, skipped, or never created, depending on the context), and FileNotFoundError for PrerequisiteInput connections (causing QuantumGraph generation to fail). PipelineTask implementations may provide custom adjustQuantum implementations for more fine-grained or configuration-driven constraints, as long as they are compatible with this minium.

deferGraphConstraint: `bool`, optional

If True, do not include this dataset type’s existence in the initial query that starts the QuantumGraph generation process. This can be used to make QuantumGraph generation faster by avoiding redundant datasets, and in certain cases it can (along with careful attention to which tasks are included in the same QuantumGraph) be used to work around the QuantumGraph generation algorithm’s inflexible handling of spatial overlaps. This option has no effect when the connection is not an overall input of the pipeline (or subset thereof) for which a graph is being created, and it never affects the ordering of quanta.

Raises:
TypeError

Raised if minimum is greater than one but multiple=False.

NotImplementedError

Raised if minimum is zero for a regular Input connection; this is not currently supported by our QuantumGraph generation algorithm.

Methods Documentation

adjustQuantum(inputs: dict[str, tuple[lsst.pipe.base.connectionTypes.BaseInput, collections.abc.Collection[lsst.daf.butler.core.datasets.ref.DatasetRef]]], outputs: dict[str, tuple[lsst.pipe.base.connectionTypes.Output, collections.abc.Collection[lsst.daf.butler.core.datasets.ref.DatasetRef]]], label: str, data_id: DataCoordinate) tuple[collections.abc.Mapping[str, tuple[lsst.pipe.base.connectionTypes.BaseInput, collections.abc.Collection[lsst.daf.butler.core.datasets.ref.DatasetRef]]], collections.abc.Mapping[str, tuple[lsst.pipe.base.connectionTypes.Output, collections.abc.Collection[lsst.daf.butler.core.datasets.ref.DatasetRef]]]]

Override to make adjustments to lsst.daf.butler.DatasetRef objects in the lsst.daf.butler.core.Quantum during the graph generation stage of the activator.

Parameters:
inputsdict

Dictionary whose keys are an input (regular or prerequisite) connection name and whose values are a tuple of the connection instance and a collection of associated DatasetRef objects. The exact type of the nested collections is unspecified; it can be assumed to be multi-pass iterable and support len and in, but it should not be mutated in place. In contrast, the outer dictionaries are guaranteed to be temporary copies that are true dict instances, and hence may be modified and even returned; this is especially useful for delegating to super (see notes below).

outputsMapping

Mapping of output datasets, with the same structure as inputs.

labelstr

Label for this task in the pipeline (should be used in all diagnostic messages).

data_idlsst.daf.butler.DataCoordinate

Data ID for this quantum in the pipeline (should be used in all diagnostic messages).

Returns:
adjusted_inputsMapping

Mapping of the same form as inputs with updated containers of input DatasetRef objects. Connections that are not changed should not be returned at all. Datasets may only be removed, not added. Nested collections may be of any multi-pass iterable type, and the order of iteration will set the order of iteration within PipelineTask.runQuantum.

adjusted_outputsMapping

Mapping of updated output datasets, with the same structure and interpretation as adjusted_inputs.

Raises:
ScalarError

Raised if any Input or PrerequisiteInput connection has multiple set to False, but multiple datasets.

NoWorkFound

Raised to indicate that this quantum should not be run; not enough datasets were found for a regular Input connection, and the quantum should be pruned or skipped.

FileNotFoundError

Raised to cause QuantumGraph generation to fail (with the message included in this exception); not enough datasets were found for a PrerequisiteInput connection.

Notes

The base class implementation performs important checks. It always returns an empty mapping (i.e. makes no adjustments). It should always called be via super by custom implementations, ideally at the end of the custom implementation with already-adjusted mappings when any datasets are actually dropped, e.g.:

def adjustQuantum(self, inputs, outputs, label, data_id):
    # Filter out some dataset refs for one connection.
    connection, old_refs = inputs["my_input"]
    new_refs = [ref for ref in old_refs if ...]
    adjusted_inputs = {"my_input", (connection, new_refs)}
    # Update the original inputs so we can pass them to super.
    inputs.update(adjusted_inputs)
    # Can ignore outputs from super because they are guaranteed
    # to be empty.
    super().adjustQuantum(inputs, outputs, label_data_id)
    # Return only the connections we modified.
    return adjusted_inputs, {}

Removing outputs here is guaranteed to affect what is actually passed to PipelineTask.runQuantum, but its effect on the larger graph may be deferred to execution, depending on the context in which adjustQuantum is being run: if one quantum removes an output that is needed by a second quantum as input, the second quantum may not be adjusted (and hence pruned or skipped) until that output is actually found to be missing at execution time.

Tasks that desire zip-iteration consistency between any combinations of connections that have the same data ID should generally implement adjustQuantum to achieve this, even if they could also run that logic during execution; this allows the system to see outputs that will not be produced because the corresponding input is missing as early as possible.

buildDatasetRefs(quantum: Quantum) tuple[lsst.pipe.base.connections.InputQuantizedConnection, lsst.pipe.base.connections.OutputQuantizedConnection]

Build QuantizedConnection corresponding to input Quantum.

Parameters:
quantumlsst.daf.butler.Quantum

Quantum object which defines the inputs and outputs for a given unit of processing.

Returns:
retValtuple of (InputQuantizedConnection,

OutputQuantizedConnection) Namespaces mapping attribute names (identifiers of connections) to butler references defined in the input lsst.daf.butler.Quantum.

getSpatialBoundsConnections() Iterable[str]

Return the names of regular input and output connections whose data IDs should be used to compute the spatial bounds of this task’s quanta.

The spatial bound for a quantum is defined as the union of the regions of all data IDs of all connections returned here, along with the region of the quantum data ID (if the task has spatial dimensions).

Returns:
connection_namescollections.abc.Iterable [ str ]

Names of collections with spatial dimensions. These are the task-internal connection names, not butler dataset type names.

Notes

The spatial bound is used to search for prerequisite inputs that have skypix dimensions. The default implementation returns an empty iterable, which is usually sufficient for tasks with spatial dimensions, but if a task’s inputs or outputs are associated with spatial regions that extend beyond the quantum data ID’s region, this method may need to be overridden to expand the set of prerequisite inputs found.

Tasks that do not have spatial dimensions that have skypix prerequisite inputs should always override this method, as the default spatial bounds otherwise cover the full sky.

getTemporalBoundsConnections() Iterable[str]

Return the names of regular input and output connections whose data IDs should be used to compute the temporal bounds of this task’s quanta.

The temporal bound for a quantum is defined as the union of the timespans of all data IDs of all connections returned here, along with the timespan of the quantum data ID (if the task has temporal dimensions).

Returns:
connection_namescollections.abc.Iterable [ str ]

Names of collections with temporal dimensions. These are the task-internal connection names, not butler dataset type names.

Notes

The temporal bound is used to search for prerequisite inputs that are calibration datasets. The default implementation returns an empty iterable, which is usually sufficient for tasks with temporal dimensions, but if a task’s inputs or outputs are associated with timespans that extend beyond the quantum data ID’s timespan, this method may need to be overridden to expand the set of prerequisite inputs found.

Tasks that do not have temporal dimensions that do not implement this method will use an infinite timespan for any calibration lookups.