LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.colorterms.Colorterm Class Reference
Inheritance diagram for lsst.pipe.tasks.colorterms.Colorterm:
lsst.pex.config.config.Config lsst.pex.config.config.ConfigMeta

Public Member Functions

 getCorrectedMagnitudes (self, refCat, filterName="deprecatedArgument")
 
 transformSource (self, source)
 
 transformMags (self, primary, secondary)
 
 propagateFluxErrors (self, primaryFluxErr, secondaryFluxErr)
 

Static Public Attributes

 primary = Field(dtype=str, doc="name of primary filter")
 
 secondary = Field(dtype=str, doc="name of secondary filter")
 
 c0 = Field(dtype=float, default=0.0, doc="Constant parameter")
 
 c1 = Field(dtype=float, default=0.0, doc="First-order parameter")
 
 c2 = Field(dtype=float, default=0.0, doc="Second-order parameter")
 

Detailed Description

Colorterm correction for one pair of filters

Notes
-----
The transformed magnitude p' is given by:
p' = primary + c0 + c1*(primary - secondary) + c2*(primary - secondary)**2

To construct a Colorterm, use keyword arguments:
Colorterm(primary=primaryFilterName, secondary=secondaryFilterName, c0=c0value, c1=c1Coeff, c2=c2Coeff)
where c0-c2 are optional. For example (omitting c2):
Colorterm(primary="g", secondary="r", c0=-0.00816446, c1=-0.08366937)

This is subclass of Config. That is a bit of a hack to make it easy to store the data
in an appropriate obs_* package as a config override file. In the long term some other
means of persistence will be used, at which point the constructor can be simplified
to not require keyword arguments. (Fixing DM-2831 will also allow making a custom constructor).

Definition at line 40 of file colorterms.py.

Member Function Documentation

◆ getCorrectedMagnitudes()

lsst.pipe.tasks.colorterms.Colorterm.getCorrectedMagnitudes ( self,
refCat,
filterName = "deprecatedArgument" )
Return the colorterm corrected magnitudes for a given filter.

Parameters
----------
refCat : `lsst.afw.table.SimpleCatalog`
    The reference catalog to apply color corrections to.
filterName : `str`, deprecated
    The camera filter to correct the reference catalog into.
    The ``filterName`` argument is unused and will be removed in v23.

Returns
-------
refMag : `np.ndarray`
    The corrected AB magnitudes.
refMagErr : `np.ndarray`
    The corrected AB magnitude errors.

Raises
------
KeyError
    Raised if the reference catalog does not have a flux uncertainty
    for that filter.

Notes
-----
WARNING: I do not know that we can trust the propagation of magnitude
errors returned by this method. They need more thorough tests.

Definition at line 64 of file colorterms.py.

64 def getCorrectedMagnitudes(self, refCat, filterName="deprecatedArgument"):
65 """Return the colorterm corrected magnitudes for a given filter.
66
67 Parameters
68 ----------
69 refCat : `lsst.afw.table.SimpleCatalog`
70 The reference catalog to apply color corrections to.
71 filterName : `str`, deprecated
72 The camera filter to correct the reference catalog into.
73 The ``filterName`` argument is unused and will be removed in v23.
74
75 Returns
76 -------
77 refMag : `np.ndarray`
78 The corrected AB magnitudes.
79 refMagErr : `np.ndarray`
80 The corrected AB magnitude errors.
81
82 Raises
83 ------
84 KeyError
85 Raised if the reference catalog does not have a flux uncertainty
86 for that filter.
87
88 Notes
89 -----
90 WARNING: I do not know that we can trust the propagation of magnitude
91 errors returned by this method. They need more thorough tests.
92 """
93 if filterName != "deprecatedArgument":
94 msg = "Colorterm.getCorrectedMagnitudes() `filterName` arg is unused and will be removed in v23."
95 warnings.warn(msg, category=FutureWarning, stacklevel=2)
96
97 def getFluxes(fluxField):
98 """Get the flux and fluxErr of this field from refCat.
99
100 Parameters
101 ----------
102 fluxField : `str`
103 Name of the source flux field to use.
104
105 Returns
106 -------
107 refFlux : `Unknown`
108 refFluxErr : `Unknown`
109
110 Raises
111 ------
112 KeyError
113 Raised if reference catalog does not have flux uncertainties for the given flux field.
114 """
115 fluxKey = refCat.schema.find(fluxField).key
116 refFlux = refCat[fluxKey]
117 try:
118 fluxErrKey = refCat.schema.find(fluxField + "Err").key
119 refFluxErr = refCat[fluxErrKey]
120 except KeyError as e:
121 raise KeyError("Reference catalog does not have flux uncertainties for %s" % fluxField) from e
122
123 return refFlux, refFluxErr
124
125 primaryFlux, primaryErr = getFluxes(self.primary + "_flux")
126 secondaryFlux, secondaryErr = getFluxes(self.secondary + "_flux")
127
128 primaryMag = u.Quantity(primaryFlux, u.nJy).to_value(u.ABmag)
129 secondaryMag = u.Quantity(secondaryFlux, u.nJy).to_value(u.ABmag)
130
131 refMag = self.transformMags(primaryMag, secondaryMag)
132 refFluxErrArr = self.propagateFluxErrors(primaryErr, secondaryErr)
133
134 # HACK convert to Jy until we have a replacement for this (DM-16903)
135 refMagErr = abMagErrFromFluxErr(refFluxErrArr*1e-9, primaryFlux*1e-9)
136
137 return refMag, refMagErr
138

