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.
112 if config.cameraGain
is None:
114 gains = [amp.getGain()
for detector
in camera
for amp
in detector.getAmplifiers()]
115 cameraGain = float(np.median(gains))
117 cameraGain = config.cameraGain
120 filterToBand = {filterName: config.physicalFilterMap[filterName]
for
121 filterName
in lutFilterNames}
124 outfileBase = config.outfileBase
126 outfileBase =
'%s-%06d' % (config.outfileBase, tract)
129 configDict = {
'outfileBase': outfileBase,
131 'exposureFile':
None,
135 'mirrorArea': mirrorArea,
136 'cameraGain': cameraGain,
137 'ccdStartIndex': camera[0].getId(),
138 'expField': FGCM_EXP_FIELD,
139 'ccdField': FGCM_CCD_FIELD,
140 'seeingField':
'DELTA_APER',
141 'fwhmField':
'PSFFWHM',
142 'skyBrightnessField':
'SKYBACKGROUND',
143 'deepFlag':
'DEEPFLAG',
144 'bands': list(config.bands),
145 'fitBands': list(config.fitBands),
146 'notFitBands': notFitBands,
147 'requiredBands': list(config.requiredBands),
148 'filterToBand': filterToBand,
151 'nStarPerRun': config.nStarPerRun,
152 'nExpPerRun': config.nExpPerRun,
153 'reserveFraction': config.reserveFraction,
154 'freezeStdAtmosphere': config.freezeStdAtmosphere,
155 'precomputeSuperStarInitialCycle': config.precomputeSuperStarInitialCycle,
156 'superStarSubCCDDict': dict(config.superStarSubCcdDict),
157 'superStarSubCCDChebyshevOrder': config.superStarSubCcdChebyshevOrder,
158 'superStarSubCCDTriangular': config.superStarSubCcdTriangular,
159 'superStarSigmaClip': config.superStarSigmaClip,
160 'superStarPlotCCDResiduals': config.superStarPlotCcdResiduals,
161 'focalPlaneSigmaClip': config.focalPlaneSigmaClip,
162 'ccdGraySubCCDDict': dict(config.ccdGraySubCcdDict),
163 'ccdGraySubCCDChebyshevOrder': config.ccdGraySubCcdChebyshevOrder,
164 'ccdGraySubCCDTriangular': config.ccdGraySubCcdTriangular,
165 'ccdGrayFocalPlaneDict': dict(config.ccdGrayFocalPlaneDict),
166 'ccdGrayFocalPlaneChebyshevOrder': config.ccdGrayFocalPlaneChebyshevOrder,
167 'ccdGrayFocalPlaneFitMinCcd': config.ccdGrayFocalPlaneFitMinCcd,
168 'cycleNumber': config.cycleNumber,
170 'deltaMagBkgOffsetPercentile': config.deltaMagBkgOffsetPercentile,
171 'deltaMagBkgPerCcd': config.deltaMagBkgPerCcd,
172 'UTBoundary': config.utBoundary,
173 'washMJDs': config.washMjds,
174 'epochMJDs': config.epochMjds,
175 'coatingMJDs': config.coatingMjds,
176 'minObsPerBand': config.minObsPerBand,
177 'latitude': config.latitude,
178 'defaultCameraOrientation': config.defaultCameraOrientation,
179 'brightObsGrayMax': config.brightObsGrayMax,
180 'minStarPerCCD': config.minStarPerCcd,
181 'minCCDPerExp': config.minCcdPerExp,
182 'maxCCDGrayErr': config.maxCcdGrayErr,
183 'minStarPerExp': config.minStarPerExp,
184 'minExpPerNight': config.minExpPerNight,
185 'expGrayInitialCut': config.expGrayInitialCut,
186 'expFwhmCutDict': dict(config.expFwhmCutDict),
187 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
188 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
189 'expGrayRecoverCut': config.expGrayRecoverCut,
190 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
191 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
192 'refStarSnMin': config.refStarSnMin,
193 'refStarOutlierNSig': config.refStarOutlierNSig,
194 'applyRefStarColorCuts': config.applyRefStarColorCuts,
195 'refStarMaxFracUse': config.refStarMaxFracUse,
196 'useExposureReferenceOffset': config.useExposureReferenceOffset,
197 'illegalValue': FGCM_ILLEGAL_VALUE,
198 'starColorCuts': starColorCutList,
199 'refStarColorCuts': refStarColorCutList,
200 'aperCorrFitNBins': config.aperCorrFitNBins,
201 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
202 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
203 'sedTermDict': config.sedterms.toDict()[
'data'],
204 'colorSplitBands': list(config.colorSplitBands),
205 'sigFgcmMaxErr': config.sigFgcmMaxErr,
206 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
207 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
208 'approxThroughputDict': dict(config.approxThroughputDict),
209 'sigmaCalRange': list(config.sigmaCalRange),
210 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
211 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
212 'sigma0Phot': config.sigma0Phot,
213 'mapLongitudeRef': config.mapLongitudeRef,
214 'mapNSide': config.mapNSide,
217 'useRetrievedPwv':
False,
218 'useNightlyRetrievedPwv':
False,
219 'pwvRetrievalSmoothBlock': 25,
220 'useQuadraticPwv': config.useQuadraticPwv,
221 'useRetrievedTauInit':
False,
222 'tauRetrievalMinCCDPerNight': 500,
223 'modelMagErrors': config.modelMagErrors,
224 'instrumentParsPerBand': config.instrumentParsPerBand,
225 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
226 'fitMirrorChromaticity': config.fitMirrorChromaticity,
227 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
228 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
229 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
230 'autoHighCutNSig': config.autoHighCutNSig,
231 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
232 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
233 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
234 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
235 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
236 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
237 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
238 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
239 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
240 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
242 'quietMode': config.quietMode,
243 'randomSeed': config.randomSeed,
244 'outputStars':
False,
245 'outputPath': os.path.abspath(
'.'),
248 'resetParameters': resetFitParameters,
250 'outputFgcmcalZpts':
True,
251 'outputZeropoints': outputZeropoints}
258 Translate the FGCM look-up-table into an fgcm-compatible object
262 lutCat: `lsst.afw.table.BaseCatalog`
263 Catalog describing the FGCM look-up table
264 physicalFilterMap: `dict`
265 Physical filter to band mapping
269 fgcmLut: `lsst.fgcm.FgcmLut`
270 Lookup table for FGCM
271 lutIndexVals: `numpy.ndarray`
272 Numpy array with LUT index information for FGCM
273 lutStd: `numpy.ndarray`
274 Numpy array with LUT standard throughput values for FGCM
278 After running this code, it is wise to `del lutCat` to clear the memory.
282 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
283 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
288 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
289 lutFilterNames.size),
290 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
291 lutStdFilterNames.size),
292 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
293 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
294 (
'PMBELEVATION',
'f8'),
295 (
'LAMBDANORM',
'f8'),
296 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
297 (
'O3',
'f8', lutCat[0][
'o3'].size),
298 (
'TAU',
'f8', lutCat[0][
'tau'].size),
299 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
300 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
303 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
304 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
305 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
306 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
307 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
308 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
309 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
310 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
311 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
312 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
313 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
314 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
317 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
323 (
'LAMBDARANGE',
'f8', 2),
324 (
'LAMBDASTEP',
'f8'),
325 (
'LAMBDASTD',
'f8', lutFilterNames.size),
326 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
327 (
'I0STD',
'f8', lutFilterNames.size),
328 (
'I1STD',
'f8', lutFilterNames.size),
329 (
'I10STD',
'f8', lutFilterNames.size),
330 (
'I2STD',
'f8', lutFilterNames.size),
331 (
'LAMBDAB',
'f8', lutFilterNames.size),
332 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
333 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
334 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
335 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
336 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
337 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
338 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
339 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
340 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
341 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
342 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
343 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
344 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
345 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
346 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
347 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
348 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
349 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
350 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
352 lutTypes = [row[
'luttype']
for row
in lutCat]
355 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
358 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
359 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
361 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
365 (
'D_SECZENITH',
'f4'),
366 (
'D_LNPWV_I1',
'f4'),
368 (
'D_LNTAU_I1',
'f4'),
369 (
'D_ALPHA_I1',
'f4'),
370 (
'D_SECZENITH_I1',
'f4')])
372 for name
in lutDerivFlat.dtype.names:
373 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
380 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
381 filterToBand=physicalFilterMap)
383 return fgcmLut, lutIndexVals, lutStd