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
135 refMagErr = abMagErrFromFluxErr(refFluxErrArr*1e-9, primaryFlux*1e-9)
136
137 return refMag, refMagErr
138