LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Classes | Functions
lsst.pipe.tasks.functors Namespace Reference

Classes

class  Color
 
class  Column
 
class  CompositeFunctor
 
class  ComputePixelScale
 
class  ConvertPixelToArcseconds
 
class  CoordColumn
 
class  CustomFunctor
 
class  DecColumn
 
class  DeconvolvedMoments
 
class  E1
 
class  E2
 
class  FootprintNPix
 
class  Functor
 
class  HsmFwhm
 
class  HsmTraceSize
 
class  IDColumn
 
class  Index
 
class  Labeller
 
class  LocalMagnitude
 
class  LocalMagnitudeErr
 
class  LocalNanojansky
 
class  LocalNanojanskyErr
 
class  LocalPhotometry
 
class  LocalWcs
 
class  Mag
 
class  MagDiff
 
class  MagErr
 
class  Magnitude
 
class  MagnitudeErr
 
class  NanoJansky
 
class  NanoJanskyErr
 
class  NanoMaggie
 
class  NumStarLabeller
 
class  Photometry
 
class  PsfHsmTraceSizeDiff
 
class  PsfSdssTraceSizeDiff
 
class  RAColumn
 
class  RadiusFromQuadrupole
 
class  ReferenceBand
 
class  SdssTraceSize
 
class  StarGalaxyLabeller
 

Functions

def init_fromDict (initDict, basePath='lsst.pipe.tasks.functors', typeKey='functor', name=None)
 
def mag_aware_eval (df, expr)
 
def fluxName (col)
 
def fluxErrName (col)
 

Function Documentation

◆ fluxErrName()

def lsst.pipe.tasks.functors.fluxErrName (   col)

Definition at line 500 of file functors.py.

500 def fluxErrName(col):
501  if not col.endswith('_instFluxErr'):
502  col += '_instFluxErr'
503  return col
504 
505 

◆ fluxName()

def lsst.pipe.tasks.functors.fluxName (   col)

Definition at line 494 of file functors.py.

494 def fluxName(col):
495  if not col.endswith('_instFlux'):
496  col += '_instFlux'
497  return col
498 
499 

◆ init_fromDict()

def lsst.pipe.tasks.functors.init_fromDict (   initDict,
  basePath = 'lsst.pipe.tasks.functors',
  typeKey = 'functor',
  name = None 
)
Initialize an object defined in a dictionary

The object needs to be importable as
    f'{basePath}.{initDict[typeKey]}'
The positional and keyword arguments (if any) are contained in
"args" and "kwargs" entries in the dictionary, respectively.
This is used in `functors.CompositeFunctor.from_yaml` to initialize
a composite functor from a specification in a YAML file.

Parameters
----------
initDict : dictionary
    Dictionary describing object's initialization.  Must contain
    an entry keyed by ``typeKey`` that is the name of the object,
    relative to ``basePath``.
basePath : str
    Path relative to module in which ``initDict[typeKey]`` is defined.
typeKey : str
    Key of ``initDict`` that is the name of the object
    (relative to `basePath`).

Definition at line 12 of file functors.py.

12 def init_fromDict(initDict, basePath='lsst.pipe.tasks.functors',
13  typeKey='functor', name=None):
14  """Initialize an object defined in a dictionary
15 
16  The object needs to be importable as
17  f'{basePath}.{initDict[typeKey]}'
18  The positional and keyword arguments (if any) are contained in
19  "args" and "kwargs" entries in the dictionary, respectively.
20  This is used in `functors.CompositeFunctor.from_yaml` to initialize
21  a composite functor from a specification in a YAML file.
22 
23  Parameters
24  ----------
25  initDict : dictionary
26  Dictionary describing object's initialization. Must contain
27  an entry keyed by ``typeKey`` that is the name of the object,
28  relative to ``basePath``.
29  basePath : str
30  Path relative to module in which ``initDict[typeKey]`` is defined.
31  typeKey : str
32  Key of ``initDict`` that is the name of the object
33  (relative to `basePath`).
34  """
35  initDict = initDict.copy()
36  # TO DO: DM-21956 We should be able to define functors outside this module
37  pythonType = doImport(f'{basePath}.{initDict.pop(typeKey)}')
38  args = []
39  if 'args' in initDict:
40  args = initDict.pop('args')
41  if isinstance(args, str):
42  args = [args]
43  try:
44  element = pythonType(*args, **initDict)
45  except Exception as e:
46  message = f'Error in constructing functor "{name}" of type {pythonType.__name__} with args: {args}'
47  raise type(e)(message, e.args)
48  return element
49 
50 

◆ mag_aware_eval()

def lsst.pipe.tasks.functors.mag_aware_eval (   df,
  expr 
)
Evaluate an expression on a DataFrame, knowing what the 'mag' function means

Builds on `pandas.DataFrame.eval`, which parses and executes math on dataframes.

Parameters
----------
df : pandas.DataFrame
    Dataframe on which to evaluate expression.

expr : str
    Expression.

Definition at line 347 of file functors.py.

347 def mag_aware_eval(df, expr):
348  """Evaluate an expression on a DataFrame, knowing what the 'mag' function means
349 
350  Builds on `pandas.DataFrame.eval`, which parses and executes math on dataframes.
351 
352  Parameters
353  ----------
354  df : pandas.DataFrame
355  Dataframe on which to evaluate expression.
356 
357  expr : str
358  Expression.
359  """
360  try:
361  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>)/log(10)', expr)
362  val = df.eval(expr_new, truediv=True)
363  except Exception: # Should check what actually gets raised
364  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>_instFlux)/log(10)', expr)
365  val = df.eval(expr_new, truediv=True)
366  return val
367 
368 
lsst::daf::persistence.utils.doImport
def doImport(pythonType)
Definition: utils.py:104
lsst.pipe.tasks.functors.mag_aware_eval
def mag_aware_eval(df, expr)
Definition: functors.py:347
type
table::Key< int > type
Definition: Detector.cc:163
lsst.pipe.tasks.functors.fluxName
def fluxName(col)
Definition: functors.py:494
lsst.pipe.tasks.functors.init_fromDict
def init_fromDict(initDict, basePath='lsst.pipe.tasks.functors', typeKey='functor', name=None)
Definition: functors.py:12
lsst.pipe.tasks.functors.fluxErrName
def fluxErrName(col)
Definition: functors.py:500