218 """Initialize the plugins according to the configuration.
221 pluginType = namedtuple(
'pluginType',
'single multi')
228 for executionOrder, name, config, PluginClass
in sorted(self.config.plugins.apply()):
231 if PluginClass.getExecutionOrder() >= BasePlugin.DEFAULT_CATALOGCALCULATION:
237 if plug.plugType ==
'single':
239 elif plug.plugType ==
'multi':
242 errorTuple = (PluginClass, PluginClass.getExecutionOrder(),
243 BasePlugin.DEFAULT_CATALOGCALCULATION)
244 raise ValueError(
"{} has an execution order less than the minimum for an catalogCalculation "
245 "plugin. Value {} : Minimum {}".format(*errorTuple))
351 """Run each of the plugins on the catalog.
353 For catalog column names see the lsst.cat schema definitions for the
354 DiaObject and DiaSource tables (http://github.com/lsst/cat).
358 diaObjectCat : `pandas.DataFrame`
359 DiaObjects to update values of and append new objects to. DataFrame
360 should be indexed on "diaObjectId"
361 diaSourceCat : `pandas.DataFrame`
362 DiaSources associated with the DiaObjects in diaObjectCat.
363 DataFrame must be indexed on
364 ["diaObjectId", "band", "diaSourceId"]`
365 updatedDiaObjectIds : `numpy.ndarray`
366 Integer ids of the DiaObjects to update and create.
367 filterNames : `list` of `str`
368 List of string names of filters to be being processed.
372 returnStruct : `lsst.pipe.base.Struct`
376 Full set of DiaObjects including both un-updated and
377 updated/new DiaObjects (`pandas.DataFrame`).
378 ``updatedDiaObjects``
379 Catalog of DiaObjects that were updated or created by this
380 task (`pandas.DataFrame`).
385 Raises if `pandas.DataFrame` indexing is not properly set.
388 diaObjectsToUpdate = diaObjectCat.loc[updatedDiaObjectIds, :]
389 self.
loglog.
info(
"Calculating summary stats for %i DiaObjects",
390 len(diaObjectsToUpdate))
392 updatingDiaSources = diaSourceCat.loc[updatedDiaObjectIds, :]
393 diaSourcesGB = updatingDiaSources.groupby(level=0)
398 for updatedDiaObjectId
in updatedDiaObjectIds:
401 objDiaSources = updatingDiaSources.loc[updatedDiaObjectId]
408 plug.calculate(diaObjects=diaObjectsToUpdate,
409 diaObjectId=updatedDiaObjectId,
410 diaSources=objDiaSources,
411 filterDiaSources=
None,
417 plug.calculate(diaObjects=diaObjectsToUpdate,
418 diaSources=diaSourcesGB,
419 filterDiaSources=
None,
422 for band
in filterNames:
424 updatingFilterDiaSources = updatingDiaSources.loc[
425 (slice(
None), band), :
429 "Continuing...", band)
432 filterDiaSourcesGB = updatingFilterDiaSources.groupby(level=0)
436 if not plug.needsFilter:
438 for updatedDiaObjectId
in updatedDiaObjectIds:
441 objDiaSources = updatingDiaSources.loc[updatedDiaObjectId]
445 filterObjDiaSources = objDiaSources.loc[band]
448 "DiaObjectId={updatedDiaObjectId} has no "
449 "DiaSources for filter=%s. "
450 "Continuing...", band)
455 plug.calculate(diaObjects=diaObjectsToUpdate,
456 diaObjectId=updatedDiaObjectId,
457 diaSources=objDiaSources,
458 filterDiaSources=filterObjDiaSources,
461 if not plug.needsFilter:
464 plug.calculate(diaObjects=diaObjectsToUpdate,
465 diaSources=diaSourcesGB,
466 filterDiaSources=filterDiaSourcesGB,
471 diaObjectCat.loc[updatedDiaObjectIds, :] = diaObjectsToUpdate
472 return lsst.pipe.base.Struct(
473 diaObjectCat=diaObjectCat,
474 updatedDiaObjects=diaObjectsToUpdate)