LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+ffe7eabc7e,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g36da64cc00+ea84795170,g3ddfee87b4+955a963fd8,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+955a963fd8,g591dd9f2cf+bac198a2cb,g5ec818987f+420292cfeb,g858d7b2824+d6c9a0a3b8,g876c692160+aabc49a3c3,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+e6cd765486,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+acd47f83f4,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+12c8382528,gba4ed39666+1ac82b564f,gbb8dafda3b+0574160a1f,gbeb006f7da+dea2fbb49f,gc28159a63d+c6dfa2ddaf,gc86a011abf+d6c9a0a3b8,gcf0d15dbbd+955a963fd8,gdaeeff99f8+1cafcb7cd4,gdc0c513512+d6c9a0a3b8,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,gee10cc3b42+90ebb246c7,gf1cff7945b+d6c9a0a3b8,w.2024.13
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask Class Reference
Inheritance diagram for lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask:
lsst.fgcmcal.fgcmBuildFromIsolatedStars.FgcmBuildFromIsolatedStarsTask lsst.fgcmcal.fgcmBuildStarsTable.FgcmBuildStarsTableTask

Public Member Functions

 __init__ (self, initInputs=None, **kwargs)
 
 fgcmMakeAllStarObservations (self, groupedHandles, visitCat, sourceSchema, camera, calibFluxApertureRadius=None)
 
 fgcmMakeVisitCatalog (self, camera, groupedHandles)
 
 fgcmMatchStars (self, visitCat, obsCat, lutHandle=None)
 

Public Attributes

 fgcmLoadReferenceCatalog
 

Protected Member Functions

 _fillVisitCatalog (self, visitCat, groupedHandles)
 
 _makeSourceMapper (self, sourceSchema)
 
 _makeFgcmVisitSchema (self, nCcd)
 
 _makeFgcmObjSchema (self)
 
 _makeFgcmObsSchema (self)
 
 _makeFgcmRefSchema (self, nReferenceBands)
 
 _getReferenceFilterNames (self, visitCat, stdFilterDict, stdLambdaDict)
 

Detailed Description

Base task to build stars for FGCM global calibration

Definition at line 187 of file fgcmBuildStarsBase.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask.__init__ ( self,
initInputs = None,
** kwargs )

Reimplemented in lsst.fgcmcal.fgcmBuildFromIsolatedStars.FgcmBuildFromIsolatedStarsTask, and lsst.fgcmcal.fgcmBuildStarsTable.FgcmBuildStarsTableTask.

Definition at line 191 of file fgcmBuildStarsBase.py.

191 def __init__(self, initInputs=None, **kwargs):
192 super().__init__(**kwargs)
193
194 self.makeSubtask("sourceSelector")
195 # Only log warning and fatal errors from the sourceSelector
196 self.sourceSelector.log.setLevel(self.sourceSelector.log.WARN)
197

Member Function Documentation

◆ _fillVisitCatalog()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._fillVisitCatalog ( self,
visitCat,
groupedHandles )
protected
Fill the visit catalog with visit metadata

Parameters
----------
visitCat : `afw.table.BaseCatalog`
    Visit catalog.  See _makeFgcmVisitSchema() for schema definition.
