48 resetFitParameters, outputZeropoints,
49 lutFilterNames, tract=None, nCore=1):
51 Make the FGCM fit cycle configuration dict
55 config : `lsst.fgcmcal.FgcmFitCycleConfig`
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.
78 Configuration dictionary for fgcm
81 notFitBands = [b
for b
in config.bands
if b
not in config.fitBands]
85 for ccut
in config.starColorCuts:
89 parts = ccut.split(
',')
90 starColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
93 refStarColorCutList = []
94 for ccut
in config.refStarColorCuts:
98 parts = ccut.split(
',')
99 refStarColorCutList.append([parts[0], parts[1], float(parts[2]), float(parts[3])])
104 if config.mirrorArea
is None:
105 mirrorArea = np.pi*(camera.telescopeDiameter*100./2.)**2.
108 mirrorArea = config.mirrorArea * 100.**2.
111 gains = [amp.getGain()
for detector
in camera
for amp
in detector.getAmplifiers()]
112 cameraGain = float(np.median(gains))
115 filterToBand = {filterName: config.physicalFilterMap[filterName]
for
116 filterName
in lutFilterNames}
119 outfileBase = config.outfileBase
121 outfileBase =
'%s-%06d' % (config.outfileBase, tract)
124 configDict = {
'outfileBase': outfileBase,
126 'exposureFile':
None,
130 'mirrorArea': mirrorArea,
131 'cameraGain': cameraGain,
132 'ccdStartIndex': camera[0].getId(),
133 'expField': FGCM_EXP_FIELD,
134 'ccdField': FGCM_CCD_FIELD,
135 'seeingField':
'DELTA_APER',
136 'fwhmField':
'PSFSIGMA',
137 'skyBrightnessField':
'SKYBACKGROUND',
138 'deepFlag':
'DEEPFLAG',
139 'bands': list(config.bands),
140 'fitBands': list(config.fitBands),
141 'notFitBands': notFitBands,
142 'requiredBands': list(config.requiredBands),
143 'filterToBand': filterToBand,
146 'nStarPerRun': config.nStarPerRun,
147 'nExpPerRun': config.nExpPerRun,
148 'reserveFraction': config.reserveFraction,
149 'freezeStdAtmosphere': config.freezeStdAtmosphere,
150 'precomputeSuperStarInitialCycle': config.precomputeSuperStarInitialCycle,
151 'superStarSubCCDDict': dict(config.superStarSubCcdDict),
152 'superStarSubCCDChebyshevOrder': config.superStarSubCcdChebyshevOrder,
153 'superStarSubCCDTriangular': config.superStarSubCcdTriangular,
154 'superStarSigmaClip': config.superStarSigmaClip,
155 'superStarPlotCCDResiduals': config.superStarPlotCcdResiduals,
156 'focalPlaneSigmaClip': config.focalPlaneSigmaClip,
157 'ccdGraySubCCDDict': dict(config.ccdGraySubCcdDict),
158 'ccdGraySubCCDChebyshevOrder': config.ccdGraySubCcdChebyshevOrder,
159 'ccdGraySubCCDTriangular': config.ccdGraySubCcdTriangular,
160 'ccdGrayFocalPlaneDict': dict(config.ccdGrayFocalPlaneDict),
161 'ccdGrayFocalPlaneChebyshevOrder': config.ccdGrayFocalPlaneChebyshevOrder,
162 'ccdGrayFocalPlaneFitMinCcd': config.ccdGrayFocalPlaneFitMinCcd,
163 'cycleNumber': config.cycleNumber,
165 'deltaMagBkgOffsetPercentile': config.deltaMagBkgOffsetPercentile,
166 'deltaMagBkgPerCcd': config.deltaMagBkgPerCcd,
167 'UTBoundary': config.utBoundary,
168 'washMJDs': config.washMjds,
169 'epochMJDs': config.epochMjds,
170 'coatingMJDs': config.coatingMjds,
171 'minObsPerBand': config.minObsPerBand,
172 'latitude': config.latitude,
173 'defaultCameraOrientation': config.defaultCameraOrientation,
174 'brightObsGrayMax': config.brightObsGrayMax,
175 'minStarPerCCD': config.minStarPerCcd,
176 'minCCDPerExp': config.minCcdPerExp,
177 'maxCCDGrayErr': config.maxCcdGrayErr,
178 'minStarPerExp': config.minStarPerExp,
179 'minExpPerNight': config.minExpPerNight,
180 'expGrayInitialCut': config.expGrayInitialCut,
181 'expGrayPhotometricCutDict': dict(config.expGrayPhotometricCutDict),
182 'expGrayHighCutDict': dict(config.expGrayHighCutDict),
183 'expGrayRecoverCut': config.expGrayRecoverCut,
184 'expVarGrayPhotometricCutDict': dict(config.expVarGrayPhotometricCutDict),
185 'expGrayErrRecoverCut': config.expGrayErrRecoverCut,
186 'refStarSnMin': config.refStarSnMin,
187 'refStarOutlierNSig': config.refStarOutlierNSig,
188 'applyRefStarColorCuts': config.applyRefStarColorCuts,
189 'refStarMaxFracUse': config.refStarMaxFracUse,
190 'useExposureReferenceOffset': config.useExposureReferenceOffset,
191 'illegalValue': FGCM_ILLEGAL_VALUE,
192 'starColorCuts': starColorCutList,
193 'refStarColorCuts': refStarColorCutList,
194 'aperCorrFitNBins': config.aperCorrFitNBins,
195 'aperCorrInputSlopeDict': dict(config.aperCorrInputSlopeDict),
196 'sedBoundaryTermDict': config.sedboundaryterms.toDict()[
'data'],
197 'sedTermDict': config.sedterms.toDict()[
'data'],
198 'colorSplitBands': list(config.colorSplitBands),
199 'sigFgcmMaxErr': config.sigFgcmMaxErr,
200 'sigFgcmMaxEGrayDict': dict(config.sigFgcmMaxEGrayDict),
201 'ccdGrayMaxStarErr': config.ccdGrayMaxStarErr,
202 'approxThroughputDict': dict(config.approxThroughputDict),
203 'sigmaCalRange': list(config.sigmaCalRange),
204 'sigmaCalFitPercentile': list(config.sigmaCalFitPercentile),
205 'sigmaCalPlotPercentile': list(config.sigmaCalPlotPercentile),
206 'sigma0Phot': config.sigma0Phot,
207 'mapLongitudeRef': config.mapLongitudeRef,
208 'mapNSide': config.mapNSide,
211 'useRetrievedPwv':
False,
212 'useNightlyRetrievedPwv':
False,
213 'pwvRetrievalSmoothBlock': 25,
214 'useQuadraticPwv': config.useQuadraticPwv,
215 'useRetrievedTauInit':
False,
216 'tauRetrievalMinCCDPerNight': 500,
217 'modelMagErrors': config.modelMagErrors,
218 'instrumentParsPerBand': config.instrumentParsPerBand,
219 'instrumentSlopeMinDeltaT': config.instrumentSlopeMinDeltaT,
220 'fitMirrorChromaticity': config.fitMirrorChromaticity,
221 'fitCCDChromaticityDict': dict(config.fitCcdChromaticityDict),
222 'useRepeatabilityForExpGrayCutsDict': dict(config.useRepeatabilityForExpGrayCutsDict),
223 'autoPhotometricCutNSig': config.autoPhotometricCutNSig,
224 'autoHighCutNSig': config.autoHighCutNSig,
225 'deltaAperInnerRadiusArcsec': config.deltaAperInnerRadiusArcsec,
226 'deltaAperOuterRadiusArcsec': config.deltaAperOuterRadiusArcsec,
227 'deltaAperFitMinNgoodObs': config.deltaAperFitMinNgoodObs,
228 'deltaAperFitPerCcdNx': config.deltaAperFitPerCcdNx,
229 'deltaAperFitPerCcdNy': config.deltaAperFitPerCcdNy,
230 'deltaAperFitSpatialNside': config.deltaAperFitSpatialNside,
231 'doComputeDeltaAperExposures': config.doComputeDeltaAperPerVisit,
232 'doComputeDeltaAperStars': config.doComputeDeltaAperPerStar,
233 'doComputeDeltaAperMap': config.doComputeDeltaAperMap,
234 'doComputeDeltaAperPerCcd': config.doComputeDeltaAperPerCcd,
236 'quietMode': config.quietMode,
237 'randomSeed': config.randomSeed,
238 'outputStars':
False,
239 'outputPath': os.path.abspath(
'.'),
242 'resetParameters': resetFitParameters,
243 'doPlots': config.doPlots,
244 'outputFgcmcalZpts':
True,
245 'outputZeropoints': outputZeropoints}
252 Translate the FGCM look-up-table into an fgcm-compatible object
256 lutCat: `lsst.afw.table.BaseCatalog`
257 Catalog describing the FGCM look-up table
258 physicalFilterMap: `dict`
259 Physical filter to band mapping
263 fgcmLut: `lsst.fgcm.FgcmLut`
264 Lookup table for FGCM
265 lutIndexVals: `numpy.ndarray`
266 Numpy array with LUT index information for FGCM
267 lutStd: `numpy.ndarray`
268 Numpy array with LUT standard throughput values for FGCM
272 After running this code, it is wise to `del lutCat` to clear the memory.
276 lutFilterNames = np.array(lutCat[0][
'physicalFilters'].split(
','), dtype=
'U')
277 lutStdFilterNames = np.array(lutCat[0][
'stdPhysicalFilters'].split(
','), dtype=
'U')
282 lutIndexVals = np.zeros(1, dtype=[(
'FILTERNAMES', lutFilterNames.dtype.str,
283 lutFilterNames.size),
284 (
'STDFILTERNAMES', lutStdFilterNames.dtype.str,
285 lutStdFilterNames.size),
286 (
'PMB',
'f8', lutCat[0][
'pmb'].size),
287 (
'PMBFACTOR',
'f8', lutCat[0][
'pmbFactor'].size),
288 (
'PMBELEVATION',
'f8'),
289 (
'LAMBDANORM',
'f8'),
290 (
'PWV',
'f8', lutCat[0][
'pwv'].size),
291 (
'O3',
'f8', lutCat[0][
'o3'].size),
292 (
'TAU',
'f8', lutCat[0][
'tau'].size),
293 (
'ALPHA',
'f8', lutCat[0][
'alpha'].size),
294 (
'ZENITH',
'f8', lutCat[0][
'zenith'].size),
297 lutIndexVals[
'FILTERNAMES'][:] = lutFilterNames
298 lutIndexVals[
'STDFILTERNAMES'][:] = lutStdFilterNames
299 lutIndexVals[
'PMB'][:] = lutCat[0][
'pmb']
300 lutIndexVals[
'PMBFACTOR'][:] = lutCat[0][
'pmbFactor']
301 lutIndexVals[
'PMBELEVATION'] = lutCat[0][
'pmbElevation']
302 lutIndexVals[
'LAMBDANORM'] = lutCat[0][
'lambdaNorm']
303 lutIndexVals[
'PWV'][:] = lutCat[0][
'pwv']
304 lutIndexVals[
'O3'][:] = lutCat[0][
'o3']
305 lutIndexVals[
'TAU'][:] = lutCat[0][
'tau']
306 lutIndexVals[
'ALPHA'][:] = lutCat[0][
'alpha']
307 lutIndexVals[
'ZENITH'][:] = lutCat[0][
'zenith']
308 lutIndexVals[
'NCCD'] = lutCat[0][
'nCcd']
311 lutStd = np.zeros(1, dtype=[(
'PMBSTD',
'f8'),
317 (
'LAMBDARANGE',
'f8', 2),
318 (
'LAMBDASTEP',
'f8'),
319 (
'LAMBDASTD',
'f8', lutFilterNames.size),
320 (
'LAMBDASTDFILTER',
'f8', lutStdFilterNames.size),
321 (
'I0STD',
'f8', lutFilterNames.size),
322 (
'I1STD',
'f8', lutFilterNames.size),
323 (
'I10STD',
'f8', lutFilterNames.size),
324 (
'I2STD',
'f8', lutFilterNames.size),
325 (
'LAMBDAB',
'f8', lutFilterNames.size),
326 (
'ATMLAMBDA',
'f8', lutCat[0][
'atmLambda'].size),
327 (
'ATMSTDTRANS',
'f8', lutCat[0][
'atmStdTrans'].size)])
328 lutStd[
'PMBSTD'] = lutCat[0][
'pmbStd']
329 lutStd[
'PWVSTD'] = lutCat[0][
'pwvStd']
330 lutStd[
'O3STD'] = lutCat[0][
'o3Std']
331 lutStd[
'TAUSTD'] = lutCat[0][
'tauStd']
332 lutStd[
'ALPHASTD'] = lutCat[0][
'alphaStd']
333 lutStd[
'ZENITHSTD'] = lutCat[0][
'zenithStd']
334 lutStd[
'LAMBDARANGE'][:] = lutCat[0][
'lambdaRange'][:]
335 lutStd[
'LAMBDASTEP'] = lutCat[0][
'lambdaStep']
336 lutStd[
'LAMBDASTD'][:] = lutCat[0][
'lambdaStd']
337 lutStd[
'LAMBDASTDFILTER'][:] = lutCat[0][
'lambdaStdFilter']
338 lutStd[
'I0STD'][:] = lutCat[0][
'i0Std']
339 lutStd[
'I1STD'][:] = lutCat[0][
'i1Std']
340 lutStd[
'I10STD'][:] = lutCat[0][
'i10Std']
341 lutStd[
'I2STD'][:] = lutCat[0][
'i2Std']
342 lutStd[
'LAMBDAB'][:] = lutCat[0][
'lambdaB']
343 lutStd[
'ATMLAMBDA'][:] = lutCat[0][
'atmLambda'][:]
344 lutStd[
'ATMSTDTRANS'][:] = lutCat[0][
'atmStdTrans'][:]
346 lutTypes = [row[
'luttype']
for row
in lutCat]
349 lutFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'I0',
'f4'),
352 lutFlat[
'I0'][:] = lutCat[lutTypes.index(
'I0')][
'lut'][:]
353 lutFlat[
'I1'][:] = lutCat[lutTypes.index(
'I1')][
'lut'][:]
355 lutDerivFlat = np.zeros(lutCat[0][
'lut'].size, dtype=[(
'D_LNPWV',
'f4'),
359 (
'D_SECZENITH',
'f4'),
360 (
'D_LNPWV_I1',
'f4'),
362 (
'D_LNTAU_I1',
'f4'),
363 (
'D_ALPHA_I1',
'f4'),
364 (
'D_SECZENITH_I1',
'f4')])
366 for name
in lutDerivFlat.dtype.names:
367 lutDerivFlat[name][:] = lutCat[lutTypes.index(name)][
'lut'][:]
374 fgcmLut = fgcm.FgcmLUT(lutIndexVals, lutFlat, lutDerivFlat, lutStd,
375 filterToBand=physicalFilterMap)
377 return fgcmLut, lutIndexVals, lutStd