114 def adjustQuantum(self, inputs, outputs, label, data_id):
115 """Validates the `lsst.daf.butler.DatasetRef` bands against the
116 subtask's list of bands to fit and drops unnecessary bands.
117
118 Parameters
119 ----------
120 inputs : `dict`
121 Dictionary whose keys are an input (regular or prerequisite)
122 connection name and whose values are a tuple of the connection
123 instance and a collection of associated `DatasetRef` objects.
124 The exact type of the nested collections is unspecified; it can be
125 assumed to be multi-pass iterable and support `len` and ``in``, but
126 it should not be mutated in place. In contrast, the outer
127 dictionaries are guaranteed to be temporary copies that are true
128 `dict` instances, and hence may be modified and even returned; this
129 is especially useful for delegating to `super` (see notes below).
130 outputs : `Mapping`
131 Mapping of output datasets, with the same structure as ``inputs``.
132 label : `str`
133 Label for this task in the pipeline (should be used in all
134 diagnostic messages).
135 data_id : `lsst.daf.butler.DataCoordinate`
136 Data ID for this quantum in the pipeline (should be used in all
137 diagnostic messages).
138
139 Returns
140 -------
141 adjusted_inputs : `Mapping`
142 Mapping of the same form as ``inputs`` with updated containers of
143 input `DatasetRef` objects. All inputs involving the 'band'
144 dimension are adjusted to put them in consistent order and remove
145 unneeded bands.
146 adjusted_outputs : `Mapping`
147 Mapping of updated output datasets; always empty for this task.
148
149 Raises
150 ------
151 lsst.pipe.base.NoWorkFound
152 Raised if there are not enough of the right bands to run the task
153 on this quantum.
154 """
155
156 bands_fit, bands_read_only = self.config.get_band_sets()
157 bands_needed = bands_fit.union(bands_read_only)
158
159 adjusted_inputs = {}
160 for connection_name, (connection, dataset_refs) in inputs.items():
161
162 if 'band' in connection.dimensions:
163 datasets_by_band = {dref.dataId['band']: dref for dref in dataset_refs}
164 if not bands_needed.issubset(datasets_by_band.keys()):
165 raise pipeBase.NoWorkFound(
166 f'DatasetRefs={dataset_refs} have data with bands in the'
167 f' set={set(datasets_by_band.keys())},'
168 f' which is not a superset of the required bands={bands_needed} defined by'
169 f' {self.config.__class__}.fit_multiband='
170 f'{self.config.fit_multiband._value.__class__}\'s attributes'
171 f' bands_fit={bands_fit} and bands_read_only()={bands_read_only}.'
172 f' Add the required bands={bands_needed.difference(datasets_by_band.keys())}.'
173 )
174
175
176 adjusted_inputs[connection_name] = (
177 connection,
178 [datasets_by_band[band] for band in bands_needed]
179 )
180
181
182 inputs.update(adjusted_inputs)
183 super().adjustQuantum(inputs, outputs, label, data_id)
184 return adjusted_inputs, {}
185
186