groupedHandles : `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
    Dataset handles, grouped by visit.

Definition at line 268 of file fgcmBuildStarsBase.py.

268 def _fillVisitCatalog(self, visitCat, groupedHandles):
269 """
270 Fill the visit catalog with visit metadata
271
272 Parameters
273 ----------
274 visitCat : `afw.table.BaseCatalog`
275 Visit catalog. See _makeFgcmVisitSchema() for schema definition.
276 groupedHandles : `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
277 Dataset handles, grouped by visit.
278 """
279
280 # Guarantee that these are sorted.
281 for i, visit in enumerate(sorted(groupedHandles)):
282 if (i % self.config.nVisitsPerCheckpoint) == 0:
283 self.log.info("Retrieving metadata for visit %d (%d/%d)", visit, i, len(groupedHandles))
284
285 handle = groupedHandles[visit][0]
286 summary = handle.get()
287
288 summaryRow = summary.find(self.config.referenceCCD)
289 if summaryRow is None:
290 # Take the first available ccd if reference isn't available
291 summaryRow = summary[0]
292
293 visitInfo = summaryRow.getVisitInfo()
294 physicalFilter = summaryRow['physical_filter']
295 # Compute the median psf sigma if possible
296 goodSigma, = np.where(summary['psfSigma'] > 0)
297 if goodSigma.size > 2:
298 psfSigma = np.median(summary['psfSigma'][goodSigma])
299 elif goodSigma.size > 0:
300 psfSigma = summary['psfSigma'][goodSigma[0]]
301 else:
302 self.log.warning("Could not find any good summary psfSigma for visit %d", visit)
303 psfSigma = 0.0
304 # Compute median background if possible
305 goodBackground, = np.where(np.nan_to_num(summary['skyBg']) > 0.0)
306 if goodBackground.size > 2:
307 skyBackground = np.median(summary['skyBg'][goodBackground])
308 elif goodBackground.size > 0:
309 skyBackground = summary['skyBg'][goodBackground[0]]
310 else:
311 self.log.warning('Could not find any good summary skyBg for visit %d', visit)
312 skyBackground = -1.0
313
314 rec = visitCat[i]
315 rec['visit'] = visit
316 rec['physicalFilter'] = physicalFilter
317 # TODO DM-26991: Use the wcs to refine the focal-plane center.
318 radec = visitInfo.getBoresightRaDec()
319 rec['telra'] = radec.getRa().asDegrees()
320 rec['teldec'] = radec.getDec().asDegrees()
321 rec['telha'] = visitInfo.getBoresightHourAngle().asDegrees()
322 rec['telrot'] = visitInfo.getBoresightRotAngle().asDegrees()
323 rec['mjd'] = visitInfo.getDate().get(system=DateTime.MJD)
324 rec['exptime'] = visitInfo.getExposureTime()
325 # convert from Pa to millibar
326 # Note that I don't know if this unit will need to be per-camera config
327 rec['pmb'] = visitInfo.getWeather().getAirPressure() / 100
328 # Flag to signify if this is a "deep" field. Not currently used
329 rec['deepFlag'] = 0
330 # Relative flat scaling (1.0 means no relative scaling)
331 rec['scaling'][:] = 1.0
332 # Median delta aperture, to be measured from stars
333 rec['deltaAper'] = 0.0
334 rec['psfSigma'] = psfSigma
335 rec['skyBackground'] = skyBackground
336 rec['used'] = 1
337

◆ _getReferenceFilterNames()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._getReferenceFilterNames ( self,
visitCat,
stdFilterDict,
stdLambdaDict )
protected
Get the reference filter names, in wavelength order, from the visitCat and
information from the look-up-table.

Parameters
----------
visitCat: `afw.table.BaseCatalog`
   Catalog with visit data for FGCM
stdFilterDict: `dict`
   Mapping of filterName to stdFilterName from LUT
stdLambdaDict: `dict`
   Mapping of stdFilterName to stdLambda from LUT

Returns
-------
referenceFilterNames: `list`
   Wavelength-ordered list of reference filter names

Definition at line 631 of file fgcmBuildStarsBase.py.

631 def _getReferenceFilterNames(self, visitCat, stdFilterDict, stdLambdaDict):
632 """
633 Get the reference filter names, in wavelength order, from the visitCat and
634 information from the look-up-table.
635
636 Parameters
637 ----------
638 visitCat: `afw.table.BaseCatalog`
639 Catalog with visit data for FGCM
640 stdFilterDict: `dict`
641 Mapping of filterName to stdFilterName from LUT
642 stdLambdaDict: `dict`
643 Mapping of stdFilterName to stdLambda from LUT
644
645 Returns
646 -------
647 referenceFilterNames: `list`
648 Wavelength-ordered list of reference filter names
649 """
650
651 # Find the unique list of filter names in visitCat
652 filterNames = np.unique(visitCat.asAstropy()['physicalFilter'])
653
654 # Find the unique list of "standard" filters
655 stdFilterNames = {stdFilterDict[filterName] for filterName in filterNames}
656
657 # And sort these by wavelength
658 referenceFilterNames = sorted(stdFilterNames, key=stdLambdaDict.get)
659
660 return referenceFilterNames

◆ _makeFgcmObjSchema()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._makeFgcmObjSchema ( self)
protected
Make a schema for the objIndexCat from fgcmMakeStars

Returns
-------
schema: `afwTable.Schema`

Definition at line 574 of file fgcmBuildStarsBase.py.

574 def _makeFgcmObjSchema(self):
575 """
576 Make a schema for the objIndexCat from fgcmMakeStars
577
578 Returns
579 -------
580 schema: `afwTable.Schema`
581 """
582
583 objSchema = afwTable.Schema()
584 objSchema.addField('fgcm_id', type=np.int32, doc='FGCM Unique ID')
585 # Will investigate making these angles...
586 objSchema.addField('ra', type=np.float64, doc='Mean object RA (deg)')
587 objSchema.addField('dec', type=np.float64, doc='Mean object Dec (deg)')
588 objSchema.addField('obsArrIndex', type=np.int32,
589 doc='Index in obsIndexTable for first observation')
590 objSchema.addField('nObs', type=np.int32, doc='Total number of observations')
591
592 return objSchema
593
Defines the fields and offsets for a table.
Definition Schema.h:51

◆ _makeFgcmObsSchema()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._makeFgcmObsSchema ( self)
protected
Make a schema for the obsIndexCat from fgcmMakeStars

Returns
-------
schema: `afwTable.Schema`

Definition at line 594 of file fgcmBuildStarsBase.py.

594 def _makeFgcmObsSchema(self):
595 """
596 Make a schema for the obsIndexCat from fgcmMakeStars
597
598 Returns
599 -------
600 schema: `afwTable.Schema`
601 """
602
603 obsSchema = afwTable.Schema()
604 obsSchema.addField('obsIndex', type=np.int32, doc='Index in observation table')
605
606 return obsSchema
607

◆ _makeFgcmRefSchema()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._makeFgcmRefSchema ( self,
nReferenceBands )
protected
Make a schema for the referenceCat from fgcmMakeStars

Parameters
----------
nReferenceBands: `int`
   Number of reference bands

Returns
-------
schema: `afwTable.Schema`

Definition at line 608 of file fgcmBuildStarsBase.py.

608 def _makeFgcmRefSchema(self, nReferenceBands):
609 """
610 Make a schema for the referenceCat from fgcmMakeStars
611
612 Parameters
613 ----------
614 nReferenceBands: `int`
615 Number of reference bands
616
617 Returns
618 -------
619 schema: `afwTable.Schema`
620 """
621
622 refSchema = afwTable.Schema()
623 refSchema.addField('fgcm_id', type=np.int32, doc='FGCM Unique ID')
624 refSchema.addField('refMag', type='ArrayF', doc='Reference magnitude array (AB)',
625 size=nReferenceBands)
626 refSchema.addField('refMagErr', type='ArrayF', doc='Reference magnitude error array',
627 size=nReferenceBands)
628
629 return refSchema
630

◆ _makeFgcmVisitSchema()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._makeFgcmVisitSchema ( self,
nCcd )
protected
Make a schema for an fgcmVisitCatalog

Parameters
----------
nCcd: `int`
   Number of CCDs in the camera

Returns
-------
schema: `afwTable.Schema`

Definition at line 538 of file fgcmBuildStarsBase.py.

538 def _makeFgcmVisitSchema(self, nCcd):
539 """
540 Make a schema for an fgcmVisitCatalog
541
542 Parameters
543 ----------
544 nCcd: `int`
545 Number of CCDs in the camera
546
547 Returns
548 -------
549 schema: `afwTable.Schema`
550 """
551
552 schema = afwTable.Schema()
553 schema.addField('visit', type=np.int64, doc="Visit number")
554 schema.addField('physicalFilter', type=str, size=30, doc="Physical filter")
555 schema.addField('telra', type=np.float64, doc="Pointing RA (deg)")
556 schema.addField('teldec', type=np.float64, doc="Pointing Dec (deg)")
557 schema.addField('telha', type=np.float64, doc="Pointing Hour Angle (deg)")
558 schema.addField('telrot', type=np.float64, doc="Camera rotation (deg)")
559 schema.addField('mjd', type=np.float64, doc="MJD of visit")
560 schema.addField('exptime', type=np.float32, doc="Exposure time")
561 schema.addField('pmb', type=np.float32, doc="Pressure (millibar)")
562 schema.addField('psfSigma', type=np.float32, doc="PSF sigma (reference CCD)")
563 schema.addField('deltaAper', type=np.float32, doc="Delta-aperture")
564 schema.addField('skyBackground', type=np.float32, doc="Sky background (ADU) (reference CCD)")
565 # the following field is not used yet
566 schema.addField('deepFlag', type=np.int32, doc="Deep observation")
567 schema.addField('scaling', type='ArrayD', doc="Scaling applied due to flat adjustment",
568 size=nCcd)
569 schema.addField('used', type=np.int32, doc="This visit has been ingested.")
570 schema.addField('sources_read', type='Flag', doc="This visit had sources read.")
571
572 return schema
573

◆ _makeSourceMapper()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask._makeSourceMapper ( self,
sourceSchema )
protected
Make a schema mapper for fgcm sources

Parameters
----------
sourceSchema: `afwTable.Schema`
   Default source schema from the butler

Returns
-------
sourceMapper: `afwTable.schemaMapper`
   Mapper to the FGCM source schema

Definition at line 338 of file fgcmBuildStarsBase.py.

338 def _makeSourceMapper(self, sourceSchema):
339 """
340 Make a schema mapper for fgcm sources
341
342 Parameters
343 ----------
344 sourceSchema: `afwTable.Schema`
345 Default source schema from the butler
346
347 Returns
348 -------
349 sourceMapper: `afwTable.schemaMapper`
350 Mapper to the FGCM source schema
351 """
352
353 # create a mapper to the preferred output
354 sourceMapper = afwTable.SchemaMapper(sourceSchema)
355
356 # map to ra/dec
357 sourceMapper.addMapping(sourceSchema['coord_ra'].asKey(), 'ra')
358 sourceMapper.addMapping(sourceSchema['coord_dec'].asKey(), 'dec')
359 sourceMapper.addMapping(sourceSchema['slot_Centroid_x'].asKey(), 'x')
360 sourceMapper.addMapping(sourceSchema['slot_Centroid_y'].asKey(), 'y')
361 # Add the mapping if the field exists in the input catalog.
362 # If the field does not exist, simply add it (set to False).
363 # This field is not required for calibration, but is useful
364 # to collate if available.
365 try:
366 sourceMapper.addMapping(sourceSchema[self.config.psfCandidateName].asKey(),
367 'psf_candidate')
368 except LookupError:
369 sourceMapper.editOutputSchema().addField(
370 "psf_candidate", type='Flag',
371 doc=("Flag set if the source was a candidate for PSF determination, "
372 "as determined by the star selector."))
373
374 # and add the fields we want
375 sourceMapper.editOutputSchema().addField(
376 "visit", type=np.int64, doc="Visit number")
377 sourceMapper.editOutputSchema().addField(
378 "ccd", type=np.int32, doc="CCD number")
379 sourceMapper.editOutputSchema().addField(
380 "instMag", type=np.float32, doc="Instrumental magnitude")
381 sourceMapper.editOutputSchema().addField(
382 "instMagErr", type=np.float32, doc="Instrumental magnitude error")
383 sourceMapper.editOutputSchema().addField(
384 "jacobian", type=np.float32, doc="Relative pixel scale from wcs jacobian")
385 sourceMapper.editOutputSchema().addField(
386 "deltaMagBkg", type=np.float32, doc="Change in magnitude due to local background offset")
387 sourceMapper.editOutputSchema().addField(
388 "deltaMagAper", type=np.float32, doc="Change in magnitude from larger to smaller aperture")
389
390 return sourceMapper
391
A mapping between the keys of two Schemas, used to copy data between them.

◆ fgcmMakeAllStarObservations()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask.fgcmMakeAllStarObservations ( self,
groupedHandles,
visitCat,
sourceSchema,
camera,
calibFluxApertureRadius = None )
Compile all good star observations from visits in visitCat.

Parameters
----------
groupedHandles : `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
    Dataset handles, grouped by visit.
visitCat : `afw.table.BaseCatalog`
    Catalog with visit data for FGCM
sourceSchema : `lsst.afw.table.Schema`
    Schema for the input src catalogs.
camera : `lsst.afw.cameraGeom.Camera`
calibFluxApertureRadius : `float`, optional
    Aperture radius for calibration flux.
inStarObsCat : `afw.table.BaseCatalog`
    Input observation catalog.  If this is incomplete, observations
    will be appended from when it was cut off.

Returns
-------
fgcmStarObservations : `afw.table.BaseCatalog`
    Full catalog of good observations.

Raises
------
RuntimeError: Raised if doSubtractLocalBackground is True and
   calibFluxApertureRadius is not set.

Reimplemented in lsst.fgcmcal.fgcmBuildStarsTable.FgcmBuildStarsTableTask.

Definition at line 198 of file fgcmBuildStarsBase.py.

201 calibFluxApertureRadius=None):
202 """
203 Compile all good star observations from visits in visitCat.
204
205 Parameters
206 ----------
207 groupedHandles : `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
208 Dataset handles, grouped by visit.
209 visitCat : `afw.table.BaseCatalog`
210 Catalog with visit data for FGCM
211 sourceSchema : `lsst.afw.table.Schema`
212 Schema for the input src catalogs.
213 camera : `lsst.afw.cameraGeom.Camera`
214 calibFluxApertureRadius : `float`, optional
215 Aperture radius for calibration flux.
216 inStarObsCat : `afw.table.BaseCatalog`
217 Input observation catalog. If this is incomplete, observations
218 will be appended from when it was cut off.
219
220 Returns
221 -------
222 fgcmStarObservations : `afw.table.BaseCatalog`
223 Full catalog of good observations.
224
225 Raises
226 ------
227 RuntimeError: Raised if doSubtractLocalBackground is True and
228 calibFluxApertureRadius is not set.
229 """
230 raise NotImplementedError("fgcmMakeAllStarObservations not implemented.")
231

◆ fgcmMakeVisitCatalog()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask.fgcmMakeVisitCatalog ( self,
camera,
groupedHandles )
Make a visit catalog with all the keys from each visit

Parameters
----------
camera: `lsst.afw.cameraGeom.Camera`
   Camera from the butler
groupedHandles: `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
    Dataset handles, grouped by visit.

