LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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