LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+b2075782a9,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g3ddfee87b4+a60788ef87,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+a60788ef87,g591dd9f2cf+ba8caea58f,g5ec818987f+864ee9cddb,g858d7b2824+9ee1ab4172,g876c692160+a40945ebb7,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+5e309b7bc6,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+aa12a14d27,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+d0da15e3be,gba4ed39666+1ac82b564f,gbb8dafda3b+5dfd9c994b,gbeb006f7da+97157f9740,gc28159a63d+c6dfa2ddaf,gc86a011abf+9ee1ab4172,gcf0d15dbbd+a60788ef87,gdaeeff99f8+1cafcb7cd4,gdc0c513512+9ee1ab4172,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,geb961e4c1e+f9439d1e6f,gee10cc3b42+90ebb246c7,gf1cff7945b+9ee1ab4172,w.2024.12
LSST Data Management Base Package
Loading...
Searching...
No Matches
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  DecErrColumn
 
class  DeconvolvedMoments
 
class  E1
 
class  E2
 
class  Ebv
 
class  Functor
 
class  HsmFwhm
 
class  HsmTraceSize
 
class  HtmIndex20
 
class  Index
 
class  LocalDipoleDiffFlux
 
class  LocalDipoleDiffFluxErr
 
class  LocalDipoleMeanFlux
 
class  LocalDipoleMeanFluxErr
 
class  LocalNanojansky
 
class  LocalNanojanskyErr
 
class  LocalPhotometry
 
class  LocalWcs
 
class  Mag
 
class  MagDiff
 
class  MagErr
 
class  NanoJansky
 
class  NanoJanskyErr
 
class  Photometry
 
class  PsfHsmTraceSizeDiff
 
class  PsfSdssTraceSizeDiff
 
class  RAColumn
 
class  RADecCovColumn
 
class  RadiusFromQuadrupole
 
class  RAErrColumn
 
class  ReferenceBand
 
class  SdssTraceSize
 

Functions

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

Function Documentation

◆ fluxErrName()

lsst.pipe.tasks.functors.fluxErrName ( col)
Append _instFluxErr to the column name if it doesn't have it already.

Definition at line 789 of file functors.py.

789def fluxErrName(col):
790 """Append _instFluxErr to the column name if it doesn't have it already."""
791 if not col.endswith('_instFluxErr'):
792 col += '_instFluxErr'
793 return col
794
795

◆ fluxName()

lsst.pipe.tasks.functors.fluxName ( col)
Append _instFlux to the column name if it doesn't have it already.

Definition at line 782 of file functors.py.

782def fluxName(col):
783 """Append _instFlux to the column name if it doesn't have it already."""
784 if not col.endswith('_instFlux'):
785 col += '_instFlux'
786 return col
787
788

◆ init_fromDict()

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 `~lsst.pipe.tasks.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 56 of file functors.py.

57 typeKey='functor', name=None):
58 """Initialize an object defined in a dictionary.
59
60 The object needs to be importable as f'{basePath}.{initDict[typeKey]}'.
61 The positional and keyword arguments (if any) are contained in "args" and
62 "kwargs" entries in the dictionary, respectively.
63 This is used in `~lsst.pipe.tasks.functors.CompositeFunctor.from_yaml` to
64 initialize a composite functor from a specification in a YAML file.
65
66 Parameters
67 ----------
68 initDict : dictionary
69 Dictionary describing object's initialization.
70 Must contain an entry keyed by ``typeKey`` that is the name of the
71 object, relative to ``basePath``.
72 basePath : str
73 Path relative to module in which ``initDict[typeKey]`` is defined.
74 typeKey : str
75 Key of ``initDict`` that is the name of the object (relative to
76 ``basePath``).
77 """
78 initDict = initDict.copy()
79 # TO DO: DM-21956 We should be able to define functors outside this module
80 pythonType = doImport(f'{basePath}.{initDict.pop(typeKey)}')
81 args = []
82 if 'args' in initDict:
83 args = initDict.pop('args')
84 if isinstance(args, str):
85 args = [args]
86 try:
87 element = pythonType(*args, **initDict)
88 except Exception as e:
89 message = f'Error in constructing functor "{name}" of type {pythonType.__name__} with args: {args}'
90 raise type(e)(message, e.args)
91 return element
92
93

◆ mag_aware_eval()

lsst.pipe.tasks.functors.mag_aware_eval ( df,
expr,
log )
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, log):
578 """Evaluate an expression on a DataFrame, knowing what the 'mag' function
579 means.
580
581 Builds on `pandas.DataFrame.eval`, which parses and executes math on
582 DataFrames.
583
584 Parameters
585 ----------
586 df : ~pandas.DataFrame
587 DataFrame on which to evaluate expression.
588
589 expr : str
590 Expression.
591 """
592 try:
593 expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>)/log(10)', expr)
594 val = df.eval(expr_new)
595 except Exception as e: # Should check what actually gets raised
596 log.error("Exception in mag_aware_eval: %s: %s", type(e).__name__, e)
597 expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>_instFlux)/log(10)', expr)
598 val = df.eval(expr_new)
599 return val
600
601