Returns
-------
visitCat: `afw.table.BaseCatalog`

Definition at line 232 of file fgcmBuildStarsBase.py.

232 def fgcmMakeVisitCatalog(self, camera, groupedHandles):
233 """
234 Make a visit catalog with all the keys from each visit
235
236 Parameters
237 ----------
238 camera: `lsst.afw.cameraGeom.Camera`
239 Camera from the butler
240 groupedHandles: `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
241 Dataset handles, grouped by visit.
242
243 Returns
244 -------
245 visitCat: `afw.table.BaseCatalog`
246 """
247
248 self.log.info("Assembling visitCatalog from %d visits", len(groupedHandles))
249
250 nCcd = len(camera)
251
252 schema = self._makeFgcmVisitSchema(nCcd)
253
254 visitCat = afwTable.BaseCatalog(schema)
255 visitCat.reserve(len(groupedHandles))
256 visitCat.resize(len(groupedHandles))
257
258 visitCat['visit'] = list(groupedHandles.keys())
259 visitCat['used'] = 0
260 visitCat['sources_read'] = False
261
262 # No matter what, fill the catalog. This will check if it was
263 # already read.
264 self._fillVisitCatalog(visitCat, groupedHandles)
265
266 return visitCat
267

◆ fgcmMatchStars()

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask.fgcmMatchStars ( self,
visitCat,
obsCat,
lutHandle = None )
Use FGCM code to match observations into unique stars.

