48 resetFitParameters, outputZeropoints,
49 lutFilterNames, tract=None, nCore=1, doPlots=False):
51 Make the FGCM fit cycle configuration dict
55 config : `lsst.fgcmcal.FgcmFitCycleConfig`
57 log : `logging.Logger`
59 camera : `lsst.afw.cameraGeom.Camera`
60 Camera from the butler
62 Maximum number of iterations
63 resetFitParameters: `bool`
64 Reset fit parameters before fitting?
65 outputZeropoints : `bool`
66 Compute zeropoints for output?
67 lutFilterNames : array-like, `str`
68 Array of physical filter names in the LUT.
69 tract : `int`, optional
70 Tract number for extending the output file name for debugging.
72 nCore : `int`, optional
73 Number of cores to use.
74 doPlots : `bool`, optional
80 Configuration dictionary for fgcm
83 notFitBands = [b
for b
in config.bands
if b
not in config.fitBands]
87 for ccut
in config.starColorCuts:
91 parts = ccut.split(
',')
92 starColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
95 refStarColorCutList = []
96 for ccut
in config.refStarColorCuts:
100 parts = ccut.split(
',')
101 refStarColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
106 if config.mirrorArea
is None:
107 mirrorArea = np.pi*(camera.telescopeDiameter*100./2.)**2.
110 mirrorArea = config.mirrorArea * 100.**2.
113 gains = [amp.getGain()
for detector
in camera
for amp
in detector.getAmplifiers()]
114 cameraGain = float(np.median(gains))
117 filterToBand = {filterName: config.physicalFilterMap[filterName]
for
118 filterName
in lutFilterNames}
121 outfileBase = config.outfileBase
123 outfileBase =
'%s-%06d' % (config.outfileBase, tract)
126 configDict = {
'outfileBase': outfileBase,
128 'exposureFile':
None,
132 'mirrorArea': mirrorArea,
133 'cameraGain': cameraGain,
134 'ccdStartIndex': camera[0].getId(),
135 'expField': FGCM_EXP_FIELD,
136 'ccdField': FGCM_CCD_FIELD,
137 'seeingField':
'DELTA_APER',
138 'fwhmField':
'PSFSIGMA',
139 'skyBrightnessField':
'SKYBACKGROUND',
140 'deepFlag':
'DEEPFLAG',
141 'bands': list(config.bands),
142 'fitBands': list(config.fitBands),
143 'notFitBands': notFitBands,
144 'requiredBands': list(config.requiredBands),
145 'filterToBand': filterToBand,
148 'nStarPerRun': config.nStarPerRun,
149 'nExpPerRun': config.nExpPerRun,
150 'reserveFraction': config.reserveFraction,
151 'freezeStdAtmosphere': config.freezeStdAtmosphere,
152 'precomputeSuperStarInitialCycle': config.precomputeSuperStarInitialCycle,
153 'superStarSubCCDDict': dict(config.superStarSubCcdDict),
154 'superStarSubCCDChebyshevOrder': config.superStarSubCcdChebyshevOrder,
155 'superStarSubCCDTriangular': config.superStarSubCcdTriangular,
156 'superStarSigmaClip': config.superStarSigmaClip,
157 'superStarPlotCCDResiduals': config.superStarPlotCcdResiduals,
158 'focalPlaneSigmaClip': config.focalPlaneSigmaClip,
159 'ccdGraySubCCDDict': dict(config.ccdGraySubCcdDict),
160 'ccdGraySubCCDChebyshevOrder': config.ccdGraySubCcdChebyshevOrder,
161 'ccdGraySubCCDTriangular': config.ccdGraySubCcdTriangular,
162 'ccdGrayFocalPlaneDict': dict(config.ccdGrayFocalPlaneDict),
163 'ccdGrayFocalPlaneChebyshevOrder': config.ccdGrayFocalPlaneChebyshevOrder,
164 'ccdGrayFocalPlaneFitMinCcd': config.ccdGrayFocalPlaneFitMinCcd,
165 'cycleNumber': config.cycleNumber,
167 'deltaMagBkgOffsetPercentile': config.deltaMagBkgOffsetPercentile,
168 'deltaMagBkgPerCcd': config.deltaMagBkgPerCcd,
169 'UTBoundary': config.utBoundary,
170 'washMJDs': config.washMjds,
171 'epochMJDs': config.epochMjds,
172 'coatingMJDs': config.coatingMjds,
173 'minObsPerBand': config.minObsPerBand,
174 'latitude': config.latitude,
175 'defaultCameraOrientation': config.defaultCameraOrientation,
176 'brightObsGrayMax': config.brightObsGrayMax,
177 'minStarPerCCD': config.minStarPerCcd,
178 'minCCDPerExp': config.minCcdPerExp,
179 'maxCCDGrayErr': config.maxCcdGrayErr,
180 'minStarPerExp': config.minStarPerExp,
181 'minExpPerNight': config.minExpPerNight,
182 'expGrayInitialCut': config.expGrayInitialCut,
183 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
184 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
185 'expGrayRecoverCut': config.expGrayRecoverCut,
186 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
187 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
188 'refStarSnMin': config.refStarSnMin,
189 'refStarOutlierNSig': config.refStarOutlierNSig,
190 'applyRefStarColorCuts': config.applyRefStarColorCuts,
191 'refStarMaxFracUse': config.refStarMaxFracUse,
192 'useExposureReferenceOffset': config.useExposureReferenceOffset,
193 'illegalValue': FGCM_ILLEGAL_VALUE,
194 'starColorCuts': starColorCutList,
195 'refStarColorCuts': refStarColorCutList,
196 'aperCorrFitNBins': config.aperCorrFitNBins,
197 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
198 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
199 'sedTermDict': config.sedterms.toDict()[
'data'],
200 'colorSplitBands': list(config.colorSplitBands),
201 'sigFgcmMaxErr': config.sigFgcmMaxErr,
202 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
203 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
204 'approxThroughputDict': dict(config.approxThroughputDict),
205 'sigmaCalRange': list(config.sigmaCalRange),
206 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
207 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
208 'sigma0Phot': config.sigma0Phot,
209 'mapLongitudeRef': config.mapLongitudeRef,
210 'mapNSide': config.mapNSide,
213 'useRetrievedPwv':
False,
214 'useNightlyRetrievedPwv':
False,
215 'pwvRetrievalSmoothBlock': 25,
216 'useQuadraticPwv': config.useQuadraticPwv,
217 'useRetrievedTauInit':
False,
218 'tauRetrievalMinCCDPerNight': 500,
219 'modelMagErrors': config.modelMagErrors,
220 'instrumentParsPerBand': config.instrumentParsPerBand,
221 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
222 'fitMirrorChromaticity': config.fitMirrorChromaticity,
223 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
224 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
225 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
226 'autoHighCutNSig': config.autoHighCutNSig,
227 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
228 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
229 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
230 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
231 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
232 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
233 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
234 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
235 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
236 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
238 'quietMode': config.quietMode,
239 'randomSeed': config.randomSeed,
240 'outputStars':
False,
241 'outputPath': os.path.abspath(
'.'),
244 'resetParameters': resetFitParameters,
246 'outputFgcmcalZpts':
True,
247 'outputZeropoints': outputZeropoints}
254 Translate the FGCM look-up-table into an fgcm-compatible object
258 lutCat: `lsst.afw.table.BaseCatalog`
259 Catalog describing the FGCM look-up table
260 physicalFilterMap: `dict`
261 Physical filter to band mapping
265 fgcmLut: `lsst.fgcm.FgcmLut`
266 Lookup table for FGCM
267 lutIndexVals: `numpy.ndarray`
268 Numpy array with LUT index information for FGCM
269 lutStd: `numpy.ndarray`
270 Numpy array with LUT standard throughput values for FGCM
274 After running this code, it is wise to `del lutCat` to clear the memory.
278 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
279 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
284 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
285 lutFilterNames.size),
286 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
287 lutStdFilterNames.size),
288 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
289 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
290 (
'PMBELEVATION',
'f8'),
291 (
'LAMBDANORM',
'f8'),
292 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
293 (
'O3',
'f8', lutCat[0][
'o3'].size),
294 (
'TAU',
'f8', lutCat[0][
'tau'].size),
295 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
296 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
299 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
300 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
301 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
302 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
303 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
304 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
305 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
306 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
307 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
308 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
309 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
310 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
313 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
319 (
'LAMBDARANGE',
'f8', 2),
320 (
'LAMBDASTEP',
'f8'),
321 (
'LAMBDASTD',
'f8', lutFilterNames.size),
322 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
323 (
'I0STD',
'f8', lutFilterNames.size),
324 (
'I1STD',
'f8', lutFilterNames.size),
325 (
'I10STD',
'f8', lutFilterNames.size),
326 (
'I2STD',
'f8', lutFilterNames.size),
327 (
'LAMBDAB',
'f8', lutFilterNames.size),
328 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
329 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
330 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
331 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
332 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
333 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
334 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
335 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
336 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
337 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
338 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
339 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
340 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
341 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
342 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
343 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
344 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
345 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
346 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
348 lutTypes = [row[
'luttype']
for row
in lutCat]
351 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
354 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
355 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
357 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
361 (
'D_SECZENITH',
'f4'),
362 (
'D_LNPWV_I1',
'f4'),
364 (
'D_LNTAU_I1',
'f4'),
365 (
'D_ALPHA_I1',
'f4'),
366 (
'D_SECZENITH_I1',
'f4')])
368 for name
in lutDerivFlat.dtype.names:
369 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
376 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
377 filterToBand=physicalFilterMap)
379 return fgcmLut, lutIndexVals, lutStd