49 resetFitParameters, outputZeropoints,
50 lutFilterNames, tract=None, nCore=1, doPlots=False):
52 Make the FGCM fit cycle configuration dict
56 config : `lsst.fgcmcal.FgcmFitCycleConfig`
58 log : `logging.Logger`
60 camera : `lsst.afw.cameraGeom.Camera`
61 Camera from the butler
63 Maximum number of iterations
64 resetFitParameters: `bool`
65 Reset fit parameters before fitting?
66 outputZeropoints : `bool`
67 Compute zeropoints for output?
68 lutFilterNames : array-like, `str`
69 Array of physical filter names in the LUT.
70 tract : `int`, optional
71 Tract number for extending the output file name for debugging.
73 nCore : `int`, optional
74 Number of cores to use.
75 doPlots : `bool`, optional
81 Configuration dictionary for fgcm
84 notFitBands = [b
for b
in config.bands
if b
not in config.fitBands]
88 for ccut
in config.starColorCuts:
92 parts = ccut.split(
',')
93 starColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
96 refStarColorCutList = []
97 for ccut
in config.refStarColorCuts:
101 parts = ccut.split(
',')
102 refStarColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
107 if config.mirrorArea
is None:
108 mirrorArea = np.pi*(camera.telescopeDiameter*100./2.)**2.
111 mirrorArea = config.mirrorArea * 100.**2.
113 if config.cameraGain
is None:
115 gains = [amp.getGain()
for detector
in camera
for amp
in detector.getAmplifiers()]
116 cameraGain = float(np.median(gains))
118 cameraGain = config.cameraGain
121 filterToBand = {filterName: config.physicalFilterMap[filterName]
for
122 filterName
in lutFilterNames}
125 outfileBase = config.outfileBase
127 outfileBase =
'%s-%06d' % (config.outfileBase, tract)
129 if config.aperCorrPerCcd:
130 seeingField =
'DELTA_APER_DETECTOR'
132 seeingField =
'DELTA_APER'
135 configDict = {
'outfileBase': outfileBase,
137 'exposureFile':
None,
141 'mirrorArea': mirrorArea,
142 'cameraGain': cameraGain,
143 'ccdStartIndex': camera[0].getId(),
144 'expField': FGCM_EXP_FIELD,
145 'ccdField': FGCM_CCD_FIELD,
146 'seeingField': seeingField,
147 'fwhmField':
'PSFFWHM',
148 'skyBrightnessField':
'SKYBACKGROUND',
149 'deepFlag':
'DEEPFLAG',
150 'bands': list(config.bands),
151 'fitBands': list(config.fitBands),
152 'notFitBands': notFitBands,
153 'requiredBands': list(config.requiredBands),
154 'filterToBand': filterToBand,
157 'nStarPerRun': config.nStarPerRun,
158 'nStarPerGrayRun': config.nStarPerGrayRun,
159 'nExpPerRun': config.nExpPerRun,
160 'reserveFraction': config.reserveFraction,
161 'freezeStdAtmosphere': config.freezeStdAtmosphere,
162 'precomputeSuperStarInitialCycle': config.precomputeSuperStarInitialCycle,
163 'superStarSubCCDDict': dict(config.superStarSubCcdDict),
164 'superStarSubCCDChebyshevOrder': config.superStarSubCcdChebyshevOrder,
165 'superStarSubCCDTriangular': config.superStarSubCcdTriangular,
166 'superStarSigmaClip': config.superStarSigmaClip,
167 'superStarPlotCCDResiduals': config.superStarPlotCcdResiduals,
168 'superStarForceZeroMean': config.superStarForceZeroMean,
169 'focalPlaneSigmaClip': config.focalPlaneSigmaClip,
170 'ccdGraySubCCDDict': dict(config.ccdGraySubCcdDict),
171 'ccdGraySubCCDChebyshevOrder': config.ccdGraySubCcdChebyshevOrder,
172 'ccdGraySubCCDTriangular': config.ccdGraySubCcdTriangular,
173 'ccdGrayFocalPlaneDict': dict(config.ccdGrayFocalPlaneDict),
174 'ccdGrayFocalPlaneChebyshevOrder': config.ccdGrayFocalPlaneChebyshevOrder,
175 'ccdGrayFocalPlaneFitMinCcd': config.ccdGrayFocalPlaneFitMinCcd,
176 'ccdGrayFocalPlaneMaxStars': config.ccdGrayFocalPlaneMaxStars,
177 'cycleNumber': config.cycleNumber,
179 'deltaMagBkgOffsetPercentile': config.deltaMagBkgOffsetPercentile,
180 'deltaMagBkgPerCcd': config.deltaMagBkgPerCcd,
181 'UTBoundary': config.utBoundary,
182 'washMJDs': config.washMjds,
183 'epochMJDs': config.epochMjds,
184 'coatingMJDs': config.coatingMjds,
185 'minObsPerBand': config.minObsPerBand,
186 'latitude': config.latitude,
187 'defaultCameraOrientation': config.defaultCameraOrientation,
188 'brightObsGrayMax': config.brightObsGrayMax,
189 'minStarPerCCD': config.minStarPerCcd,
190 'minCCDPerExp': config.minCcdPerExp,
191 'maxCCDGrayErr': config.maxCcdGrayErr,
192 'minStarPerExp': config.minStarPerExp,
193 'minExpPerNight': config.minExpPerNight,
194 'expGrayInitialCut': config.expGrayInitialCut,
195 'expFwhmCutDict': dict(config.expFwhmCutDict),
196 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
197 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
198 'expGrayRecoverCut': config.expGrayRecoverCut,
199 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
200 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
201 'refStarSnMin': config.refStarSnMin,
202 'refStarOutlierNSig': config.refStarOutlierNSig,
203 'applyRefStarColorCuts': config.applyRefStarColorCuts,
204 'refStarMaxFracUse': config.refStarMaxFracUse,
205 'useExposureReferenceOffset': config.useExposureReferenceOffset,
206 'illegalValue': FGCM_ILLEGAL_VALUE,
207 'starColorCuts': starColorCutList,
208 'refStarColorCuts': refStarColorCutList,
209 'aperCorrFitNBins': config.aperCorrFitNBins,
210 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
211 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
212 'sedTermDict': config.sedterms.toDict()[
'data'],
213 'colorSplitBands': list(config.colorSplitBands),
214 'sigFgcmMaxErr': config.sigFgcmMaxErr,
215 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
216 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
217 'approxThroughputDict': dict(config.approxThroughputDict),
218 'sigmaCalRange': list(config.sigmaCalRange),
219 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
220 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
221 'sigma0Phot': config.sigma0Phot,
222 'mapLongitudeRef': config.mapLongitudeRef,
223 'mapNSide': config.mapNSide,
226 'useRetrievedPwv':
False,
227 'useNightlyRetrievedPwv':
False,
228 'pwvRetrievalSmoothBlock': 25,
229 'useQuadraticPwv': config.useQuadraticPwv,
230 'useRetrievedTauInit':
False,
231 'tauRetrievalMinCCDPerNight': 500,
232 'modelMagErrors': config.modelMagErrors,
233 'instrumentParsPerBand': config.instrumentParsPerBand,
234 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
235 'fitMirrorChromaticity': config.fitMirrorChromaticity,
236 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
237 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
238 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
239 'autoHighCutNSig': config.autoHighCutNSig,
240 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
241 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
242 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
243 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
244 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
245 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
246 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
247 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
248 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
249 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
251 'quietMode': config.quietMode,
252 'randomSeed': config.randomSeed,
253 'outputStars':
False,
254 'outputPath': os.path.abspath(
'.'),
257 'resetParameters': resetFitParameters,
259 'outputFgcmcalZpts':
True,
260 'outputZeropoints': outputZeropoints}
267 Translate the FGCM look-up-table into an fgcm-compatible object
271 lutCat: `lsst.afw.table.BaseCatalog`
272 Catalog describing the FGCM look-up table
273 physicalFilterMap: `dict`
274 Physical filter to band mapping
278 fgcmLut: `lsst.fgcm.FgcmLut`
279 Lookup table for FGCM
280 lutIndexVals: `numpy.ndarray`
281 Numpy array with LUT index information for FGCM
282 lutStd: `numpy.ndarray`
283 Numpy array with LUT standard throughput values for FGCM
287 After running this code, it is wise to `del lutCat` to clear the memory.
291 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
292 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
297 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
298 lutFilterNames.size),
299 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
300 lutStdFilterNames.size),
301 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
302 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
303 (
'PMBELEVATION',
'f8'),
304 (
'LAMBDANORM',
'f8'),
305 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
306 (
'O3',
'f8', lutCat[0][
'o3'].size),
307 (
'TAU',
'f8', lutCat[0][
'tau'].size),
308 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
309 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
312 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
313 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
314 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
315 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
316 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
317 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
318 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
319 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
320 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
321 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
322 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
323 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
326 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
332 (
'LAMBDARANGE',
'f8', 2),
333 (
'LAMBDASTEP',
'f8'),
334 (
'LAMBDASTD',
'f8', lutFilterNames.size),
335 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
336 (
'I0STD',
'f8', lutFilterNames.size),
337 (
'I1STD',
'f8', lutFilterNames.size),
338 (
'I10STD',
'f8', lutFilterNames.size),
339 (
'I2STD',
'f8', lutFilterNames.size),
340 (
'LAMBDAB',
'f8', lutFilterNames.size),
341 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
342 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
343 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
344 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
345 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
346 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
347 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
348 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
349 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
350 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
351 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
352 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
353 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
354 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
355 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
356 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
357 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
358 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
359 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
361 lutTypes = [row[
'luttype']
for row
in lutCat]
364 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
367 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
368 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
370 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
374 (
'D_SECZENITH',
'f4'),
375 (
'D_LNPWV_I1',
'f4'),
377 (
'D_LNTAU_I1',
'f4'),
378 (
'D_ALPHA_I1',
'f4'),
379 (
'D_SECZENITH_I1',
'f4')])
381 for name
in lutDerivFlat.dtype.names:
382 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
389 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
390 filterToBand=physicalFilterMap)
392 return fgcmLut, lutIndexVals, lutStd