LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-10-g17396bd+0db626c9d4,21.0.0-11-ga42c5b2+8e919b1fde,21.0.0-11-gf32158d+0ebe75d2c4,21.0.0-12-g21f7bf3+5457518a9a,21.0.0-12-g9de0849+524af766c8,21.0.0-14-gbfe4b77+9a33cf3f69,21.0.0-16-g0fb55c1+2e80f2f4c5,21.0.0-19-g4cded4ca+da87cab2e2,21.0.0-2-g103fe59+7aa255a7ca,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+7df4c6fa3d,21.0.0-2-g7f82c8f+0b5b78a3be,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+0b5b78a3be,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+632ec57a44,21.0.0-2-gfc62afb+7df4c6fa3d,21.0.0-25-g1d57be3cd+e9f70389b0,21.0.0-3-g357aad2+3b365e1178,21.0.0-3-g4a4ce7f+7df4c6fa3d,21.0.0-3-g4be5c26+7df4c6fa3d,21.0.0-3-g65f322c+79dc209d58,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+0db626c9d4,21.0.0-4-g591bb35+0db626c9d4,21.0.0-4-g65b4814+2e80f2f4c5,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+7b7c27da6e,21.0.0-5-gd00fb1e+52bf7bf9f3,21.0.0-6-gc675373+7df4c6fa3d,21.0.0-61-ge77b8116+a869d0a5a5,21.0.0-7-g04766d7+5bf495eb54,21.0.0-7-g98eecf7+d1bd76f71f,21.0.0-7-gdf92d54+04719a4bac,master-gac4afde19b+0db626c9d4,w.2021.13
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.pipe.tasks.postprocess.PostprocessAnalysis Class Reference
Inheritance diagram for lsst.pipe.tasks.postprocess.PostprocessAnalysis:

Public Member Functions

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

Public Attributes

 parq
 
 functors
 
 filt
 
 flags
 
 refFlags
 

Detailed Description

Calculate columns from ParquetTable

This object manages and organizes an arbitrary set of computations
on a catalog.  The catalog is defined by a
`lsst.pipe.tasks.parquetTable.ParquetTable` object (or list thereof), such as a
`deepCoadd_obj` dataset, and the computations are defined by a collection
of `lsst.pipe.tasks.functor.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 `ParquetTable` object 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
----------
parq : `lsst.pipe.tasks.ParquetTable` (or list of such)
    Source catalog(s) for computation

functors : `list`, `dict`, or `lsst.pipe.tasks.functors.CompositeFunctor`
    Computations to do (functors that act on `parq`).
    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.

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

Definition at line 342 of file postprocess.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 399 of file postprocess.py.

399  def __init__(self, parq, functors, filt=None, flags=None, refFlags=None):
400  self.parq = parq
401  self.functors = functors
402 
403  self.filt = filt
404  self.flags = list(flags) if flags is not None else []
405  self.refFlags = list(self._defaultRefFlags)
406  if refFlags is not None:
407  self.refFlags += list(refFlags)
408 
409  self._df = None
410 
daf::base::PropertyList * list
Definition: fits.cc:913

Member Function Documentation

◆ compute()

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

Definition at line 442 of file postprocess.py.

442  def compute(self, dropna=False, pool=None):
443  # map over multiple parquet tables
444  if type(self.parq) in (list, tuple):
445  if pool is None:
446  dflist = [self.func(parq, dropna=dropna) for parq in self.parq]
447  else:
448  # TODO: Figure out why this doesn't work (pyarrow pickling issues?)
449  dflist = pool.map(functools.partial(self.func, dropna=dropna), self.parq)
450  self._df = pd.concat(dflist)
451  else:
452  self._df = self.func(self.parq, dropna=dropna)
453 
454  return self._df
455 
456 
table::Key< int > type
Definition: Detector.cc:163

◆ defaultFuncs()

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

Definition at line 412 of file postprocess.py.

412  def defaultFuncs(self):
413  funcs = dict(self._defaultFuncs)
414  return funcs
415 

◆ df()

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

Definition at line 437 of file postprocess.py.

437  def df(self):
438  if self._df is None:
439  self.compute()
440  return self._df
441 

◆ func()

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

Definition at line 417 of file postprocess.py.

417  def func(self):
418  additionalFuncs = self.defaultFuncs
419  additionalFuncs.update({flag: Column(flag, dataset='ref') for flag in self.refFlags})
420  additionalFuncs.update({flag: Column(flag, dataset='meas') for flag in self.flags})
421 
422  if isinstance(self.functors, CompositeFunctor):
423  func = self.functors
424  else:
425  func = CompositeFunctor(self.functors)
426 
427  func.funcDict.update(additionalFuncs)
428  func.filt = self.filt
429 
430  return func
431 

◆ noDupCols()

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

Definition at line 433 of file postprocess.py.

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

Member Data Documentation

◆ filt

lsst.pipe.tasks.postprocess.PostprocessAnalysis.filt

Definition at line 403 of file postprocess.py.

◆ flags

lsst.pipe.tasks.postprocess.PostprocessAnalysis.flags

Definition at line 404 of file postprocess.py.

◆ functors

lsst.pipe.tasks.postprocess.PostprocessAnalysis.functors

Definition at line 401 of file postprocess.py.

◆ parq

lsst.pipe.tasks.postprocess.PostprocessAnalysis.parq

Definition at line 400 of file postprocess.py.

◆ refFlags

lsst.pipe.tasks.postprocess.PostprocessAnalysis.refFlags

Definition at line 405 of file postprocess.py.


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