LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.pipe.tasks.postprocess.TransformCatalogBaseTask Class Reference
Inheritance diagram for lsst.pipe.tasks.postprocess.TransformCatalogBaseTask:

Public Member Functions

def outputDataset (self)
 
def inputDataset (self)
 
def ConfigClass (self)
 
def __init__ (self, *args, **kwargs)
 
def runQuantum (self, butlerQC, inputRefs, outputRefs)
 
def runDataRef (self, dataRef)
 
def run (self, parq, funcs=None, dataId=None, band=None)
 
def getFunctors (self)
 
def getAnalysis (self, parq, funcs=None, band=None)
 
def transform (self, band, parq, funcs, dataId)
 
def write (self, df, parqRef)
 
def writeMetadata (self, dataRef)
 

Public Attributes

 funcs
 

Detailed Description

Base class for transforming/standardizing a catalog

by applying functors that convert units and apply calibrations.
The purpose of this task is to perform a set of computations on
an input `ParquetTable` dataset (such as `deepCoadd_obj`) and write the
results to a new dataset (which needs to be declared in an `outputDataset`
attribute).

The calculations to be performed are defined in a YAML file that specifies
a set of functors to be computed, provided as
a `--functorFile` config parameter.  An example of such a YAML file
is the following:

    funcs:
        psfMag:
            functor: Mag
            args:
                - base_PsfFlux
            filt: HSC-G
            dataset: meas
        cmodel_magDiff:
            functor: MagDiff
            args:
                - modelfit_CModel
                - base_PsfFlux
            filt: HSC-G
        gauss_magDiff:
            functor: MagDiff
            args:
                - base_GaussianFlux
                - base_PsfFlux
            filt: HSC-G
        count:
            functor: Column
            args:
                - base_InputCount_value
            filt: HSC-G
        deconvolved_moments:
            functor: DeconvolvedMoments
            filt: HSC-G
            dataset: forced_src
    refFlags:
        - calib_psfUsed
        - merge_measurement_i
        - merge_measurement_r
        - merge_measurement_z
        - merge_measurement_y
        - merge_measurement_g
        - base_PixelFlags_flag_inexact_psfCenter
        - detect_isPrimary

The names for each entry under "func" will become the names of columns in the
output dataset.  All the functors referenced are defined in `lsst.pipe.tasks.functors`.
Positional arguments to be passed to each functor are in the `args` list,
and any additional entries for each column other than "functor" or "args" (e.g., `'filt'`,
`'dataset'`) are treated as keyword arguments to be passed to the functor initialization.

The "flags" entry is the default shortcut for `Column` functors.
All columns listed under "flags" will be copied to the output table
untransformed. They can be of any datatype.
In the special case of transforming a multi-level oject table with
band and dataset indices (deepCoadd_obj), these will be taked from the
`meas` dataset and exploded out per band.

There are two special shortcuts that only apply when transforming
multi-level Object (deepCoadd_obj) tables:
 -  The "refFlags" entry is shortcut for `Column` functor
    taken from the `'ref'` dataset if transforming an ObjectTable.
 -  The "forcedFlags" entry is shortcut for `Column` functors.
    taken from the ``forced_src`` dataset if transforming an ObjectTable.
    These are expanded out per band.


This task uses the `lsst.pipe.tasks.postprocess.PostprocessAnalysis` object
to organize and excecute the calculations.

Definition at line 558 of file postprocess.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.__init__ (   self,
args,
**  kwargs 
)

Definition at line 652 of file postprocess.py.

652  def __init__(self, *args, **kwargs):
653  super().__init__(*args, **kwargs)
654  if self.config.functorFile:
655  self.log.info('Loading tranform functor definitions from %s',
656  self.config.functorFile)
657  self.funcs = CompositeFunctor.from_file(self.config.functorFile)
658  self.funcs.update(dict(PostprocessAnalysis._defaultFuncs))
659  else:
660  self.funcs = None
661 

Member Function Documentation

◆ ConfigClass()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.ConfigClass (   self)

Definition at line 649 of file postprocess.py.

649  def ConfigClass(self):
650  raise NotImplementedError('Subclass must define "ConfigClass" attribute')
651 

◆ getAnalysis()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.getAnalysis (   self,
  parq,
  funcs = None,
  band = None 
)

Definition at line 712 of file postprocess.py.

712  def getAnalysis(self, parq, funcs=None, band=None):
713  if funcs is None:
714  funcs = self.funcs
715  analysis = PostprocessAnalysis(parq, funcs, filt=band)
716  return analysis
717 

◆ getFunctors()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.getFunctors (   self)

Definition at line 709 of file postprocess.py.

709  def getFunctors(self):
710  return self.funcs
711 

◆ inputDataset()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.inputDataset (   self)

Definition at line 645 of file postprocess.py.