Parameters
----------
visitCat: `afw.table.BaseCatalog`
   Catalog with visit data for fgcm
obsCat: `afw.table.BaseCatalog`
   Full catalog of star observations for fgcm
lutHandle: `lsst.daf.butler.DeferredDatasetHandle`, optional
   Data reference to fgcm look-up table (used if matching reference stars).

Returns
-------
fgcmStarIdCat: `afw.table.BaseCatalog`
   Catalog of unique star identifiers and index keys
fgcmStarIndicesCat: `afwTable.BaseCatalog`
   Catalog of unique star indices
fgcmRefCat: `afw.table.BaseCatalog`
   Catalog of matched reference stars.
   Will be None if `config.doReferenceMatches` is False.

Definition at line 392 of file fgcmBuildStarsBase.py.

392 def fgcmMatchStars(self, visitCat, obsCat, lutHandle=None):
393 """
394 Use FGCM code to match observations into unique stars.
395
396 Parameters
397 ----------
398 visitCat: `afw.table.BaseCatalog`
399 Catalog with visit data for fgcm
400 obsCat: `afw.table.BaseCatalog`
401 Full catalog of star observations for fgcm
402 lutHandle: `lsst.daf.butler.DeferredDatasetHandle`, optional
403 Data reference to fgcm look-up table (used if matching reference stars).
404
405 Returns
406 -------
407 fgcmStarIdCat: `afw.table.BaseCatalog`
408 Catalog of unique star identifiers and index keys
409 fgcmStarIndicesCat: `afwTable.BaseCatalog`
410 Catalog of unique star indices
411 fgcmRefCat: `afw.table.BaseCatalog`
412 Catalog of matched reference stars.
413 Will be None if `config.doReferenceMatches` is False.
414 """
415 # get filter names into a numpy array...
416 # This is the type that is expected by the fgcm code
417 visitFilterNames = np.zeros(len(visitCat), dtype='a30')
418 for i in range(len(visitCat)):
419 visitFilterNames[i] = visitCat[i]['physicalFilter']
420
421 # match to put filterNames with observations
422 visitIndex = np.searchsorted(visitCat['visit'],
423 obsCat['visit'])
424
425 obsFilterNames = visitFilterNames[visitIndex]
426
427 if self.config.doReferenceMatches:
428 # Get the reference filter names, using the LUT
429 lutCat = lutHandle.get()
430
431 stdFilterDict = {filterName: stdFilter for (filterName, stdFilter) in
432 zip(lutCat[0]['physicalFilters'].split(','),
433 lutCat[0]['stdPhysicalFilters'].split(','))}
434 stdLambdaDict = {stdFilter: stdLambda for (stdFilter, stdLambda) in
435 zip(lutCat[0]['stdPhysicalFilters'].split(','),
436 lutCat[0]['lambdaStdFilter'])}
437
438 del lutCat
439
440 referenceFilterNames = self._getReferenceFilterNames(visitCat,
441 stdFilterDict,
442 stdLambdaDict)
443 self.log.info("Using the following reference filters: %s" %
444 (', '.join(referenceFilterNames)))
445
446 else:
447 # This should be an empty list
448 referenceFilterNames = []
449
450 # make the fgcm starConfig dict
451 starConfig = {'logger': self.log,
452 'useHtm': True,
453 'filterToBand': self.config.physicalFilterMap,
454 'requiredBands': self.config.requiredBands,
455 'minPerBand': self.config.minPerBand,
456 'matchRadius': self.config.matchRadius,
457 'isolationRadius': self.config.isolationRadius,
458 'matchNSide': self.config.matchNside,
459 'coarseNSide': self.config.coarseNside,
460 'densNSide': self.config.densityCutNside,
461 'densMaxPerPixel': self.config.densityCutMaxPerPixel,
462 'randomSeed': self.config.randomSeed,
463 'primaryBands': self.config.primaryBands,
464 'referenceFilterNames': referenceFilterNames}
465
466 # initialize the FgcmMakeStars object
467 fgcmMakeStars = fgcm.FgcmMakeStars(starConfig)
468
469 # make the primary stars
470 # note that the ra/dec native Angle format is radians
471 # We determine the conversion from the native units (typically
472 # radians) to degrees for the first observation. This allows us
473 # to treate ra/dec as numpy arrays rather than Angles, which would
474 # be approximately 600x slower.
475 conv = obsCat[0]['ra'].asDegrees() / float(obsCat[0]['ra'])
476 fgcmMakeStars.makePrimaryStars(obsCat['ra'] * conv,
477 obsCat['dec'] * conv,
478 filterNameArray=obsFilterNames,
479 bandSelected=False)
480
481 # and match all the stars
482 fgcmMakeStars.makeMatchedStars(obsCat['ra'] * conv,
483 obsCat['dec'] * conv,
484 obsFilterNames)
485
486 if self.config.doReferenceMatches:
487 fgcmMakeStars.makeReferenceMatches(self.fgcmLoadReferenceCatalog)
488
489 # now persist
490
491 objSchema = self._makeFgcmObjSchema()
492
493 # make catalog and records
494 fgcmStarIdCat = afwTable.BaseCatalog(objSchema)
495 fgcmStarIdCat.reserve(fgcmMakeStars.objIndexCat.size)
496 for i in range(fgcmMakeStars.objIndexCat.size):
497 fgcmStarIdCat.addNew()
498
499 # fill the catalog
500 fgcmStarIdCat['fgcm_id'][:] = fgcmMakeStars.objIndexCat['fgcm_id']
501 fgcmStarIdCat['ra'][:] = fgcmMakeStars.objIndexCat['ra']
502 fgcmStarIdCat['dec'][:] = fgcmMakeStars.objIndexCat['dec']
503 fgcmStarIdCat['obsArrIndex'][:] = fgcmMakeStars.objIndexCat['obsarrindex']
504 fgcmStarIdCat['nObs'][:] = fgcmMakeStars.objIndexCat['nobs']
505
506 obsSchema = self._makeFgcmObsSchema()
507
508 fgcmStarIndicesCat = afwTable.BaseCatalog(obsSchema)
509 fgcmStarIndicesCat.reserve(fgcmMakeStars.obsIndexCat.size)
510 for i in range(fgcmMakeStars.obsIndexCat.size):
511 fgcmStarIndicesCat.addNew()
512
513 fgcmStarIndicesCat['obsIndex'][:] = fgcmMakeStars.obsIndexCat['obsindex']
514
515 if self.config.doReferenceMatches:
516 refSchema = self._makeFgcmRefSchema(len(referenceFilterNames))
517
518 fgcmRefCat = afwTable.BaseCatalog(refSchema)
519 fgcmRefCat.reserve(fgcmMakeStars.referenceCat.size)
520
521 for i in range(fgcmMakeStars.referenceCat.size):
522 fgcmRefCat.addNew()
523
524 fgcmRefCat['fgcm_id'][:] = fgcmMakeStars.referenceCat['fgcm_id']
525 fgcmRefCat['refMag'][:, :] = fgcmMakeStars.referenceCat['refMag']
526 fgcmRefCat['refMagErr'][:, :] = fgcmMakeStars.referenceCat['refMagErr']
527
528 md = PropertyList()
529 md.set("REFSTARS_FORMAT_VERSION", REFSTARS_FORMAT_VERSION)
530 md.set("FILTERNAMES", referenceFilterNames)
531 fgcmRefCat.setMetadata(md)
532
533 else:
534 fgcmRefCat = None
535
536 return fgcmStarIdCat, fgcmStarIndicesCat, fgcmRefCat
537

Member Data Documentation

◆ fgcmLoadReferenceCatalog

lsst.fgcmcal.fgcmBuildStarsBase.FgcmBuildStarsBaseTask.fgcmLoadReferenceCatalog

Definition at line 487 of file fgcmBuildStarsBase.py.


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