21 """Base class for BuildStars using src tables or sourceTable_visit tables.
31 import lsst.daf.persistence
as dafPersist
32 import lsst.pex.config
as pexConfig
33 import lsst.pipe.base
as pipeBase
34 import lsst.afw.table
as afwTable
35 import lsst.geom
as geom
36 from lsst.daf.base
import PropertyList
37 from lsst.daf.base.dateTime
import DateTime
38 from lsst.meas.algorithms.sourceSelector
import sourceSelectorRegistry
40 from .utilities
import computeApertureRadiusFromDataRef
41 from .fgcmLoadReferenceCatalog
import FgcmLoadReferenceCatalogTask
45 REFSTARS_FORMAT_VERSION = 1
47 __all__ = [
'FgcmBuildStarsConfigBase',
'FgcmBuildStarsRunner',
'FgcmBuildStarsBaseTask']
51 """Base config for FgcmBuildStars tasks"""
53 instFluxField = pexConfig.Field(
54 doc=(
"Faull name of the source instFlux field to use, including 'instFlux'. "
55 "The associated flag will be implicitly included in badFlags"),
57 default=
'slot_CalibFlux_instFlux',
59 minPerBand = pexConfig.Field(
60 doc=
"Minimum observations per band",
64 matchRadius = pexConfig.Field(
65 doc=
"Match radius (arcseconds)",
69 isolationRadius = pexConfig.Field(
70 doc=
"Isolation radius (arcseconds)",
74 densityCutNside = pexConfig.Field(
75 doc=
"Density cut healpix nside",
79 densityCutMaxPerPixel = pexConfig.Field(
80 doc=
"Density cut number of stars per pixel",
84 matchNside = pexConfig.Field(
85 doc=
"Healpix Nside for matching",
89 coarseNside = pexConfig.Field(
90 doc=
"Healpix coarse Nside for partitioning matches",
94 filterMap = pexConfig.DictField(
95 doc=
"Mapping from 'filterName' to band.",
100 requiredBands = pexConfig.ListField(
101 doc=
"Bands required for each star",
105 primaryBands = pexConfig.ListField(
106 doc=(
"Bands for 'primary' star matches. "
107 "A star must be observed in one of these bands to be considered "
108 "as a calibration star."),
112 visitDataRefName = pexConfig.Field(
113 doc=
"dataRef name for the 'visit' field, usually 'visit'.",
117 ccdDataRefName = pexConfig.Field(
118 doc=
"dataRef name for the 'ccd' field, usually 'ccd' or 'detector'.",
122 doApplyWcsJacobian = pexConfig.Field(
123 doc=
"Apply the jacobian of the WCS to the star observations prior to fit?",
127 doModelErrorsWithBackground = pexConfig.Field(
128 doc=
"Model flux errors with background term?",
132 psfCandidateName = pexConfig.Field(
133 doc=
"Name of field with psf candidate flag for propagation",
135 default=
"calib_psf_candidate"
137 doSubtractLocalBackground = pexConfig.Field(
138 doc=(
"Subtract the local background before performing calibration? "
139 "This is only supported for circular aperture calibration fluxes."),
143 localBackgroundFluxField = pexConfig.Field(
144 doc=
"Full name of the local background instFlux field to use.",
146 default=
'base_LocalBackground_instFlux'
148 sourceSelector = sourceSelectorRegistry.makeField(
149 doc=
"How to select sources",
152 apertureInnerInstFluxField = pexConfig.Field(
153 doc=(
"Full name of instFlux field that contains inner aperture "
154 "flux for aperture correction proxy"),
156 default=
'base_CircularApertureFlux_12_0_instFlux'
158 apertureOuterInstFluxField = pexConfig.Field(
159 doc=(
"Full name of instFlux field that contains outer aperture "
160 "flux for aperture correction proxy"),
162 default=
'base_CircularApertureFlux_17_0_instFlux'
164 doReferenceMatches = pexConfig.Field(
165 doc=
"Match reference catalog as additional constraint on calibration",
169 fgcmLoadReferenceCatalog = pexConfig.ConfigurableField(
170 target=FgcmLoadReferenceCatalogTask,
171 doc=
"FGCM reference object loader",
173 nVisitsPerCheckpoint = pexConfig.Field(
174 doc=
"Number of visits read between checkpoints",
181 sourceSelector.setDefaults()
183 sourceSelector.doFlags =
True
184 sourceSelector.doUnresolved =
True
185 sourceSelector.doSignalToNoise =
True
186 sourceSelector.doIsolated =
True
188 sourceSelector.signalToNoise.minimum = 10.0
189 sourceSelector.signalToNoise.maximum = 1000.0
193 sourceSelector.unresolved.maximum = 0.5
197 """Subclass of TaskRunner for FgcmBuildStars tasks
199 fgcmBuildStarsTask.run() and fgcmBuildStarsTableTask.run() take a number of
200 arguments, one of which is the butler (for persistence and mapper data),
201 and a list of dataRefs extracted from the command line. Note that FGCM
202 runs on a large set of dataRefs, and not on single dataRef/tract/patch.
203 This class transforms the process arguments generated by the ArgumentParser
204 into the arguments expected by FgcmBuildStarsTask.run(). This runner does
205 not use any parallelization.
210 Return a list with one element: a tuple with the butler and
214 return [(parsedCmd.butler, parsedCmd.id.refList)]
220 args: `tuple` with (butler, dataRefList)
224 exitStatus: `list` with `lsst.pipe.base.Struct`
225 exitStatus (0: success; 1: failure)
227 butler, dataRefList = args
229 task = self.TaskClass(config=self.config, log=self.log)
233 task.runDataRef(butler, dataRefList)
236 task.runDataRef(butler, dataRefList)
237 except Exception
as e:
239 task.log.fatal(
"Failed: %s" % e)
240 if not isinstance(e, pipeBase.TaskError):
241 traceback.print_exc(file=sys.stderr)
243 task.writeMetadata(butler)
246 return [pipeBase.Struct(exitStatus=exitStatus)]
250 Run the task, with no multiprocessing
254 parsedCmd: `lsst.pipe.base.ArgumentParser` parsed command line
259 if self.precall(parsedCmd):
261 resultList = self(targetList[0])
268 Base task to build stars for FGCM global calibration
272 butler : `lsst.daf.persistence.Butler`
274 def __init__(self, butler=None, initInputs=None, **kwargs):
277 self.makeSubtask(
"sourceSelector")
279 self.sourceSelector.log.setLevel(self.sourceSelector.log.WARN)
282 def _getMetadataName(self):
288 Cross-match and make star list for FGCM Input
292 butler: `lsst.daf.persistence.Butler`
293 dataRefs: `list` of `lsst.daf.persistence.ButlerDataRef`
294 Source data references for the input visits.
298 RuntimeErrror: Raised if `config.doReferenceMatches` is set and
299 an fgcmLookUpTable is not available, or if computeFluxApertureRadius()
300 fails if the calibFlux is not a CircularAperture flux.
302 datasetType = dataRefs[0].butlerSubset.datasetType
303 self.log.info(
"Running with %d %s dataRefs", len(dataRefs), datasetType)
305 if self.config.doReferenceMatches:
306 self.makeSubtask(
"fgcmLoadReferenceCatalog", butler=butler)
308 if not butler.datasetExists(
'fgcmLookUpTable'):
309 raise RuntimeError(
"Must have fgcmLookUpTable if using config.doReferenceMatches")
312 calibFluxApertureRadius =
None
313 if self.config.doSubtractLocalBackground:
316 self.config.instFluxField)
317 except RuntimeError
as e:
318 raise RuntimeError(
"Could not determine aperture radius from %s. "
319 "Cannot use doSubtractLocalBackground." %
320 (self.config.instFluxField))
from e
322 camera = butler.get(
'camera')
330 visitCatDataRef = butler.dataRef(
'fgcmVisitCatalog')
331 filename = visitCatDataRef.get(
'fgcmVisitCatalog_filename')[0]
332 if os.path.exists(filename):
334 inVisitCat = visitCatDataRef.get()
335 if len(inVisitCat) != len(groupedDataRefs):
336 raise RuntimeError(
"Existing visitCatalog found, but has an inconsistent "
337 "number of visits. Cannot continue.")
342 visitCatDataRef=visitCatDataRef,
343 inVisitCat=inVisitCat)
346 visitCatDataRef.put(visitCat)
348 starObsDataRef = butler.dataRef(
'fgcmStarObservations')
349 filename = starObsDataRef.get(
'fgcmStarObservations_filename')[0]
350 if os.path.exists(filename):
351 inStarObsCat = starObsDataRef.get()
355 rad = calibFluxApertureRadius
356 sourceSchemaDataRef = butler.dataRef(
'src_schema')
361 calibFluxApertureRadius=rad,
362 starObsDataRef=starObsDataRef,
363 visitCatDataRef=visitCatDataRef,
364 inStarObsCat=inStarObsCat)
365 visitCatDataRef.put(visitCat)
366 starObsDataRef.put(fgcmStarObservationCat)
369 if self.config.doReferenceMatches:
370 lutDataRef = butler.dataRef(
'fgcmLookUpTable')
373 fgcmStarIdCat, fgcmStarIndicesCat, fgcmRefCat = self.
fgcmMatchStars(visitCat,
374 fgcmStarObservationCat,
375 lutDataRef=lutDataRef)
378 butler.put(fgcmStarIdCat,
'fgcmStarIds')
379 butler.put(fgcmStarIndicesCat,
'fgcmStarIndices')
380 if fgcmRefCat
is not None:
381 butler.put(fgcmRefCat,
'fgcmReferenceStars')
384 def _findAndGroupDataRefs(self, camera, dataRefs, butler=None, calexpDataRefDict=None):
386 Find and group dataRefs (by visit). For Gen2 usage, set butler, and for
387 Gen3, use calexpDataRefDict
391 camera : `lsst.afw.cameraGeom.Camera`
392 Camera from the butler.
393 dataRefs : `list` of `lsst.daf.persistence.ButlerDataRef` or
394 `lsst.daf.butler.DeferredDatasetHandle`
395 Data references for the input visits.
396 butler : `lsst.daf.persistence.Butler`, optional
397 Gen2 butler when used as CommandLineTask
398 calexpDataRefDict : `dict`, optional
399 Dictionary of Gen3 deferred data refs for calexps
403 groupedDataRefs : `OrderedDict` [`int`, `list`]
404 Dictionary with sorted visit keys, and `list`s of
405 `lsst.daf.persistence.ButlerDataRef` or
406 `lsst.daf.butler.DeferredDatasetHandle`
410 RuntimeError : Raised if neither or both of butler and dataRefDict are set.
412 raise NotImplementedError(
"_findAndGroupDataRefs not implemented.")
418 calibFluxApertureRadius=None,
419 visitCatDataRef=None,
423 Compile all good star observations from visits in visitCat. Checkpoint files
424 will be stored if both visitCatDataRef and starObsDataRef are not None.
428 groupedDataRefs: `dict` of `list`s
429 Lists of `~lsst.daf.persistence.ButlerDataRef` or
430 `~lsst.daf.butler.DeferredDatasetHandle`, grouped by visit.
431 visitCat: `~afw.table.BaseCatalog`
432 Catalog with visit data for FGCM
433 sourceSchemaDataRef: `~lsst.daf.persistence.ButlerDataRef` or
434 `~lsst.daf.butler.DeferredDatasetHandle`
435 DataRef for the schema of the src catalogs.
436 camera: `~lsst.afw.cameraGeom.Camera`
437 calibFluxApertureRadius: `float`, optional
438 Aperture radius for calibration flux.
439 visitCatDataRef: `~lsst.daf.persistence.ButlerDataRef`, optional
440 Dataref to write visitCat for checkpoints
441 starObsDataRef: `~lsst.daf.persistence.ButlerDataRef`, optional
442 Dataref to write the star observation catalog for checkpoints.
443 inStarObsCat: `~afw.table.BaseCatalog`
444 Input observation catalog. If this is incomplete, observations
445 will be appended from when it was cut off.
449 fgcmStarObservations: `afw.table.BaseCatalog`
450 Full catalog of good observations.
454 RuntimeError: Raised if doSubtractLocalBackground is True and
455 calibFluxApertureRadius is not set.
457 raise NotImplementedError(
"fgcmMakeAllStarObservations not implemented.")
460 visitCatDataRef=None, inVisitCat=None):
462 Make a visit catalog with all the keys from each visit
466 camera: `lsst.afw.cameraGeom.Camera`
467 Camera from the butler
468 groupedDataRefs: `dict`
469 Dictionary with visit keys, and `list`s of
470 `lsst.daf.persistence.ButlerDataRef`
471 bkgDataRefDict: `dict`, optional
472 Dictionary of gen3 dataRefHandles for background info.
473 visitCatDataRef: `lsst.daf.persistence.ButlerDataRef`, optional
474 Dataref to write visitCat for checkpoints
475 inVisitCat: `afw.table.BaseCatalog`, optional
476 Input (possibly incomplete) visit catalog
480 visitCat: `afw.table.BaseCatalog`
483 self.log.info(
"Assembling visitCatalog from %d %ss" %
484 (len(groupedDataRefs), self.config.visitDataRefName))
488 if inVisitCat
is None:
491 visitCat = afwTable.BaseCatalog(schema)
492 visitCat.reserve(len(groupedDataRefs))
493 visitCat.resize(len(groupedDataRefs))
495 visitCat[
'visit'] = list(groupedDataRefs.keys())
497 visitCat[
'sources_read'] =
False
499 visitCat = inVisitCat
504 bkgDataRefDict=bkgDataRefDict,
505 visitCatDataRef=visitCatDataRef)
509 def _fillVisitCatalog(self, visitCat, groupedDataRefs, bkgDataRefDict=None,
510 visitCatDataRef=None):
512 Fill the visit catalog with visit metadata
516 visitCat: `afw.table.BaseCatalog`
517 Catalog with schema from _makeFgcmVisitSchema()
518 groupedDataRefs: `dict`
519 Dictionary with visit keys, and `list`s of
520 `lsst.daf.persistence.ButlerDataRef`
521 visitCatDataRef: `lsst.daf.persistence.ButlerDataRef`, optional
522 Dataref to write visitCat for checkpoints
523 bkgDataRefDict: `dict`, optional
524 Dictionary of gen3 dataRefHandles for background info. FIXME
526 bbox = geom.BoxI(geom.PointI(0, 0), geom.PointI(1, 1))
528 for i, visit
in enumerate(groupedDataRefs):
535 if visitCat[
'used'][i]:
538 if (i % self.config.nVisitsPerCheckpoint) == 0:
539 self.log.info(
"Retrieving metadata for %s %d (%d/%d)" %
540 (self.config.visitDataRefName, visit, i, len(groupedDataRefs)))
542 if visitCatDataRef
is not None:
543 visitCatDataRef.put(visitCat)
548 dataRef = groupedDataRefs[visit][0]
549 if isinstance(dataRef, dafPersist.ButlerDataRef):
550 exp = dataRef.get(datasetType=
'calexp_sub', bbox=bbox)
551 visitInfo = exp.getInfo().getVisitInfo()
555 visitInfo = dataRef.get(component=
'visitInfo')
556 f = dataRef.get(component=
'filter')
557 psf = dataRef.get(component=
'psf')
561 rec[
'filtername'] = f.getName()
565 radec = visitInfo.getBoresightRaDec()
566 rec[
'telra'] = radec.getRa().asDegrees()
567 rec[
'teldec'] = radec.getDec().asDegrees()
568 rec[
'telha'] = visitInfo.getBoresightHourAngle().asDegrees()
569 rec[
'telrot'] = visitInfo.getBoresightRotAngle().asDegrees()
570 rec[
'mjd'] = visitInfo.getDate().get(system=DateTime.MJD)
571 rec[
'exptime'] = visitInfo.getExposureTime()
574 rec[
'pmb'] = visitInfo.getWeather().getAirPressure() / 100
578 rec[
'scaling'][:] = 1.0
580 rec[
'deltaAper'] = 0.0
582 rec[
'psfSigma'] = psf.computeShape().getDeterminantRadius()
584 if self.config.doModelErrorsWithBackground:
586 if isinstance(dataRef, dafPersist.ButlerDataRef):
587 det = dataRef.dataId[self.config.ccdDataRefName]
588 if dataRef.datasetExists(datasetType=
'calexpBackground'):
589 bgList = dataRef.get(datasetType=
'calexpBackground')
592 det = dataRef.dataId.byName()[
'detector']
594 bkgRef = bkgDataRefDict[(visit, det)]
595 bgList = bkgRef.get()
601 bgStats = (bg[0].getStatsImage().getImage().array
603 rec[
'skyBackground'] = sum(np.median(bg[np.isfinite(bg)])
for bg
in bgStats)
605 self.log.warn(
'Sky background not found for visit %d / ccd %d' %
607 rec[
'skyBackground'] = -1.0
609 rec[
'skyBackground'] = -1.0
613 def _makeSourceMapper(self, sourceSchema):
615 Make a schema mapper for fgcm sources
619 sourceSchema: `afwTable.Schema`
620 Default source schema from the butler
624 sourceMapper: `afwTable.schemaMapper`
625 Mapper to the FGCM source schema
629 sourceMapper = afwTable.SchemaMapper(sourceSchema)
632 sourceMapper.addMapping(sourceSchema[
'coord_ra'].asKey(),
'ra')
633 sourceMapper.addMapping(sourceSchema[
'coord_dec'].asKey(),
'dec')
634 sourceMapper.addMapping(sourceSchema[
'slot_Centroid_x'].asKey(),
'x')
635 sourceMapper.addMapping(sourceSchema[
'slot_Centroid_y'].asKey(),
'y')
641 sourceMapper.addMapping(sourceSchema[self.config.psfCandidateName].asKey(),
644 sourceMapper.editOutputSchema().addField(
645 "psf_candidate", type=
'Flag',
646 doc=(
"Flag set if the source was a candidate for PSF determination, "
647 "as determined by the star selector."))
650 sourceMapper.editOutputSchema().addField(
651 "visit", type=np.int32, doc=
"Visit number")
652 sourceMapper.editOutputSchema().addField(
653 "ccd", type=np.int32, doc=
"CCD number")
654 sourceMapper.editOutputSchema().addField(
655 "instMag", type=np.float32, doc=
"Instrumental magnitude")
656 sourceMapper.editOutputSchema().addField(
657 "instMagErr", type=np.float32, doc=
"Instrumental magnitude error")
658 sourceMapper.editOutputSchema().addField(
659 "jacobian", type=np.float32, doc=
"Relative pixel scale from wcs jacobian")
660 sourceMapper.editOutputSchema().addField(
661 "deltaMagBkg", type=np.float32, doc=
"Change in magnitude due to local background offset")
667 Use FGCM code to match observations into unique stars.
671 visitCat: `afw.table.BaseCatalog`
672 Catalog with visit data for fgcm
673 obsCat: `afw.table.BaseCatalog`
674 Full catalog of star observations for fgcm
675 lutDataRef: `lsst.daf.persistence.ButlerDataRef` or
676 `lsst.daf.butler.DeferredDatasetHandle`, optional
677 Data reference to fgcm look-up table (used if matching reference stars).
681 fgcmStarIdCat: `afw.table.BaseCatalog`
682 Catalog of unique star identifiers and index keys
683 fgcmStarIndicesCat: `afwTable.BaseCatalog`
684 Catalog of unique star indices
685 fgcmRefCat: `afw.table.BaseCatalog`
686 Catalog of matched reference stars.
687 Will be None if `config.doReferenceMatches` is False.
691 visitFilterNames = np.zeros(len(visitCat), dtype=
'a10')
692 for i
in range(len(visitCat)):
693 visitFilterNames[i] = visitCat[i][
'filtername']
696 visitIndex = np.searchsorted(visitCat[
'visit'],
699 obsFilterNames = visitFilterNames[visitIndex]
701 if self.config.doReferenceMatches:
703 lutCat = lutDataRef.get()
705 stdFilterDict = {filterName: stdFilter
for (filterName, stdFilter)
in
706 zip(lutCat[0][
'filterNames'].split(
','),
707 lutCat[0][
'stdFilterNames'].split(
','))}
708 stdLambdaDict = {stdFilter: stdLambda
for (stdFilter, stdLambda)
in
709 zip(lutCat[0][
'stdFilterNames'].split(
','),
710 lutCat[0][
'lambdaStdFilter'])}
717 self.log.info(
"Using the following reference filters: %s" %
718 (
', '.join(referenceFilterNames)))
722 referenceFilterNames = []
726 starConfig = {
'logger': self.log,
727 'filterToBand': self.config.filterMap,
728 'requiredBands': self.config.requiredBands,
729 'minPerBand': self.config.minPerBand,
730 'matchRadius': self.config.matchRadius,
731 'isolationRadius': self.config.isolationRadius,
732 'matchNSide': self.config.matchNside,
733 'coarseNSide': self.config.coarseNside,
734 'densNSide': self.config.densityCutNside,
735 'densMaxPerPixel': self.config.densityCutMaxPerPixel,
736 'primaryBands': self.config.primaryBands,
737 'referenceFilterNames': referenceFilterNames}
740 fgcmMakeStars = fgcm.FgcmMakeStars(starConfig)
748 conv = obsCat[0][
'ra'].asDegrees() / float(obsCat[0][
'ra'])
749 fgcmMakeStars.makePrimaryStars(obsCat[
'ra'] * conv,
750 obsCat[
'dec'] * conv,
751 filterNameArray=obsFilterNames,
755 fgcmMakeStars.makeMatchedStars(obsCat[
'ra'] * conv,
756 obsCat[
'dec'] * conv,
759 if self.config.doReferenceMatches:
760 fgcmMakeStars.makeReferenceMatches(self.fgcmLoadReferenceCatalog)
767 fgcmStarIdCat = afwTable.BaseCatalog(objSchema)
768 fgcmStarIdCat.reserve(fgcmMakeStars.objIndexCat.size)
769 for i
in range(fgcmMakeStars.objIndexCat.size):
770 fgcmStarIdCat.addNew()
773 fgcmStarIdCat[
'fgcm_id'][:] = fgcmMakeStars.objIndexCat[
'fgcm_id']
774 fgcmStarIdCat[
'ra'][:] = fgcmMakeStars.objIndexCat[
'ra']
775 fgcmStarIdCat[
'dec'][:] = fgcmMakeStars.objIndexCat[
'dec']
776 fgcmStarIdCat[
'obsArrIndex'][:] = fgcmMakeStars.objIndexCat[
'obsarrindex']
777 fgcmStarIdCat[
'nObs'][:] = fgcmMakeStars.objIndexCat[
'nobs']
781 fgcmStarIndicesCat = afwTable.BaseCatalog(obsSchema)
782 fgcmStarIndicesCat.reserve(fgcmMakeStars.obsIndexCat.size)
783 for i
in range(fgcmMakeStars.obsIndexCat.size):
784 fgcmStarIndicesCat.addNew()
786 fgcmStarIndicesCat[
'obsIndex'][:] = fgcmMakeStars.obsIndexCat[
'obsindex']
788 if self.config.doReferenceMatches:
791 fgcmRefCat = afwTable.BaseCatalog(refSchema)
792 fgcmRefCat.reserve(fgcmMakeStars.referenceCat.size)
794 for i
in range(fgcmMakeStars.referenceCat.size):
797 fgcmRefCat[
'fgcm_id'][:] = fgcmMakeStars.referenceCat[
'fgcm_id']
798 fgcmRefCat[
'refMag'][:, :] = fgcmMakeStars.referenceCat[
'refMag']
799 fgcmRefCat[
'refMagErr'][:, :] = fgcmMakeStars.referenceCat[
'refMagErr']
802 md.set(
"REFSTARS_FORMAT_VERSION", REFSTARS_FORMAT_VERSION)
803 md.set(
"FILTERNAMES", referenceFilterNames)
804 fgcmRefCat.setMetadata(md)
809 return fgcmStarIdCat, fgcmStarIndicesCat, fgcmRefCat
811 def _makeFgcmVisitSchema(self, nCcd):
813 Make a schema for an fgcmVisitCatalog
818 Number of CCDs in the camera
822 schema: `afwTable.Schema`
825 schema = afwTable.Schema()
826 schema.addField(
'visit', type=np.int32, doc=
"Visit number")
828 schema.addField(
'filtername', type=str, size=10, doc=
"Filter name")
829 schema.addField(
'telra', type=np.float64, doc=
"Pointing RA (deg)")
830 schema.addField(
'teldec', type=np.float64, doc=
"Pointing Dec (deg)")
831 schema.addField(
'telha', type=np.float64, doc=
"Pointing Hour Angle (deg)")
832 schema.addField(
'telrot', type=np.float64, doc=
"Camera rotation (deg)")
833 schema.addField(
'mjd', type=np.float64, doc=
"MJD of visit")
834 schema.addField(
'exptime', type=np.float32, doc=
"Exposure time")
835 schema.addField(
'pmb', type=np.float32, doc=
"Pressure (millibar)")
836 schema.addField(
'psfSigma', type=np.float32, doc=
"PSF sigma (reference CCD)")
837 schema.addField(
'deltaAper', type=np.float32, doc=
"Delta-aperture")
838 schema.addField(
'skyBackground', type=np.float32, doc=
"Sky background (ADU) (reference CCD)")
840 schema.addField(
'deepFlag', type=np.int32, doc=
"Deep observation")
841 schema.addField(
'scaling', type=
'ArrayD', doc=
"Scaling applied due to flat adjustment",
843 schema.addField(
'used', type=np.int32, doc=
"This visit has been ingested.")
844 schema.addField(
'sources_read', type=
'Flag', doc=
"This visit had sources read.")
848 def _makeFgcmObjSchema(self):
850 Make a schema for the objIndexCat from fgcmMakeStars
854 schema: `afwTable.Schema`
857 objSchema = afwTable.Schema()
858 objSchema.addField(
'fgcm_id', type=np.int32, doc=
'FGCM Unique ID')
860 objSchema.addField(
'ra', type=np.float64, doc=
'Mean object RA (deg)')
861 objSchema.addField(
'dec', type=np.float64, doc=
'Mean object Dec (deg)')
862 objSchema.addField(
'obsArrIndex', type=np.int32,
863 doc=
'Index in obsIndexTable for first observation')
864 objSchema.addField(
'nObs', type=np.int32, doc=
'Total number of observations')
868 def _makeFgcmObsSchema(self):
870 Make a schema for the obsIndexCat from fgcmMakeStars
874 schema: `afwTable.Schema`
877 obsSchema = afwTable.Schema()
878 obsSchema.addField(
'obsIndex', type=np.int32, doc=
'Index in observation table')
882 def _makeFgcmRefSchema(self, nReferenceBands):
884 Make a schema for the referenceCat from fgcmMakeStars
888 nReferenceBands: `int`
889 Number of reference bands
893 schema: `afwTable.Schema`
896 refSchema = afwTable.Schema()
897 refSchema.addField(
'fgcm_id', type=np.int32, doc=
'FGCM Unique ID')
898 refSchema.addField(
'refMag', type=
'ArrayF', doc=
'Reference magnitude array (AB)',
899 size=nReferenceBands)
900 refSchema.addField(
'refMagErr', type=
'ArrayF', doc=
'Reference magnitude error array',
901 size=nReferenceBands)
905 def _getReferenceFilterNames(self, visitCat, stdFilterDict, stdLambdaDict):
907 Get the reference filter names, in wavelength order, from the visitCat and
908 information from the look-up-table.
912 visitCat: `afw.table.BaseCatalog`
913 Catalog with visit data for FGCM
914 stdFilterDict: `dict`
915 Mapping of filterName to stdFilterName from LUT
916 stdLambdaDict: `dict`
917 Mapping of stdFilterName to stdLambda from LUT
921 referenceFilterNames: `list`
922 Wavelength-ordered list of reference filter names
926 filterNames = np.unique(visitCat.asAstropy()[
'filtername'])
929 stdFilterNames = {stdFilterDict[filterName]
for filterName
in filterNames}
932 referenceFilterNames = sorted(stdFilterNames, key=stdLambdaDict.get)
934 return referenceFilterNames