645  def inputDataset(self):
646  raise NotImplementedError('Subclass must define "inputDataset" attribute')
647 

◆ outputDataset()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.outputDataset (   self)

Definition at line 641 of file postprocess.py.

641  def outputDataset(self):
642  raise NotImplementedError('Subclass must define "outputDataset" attribute')
643 

◆ run()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.run (   self,
  parq,
  funcs = None,
  dataId = None,
  band = None 
)
Do postprocessing calculations

Takes a `ParquetTable` object and dataId,
returns a dataframe with results of postprocessing calculations.

Parameters
----------
parq : `lsst.pipe.tasks.parquetTable.ParquetTable`
    ParquetTable from which calculations are done.
funcs : `lsst.pipe.tasks.functors.Functors`
    Functors to apply to the table's columns
dataId : dict, optional
    Used to add a `patchId` column to the output dataframe.
band : `str`, optional
    Filter band that is being processed.

Returns
------
    `pandas.DataFrame`

Definition at line 681 of file postprocess.py.

681  def run(self, parq, funcs=None, dataId=None, band=None):
682  """Do postprocessing calculations
683 
684  Takes a `ParquetTable` object and dataId,
685  returns a dataframe with results of postprocessing calculations.
686 
687  Parameters
688  ----------
689  parq : `lsst.pipe.tasks.parquetTable.ParquetTable`
690  ParquetTable from which calculations are done.
691  funcs : `lsst.pipe.tasks.functors.Functors`
692  Functors to apply to the table's columns
693  dataId : dict, optional
694  Used to add a `patchId` column to the output dataframe.
695  band : `str`, optional
696  Filter band that is being processed.
697 
698  Returns
699  ------
700  `pandas.DataFrame`
701 
702  """
703  self.log.info("Transforming/standardizing the source table dataId: %s", dataId)
704 
705  df = self.transform(band, parq, funcs, dataId).df
706  self.log.info("Made a table of %d columns and %d rows", len(df.columns), len(df))
707  return df
708 
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603

◆ runDataRef()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.runDataRef (   self,
  dataRef 
)

Definition at line 672 of file postprocess.py.

672  def runDataRef(self, dataRef):
673  parq = dataRef.get()
674  if self.funcs is None:
675  raise ValueError("config.functorFile is None. "
676  "Must be a valid path to yaml in order to run as a CommandlineTask.")
677  df = self.run(parq, funcs=self.funcs, dataId=dataRef.dataId)
678  self.write(df, dataRef)
679  return df
680 

◆ runQuantum()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.runQuantum (   self,
  butlerQC,
  inputRefs,
  outputRefs 
)

Definition at line 662 of file postprocess.py.

662  def runQuantum(self, butlerQC, inputRefs, outputRefs):
663  inputs = butlerQC.get(inputRefs)
664  if self.funcs is None:
665  raise ValueError("config.functorFile is None. "
666  "Must be a valid path to yaml in order to run Task as a PipelineTask.")
667  result = self.run(parq=inputs['inputCatalog'], funcs=self.funcs,
668  dataId=outputRefs.outputCatalog.dataId.full)
669  outputs = pipeBase.Struct(outputCatalog=result)
670  butlerQC.put(outputs, outputRefs)
671 

◆ transform()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.transform (   self,
  band,
  parq,
  funcs,
  dataId 
)

Definition at line 718 of file postprocess.py.

718  def transform(self, band, parq, funcs, dataId):
719  analysis = self.getAnalysis(parq, funcs=funcs, band=band)
720  df = analysis.df
721  if dataId is not None:
722  for key, value in dataId.items():
723  df[str(key)] = value
724 
725  if self.config.primaryKey:
726  if df.index.name != self.config.primaryKey and self.config.primaryKey in df:
727  df.reset_index(inplace=True, drop=True)
728  df.set_index(self.config.primaryKey, inplace=True)
729 
730  return pipeBase.Struct(
731  df=df,
732  analysis=analysis
733  )
734 
table::Key< int > transform

◆ write()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.write (   self,
  df,
  parqRef 
)

Definition at line 735 of file postprocess.py.

735  def write(self, df, parqRef):
736  parqRef.put(ParquetTable(dataFrame=df), self.outputDataset)
737 
void write(OutputArchiveHandle &handle) const override

◆ writeMetadata()

def lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.writeMetadata (   self,
  dataRef 
)
No metadata to write.

Definition at line 738 of file postprocess.py.

738  def writeMetadata(self, dataRef):
739  """No metadata to write.
740  """
741  pass
742 
743 
def writeMetadata(self, dataRefList)
No metadata to write, and not sure how to write it for a list of dataRefs.

Member Data Documentation

◆ funcs

lsst.pipe.tasks.postprocess.TransformCatalogBaseTask.funcs

Definition at line 657 of file postprocess.py.


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