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.",
99 deprecated=(
"This field is no longer used, and has been deprecated by "
100 "DM-28088. It will be removed after v22. Use "
101 "physicalFilterMap instead.")
106 physicalFilterMap = pexConfig.DictField(
107 doc=
"Mapping from 'physicalFilter' to band.",
112 requiredBands = pexConfig.ListField(
113 doc=
"Bands required for each star",
117 primaryBands = pexConfig.ListField(
118 doc=(
"Bands for 'primary' star matches. "
119 "A star must be observed in one of these bands to be considered "
120 "as a calibration star."),
124 visitDataRefName = pexConfig.Field(
125 doc=
"dataRef name for the 'visit' field, usually 'visit'.",
129 ccdDataRefName = pexConfig.Field(
130 doc=
"dataRef name for the 'ccd' field, usually 'ccd' or 'detector'.",
134 doApplyWcsJacobian = pexConfig.Field(
135 doc=
"Apply the jacobian of the WCS to the star observations prior to fit?",
139 doModelErrorsWithBackground = pexConfig.Field(
140 doc=
"Model flux errors with background term?",
144 psfCandidateName = pexConfig.Field(
145 doc=
"Name of field with psf candidate flag for propagation",
147 default=
"calib_psf_candidate"
149 doSubtractLocalBackground = pexConfig.Field(
150 doc=(
"Subtract the local background before performing calibration? "
151 "This is only supported for circular aperture calibration fluxes."),
155 localBackgroundFluxField = pexConfig.Field(
156 doc=
"Full name of the local background instFlux field to use.",
158 default=
'base_LocalBackground_instFlux'
160 sourceSelector = sourceSelectorRegistry.makeField(
161 doc=
"How to select sources",
164 apertureInnerInstFluxField = pexConfig.Field(
165 doc=(
"Full name of instFlux field that contains inner aperture "
166 "flux for aperture correction proxy"),
168 default=
'base_CircularApertureFlux_12_0_instFlux'
170 apertureOuterInstFluxField = pexConfig.Field(
171 doc=(
"Full name of instFlux field that contains outer aperture "
172 "flux for aperture correction proxy"),
174 default=
'base_CircularApertureFlux_17_0_instFlux'
176 doReferenceMatches = pexConfig.Field(
177 doc=
"Match reference catalog as additional constraint on calibration",
181 fgcmLoadReferenceCatalog = pexConfig.ConfigurableField(
182 target=FgcmLoadReferenceCatalogTask,
183 doc=
"FGCM reference object loader",
185 nVisitsPerCheckpoint = pexConfig.Field(
186 doc=
"Number of visits read between checkpoints",
193 sourceSelector.setDefaults()
195 sourceSelector.doFlags =
True
196 sourceSelector.doUnresolved =
True
197 sourceSelector.doSignalToNoise =
True
198 sourceSelector.doIsolated =
True
200 sourceSelector.signalToNoise.minimum = 10.0
201 sourceSelector.signalToNoise.maximum = 1000.0
205 sourceSelector.unresolved.maximum = 0.5
209 """Subclass of TaskRunner for FgcmBuildStars tasks
211 fgcmBuildStarsTask.run() and fgcmBuildStarsTableTask.run() take a number of
212 arguments, one of which is the butler (for persistence and mapper data),
213 and a list of dataRefs extracted from the command line. Note that FGCM
214 runs on a large set of dataRefs, and not on single dataRef/tract/patch.
215 This class transforms the process arguments generated by the ArgumentParser
216 into the arguments expected by FgcmBuildStarsTask.run(). This runner does
217 not use any parallelization.
222 Return a list with one element: a tuple with the butler and
226 return [(parsedCmd.butler, parsedCmd.id.refList)]
232 args: `tuple` with (butler, dataRefList)
236 exitStatus: `list` with `lsst.pipe.base.Struct`
237 exitStatus (0: success; 1: failure)
239 butler, dataRefList = args
241 task = self.TaskClass(config=self.config, log=self.log)
245 task.runDataRef(butler, dataRefList)
248 task.runDataRef(butler, dataRefList)
249 except Exception
as e:
251 task.log.fatal(
"Failed: %s" % e)
252 if not isinstance(e, pipeBase.TaskError):
253 traceback.print_exc(file=sys.stderr)
255 task.writeMetadata(butler)
258 return [pipeBase.Struct(exitStatus=exitStatus)]
262 Run the task, with no multiprocessing
266 parsedCmd: `lsst.pipe.base.ArgumentParser` parsed command line
271 if self.precall(parsedCmd):
273 resultList = self(targetList[0])
280 Base task to build stars for FGCM global calibration
284 butler : `lsst.daf.persistence.Butler`
286 def __init__(self, butler=None, initInputs=None, **kwargs):
289 self.makeSubtask(
"sourceSelector")
291 self.sourceSelector.log.setLevel(self.sourceSelector.log.WARN)
294 def _getMetadataName(self):
300 Cross-match and make star list for FGCM Input
304 butler: `lsst.daf.persistence.Butler`
305 dataRefs: `list` of `lsst.daf.persistence.ButlerDataRef`
306 Source data references for the input visits.
310 RuntimeErrror: Raised if `config.doReferenceMatches` is set and
311 an fgcmLookUpTable is not available, or if computeFluxApertureRadius()
312 fails if the calibFlux is not a CircularAperture flux.
314 datasetType = dataRefs[0].butlerSubset.datasetType
315 self.log.info(
"Running with %d %s dataRefs", len(dataRefs), datasetType)
317 if self.config.doReferenceMatches:
318 self.makeSubtask(
"fgcmLoadReferenceCatalog", butler=butler)
320 if not butler.datasetExists(
'fgcmLookUpTable'):
321 raise RuntimeError(
"Must have fgcmLookUpTable if using config.doReferenceMatches")
324 calibFluxApertureRadius =
None
325 if self.config.doSubtractLocalBackground:
328 self.config.instFluxField)
329 except RuntimeError
as e:
330 raise RuntimeError(
"Could not determine aperture radius from %s. "
331 "Cannot use doSubtractLocalBackground." %
332 (self.config.instFluxField))
from e
334 camera = butler.get(
'camera')
342 visitCatDataRef = butler.dataRef(
'fgcmVisitCatalog')
343 filename = visitCatDataRef.get(
'fgcmVisitCatalog_filename')[0]
344 if os.path.exists(filename):
346 inVisitCat = visitCatDataRef.get()
347 if len(inVisitCat) != len(groupedDataRefs):
348 raise RuntimeError(
"Existing visitCatalog found, but has an inconsistent "
349 "number of visits. Cannot continue.")
354 visitCatDataRef=visitCatDataRef,
355 inVisitCat=inVisitCat)
358 visitCatDataRef.put(visitCat)
360 starObsDataRef = butler.dataRef(
'fgcmStarObservations')
361 filename = starObsDataRef.get(
'fgcmStarObservations_filename')[0]
362 if os.path.exists(filename):
363 inStarObsCat = starObsDataRef.get()
367 rad = calibFluxApertureRadius
368 sourceSchemaDataRef = butler.dataRef(
'src_schema')
373 calibFluxApertureRadius=rad,
374 starObsDataRef=starObsDataRef,
375 visitCatDataRef=visitCatDataRef,
376 inStarObsCat=inStarObsCat)
377 visitCatDataRef.put(visitCat)
378 starObsDataRef.put(fgcmStarObservationCat)
381 if self.config.doReferenceMatches:
382 lutDataRef = butler.dataRef(
'fgcmLookUpTable')
385 fgcmStarIdCat, fgcmStarIndicesCat, fgcmRefCat = self.
fgcmMatchStarsfgcmMatchStars(visitCat,
386 fgcmStarObservationCat,
387 lutDataRef=lutDataRef)
390 butler.put(fgcmStarIdCat,
'fgcmStarIds')
391 butler.put(fgcmStarIndicesCat,
'fgcmStarIndices')
392 if fgcmRefCat
is not None:
393 butler.put(fgcmRefCat,
'fgcmReferenceStars')
396 def _findAndGroupDataRefsGen2(self, butler, camera, dataRefs):
398 Find and group dataRefs (by visit); Gen2 only.
402 butler : `lsst.daf.persistence.Butler`
404 camera : `lsst.afw.cameraGeom.Camera`
405 Camera from the butler.
406 dataRefs : `list` of `lsst.daf.persistence.ButlerDataRef`
407 Data references for the input visits.
411 groupedDataRefs : `dict` [`int`, `list`]
412 Dictionary with sorted visit keys, and `list`s of
413 `lsst.daf.persistence.ButlerDataRef`
415 raise NotImplementedError(
"_findAndGroupDataRefsGen2 not implemented.")
421 calibFluxApertureRadius=None,
422 visitCatDataRef=None,
426 Compile all good star observations from visits in visitCat. Checkpoint files
427 will be stored if both visitCatDataRef and starObsDataRef are not None.
431 groupedDataRefs: `dict` of `list`s
432 Lists of `~lsst.daf.persistence.ButlerDataRef` or
433 `~lsst.daf.butler.DeferredDatasetHandle`, grouped by visit.
434 visitCat: `~afw.table.BaseCatalog`
435 Catalog with visit data for FGCM
436 sourceSchemaDataRef: `~lsst.daf.persistence.ButlerDataRef` or
437 `~lsst.daf.butler.DeferredDatasetHandle`
438 DataRef for the schema of the src catalogs.
439 camera: `~lsst.afw.cameraGeom.Camera`
440 calibFluxApertureRadius: `float`, optional
441 Aperture radius for calibration flux.
442 visitCatDataRef: `~lsst.daf.persistence.ButlerDataRef`, optional
443 Dataref to write visitCat for checkpoints
444 starObsDataRef: `~lsst.daf.persistence.ButlerDataRef`, optional
445 Dataref to write the star observation catalog for checkpoints.
446 inStarObsCat: `~afw.table.BaseCatalog`
447 Input observation catalog. If this is incomplete, observations
448 will be appended from when it was cut off.
452 fgcmStarObservations: `afw.table.BaseCatalog`
453 Full catalog of good observations.
457 RuntimeError: Raised if doSubtractLocalBackground is True and
458 calibFluxApertureRadius is not set.
460 raise NotImplementedError(
"fgcmMakeAllStarObservations not implemented.")
463 visitCatDataRef=None, inVisitCat=None):
465 Make a visit catalog with all the keys from each visit
469 camera: `lsst.afw.cameraGeom.Camera`
470 Camera from the butler
471 groupedDataRefs: `dict`
472 Dictionary with visit keys, and `list`s of
473 `lsst.daf.persistence.ButlerDataRef`
474 bkgDataRefDict: `dict`, optional
475 Dictionary of gen3 dataRefHandles for background info.
476 visitCatDataRef: `lsst.daf.persistence.ButlerDataRef`, optional
477 Dataref to write visitCat for checkpoints
478 inVisitCat: `afw.table.BaseCatalog`, optional
479 Input (possibly incomplete) visit catalog
483 visitCat: `afw.table.BaseCatalog`
486 self.log.info(
"Assembling visitCatalog from %d %ss" %
487 (len(groupedDataRefs), self.config.visitDataRefName))
491 if inVisitCat
is None:
494 visitCat = afwTable.BaseCatalog(schema)
495 visitCat.reserve(len(groupedDataRefs))
496 visitCat.resize(len(groupedDataRefs))
498 visitCat[
'visit'] = list(groupedDataRefs.keys())
500 visitCat[
'sources_read'] =
False
502 visitCat = inVisitCat
507 bkgDataRefDict=bkgDataRefDict,
508 visitCatDataRef=visitCatDataRef)
512 def _fillVisitCatalog(self, visitCat, groupedDataRefs, bkgDataRefDict=None,
513 visitCatDataRef=None):
515 Fill the visit catalog with visit metadata
519 visitCat: `afw.table.BaseCatalog`
520 Catalog with schema from _makeFgcmVisitSchema()
521 groupedDataRefs: `dict`
522 Dictionary with visit keys, and `list`s of
523 `lsst.daf.persistence.ButlerDataRef`
524 visitCatDataRef: `lsst.daf.persistence.ButlerDataRef`, optional
525 Dataref to write visitCat for checkpoints
526 bkgDataRefDict: `dict`, optional
527 Dictionary of gen3 dataRefHandles for background info. FIXME
529 bbox = geom.BoxI(geom.PointI(0, 0), geom.PointI(1, 1))
531 for i, visit
in enumerate(groupedDataRefs):
538 if visitCat[
'used'][i]:
541 if (i % self.config.nVisitsPerCheckpoint) == 0:
542 self.log.info(
"Retrieving metadata for %s %d (%d/%d)" %
543 (self.config.visitDataRefName, visit, i, len(groupedDataRefs)))
545 if visitCatDataRef
is not None:
546 visitCatDataRef.put(visitCat)
548 dataRef = groupedDataRefs[visit][0]
549 if isinstance(dataRef, dafPersist.ButlerDataRef):
552 exp = dataRef.get(datasetType=
'calexp_sub', bbox=bbox)
553 visitInfo = exp.getInfo().getVisitInfo()
554 label = dataRef.get(datasetType=
'calexp_filterLabel')
555 physicalFilter = label.physicalLabel
557 psfSigma = psf.computeShape().getDeterminantRadius()
560 summary = dataRef.get()
562 summaryRow = summary.find(self.config.referenceCCD)
563 if summaryRow
is None:
565 summaryRow = summary[0]
567 visitInfo = summaryRow.getVisitInfo()
568 physicalFilter = summaryRow[
'physical_filter']
570 goodSigma, = np.where(summary[
'psfSigma'] > 0)
571 if goodSigma.size > 2:
572 psfSigma = np.median(summary[
'psfSigma'][goodSigma])
574 psfSigma = np.mean(summary[
'psfSigma'][goodSigma])
580 rec[
'physicalFilter'] = physicalFilter
584 radec = visitInfo.getBoresightRaDec()
585 rec[
'telra'] = radec.getRa().asDegrees()
586 rec[
'teldec'] = radec.getDec().asDegrees()
587 rec[
'telha'] = visitInfo.getBoresightHourAngle().asDegrees()
588 rec[
'telrot'] = visitInfo.getBoresightRotAngle().asDegrees()
589 rec[
'mjd'] = visitInfo.getDate().get(system=DateTime.MJD)
590 rec[
'exptime'] = visitInfo.getExposureTime()
593 rec[
'pmb'] = visitInfo.getWeather().getAirPressure() / 100
597 rec[
'scaling'][:] = 1.0
599 rec[
'deltaAper'] = 0.0
600 rec[
'psfSigma'] = psfSigma
602 if self.config.doModelErrorsWithBackground:
604 if isinstance(dataRef, dafPersist.ButlerDataRef):
605 det = dataRef.dataId[self.config.ccdDataRefName]
606 if dataRef.datasetExists(datasetType=
'calexpBackground'):
607 bgList = dataRef.get(datasetType=
'calexpBackground')
610 det = dataRef.dataId[
'detector']
612 bkgRef = bkgDataRefDict[(visit, det)]
613 bgList = bkgRef.get()
619 bgStats = (bg[0].getStatsImage().getImage().array
621 rec[
'skyBackground'] = sum(np.median(bg[np.isfinite(bg)])
for bg
in bgStats)
623 self.log.warn(
'Sky background not found for visit %d / ccd %d' %
625 rec[
'skyBackground'] = -1.0
627 rec[
'skyBackground'] = -1.0
631 def _makeSourceMapper(self, sourceSchema):
633 Make a schema mapper for fgcm sources
637 sourceSchema: `afwTable.Schema`
638 Default source schema from the butler
642 sourceMapper: `afwTable.schemaMapper`
643 Mapper to the FGCM source schema
647 sourceMapper = afwTable.SchemaMapper(sourceSchema)
650 sourceMapper.addMapping(sourceSchema[
'coord_ra'].asKey(),
'ra')
651 sourceMapper.addMapping(sourceSchema[
'coord_dec'].asKey(),
'dec')
652 sourceMapper.addMapping(sourceSchema[
'slot_Centroid_x'].asKey(),
'x')
653 sourceMapper.addMapping(sourceSchema[
'slot_Centroid_y'].asKey(),
'y')
659 sourceMapper.addMapping(sourceSchema[self.config.psfCandidateName].asKey(),
662 sourceMapper.editOutputSchema().addField(
663 "psf_candidate", type=
'Flag',
664 doc=(
"Flag set if the source was a candidate for PSF determination, "
665 "as determined by the star selector."))
668 sourceMapper.editOutputSchema().addField(
669 "visit", type=np.int32, doc=
"Visit number")
670 sourceMapper.editOutputSchema().addField(
671 "ccd", type=np.int32, doc=
"CCD number")
672 sourceMapper.editOutputSchema().addField(
673 "instMag", type=np.float32, doc=
"Instrumental magnitude")
674 sourceMapper.editOutputSchema().addField(
675 "instMagErr", type=np.float32, doc=
"Instrumental magnitude error")
676 sourceMapper.editOutputSchema().addField(
677 "jacobian", type=np.float32, doc=
"Relative pixel scale from wcs jacobian")
678 sourceMapper.editOutputSchema().addField(
679 "deltaMagBkg", type=np.float32, doc=
"Change in magnitude due to local background offset")
685 Use FGCM code to match observations into unique stars.
689 visitCat: `afw.table.BaseCatalog`
690 Catalog with visit data for fgcm
691 obsCat: `afw.table.BaseCatalog`
692 Full catalog of star observations for fgcm
693 lutDataRef: `lsst.daf.persistence.ButlerDataRef` or
694 `lsst.daf.butler.DeferredDatasetHandle`, optional
695 Data reference to fgcm look-up table (used if matching reference stars).
699 fgcmStarIdCat: `afw.table.BaseCatalog`
700 Catalog of unique star identifiers and index keys
701 fgcmStarIndicesCat: `afwTable.BaseCatalog`
702 Catalog of unique star indices
703 fgcmRefCat: `afw.table.BaseCatalog`
704 Catalog of matched reference stars.
705 Will be None if `config.doReferenceMatches` is False.
709 visitFilterNames = np.zeros(len(visitCat), dtype=
'a30')
710 for i
in range(len(visitCat)):
711 visitFilterNames[i] = visitCat[i][
'physicalFilter']
714 visitIndex = np.searchsorted(visitCat[
'visit'],
717 obsFilterNames = visitFilterNames[visitIndex]
719 if self.config.doReferenceMatches:
721 lutCat = lutDataRef.get()
723 stdFilterDict = {filterName: stdFilter
for (filterName, stdFilter)
in
724 zip(lutCat[0][
'physicalFilters'].split(
','),
725 lutCat[0][
'stdPhysicalFilters'].split(
','))}
726 stdLambdaDict = {stdFilter: stdLambda
for (stdFilter, stdLambda)
in
727 zip(lutCat[0][
'stdPhysicalFilters'].split(
','),
728 lutCat[0][
'lambdaStdFilter'])}
735 self.log.info(
"Using the following reference filters: %s" %
736 (
', '.join(referenceFilterNames)))
740 referenceFilterNames = []
743 starConfig = {
'logger': self.log,
744 'filterToBand': self.config.physicalFilterMap,
745 'requiredBands': self.config.requiredBands,
746 'minPerBand': self.config.minPerBand,
747 'matchRadius': self.config.matchRadius,
748 'isolationRadius': self.config.isolationRadius,
749 'matchNSide': self.config.matchNside,
750 'coarseNSide': self.config.coarseNside,
751 'densNSide': self.config.densityCutNside,
752 'densMaxPerPixel': self.config.densityCutMaxPerPixel,
753 'primaryBands': self.config.primaryBands,
754 'referenceFilterNames': referenceFilterNames}
757 fgcmMakeStars = fgcm.FgcmMakeStars(starConfig)
765 conv = obsCat[0][
'ra'].asDegrees() / float(obsCat[0][
'ra'])
766 fgcmMakeStars.makePrimaryStars(obsCat[
'ra'] * conv,
767 obsCat[
'dec'] * conv,
768 filterNameArray=obsFilterNames,
772 fgcmMakeStars.makeMatchedStars(obsCat[
'ra'] * conv,
773 obsCat[
'dec'] * conv,
776 if self.config.doReferenceMatches:
777 fgcmMakeStars.makeReferenceMatches(self.fgcmLoadReferenceCatalog)
784 fgcmStarIdCat = afwTable.BaseCatalog(objSchema)
785 fgcmStarIdCat.reserve(fgcmMakeStars.objIndexCat.size)
786 for i
in range(fgcmMakeStars.objIndexCat.size):
787 fgcmStarIdCat.addNew()
790 fgcmStarIdCat[
'fgcm_id'][:] = fgcmMakeStars.objIndexCat[
'fgcm_id']
791 fgcmStarIdCat[
'ra'][:] = fgcmMakeStars.objIndexCat[
'ra']
792 fgcmStarIdCat[
'dec'][:] = fgcmMakeStars.objIndexCat[
'dec']
793 fgcmStarIdCat[
'obsArrIndex'][:] = fgcmMakeStars.objIndexCat[
'obsarrindex']
794 fgcmStarIdCat[
'nObs'][:] = fgcmMakeStars.objIndexCat[
'nobs']
798 fgcmStarIndicesCat = afwTable.BaseCatalog(obsSchema)
799 fgcmStarIndicesCat.reserve(fgcmMakeStars.obsIndexCat.size)
800 for i
in range(fgcmMakeStars.obsIndexCat.size):
801 fgcmStarIndicesCat.addNew()
803 fgcmStarIndicesCat[
'obsIndex'][:] = fgcmMakeStars.obsIndexCat[
'obsindex']
805 if self.config.doReferenceMatches:
808 fgcmRefCat = afwTable.BaseCatalog(refSchema)
809 fgcmRefCat.reserve(fgcmMakeStars.referenceCat.size)
811 for i
in range(fgcmMakeStars.referenceCat.size):
814 fgcmRefCat[
'fgcm_id'][:] = fgcmMakeStars.referenceCat[
'fgcm_id']
815 fgcmRefCat[
'refMag'][:, :] = fgcmMakeStars.referenceCat[
'refMag']
816 fgcmRefCat[
'refMagErr'][:, :] = fgcmMakeStars.referenceCat[
'refMagErr']
819 md.set(
"REFSTARS_FORMAT_VERSION", REFSTARS_FORMAT_VERSION)
820 md.set(
"FILTERNAMES", referenceFilterNames)
821 fgcmRefCat.setMetadata(md)
826 return fgcmStarIdCat, fgcmStarIndicesCat, fgcmRefCat
828 def _makeFgcmVisitSchema(self, nCcd):
830 Make a schema for an fgcmVisitCatalog
835 Number of CCDs in the camera
839 schema: `afwTable.Schema`
842 schema = afwTable.Schema()
843 schema.addField(
'visit', type=np.int32, doc=
"Visit number")
844 schema.addField(
'physicalFilter', type=str, size=30, doc=
"Physical filter")
845 schema.addField(
'telra', type=np.float64, doc=
"Pointing RA (deg)")
846 schema.addField(
'teldec', type=np.float64, doc=
"Pointing Dec (deg)")
847 schema.addField(
'telha', type=np.float64, doc=
"Pointing Hour Angle (deg)")
848 schema.addField(
'telrot', type=np.float64, doc=
"Camera rotation (deg)")
849 schema.addField(
'mjd', type=np.float64, doc=
"MJD of visit")
850 schema.addField(
'exptime', type=np.float32, doc=
"Exposure time")
851 schema.addField(
'pmb', type=np.float32, doc=
"Pressure (millibar)")
852 schema.addField(
'psfSigma', type=np.float32, doc=
"PSF sigma (reference CCD)")
853 schema.addField(
'deltaAper', type=np.float32, doc=
"Delta-aperture")
854 schema.addField(
'skyBackground', type=np.float32, doc=
"Sky background (ADU) (reference CCD)")
856 schema.addField(
'deepFlag', type=np.int32, doc=
"Deep observation")
857 schema.addField(
'scaling', type=
'ArrayD', doc=
"Scaling applied due to flat adjustment",
859 schema.addField(
'used', type=np.int32, doc=
"This visit has been ingested.")
860 schema.addField(
'sources_read', type=
'Flag', doc=
"This visit had sources read.")
864 def _makeFgcmObjSchema(self):
866 Make a schema for the objIndexCat from fgcmMakeStars
870 schema: `afwTable.Schema`
873 objSchema = afwTable.Schema()
874 objSchema.addField(
'fgcm_id', type=np.int32, doc=
'FGCM Unique ID')
876 objSchema.addField(
'ra', type=np.float64, doc=
'Mean object RA (deg)')
877 objSchema.addField(
'dec', type=np.float64, doc=
'Mean object Dec (deg)')
878 objSchema.addField(
'obsArrIndex', type=np.int32,
879 doc=
'Index in obsIndexTable for first observation')
880 objSchema.addField(
'nObs', type=np.int32, doc=
'Total number of observations')
884 def _makeFgcmObsSchema(self):
886 Make a schema for the obsIndexCat from fgcmMakeStars
890 schema: `afwTable.Schema`
893 obsSchema = afwTable.Schema()
894 obsSchema.addField(
'obsIndex', type=np.int32, doc=
'Index in observation table')
898 def _makeFgcmRefSchema(self, nReferenceBands):
900 Make a schema for the referenceCat from fgcmMakeStars
904 nReferenceBands: `int`
905 Number of reference bands
909 schema: `afwTable.Schema`
912 refSchema = afwTable.Schema()
913 refSchema.addField(
'fgcm_id', type=np.int32, doc=
'FGCM Unique ID')
914 refSchema.addField(
'refMag', type=
'ArrayF', doc=
'Reference magnitude array (AB)',
915 size=nReferenceBands)
916 refSchema.addField(
'refMagErr', type=
'ArrayF', doc=
'Reference magnitude error array',
917 size=nReferenceBands)
921 def _getReferenceFilterNames(self, visitCat, stdFilterDict, stdLambdaDict):
923 Get the reference filter names, in wavelength order, from the visitCat and
924 information from the look-up-table.
928 visitCat: `afw.table.BaseCatalog`
929 Catalog with visit data for FGCM
930 stdFilterDict: `dict`
931 Mapping of filterName to stdFilterName from LUT
932 stdLambdaDict: `dict`
933 Mapping of stdFilterName to stdLambda from LUT
937 referenceFilterNames: `list`
938 Wavelength-ordered list of reference filter names
942 filterNames = np.unique(visitCat.asAstropy()[
'physicalFilter'])
945 stdFilterNames = {stdFilterDict[filterName]
for filterName
in filterNames}
948 referenceFilterNames = sorted(stdFilterNames, key=stdLambdaDict.get)
950 return referenceFilterNames
def fgcmMatchStars(self, visitCat, obsCat, lutDataRef=None)
def _makeFgcmVisitSchema(self, nCcd)
def _getReferenceFilterNames(self, visitCat, stdFilterDict, stdLambdaDict)
def runDataRef(self, butler, dataRefs)
def _makeFgcmObjSchema(self)
def _fillVisitCatalog(self, visitCat, groupedDataRefs, bkgDataRefDict=None, visitCatDataRef=None)
def _makeFgcmObsSchema(self)
def fgcmMakeVisitCatalog(self, camera, groupedDataRefs, bkgDataRefDict=None, visitCatDataRef=None, inVisitCat=None)
def fgcmMakeAllStarObservations(self, groupedDataRefs, visitCat, sourceSchemaDataRef, camera, calibFluxApertureRadius=None, visitCatDataRef=None, starObsDataRef=None, inStarObsCat=None)
def _findAndGroupDataRefsGen2(self, butler, camera, dataRefs)
def __init__(self, butler=None, initInputs=None, **kwargs)
def _makeFgcmRefSchema(self, nReferenceBands)
def getTargetList(parsedCmd)
def computeApertureRadiusFromDataRef(dataRef, fluxField)