LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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 505 of file functors.py.

505 def fluxErrName(col):
506  if not col.endswith('_instFluxErr'):
507  col += '_instFluxErr'
508  return col
509 
510 

◆ fluxName()

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

Definition at line 499 of file functors.py.

499 def fluxName(col):
500  if not col.endswith('_instFlux'):
501  col += '_instFlux'
502  return col
503 
504 

◆ 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 352 of file functors.py.

352 def mag_aware_eval(df, expr):
353  """Evaluate an expression on a DataFrame, knowing what the 'mag' function means
354 
355  Builds on `pandas.DataFrame.eval`, which parses and executes math on dataframes.
356 
357  Parameters
358  ----------
359  df : pandas.DataFrame
360  Dataframe on which to evaluate expression.
361 
362  expr : str
363  Expression.
364  """
365  try:
366  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>)/log(10)', expr)
367  val = df.eval(expr_new, truediv=True)
368  except Exception: # Should check what actually gets raised
369  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>_instFlux)/log(10)', expr)
370  val = df.eval(expr_new, truediv=True)
371  return val
372 
373 
lsst.pipe.tasks.functors.mag_aware_eval
def mag_aware_eval(df, expr)
Definition: functors.py:352
lsst.pex.config.config.doImport
doImport
Definition: config.py:48
type
table::Key< int > type
Definition: Detector.cc:163
lsst.pipe.tasks.functors.fluxName
def fluxName(col)
Definition: functors.py:499
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:505