LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions
lsst.pipe.tasks.functors Namespace Reference

Classes

class  Color
 
class  Column
 
class  CompositeFunctor
 
class  ComputePixelScale
 
class  ConvertPixelSqToArcsecondsSq
 
class  ConvertPixelToArcseconds
 
class  CoordColumn
 
class  CustomFunctor
 
class  DecColumn
 
class  DeconvolvedMoments
 
class  E1
 
class  E2
 
class  Ebv
 
class  FootprintNPix
 
class  Functor
 
class  HsmFwhm
 
class  HsmTraceSize
 
class  HtmIndex20
 
class  IDColumn
 
class  Index
 
class  Labeller
 
class  LocalDipoleDiffFlux
 
class  LocalDipoleDiffFluxErr
 
class  LocalDipoleMeanFlux
 
class  LocalDipoleMeanFluxErr
 
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  Ratio
 
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 767 of file functors.py.

767def fluxErrName(col):
768 if not col.endswith('_instFluxErr'):
769 col += '_instFluxErr'
770 return col
771
772

◆ fluxName()

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

Definition at line 761 of file functors.py.

761def fluxName(col):
762 if not col.endswith('_instFlux'):
763 col += '_instFlux'
764 return col
765
766

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

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

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