LSST Applications g063fba187b+eddd1b24d7,g0f08755f38+4a855ab515,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+062a45aee3,g1dcb35cd9c+45d3fa5522,g20f6ffc8e0+4a855ab515,g217e2c1bcf+f55e51b560,g28da252d5a+7d8e536cc7,g2bbee38e9b+2d92fc7d83,g2bc492864f+2d92fc7d83,g3156d2b45e+6e55a43351,g32e5bea42b+625186cc6b,g347aa1857d+2d92fc7d83,g35bb328faa+a8ce1bb630,g3a166c0a6a+2d92fc7d83,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+1af189bab1,g7af13505b9+7b6a50a2f8,g80478fca09+6174b7f182,g82479be7b0+5b71efbaf0,g858d7b2824+4a855ab515,g9125e01d80+a8ce1bb630,ga5288a1d22+61618a97c4,gb58c049af0+d64f4d3760,gc28159a63d+2d92fc7d83,gc5452a3dca+f4add4ffd5,gcab2d0539d+d9f5af7f69,gcf0d15dbbd+6c7e0a19ec,gda6a2b7d83+6c7e0a19ec,gdaeeff99f8+1711a396fd,ge79ae78c31+2d92fc7d83,gef2f8181fd+55fff6f525,gf0baf85859+c1f95f4921,gfa517265be+4a855ab515,gfa999e8aa5+17cd334064,w.2024.51
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  ConvertDetectorAngleToPositionAngle
 
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 792 of file functors.py.

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

◆ fluxName()

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

Definition at line 785 of file functors.py.

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

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

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

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

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