LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Classes | Functions
lsst.pipe.tasks.functors Namespace Reference

Classes

class  Functor
 
class  CompositeFunctor
 
class  CustomFunctor
 
class  Column
 
class  Index
 
class  IDColumn
 
class  FootprintNPix
 
class  CoordColumn
 
class  RAColumn
 
class  DecColumn
 
class  Mag
 
class  MagErr
 
class  NanoMaggie
 
class  MagDiff
 
class  Color
 
class  Labeller
 
class  StarGalaxyLabeller
 
class  NumStarLabeller
 
class  DeconvolvedMoments
 
class  SdssTraceSize
 
class  PsfSdssTraceSizeDiff
 
class  HsmTraceSize
 
class  PsfHsmTraceSizeDiff
 
class  HsmFwhm
 
class  E1
 
class  E2
 
class  RadiusFromQuadrupole
 
class  LocalWcs
 
class  ComputePixelScale
 
class  ConvertPixelToArcseconds
 
class  ConvertPixelSqToArcsecondsSq
 
class  ReferenceBand
 
class  Photometry
 
class  NanoJansky
 
class  NanoJanskyErr
 
class  Magnitude
 
class  MagnitudeErr
 
class  LocalPhotometry
 
class  LocalNanojansky
 
class  LocalNanojanskyErr
 
class  LocalMagnitude
 
class  LocalMagnitudeErr
 
class  LocalDipoleMeanFlux
 
class  LocalDipoleMeanFluxErr
 
class  LocalDipoleDiffFlux
 
class  LocalDipoleDiffFluxErr
 
class  Ratio
 

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

690 def fluxErrName(col):
691  if not col.endswith('_instFluxErr'):
692  col += '_instFluxErr'
693  return col
694 
695 

◆ fluxName()

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

Definition at line 684 of file functors.py.

684 def fluxName(col):
685  if not col.endswith('_instFlux'):
686  col += '_instFlux'
687  return col
688 
689 

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

15  typeKey='functor', name=None):
16  """Initialize an object defined in a dictionary
17 
18  The object needs to be importable as
19  f'{basePath}.{initDict[typeKey]}'
20  The positional and keyword arguments (if any) are contained in
21  "args" and "kwargs" entries in the dictionary, respectively.
22  This is used in `functors.CompositeFunctor.from_yaml` to initialize
23  a composite functor from a specification in a YAML file.
24 
25  Parameters
26  ----------
27  initDict : dictionary
28  Dictionary describing object's initialization. Must contain
29  an entry keyed by ``typeKey`` that is the name of the object,
30  relative to ``basePath``.
31  basePath : str
32  Path relative to module in which ``initDict[typeKey]`` is defined.
33  typeKey : str
34  Key of ``initDict`` that is the name of the object
35  (relative to `basePath`).
36  """
37  initDict = initDict.copy()
38  # TO DO: DM-21956 We should be able to define functors outside this module
39  pythonType = doImport(f'{basePath}.{initDict.pop(typeKey)}')
40  args = []
41  if 'args' in initDict:
42  args = initDict.pop('args')
43  if isinstance(args, str):
44  args = [args]
45  try:
46  element = pythonType(*args, **initDict)
47  except Exception as e:
48  message = f'Error in constructing functor "{name}" of type {pythonType.__name__} with args: {args}'
49  raise type(e)(message, e.args)
50  return element
51 
52 
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 537 of file functors.py.

537 def mag_aware_eval(df, expr):
538  """Evaluate an expression on a DataFrame, knowing what the 'mag' function means
539 
540  Builds on `pandas.DataFrame.eval`, which parses and executes math on dataframes.
541 
542  Parameters
543  ----------
544  df : pandas.DataFrame
545  Dataframe on which to evaluate expression.
546 
547  expr : str
548  Expression.
549  """
550  try:
551  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>)/log(10)', expr)
552  val = df.eval(expr_new, truediv=True)
553  except Exception: # Should check what actually gets raised
554  expr_new = re.sub(r'mag\‍((\w+)\‍)', r'-2.5*log(\g<1>_instFlux)/log(10)', expr)
555  val = df.eval(expr_new, truediv=True)
556  return val
557 
558 
def mag_aware_eval(df, expr)
Definition: functors.py:537