◆ propagateFluxErrors()

lsst.pipe.tasks.colorterms.Colorterm.propagateFluxErrors ( self,
primaryFluxErr,
secondaryFluxErr )

Definition at line 173 of file colorterms.py.

173 def propagateFluxErrors(self, primaryFluxErr, secondaryFluxErr):
174 return np.hypot((1 + self.c1)*primaryFluxErr, self.c1*secondaryFluxErr)
175
176

◆ transformMags()

lsst.pipe.tasks.colorterms.Colorterm.transformMags ( self,
primary,
secondary )
Transform brightness

Parameters
----------
primary : `float`
    Brightness in primary filter (magnitude).
secondary : `float`
    Brightness in secondary filter (magnitude).

Returns
-------
transformed : `float`
    The transformed brightness (as a magnitude).

Definition at line 155 of file colorterms.py.

155 def transformMags(self, primary, secondary):
156 """Transform brightness
157
158 Parameters
159 ----------
160 primary : `float`
161 Brightness in primary filter (magnitude).
162 secondary : `float`
163 Brightness in secondary filter (magnitude).
164
165 Returns
166 -------
167 transformed : `float`
168 The transformed brightness (as a magnitude).
169 """
170 color = primary - secondary
171 return primary + self.c0 + color*(self.c1 + color*self.c2)
172

◆ transformSource()

lsst.pipe.tasks.colorterms.Colorterm.transformSource ( self,
source )
Transform the brightness of a source

Parameters
----------
source : `Unknown`
    Source whose brightness is to be converted; must support get(filterName)
    (e.g. source.get("r")) method, as do afw::table::Source and dicts.

Returns
-------
transformed : `float`
    The transformed source magnitude.

Definition at line 139 of file colorterms.py.

139 def transformSource(self, source):
140 """Transform the brightness of a source
141
142 Parameters
143 ----------
144 source : `Unknown`
145 Source whose brightness is to be converted; must support get(filterName)
146 (e.g. source.get("r")) method, as do afw::table::Source and dicts.
147
148 Returns
149 -------
150 transformed : `float`
151 The transformed source magnitude.
152 """
153 return self.transformMags(source.get(self.primary), source.get(self.secondary))
154

Member Data Documentation

◆ c0

lsst.pipe.tasks.colorterms.Colorterm.c0 = Field(dtype=float, default=0.0, doc="Constant parameter")
static

Definition at line 60 of file colorterms.py.

◆ c1

lsst.pipe.tasks.colorterms.Colorterm.c1 = Field(dtype=float, default=0.0, doc="First-order parameter")
static

Definition at line 61 of file colorterms.py.

◆ c2

lsst.pipe.tasks.colorterms.Colorterm.c2 = Field(dtype=float, default=0.0, doc="Second-order parameter")
static

Definition at line 62 of file colorterms.py.

◆ primary

lsst.pipe.tasks.colorterms.Colorterm.primary = Field(dtype=str, doc="name of primary filter")
static

Definition at line 58 of file colorterms.py.

◆ secondary

lsst.pipe.tasks.colorterms.Colorterm.secondary = Field(dtype=str, doc="name of secondary filter")
static

Definition at line 59 of file colorterms.py.


The documentation for this class was generated from the following file: