LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Classes | Functions
lsst.pipe.tasks.functors Namespace Reference

Classes

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

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

751 def fluxErrName(col):
752  if not col.endswith('_instFluxErr'):
753  col += '_instFluxErr'
754  return col
755 
756 

◆ fluxName()

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

Definition at line 745 of file functors.py.

745 def fluxName(col):
746  if not col.endswith('_instFlux'):
747  col += '_instFlux'
748  return col
749 
750 

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

40  typeKey='functor', name=None):
41  """Initialize an object defined in a dictionary
42 
43  The object needs to be importable as
44  f'{basePath}.{initDict[typeKey]}'
45  The positional and keyword arguments (if any) are contained in
46  "args" and "kwargs" entries in the dictionary, respectively.
47  This is used in `functors.CompositeFunctor.from_yaml` to initialize
48  a composite functor from a specification in a YAML file.
49 
50  Parameters
51  ----------
52  initDict : dictionary
53  Dictionary describing object's initialization. Must contain
54  an entry keyed by ``typeKey`` that is the name of the object,
55  relative to ``basePath``.
56  basePath : str
57  Path relative to module in which ``initDict[typeKey]`` is defined.
58  typeKey : str
59  Key of ``initDict`` that is the name of the object
60  (relative to `basePath`).
61  """
62  initDict = initDict.copy()
63  # TO DO: DM-21956 We should be able to define functors outside this module
64  pythonType = doImport(f'{basePath}.{initDict.pop(typeKey)}')
65  args = []
66  if 'args' in initDict:
67  args = initDict.pop('args')
68  if isinstance(args, str):
69  args = [args]
70  try:
71  element = pythonType(*args, **initDict)
72  except Exception as e:
73  message = f'Error in constructing functor "{name}" of type {pythonType.__name__} with args: {args}'
74  raise type(e)(message, e.args)
75  return element
76 
77 
table::Key< int > type
Definition: Detector.cc:163

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

568 def mag_aware_eval(df, expr):
569  """Evaluate an expression on a DataFrame, knowing what the 'mag' function means
570 
571  Builds on `pandas.DataFrame.eval`, which parses and executes math on dataframes.
572 
573  Parameters
574  ----------
575  df : pandas.DataFrame
576  Dataframe on which to evaluate expression.
577 
578  expr : str
579  Expression.
580  """
581  try:
582  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>)/log(10)', expr)
583  val = df.eval(expr_new, truediv=True)
584  except Exception: # Should check what actually gets raised
585  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>_instFlux)/log(10)', expr)
586  val = df.eval(expr_new, truediv=True)
587  return val
588 
589 
def mag_aware_eval(df, expr)
Definition: functors.py:568