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':
'PSFSIGMA',
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 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
187 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
188 'expGrayRecoverCut': config.expGrayRecoverCut,
189 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
190 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
191 'refStarSnMin': config.refStarSnMin,
192 'refStarOutlierNSig': config.refStarOutlierNSig,
193 'applyRefStarColorCuts': config.applyRefStarColorCuts,
194 'refStarMaxFracUse': config.refStarMaxFracUse,
195 'useExposureReferenceOffset': config.useExposureReferenceOffset,
196 'illegalValue': FGCM_ILLEGAL_VALUE,
197 'starColorCuts': starColorCutList,
198 'refStarColorCuts': refStarColorCutList,
199 'aperCorrFitNBins': config.aperCorrFitNBins,
200 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
201 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
202 'sedTermDict': config.sedterms.toDict()[
'data'],
203 'colorSplitBands': list(config.colorSplitBands),
204 'sigFgcmMaxErr': config.sigFgcmMaxErr,
205 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
206 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
207 'approxThroughputDict': dict(config.approxThroughputDict),
208 'sigmaCalRange': list(config.sigmaCalRange),
209 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
210 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
211 'sigma0Phot': config.sigma0Phot,
212 'mapLongitudeRef': config.mapLongitudeRef,
213 'mapNSide': config.mapNSide,
216 'useRetrievedPwv':
False,
217 'useNightlyRetrievedPwv':
False,
218 'pwvRetrievalSmoothBlock': 25,
219 'useQuadraticPwv': config.useQuadraticPwv,
220 'useRetrievedTauInit':
False,
221 'tauRetrievalMinCCDPerNight': 500,
222 'modelMagErrors': config.modelMagErrors,
223 'instrumentParsPerBand': config.instrumentParsPerBand,
224 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
225 'fitMirrorChromaticity': config.fitMirrorChromaticity,
226 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
227 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
228 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
229 'autoHighCutNSig': config.autoHighCutNSig,
230 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
231 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
232 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
233 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
234 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
235 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
236 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
237 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
238 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
239 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
241 'quietMode': config.quietMode,
242 'randomSeed': config.randomSeed,
243 'outputStars':
False,
244 'outputPath': os.path.abspath(
'.'),
247 'resetParameters': resetFitParameters,
249 'outputFgcmcalZpts':
True,
250 'outputZeropoints': outputZeropoints}
257 Translate the FGCM look-up-table into an fgcm-compatible object
261 lutCat: `lsst.afw.table.BaseCatalog`
262 Catalog describing the FGCM look-up table
263 physicalFilterMap: `dict`
264 Physical filter to band mapping
268 fgcmLut: `lsst.fgcm.FgcmLut`
269 Lookup table for FGCM
270 lutIndexVals: `numpy.ndarray`
271 Numpy array with LUT index information for FGCM
272 lutStd: `numpy.ndarray`
273 Numpy array with LUT standard throughput values for FGCM
277 After running this code, it is wise to `del lutCat` to clear the memory.
281 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
282 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
287 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
288 lutFilterNames.size),
289 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
290 lutStdFilterNames.size),
291 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
292 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
293 (
'PMBELEVATION',
'f8'),
294 (
'LAMBDANORM',
'f8'),
295 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
296 (
'O3',
'f8', lutCat[0][
'o3'].size),
297 (
'TAU',
'f8', lutCat[0][
'tau'].size),
298 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
299 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
302 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
303 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
304 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
305 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
306 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
307 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
308 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
309 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
310 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
311 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
312 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
313 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
316 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
322 (
'LAMBDARANGE',
'f8', 2),
323 (
'LAMBDASTEP',
'f8'),
324 (
'LAMBDASTD',
'f8', lutFilterNames.size),
325 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
326 (
'I0STD',
'f8', lutFilterNames.size),
327 (
'I1STD',
'f8', lutFilterNames.size),
328 (
'I10STD',
'f8', lutFilterNames.size),
329 (
'I2STD',
'f8', lutFilterNames.size),
330 (
'LAMBDAB',
'f8', lutFilterNames.size),
331 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
332 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
333 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
334 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
335 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
336 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
337 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
338 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
339 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
340 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
341 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
342 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
343 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
344 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
345 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
346 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
347 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
348 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
349 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
351 lutTypes = [row[
'luttype']
for row
in lutCat]
354 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
357 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
358 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
360 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
364 (
'D_SECZENITH',
'f4'),
365 (
'D_LNPWV_I1',
'f4'),
367 (
'D_LNTAU_I1',
'f4'),
368 (
'D_ALPHA_I1',
'f4'),
369 (
'D_SECZENITH_I1',
'f4')])
371 for name
in lutDerivFlat.dtype.names:
372 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
379 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
380 filterToBand=physicalFilterMap)
382 return fgcmLut, lutIndexVals, lutStd