LSST Applications g063fba187b+fee0456c91,g0f08755f38+ea96e5a5a3,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+90257ff92a,g20f6ffc8e0+ea96e5a5a3,g217e2c1bcf+937a289c59,g28da252d5a+daa7da44eb,g2bbee38e9b+253935c60e,g2bc492864f+253935c60e,g3156d2b45e+6e55a43351,g32e5bea42b+31359a2a7a,g347aa1857d+253935c60e,g35bb328faa+a8ce1bb630,g3a166c0a6a+253935c60e,g3b1af351f3+a8ce1bb630,g3e281a1b8c+c5dd892a6c,g414038480c+416496e02f,g41af890bb2+afe91b1188,g599934f4f4+0db33f7991,g7af13505b9+e36de7bce6,g80478fca09+da231ba887,g82479be7b0+a4516e59e3,g858d7b2824+ea96e5a5a3,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+bc6ab8dfbd,gb58c049af0+d64f4d3760,gc28159a63d+253935c60e,gcab2d0539d+3f2b72788c,gcf0d15dbbd+4ea9c45075,gda6a2b7d83+4ea9c45075,gdaeeff99f8+1711a396fd,ge79ae78c31+253935c60e,gef2f8181fd+3031e3cf99,gf0baf85859+c1f95f4921,gfa517265be+ea96e5a5a3,gfa999e8aa5+17cd334064,w.2024.50
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