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 if config.aperCorrUsePsfFwhm:
131 seeingField =
'PSFFWHM_DETECTOR'
133 seeingField =
'DELTA_APER_DETECTOR'
134 seeingSubExposure =
True
136 if config.aperCorrUsePsfFwhm:
137 seeingField =
'PSFFWHM'
139 seeingField =
'DELTA_APER'
140 seeingSubExposure =
False
143 configDict = {
'outfileBase': outfileBase,
145 'exposureFile':
None,
149 'mirrorArea': mirrorArea,
150 'cameraGain': cameraGain,
151 'ccdStartIndex': camera[0].getId(),
152 'expField': FGCM_EXP_FIELD,
153 'ccdField': FGCM_CCD_FIELD,
154 'seeingField': seeingField,
155 'fwhmField':
'PSFFWHM',
156 'skyBrightnessField':
'SKYBACKGROUND',
157 'deepFlag':
'DEEPFLAG',
158 'bands': list(config.bands),
159 'fitBands': list(config.fitBands),
160 'notFitBands': notFitBands,
161 'requiredBands': list(config.requiredBands),
162 'filterToBand': filterToBand,
165 'nStarPerRun': config.nStarPerRun,
166 'nStarPerGrayRun': config.nStarPerGrayRun,
167 'nExpPerRun': config.nExpPerRun,
168 'reserveFraction': config.reserveFraction,
169 'freezeStdAtmosphere': config.freezeStdAtmosphere,
170 'precomputeSuperStarInitialCycle': config.precomputeSuperStarInitialCycle,
171 'superStarSubCCDDict': dict(config.superStarSubCcdDict),
172 'superStarSubCCDChebyshevOrder': config.superStarSubCcdChebyshevOrder,
173 'superStarSubCCDTriangular': config.superStarSubCcdTriangular,
174 'superStarSigmaClip': config.superStarSigmaClip,
175 'superStarPlotCCDResiduals': config.superStarPlotCcdResiduals,
176 'superStarForceZeroMean': config.superStarForceZeroMean,
177 'focalPlaneSigmaClip': config.focalPlaneSigmaClip,
178 'ccdGraySubCCDDict': dict(config.ccdGraySubCcdDict),
179 'ccdGraySubCCDChebyshevOrder': config.ccdGraySubCcdChebyshevOrder,
180 'ccdGraySubCCDTriangular': config.ccdGraySubCcdTriangular,
181 'ccdGrayFocalPlaneDict': dict(config.ccdGrayFocalPlaneDict),
182 'ccdGrayFocalPlaneChebyshevOrder': config.ccdGrayFocalPlaneChebyshevOrder,
183 'ccdGrayFocalPlaneFitMinCcd': config.ccdGrayFocalPlaneFitMinCcd,
184 'ccdGrayFocalPlaneMaxStars': config.ccdGrayFocalPlaneMaxStars,
185 'cycleNumber': config.cycleNumber,
187 'deltaMagBkgOffsetPercentile': config.deltaMagBkgOffsetPercentile,
188 'deltaMagBkgPerCcd': config.deltaMagBkgPerCcd,
189 'UTBoundary': config.utBoundary,
190 'washMJDs': config.washMjds,
191 'epochMJDs': config.epochMjds,
192 'coatingMJDs': config.coatingMjds,
193 'minObsPerBand': config.minObsPerBand,
194 'latitude': config.latitude,
195 'defaultCameraOrientation': config.defaultCameraOrientation,
196 'brightObsGrayMax': config.brightObsGrayMax,
197 'minStarPerCCD': config.minStarPerCcd,
198 'minCCDPerExp': config.minCcdPerExp,
199 'maxCCDGrayErr': config.maxCcdGrayErr,
200 'minStarPerExp': config.minStarPerExp,
201 'minExpPerNight': config.minExpPerNight,
202 'expGrayInitialCut': config.expGrayInitialCut,
203 'expFwhmCutDict': dict(config.expFwhmCutDict),
204 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
205 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
206 'expGrayRecoverCut': config.expGrayRecoverCut,
207 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
208 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
209 'refStarSnMin': config.refStarSnMin,
210 'refStarOutlierNSig': config.refStarOutlierNSig,
211 'applyRefStarColorCuts': config.applyRefStarColorCuts,
212 'refStarMaxFracUse': config.refStarMaxFracUse,
213 'useExposureReferenceOffset': config.useExposureReferenceOffset,
214 'illegalValue': FGCM_ILLEGAL_VALUE,
215 'starColorCuts': starColorCutList,
216 'refStarColorCuts': refStarColorCutList,
217 'aperCorrFitNBins': config.aperCorrFitNBins,
218 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
219 'seeingSubExposure': seeingSubExposure,
220 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
221 'sedTermDict': config.sedterms.toDict()[
'data'],
222 'colorSplitBands': list(config.colorSplitBands),
223 'sigFgcmMaxErr': config.sigFgcmMaxErr,
224 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
225 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
226 'approxThroughputDict': dict(config.approxThroughputDict),
227 'sigmaCalRange': list(config.sigmaCalRange),
228 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
229 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
230 'sigma0Phot': config.sigma0Phot,
231 'mapLongitudeRef': config.mapLongitudeRef,
232 'mapNSide': config.mapNSide,
235 'useRetrievedPwv':
False,
236 'useNightlyRetrievedPwv':
False,
237 'pwvRetrievalSmoothBlock': 25,
238 'useQuadraticPwv': config.useQuadraticPwv,
239 'useRetrievedTauInit':
False,
240 'tauRetrievalMinCCDPerNight': 500,
241 'modelMagErrors': config.modelMagErrors,
242 'instrumentParsPerBand': config.instrumentParsPerBand,
243 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
244 'fitMirrorChromaticity': config.fitMirrorChromaticity,
245 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
246 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
247 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
248 'autoHighCutNSig': config.autoHighCutNSig,
249 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
250 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
251 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
252 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
253 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
254 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
255 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
256 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
257 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
258 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
260 'quietMode': config.quietMode,
261 'randomSeed': config.randomSeed,
262 'outputStars':
False,
263 'outputPath': os.path.abspath(
'.'),
266 'resetParameters': resetFitParameters,
268 'outputFgcmcalZpts':
True,
269 'outputZeropoints': outputZeropoints}
276 Translate the FGCM look-up-table into an fgcm-compatible object
280 lutCat: `lsst.afw.table.BaseCatalog`
281 Catalog describing the FGCM look-up table
282 physicalFilterMap: `dict`
283 Physical filter to band mapping
287 fgcmLut: `lsst.fgcm.FgcmLut`
288 Lookup table for FGCM
289 lutIndexVals: `numpy.ndarray`
290 Numpy array with LUT index information for FGCM
291 lutStd: `numpy.ndarray`
292 Numpy array with LUT standard throughput values for FGCM
296 After running this code, it is wise to `del lutCat` to clear the memory.
300 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
301 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
306 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
307 lutFilterNames.size),
308 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
309 lutStdFilterNames.size),
310 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
311 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
312 (
'PMBELEVATION',
'f8'),
313 (
'LAMBDANORM',
'f8'),
314 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
315 (
'O3',
'f8', lutCat[0][
'o3'].size),
316 (
'TAU',
'f8', lutCat[0][
'tau'].size),
317 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
318 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
321 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
322 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
323 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
324 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
325 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
326 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
327 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
328 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
329 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
330 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
331 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
332 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
335 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
341 (
'LAMBDARANGE',
'f8', 2),
342 (
'LAMBDASTEP',
'f8'),
343 (
'LAMBDASTD',
'f8', lutFilterNames.size),
344 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
345 (
'I0STD',
'f8', lutFilterNames.size),
346 (
'I1STD',
'f8', lutFilterNames.size),
347 (
'I10STD',
'f8', lutFilterNames.size),
348 (
'I2STD',
'f8', lutFilterNames.size),
349 (
'LAMBDAB',
'f8', lutFilterNames.size),
350 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
351 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
352 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
353 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
354 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
355 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
356 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
357 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
358 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
359 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
360 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
361 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
362 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
363 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
364 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
365 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
366 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
367 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
368 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
370 lutTypes = [row[
'luttype']
for row
in lutCat]
373 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
376 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
377 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
379 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
383 (
'D_SECZENITH',
'f4'),
384 (
'D_LNPWV_I1',
'f4'),
386 (
'D_LNTAU_I1',
'f4'),
387 (
'D_ALPHA_I1',
'f4'),
388 (
'D_SECZENITH_I1',
'f4')])
390 for name
in lutDerivFlat.dtype.names:
391 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
398 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
399 filterToBand=physicalFilterMap)
401 return fgcmLut, lutIndexVals, lutStd