23"""Class for running fgcmcal on a single tract using sourceTable_visit tables.
32from .fgcmBuildStarsTable
import FgcmBuildStarsTableTask
33from .fgcmCalibrateTractBase
import (FgcmCalibrateTractConfigBase,
34 FgcmCalibrateTractBaseTask)
35from .utilities
import lookupStaticCalibrations
37__all__ = [
'FgcmCalibrateTractTableConfig',
'FgcmCalibrateTractTableTask']
41 dimensions=(
"instrument",
43 camera = connectionTypes.PrerequisiteInput(
44 doc=
"Camera instrument",
46 storageClass=
"Camera",
47 dimensions=(
"instrument",),
48 lookupFunction=lookupStaticCalibrations,
52 fgcmLookUpTable = connectionTypes.PrerequisiteInput(
53 doc=(
"Atmosphere + instrument look-up-table for FGCM throughput and "
54 "chromatic corrections."),
55 name=
"fgcmLookUpTable",
56 storageClass=
"Catalog",
57 dimensions=(
"instrument",),
61 sourceSchema = connectionTypes.InitInput(
62 doc=
"Schema for source catalogs",
64 storageClass=
"SourceCatalog",
67 refCat = connectionTypes.PrerequisiteInput(
68 doc=
"Reference catalog to use for photometric calibration",
70 storageClass=
"SimpleCatalog",
71 dimensions=(
"skypix",),
76 source_catalogs = connectionTypes.Input(
77 doc=
"Source table in parquet format, per visit",
78 name=
"sourceTable_visit",
79 storageClass=
"DataFrame",
80 dimensions=(
"instrument",
"visit"),
85 visitSummary = connectionTypes.Input(
86 doc=
"Per-visit summary statistics table",
88 storageClass=
"ExposureCatalog",
89 dimensions=(
"instrument",
"visit"),
94 background = connectionTypes.Input(
95 doc=
"Calexp background model",
96 name=
"calexpBackground",
97 storageClass=
"Background",
98 dimensions=(
"instrument",
"visit",
"detector"),
103 fgcmPhotoCalib = connectionTypes.Output(
104 doc=
"Per-tract, per-visit photoCalib exposure catalogs produced from fgcm calibration",
105 name=
"fgcmPhotoCalibTractCatalog",
106 storageClass=
"ExposureCatalog",
107 dimensions=(
"instrument",
"tract",
"visit",),
111 fgcmTransmissionAtmosphere = connectionTypes.Output(
112 doc=
"Per-visit atmosphere transmission files produced from fgcm calibration",
113 name=
"transmission_atmosphere_fgcm_tract",
114 storageClass=
"TransmissionCurve",
115 dimensions=(
"instrument",
"tract",
"visit",),
119 fgcmRepeatability = connectionTypes.Output(
120 doc=
"Per-band raw repeatability numbers in the fgcm tract calibration",
121 name=
"fgcmRawRepeatability",
122 storageClass=
"Catalog",
123 dimensions=(
"instrument",
"tract",),
130 if not config.fgcmBuildStars.doModelErrorsWithBackground:
131 self.inputs.remove(
"background")
133 if not config.fgcmOutputProducts.doAtmosphereOutput:
134 self.prerequisiteInputs.remove(
"fgcmAtmosphereParameters")
135 if not config.fgcmOutputProducts.doZeropointOutput:
136 self.prerequisiteInputs.remove(
"fgcmZeropoints")
139 return (
"visitSummary",)
143 pipelineConnections=FgcmCalibrateTractTableConnections):
144 """Config for FgcmCalibrateTractTable task"""
157 Calibrate a single tract using fgcmcal, using sourceTable_visit (parquet)
160 ConfigClass = FgcmCalibrateTractTableConfig
161 _DefaultName = "fgcmCalibrateTractTable"
163 canMultiprocess =
False
165 def __init__(self, initInputs=None, **kwargs):
166 super().__init__(initInputs=initInputs, **kwargs)
167 if initInputs
is not None:
171 handleDict = butlerQC.get(inputRefs)
173 self.log.info(
"Running with %d sourceTable_visit handles", (len(handleDict[
'source_catalogs'])))
176 tract = butlerQC.quantum.dataId[
'tract']
180 sourceTableHandles = handleDict[
'source_catalogs']
181 sourceTableHandleDict = {sourceTableHandle.dataId[
'visit']: sourceTableHandle
for
182 sourceTableHandle
in sourceTableHandles}
184 visitSummaryHandles = handleDict[
'visitSummary']
185 visitSummaryHandleDict = {visitSummaryHandle.dataId[
'visit']: visitSummaryHandle
for
186 visitSummaryHandle
in visitSummaryHandles}
188 handleDict[
'sourceTableHandleDict'] = sourceTableHandleDict
189 handleDict[
'visitSummaryHandleDict'] = visitSummaryHandleDict
192 if self.config.fgcmOutputProducts.doZeropointOutput:
193 photoCalibRefDict = {photoCalibRef.dataId.byName()[
'visit']:
194 photoCalibRef
for photoCalibRef
in outputRefs.fgcmPhotoCalib}
195 handleDict[
'fgcmPhotoCalibs'] = photoCalibRefDict
197 if self.config.fgcmOutputProducts.doAtmosphereOutput:
198 atmRefDict = {atmRef.dataId.byName()[
'visit']: atmRef
for
199 atmRef
in outputRefs.fgcmTransmissionAtmosphere}
200 handleDict[
'fgcmTransmissionAtmospheres'] = atmRefDict
202 if self.config.fgcmBuildStars.doReferenceMatches:
204 refConfig.filterMap = self.config.fgcmBuildStars.fgcmLoadReferenceCatalog.filterMap
206 for ref
in inputRefs.refCat],
207 refCats=butlerQC.get(inputRefs.refCat),
208 name=self.config.connections.refCat,
211 buildStarsRefObjLoader = loader
213 buildStarsRefObjLoader =
None
215 if self.config.fgcmOutputProducts.doReferenceCalibration:
216 refConfig = self.config.fgcmOutputProducts.refObjLoader
218 for ref
in inputRefs.refCat],
219 refCats=butlerQC.get(inputRefs.refCat),
220 name=self.config.connections.refCat,
223 self.fgcmOutputProducts.refObjLoader = loader
225 struct = self.
run(handleDict, tract,
226 buildStarsRefObjLoader=buildStarsRefObjLoader)
228 if struct.photoCalibCatalogs
is not None:
229 self.log.info(
"Outputting photoCalib catalogs.")
230 for visit, expCatalog
in struct.photoCalibCatalogs:
231 butlerQC.put(expCatalog, photoCalibRefDict[visit])
232 self.log.info(
"Done outputting photoCalib catalogs.")
234 if struct.atmospheres
is not None:
235 self.log.info(
"Outputting atmosphere transmission files.")
236 for visit, atm
in struct.atmospheres:
237 butlerQC.put(atm, atmRefDict[visit])
238 self.log.info(
"Done outputting atmosphere files.")
242 schema.addField(
'rawRepeatability', type=np.float64,
243 doc=
"Per-band raw repeatability in FGCM calibration.")
245 repeatabilityCat.resize(len(struct.repeatability))
246 repeatabilityCat[
'rawRepeatability'][:] = struct.repeatability
248 butlerQC.put(repeatabilityCat, outputRefs.fgcmRepeatability)
Defines the fields and offsets for a table.
run(self, handleDict, tract, buildStarsRefObjLoader=None, returnCatalogs=True)
getSpatialBoundsConnections(self)
__init__(self, *config=None)
runQuantum(self, butlerQC, inputRefs, outputRefs)