199 def validateIsrConfig(isrTask, mandatory=None, forbidden=None, desirable=None, undesirable=None,
200 checkTrim=True, logName=None):
201 """Check that appropriate ISR settings have been selected for the task.
203 Note that this checks that the task itself is configured correctly rather
204 than checking a config.
208 isrTask : `lsst.ip.isr.IsrTask`
209 The task whose config is to be validated
211 mandatory : `iterable` of `str`
212 isr steps that must be set to True. Raises if False or missing
214 forbidden : `iterable` of `str`
215 isr steps that must be set to False. Raises if True, warns if missing
217 desirable : `iterable` of `str`
218 isr steps that should probably be set to True. Warns is False, info if
221 undesirable : `iterable` of `str`
222 isr steps that should probably be set to False. Warns is True, info if
226 Check to ensure the isrTask's assembly subtask is trimming the images.
227 This is a separate config as it is very ugly to do this within the
228 normal configuration lists as it is an option of a sub task.
233 Raised if ``mandatory`` config parameters are False,
234 or if ``forbidden`` parameters are True.
237 Raised if parameter ``isrTask`` is an invalid type.
241 Logs warnings using an isrValidation logger for desirable/undesirable
242 options that are of the wrong polarity or if keys are missing.
244 if not isinstance(isrTask, ipIsr.IsrTask):
245 raise TypeError(f
'Must supply an instance of lsst.ip.isr.IsrTask not {type(isrTask)}')
247 configDict = isrTask.config.toDict()
249 if logName
and isinstance(logName, str):
250 log = lsst.log.getLogger(logName)
252 log = lsst.log.getLogger(
"isrValidation")
255 for configParam
in mandatory:
256 if configParam
not in configDict:
257 raise RuntimeError(f
"Mandatory parameter {configParam} not found in the isr configuration.")
258 if configDict[configParam]
is False:
259 raise RuntimeError(f
"Must set config.isr.{configParam} to True for this task.")
262 for configParam
in forbidden:
263 if configParam
not in configDict:
264 log.warn(f
"Failed to find forbidden key {configParam} in the isr config. The keys in the"
265 " forbidden list should each have an associated Field in IsrConfig:"
266 " check that there is not a typo in this case.")
268 if configDict[configParam]
is True:
269 raise RuntimeError(f
"Must set config.isr.{configParam} to False for this task.")
272 for configParam
in desirable:
273 if configParam
not in configDict:
274 log.info(f
"Failed to find key {configParam} in the isr config. You probably want" +
275 " to set the equivalent for your obs_package to True.")
277 if configDict[configParam]
is False:
278 log.warn(f
"Found config.isr.{configParam} set to False for this task." +
279 " The cp_pipe Config recommends setting this to True.")
281 for configParam
in undesirable:
282 if configParam
not in configDict:
283 log.info(f
"Failed to find key {configParam} in the isr config. You probably want" +
284 " to set the equivalent for your obs_package to False.")
286 if configDict[configParam]
is True:
287 log.warn(f
"Found config.isr.{configParam} set to True for this task." +
288 " The cp_pipe Config recommends setting this to False.")
291 if not isrTask.assembleCcd.config.doTrim:
292 raise RuntimeError(
"Must trim when assembling CCDs. Set config.isr.assembleCcd.doTrim to True")