23 """Class for running fgcmcal on a single tract using sourceTable_visit tables.
32 from .dataIds
import TractCheckDataIdContainer
33 from .fgcmBuildStarsTable
import FgcmBuildStarsTableTask
34 from .fgcmCalibrateTractBase
import (FgcmCalibrateTractConfigBase, FgcmCalibrateTractRunner,
35 FgcmCalibrateTractBaseTask)
36 from .utilities
import lookupStaticCalibrations
38 __all__ = [
'FgcmCalibrateTractTableConfig',
'FgcmCalibrateTractTableTask']
42 dimensions=(
"instrument",
44 camera = connectionTypes.PrerequisiteInput(
45 doc=
"Camera instrument",
47 storageClass=
"Camera",
48 dimensions=(
"instrument",),
49 lookupFunction=lookupStaticCalibrations,
53 fgcmLookUpTable = connectionTypes.PrerequisiteInput(
54 doc=(
"Atmosphere + instrument look-up-table for FGCM throughput and "
55 "chromatic corrections."),
56 name=
"fgcmLookUpTable",
57 storageClass=
"Catalog",
58 dimensions=(
"instrument",),
62 sourceSchema = connectionTypes.PrerequisiteInput(
63 doc=
"Schema for source catalogs",
65 storageClass=
"SourceCatalog",
69 refCat = connectionTypes.PrerequisiteInput(
70 doc=
"Reference catalog to use for photometric calibration",
72 storageClass=
"SimpleCatalog",
73 dimensions=(
"skypix",),
78 source_catalogs = connectionTypes.Input(
79 doc=
"Source table in parquet format, per visit",
80 name=
"sourceTable_visit",
81 storageClass=
"DataFrame",
82 dimensions=(
"instrument",
"visit"),
87 visitSummary = connectionTypes.Input(
88 doc=
"Per-visit summary statistics table",
90 storageClass=
"ExposureCatalog",
91 dimensions=(
"instrument",
"visit"),
96 background = connectionTypes.Input(
97 doc=
"Calexp background model",
98 name=
"calexpBackground",
99 storageClass=
"Background",
100 dimensions=(
"instrument",
"visit",
"detector"),
105 fgcmPhotoCalib = connectionTypes.Output(
106 doc=
"Per-tract, per-visit photoCalib exposure catalogs produced from fgcm calibration",
107 name=
"fgcmPhotoCalibTractCatalog",
108 storageClass=
"ExposureCatalog",
109 dimensions=(
"instrument",
"tract",
"visit",),
113 fgcmTransmissionAtmosphere = connectionTypes.Output(
114 doc=
"Per-visit atmosphere transmission files produced from fgcm calibration",
115 name=
"transmission_atmosphere_fgcm_tract",
116 storageClass=
"TransmissionCurve",
117 dimensions=(
"instrument",
"tract",
"visit",),
121 fgcmRepeatability = connectionTypes.Output(
122 doc=
"Per-band raw repeatability numbers in the fgcm tract calibration",
123 name=
"fgcmRawRepeatability",
124 storageClass=
"Catalog",
125 dimensions=(
"instrument",
"tract",),
133 loaderName = config.fgcmBuildStars.fgcmLoadReferenceCatalog.refObjLoader.ref_dataset_name
134 if config.connections.refCat != loaderName:
135 raise ValueError(
"connections.refCat must be the same as "
136 "config.fgcmBuildStars.fgcmLoadReferenceCatalog.refObjLoader.ref_dataset_name")
137 if config.fgcmOutputProducts.doReferenceCalibration:
138 loaderName = config.fgcmOutputProducts.refObjLoader.ref_dataset_name
139 if config.connections.refCat != loaderName:
140 raise ValueError(
"connections.refCat must be the same as "
141 "config.fgcmOutputProducts.refObjLoader.ref_dataset_name")
143 if not config.fgcmBuildStars.doModelErrorsWithBackground:
144 self.inputs.remove(
"background")
146 if config.fgcmOutputProducts.doRefcatOutput:
147 raise ValueError(
"FgcmCalibrateTractTableTask (Gen3) does not support doRefcatOutput")
148 if not config.fgcmOutputProducts.doAtmosphereOutput:
149 self.prerequisiteInputs.remove(
"fgcmAtmosphereParameters")
150 if not config.fgcmOutputProducts.doZeropointOutput:
151 self.prerequisiteInputs.remove(
"fgcmZeropoints")
155 pipelineConnections=FgcmCalibrateTractTableConnections):
156 """Config for FgcmCalibrateTractTable task"""
162 self.
fgcmBuildStarsfgcmBuildStars.retarget(FgcmBuildStarsTableTask)
169 Calibrate a single tract using fgcmcal, using sourceTable_visit (parquet)
172 ConfigClass = FgcmCalibrateTractTableConfig
173 RunnerClass = FgcmCalibrateTractRunner
174 _DefaultName =
"fgcmCalibrateTractTable"
176 canMultiprocess =
False
179 dataRefDict = butlerQC.get(inputRefs)
181 self.log.
info(
"Running with %d sourceTable_visit dataRefs", (len(dataRefDict[
'source_catalogs'])))
184 tract = butlerQC.quantum.dataId[
'tract']
186 sourceTableRefs = dataRefDict[
'source_catalogs']
187 sourceTableDataRefDict = {sourceTableRef.dataId[
'visit']: sourceTableRef
for
188 sourceTableRef
in sourceTableRefs}
190 visitSummaryRefs = dataRefDict[
'visitSummary']
191 visitSummaryDataRefDict = {visitSummaryRef.dataId[
'visit']: visitSummaryRef
for
192 visitSummaryRef
in visitSummaryRefs}
194 dataRefDict[
'sourceTableDataRefDict'] = sourceTableDataRefDict
195 dataRefDict[
'visitSummaryDataRefDict'] = visitSummaryDataRefDict
198 if self.config.fgcmOutputProducts.doZeropointOutput:
199 photoCalibRefDict = {photoCalibRef.dataId.byName()[
'visit']:
200 photoCalibRef
for photoCalibRef
in outputRefs.fgcmPhotoCalib}
201 dataRefDict[
'fgcmPhotoCalibs'] = photoCalibRefDict
203 if self.config.fgcmOutputProducts.doAtmosphereOutput:
204 atmRefDict = {atmRef.dataId.byName()[
'visit']: atmRef
for
205 atmRef
in outputRefs.fgcmTransmissionAtmosphere}
206 dataRefDict[
'fgcmTransmissionAtmospheres'] = atmRefDict
208 if self.config.fgcmBuildStars.doReferenceMatches:
209 refConfig = self.config.fgcmBuildStars.fgcmLoadReferenceCatalog.refObjLoader
211 for ref
in inputRefs.refCat],
212 refCats=butlerQC.get(inputRefs.refCat),
215 buildStarsRefObjLoader = loader
217 buildStarsRefObjLoader =
None
219 if self.config.fgcmOutputProducts.doReferenceCalibration:
220 refConfig = self.config.fgcmOutputProducts.refObjLoader
222 for ref
in inputRefs.refCat],
223 refCats=butlerQC.get(inputRefs.refCat),
226 self.fgcmOutputProducts.refObjLoader = loader
228 struct = self.
runrun(dataRefDict, tract,
229 buildStarsRefObjLoader=buildStarsRefObjLoader)
231 if struct.photoCalibCatalogs
is not None:
232 self.log.
info(
"Outputting photoCalib catalogs.")
233 for visit, expCatalog
in struct.photoCalibCatalogs:
234 butlerQC.put(expCatalog, photoCalibRefDict[visit])
235 self.log.
info(
"Done outputting photoCalib catalogs.")
237 if struct.atmospheres
is not None:
238 self.log.
info(
"Outputting atmosphere transmission files.")
239 for visit, atm
in struct.atmospheres:
240 butlerQC.put(atm, atmRefDict[visit])
241 self.log.
info(
"Done outputting atmosphere files.")
245 schema.addField(
'rawRepeatability', type=np.float64,
246 doc=
"Per-band raw repeatability in FGCM calibration.")
248 repeatabilityCat.resize(len(struct.repeatability))
249 repeatabilityCat[
'rawRepeatability'][:] = struct.repeatability
251 butlerQC.put(repeatabilityCat, outputRefs.fgcmRepeatability)
256 def _makeArgumentParser(cls):
257 parser = pipeBase.ArgumentParser(name=cls.
_DefaultName_DefaultName)
258 parser.add_id_argument(
"--id",
"sourceTable_visit",
259 help=
"Data ID, e.g. --id visit=6789 tract=9617",
260 ContainerClass=TractCheckDataIdContainer)
Defines the fields and offsets for a table.
def run(self, dataRefDict, tract, buildStarsRefObjLoader=None, returnCatalogs=True, butler=None)
def __init__(self, *config=None)
def runQuantum(self, butlerQC, inputRefs, outputRefs)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations.