LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
lsst.pipe.tasks.postprocess.PostprocessAnalysis Class Reference
Inheritance diagram for lsst.pipe.tasks.postprocess.PostprocessAnalysis:

Public Member Functions

 __init__ (self, handles, functors, filt=None, flags=None, refFlags=None, forcedFlags=None)
 
 defaultFuncs (self)
 
 func (self)
 
 noDupCols (self)
 
 df (self)
 
 compute (self, dropna=False, pool=None)
 

Public Attributes

 handles
 
 functors
 
 filt
 
 flags
 
 forcedFlags
 
 refFlags
 

Protected Attributes

 _df
 

Static Protected Attributes

list _defaultRefFlags = []
 
tuple _defaultFuncs = ()
 

Detailed Description

Calculate columns from DataFrames or handles storing DataFrames.

This object manages and organizes an arbitrary set of computations
on a catalog.  The catalog is defined by a
`DeferredDatasetHandle` or `InMemoryDatasetHandle` object
(or list thereof), such as a ``deepCoadd_obj`` dataset, and the
computations are defined by a collection of
`~lsst.pipe.tasks.functors.Functor` objects (or, equivalently, a
``CompositeFunctor``).

After the object is initialized, accessing the ``.df`` attribute (which
holds the `pandas.DataFrame` containing the results of the calculations)
triggers computation of said dataframe.

One of the conveniences of using this object is the ability to define a
desired common filter for all functors.  This enables the same functor
collection to be passed to several different `PostprocessAnalysis` objects
without having to change the original functor collection, since the ``filt``
keyword argument of this object triggers an overwrite of the ``filt``
property for all functors in the collection.

This object also allows a list of refFlags to be passed, and defines a set
of default refFlags that are always included even if not requested.

If a list of DataFrames or Handles is passed, rather than a single one,
then the calculations will be mapped over all the input catalogs.  In
principle, it should be straightforward to parallelize this activity, but
initial tests have failed (see TODO in code comments).

Parameters
----------
handles : `~lsst.daf.butler.DeferredDatasetHandle` or
          `~lsst.pipe.base.InMemoryDatasetHandle` or
          list of these.
    Source catalog(s) for computation.
functors : `list`, `dict`, or `~lsst.pipe.tasks.functors.CompositeFunctor`
    Computations to do (functors that act on ``handles``).
    If a dict, the output
    DataFrame will have columns keyed accordingly.
    If a list, the column keys will come from the
    ``.shortname`` attribute of each functor.

filt : `str`, optional
    Filter in which to calculate.  If provided,
    this will overwrite any existing ``.filt`` attribute
    of the provided functors.

flags : `list`, optional
    List of flags (per-band) to include in output table.
    Taken from the ``meas`` dataset if applied to a multilevel Object Table.

refFlags : `list`, optional
    List of refFlags (only reference band) to include in output table.

forcedFlags : `list`, optional
    List of flags (per-band) to include in output table.
    Taken from the ``forced_src`` dataset if applied to a
    multilevel Object Table. Intended for flags from measurement plugins
    only run during multi-band forced-photometry.

Definition at line 441 of file postprocess.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.__init__ ( self,
handles,
functors,
filt = None,
flags = None,
refFlags = None,
forcedFlags = None )

Definition at line 505 of file postprocess.py.

505 def __init__(self, handles, functors, filt=None, flags=None, refFlags=None, forcedFlags=None):
506 self.handles = handles
507 self.functors = functors
508
509 self.filt = filt
510 self.flags = list(flags) if flags is not None else []
511 self.forcedFlags = list(forcedFlags) if forcedFlags is not None else []
512 self.refFlags = list(self._defaultRefFlags)
513 if refFlags is not None:
514 self.refFlags += list(refFlags)
515
516 self._df = None
517

Member Function Documentation

◆ compute()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.compute ( self,
dropna = False,
pool = None )

Definition at line 550 of file postprocess.py.

550 def compute(self, dropna=False, pool=None):
551 # map over multiple handles
552 if type(self.handles) in (list, tuple):
553 if pool is None:
554 dflist = [self.func(handle, dropna=dropna) for handle in self.handles]
555 else:
556 # TODO: Figure out why this doesn't work (pyarrow pickling
557 # issues?)
558 dflist = pool.map(functools.partial(self.func, dropna=dropna), self.handles)
559 self._df = pd.concat(dflist)
560 else:
561 self._df = self.func(self.handles, dropna=dropna)
562
563 return self._df
564
565

◆ defaultFuncs()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.defaultFuncs ( self)

Definition at line 519 of file postprocess.py.

519 def defaultFuncs(self):
520 funcs = dict(self._defaultFuncs)
521 return funcs
522

◆ df()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.df ( self)

Definition at line 545 of file postprocess.py.

545 def df(self):
546 if self._df is None:
547 self.compute()
548 return self._df
549

◆ func()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.func ( self)

Definition at line 524 of file postprocess.py.

524 def func(self):
525 additionalFuncs = self.defaultFuncs
526 additionalFuncs.update({flag: Column(flag, dataset='forced_src') for flag in self.forcedFlags})
527 additionalFuncs.update({flag: Column(flag, dataset='ref') for flag in self.refFlags})
528 additionalFuncs.update({flag: Column(flag, dataset='meas') for flag in self.flags})
529
530 if isinstance(self.functors, CompositeFunctor):
531 func = self.functors
532 else:
533 func = CompositeFunctor(self.functors)
534
535 func.funcDict.update(additionalFuncs)
536 func.filt = self.filt
537
538 return func
539

◆ noDupCols()

lsst.pipe.tasks.postprocess.PostprocessAnalysis.noDupCols ( self)

Definition at line 541 of file postprocess.py.

541 def noDupCols(self):
542 return [name for name, func in self.func.funcDict.items() if func.noDup or func.dataset == 'ref']
543

Member Data Documentation

◆ _defaultFuncs

tuple lsst.pipe.tasks.postprocess.PostprocessAnalysis._defaultFuncs = ()
staticprotected

Definition at line 503 of file postprocess.py.

◆ _defaultRefFlags

list lsst.pipe.tasks.postprocess.PostprocessAnalysis._defaultRefFlags = []
staticprotected

Definition at line 502 of file postprocess.py.

◆ _df

lsst.pipe.tasks.postprocess.PostprocessAnalysis._df
protected

Definition at line 516 of file postprocess.py.

◆ filt

lsst.pipe.tasks.postprocess.PostprocessAnalysis.filt

Definition at line 509 of file postprocess.py.

◆ flags

lsst.pipe.tasks.postprocess.PostprocessAnalysis.flags

Definition at line 510 of file postprocess.py.

◆ forcedFlags

lsst.pipe.tasks.postprocess.PostprocessAnalysis.forcedFlags

Definition at line 511 of file postprocess.py.

◆ functors

lsst.pipe.tasks.postprocess.PostprocessAnalysis.functors

Definition at line 507 of file postprocess.py.

◆ handles

lsst.pipe.tasks.postprocess.PostprocessAnalysis.handles

Definition at line 506 of file postprocess.py.

◆ refFlags

lsst.pipe.tasks.postprocess.PostprocessAnalysis.refFlags

Definition at line 512 of file postprocess.py.


The documentation for this class was generated from the following file: