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