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")
140 pipelineConnections=FgcmCalibrateTractTableConnections):
141 """Config for FgcmCalibrateTractTable task"""
154 Calibrate a single tract using fgcmcal, using sourceTable_visit (parquet)
157 ConfigClass = FgcmCalibrateTractTableConfig
158 _DefaultName = "fgcmCalibrateTractTable"
160 canMultiprocess =
False
162 def __init__(self, initInputs=None, **kwargs):
163 super().__init__(initInputs=initInputs, **kwargs)
164 if initInputs
is not None:
168 handleDict = butlerQC.get(inputRefs)
170 self.log.info(
"Running with %d sourceTable_visit handles", (len(handleDict[
'source_catalogs'])))
173 tract = butlerQC.quantum.dataId[
'tract']
177 sourceTableHandles = handleDict[
'source_catalogs']
178 sourceTableHandleDict = {sourceTableHandle.dataId[
'visit']: sourceTableHandle
for
179 sourceTableHandle
in sourceTableHandles}
181 visitSummaryHandles = handleDict[
'visitSummary']
182 visitSummaryHandleDict = {visitSummaryHandle.dataId[
'visit']: visitSummaryHandle
for
183 visitSummaryHandle
in visitSummaryHandles}
185 handleDict[
'sourceTableHandleDict'] = sourceTableHandleDict
186 handleDict[
'visitSummaryHandleDict'] = visitSummaryHandleDict
189 if self.config.fgcmOutputProducts.doZeropointOutput:
190 photoCalibRefDict = {photoCalibRef.dataId.byName()[
'visit']:
191 photoCalibRef
for photoCalibRef
in outputRefs.fgcmPhotoCalib}
192 handleDict[
'fgcmPhotoCalibs'] = photoCalibRefDict
194 if self.config.fgcmOutputProducts.doAtmosphereOutput:
195 atmRefDict = {atmRef.dataId.byName()[
'visit']: atmRef
for
196 atmRef
in outputRefs.fgcmTransmissionAtmosphere}
197 handleDict[
'fgcmTransmissionAtmospheres'] = atmRefDict
199 if self.config.fgcmBuildStars.doReferenceMatches:
201 refConfig.filterMap = self.config.fgcmBuildStars.fgcmLoadReferenceCatalog.filterMap
203 for ref
in inputRefs.refCat],
204 refCats=butlerQC.get(inputRefs.refCat),
205 name=self.config.connections.refCat,
208 buildStarsRefObjLoader = loader
210 buildStarsRefObjLoader =
None
212 if self.config.fgcmOutputProducts.doReferenceCalibration:
213 refConfig = self.config.fgcmOutputProducts.refObjLoader
215 for ref
in inputRefs.refCat],
216 refCats=butlerQC.get(inputRefs.refCat),
217 name=self.config.connections.refCat,
220 self.fgcmOutputProducts.refObjLoader = loader
222 struct = self.
run(handleDict, tract,
223 buildStarsRefObjLoader=buildStarsRefObjLoader)
225 if struct.photoCalibCatalogs
is not None:
226 self.log.info(
"Outputting photoCalib catalogs.")
227 for visit, expCatalog
in struct.photoCalibCatalogs:
228 butlerQC.put(expCatalog, photoCalibRefDict[visit])
229 self.log.info(
"Done outputting photoCalib catalogs.")
231 if struct.atmospheres
is not None:
232 self.log.info(
"Outputting atmosphere transmission files.")
233 for visit, atm
in struct.atmospheres:
234 butlerQC.put(atm, atmRefDict[visit])
235 self.log.info(
"Done outputting atmosphere files.")
239 schema.addField(
'rawRepeatability', type=np.float64,
240 doc=
"Per-band raw repeatability in FGCM calibration.")
242 repeatabilityCat.resize(len(struct.repeatability))
243 repeatabilityCat[
'rawRepeatability'][:] = struct.repeatability
245 butlerQC.put(repeatabilityCat, outputRefs.fgcmRepeatability)
Defines the fields and offsets for a table.
def run(self, handleDict, tract, buildStarsRefObjLoader=None, returnCatalogs=True)
def __init__(self, *config=None)
def runQuantum(self, butlerQC, inputRefs, outputRefs)