164 def getFgcmReferenceStarsSkyCircle(self, ra, dec, radius, filterList):
165 """
166 Get a reference catalog that overlaps a circular sky region, using
167 multiple filters. In addition, apply colorterms if available.
168
169 Return format is a numpy recarray for use with fgcm.
170
171 dtype = ([('ra', `np.float64`),
172 ('dec', `np.float64`),
173 ('refMag', `np.float32`, len(filterList)),
174 ('refMagErr', `np.float32`, len(filterList)])
175
176 Reference magnitudes (AB) will be 99 for non-detections.
177
178 Parameters
179 ----------
180 ra: `float`
181 ICRS right ascension, degrees.
182 dec: `float`
183 ICRS declination, degrees.
184 radius: `float`
185 Radius to search, degrees.
186 filterList: `list`
187 list of `str` of camera filter names.
188
189 Returns
190 -------
191 fgcmRefCat: `np.recarray`
192 """
193
195
196
197 if self._fluxFilters is None or self._fluxFilters != filterList:
198 self._determine_flux_fields(center, filterList)
199
200 skyCircle = self.refObjLoader.loadSkyCircle(center,
201 radius * lsst.geom.degrees,
202 self._referenceFilter)
203
204 if not skyCircle.refCat.isContiguous():
205 refCat = skyCircle.refCat.copy(deep=True)
206 else:
207 refCat = skyCircle.refCat
208
209
210 goodSources = self.referenceSelector.selectSources(refCat)
211 selected = goodSources.selected
212
213 fgcmRefCat = np.zeros(np.sum(selected), dtype=[('ra', 'f8'),
214 ('dec', 'f8'),
215 ('refMag', 'f4', len(filterList)),
216 ('refMagErr', 'f4', len(filterList))])
217 if fgcmRefCat.size == 0:
218
219 return fgcmRefCat
220
221
222
223
224
225
226
227 conv = refCat[0]['coord_ra'].asDegrees() / float(refCat[0]['coord_ra'])
228 fgcmRefCat['ra'] = refCat['coord_ra'][selected] * conv
229 fgcmRefCat['dec'] = refCat['coord_dec'][selected] * conv
230
231
232 fgcmRefCat['refMag'][:, :] = 99.0
233 fgcmRefCat['refMagErr'][:, :] = 99.0
234
235 if self.config.applyColorTerms:
236 for i, (filterName, fluxField) in enumerate(zip(self._fluxFilters, self._fluxFields)):
237 if fluxField is None:
238 continue
239
240 self.log.debug("Applying color terms for filtername=%r" % (filterName))
241
242 colorterm = self.config.colorterms.getColorterm(filterName, self.refCatName, doRaise=True)
243
244 refMag, refMagErr = colorterm.getCorrectedMagnitudes(refCat)
245
246
247
248
249
250 good, = np.where((np.nan_to_num(refMag[selected]) < 90.0)
251 & (np.nan_to_num(refMagErr[selected]) < 90.0)
252 & (np.nan_to_num(refMagErr[selected]) > 0.0))
253
254 fgcmRefCat['refMag'][good, i] = refMag[selected][good]
255 fgcmRefCat['refMagErr'][good, i] = refMagErr[selected][good]
256
257 else:
258
259
260 for i, (filterName, fluxField) in enumerate(zip(self._fluxFilters, self._fluxFields)):
261
262
263 good, = np.where((np.nan_to_num(refCat[fluxField][selected]) > 0.0)
264 & (np.nan_to_num(refCat[fluxField+'Err'][selected]) > 0.0))
265 refMag = (refCat[fluxField][selected][good] * units.nJy).to_value(units.ABmag)
266 refMagErr = abMagErrFromFluxErr(refCat[fluxField+'Err'][selected][good],
267 refCat[fluxField][selected][good])
268 fgcmRefCat['refMag'][good, i] = refMag
269 fgcmRefCat['refMagErr'][good, i] = refMagErr
270
271 return fgcmRefCat
272