33
33
from lsst .meas .algorithms .sourceSelector import sourceSelectorRegistry
34
34
35
35
from .fgcmLoadReferenceCatalog import FgcmLoadReferenceCatalogTask
36
+ from .utilities import computeReferencePixelScale
36
37
37
38
import fgcm
38
39
@@ -259,13 +260,15 @@ def fgcmMakeVisitCatalog(self, camera, groupedHandles):
259
260
visitCat ['used' ] = 0
260
261
visitCat ['sources_read' ] = False
261
262
263
+ defaultPixelScale = computeReferencePixelScale (camera )
264
+
262
265
# No matter what, fill the catalog. This will check if it was
263
266
# already read.
264
- self ._fillVisitCatalog (visitCat , groupedHandles )
267
+ self ._fillVisitCatalog (visitCat , groupedHandles , defaultPixelScale )
265
268
266
269
return visitCat
267
270
268
- def _fillVisitCatalog (self , visitCat , groupedHandles ):
271
+ def _fillVisitCatalog (self , visitCat , groupedHandles , defaultPixelScale ):
269
272
"""
270
273
Fill the visit catalog with visit metadata
271
274
@@ -275,6 +278,8 @@ def _fillVisitCatalog(self, visitCat, groupedHandles):
275
278
Visit catalog. See _makeFgcmVisitSchema() for schema definition.
276
279
groupedHandles : `dict` [`list` [`lsst.daf.butler.DeferredDatasetHandle`]]
277
280
Dataset handles, grouped by visit.
281
+ defaultPixelScale : `float`
282
+ Default pixel scale to use if not in visit summary (arcsecond/pixel).
278
283
"""
279
284
280
285
# Guarantee that these are sorted.
@@ -292,15 +297,24 @@ def _fillVisitCatalog(self, visitCat, groupedHandles):
292
297
293
298
visitInfo = summaryRow .getVisitInfo ()
294
299
physicalFilter = summaryRow ['physical_filter' ]
295
- # Compute the median psf sigma if possible
296
- goodSigma , = np .where (summary ['psfSigma' ] > 0 )
300
+ # Compute the median psf sigma and fwhm if possible.
301
+ if 'pixelScale' in summary .schema :
302
+ # This is not available in the older test summaries
303
+ pixelScales = summary ['pixelScale' ]
304
+ else :
305
+ pixelScales = np .full (len (summary ['psfSigma' ]), defaultPixelScale )
306
+ psfSigmas = summary ['psfSigma' ]
307
+ goodSigma , = np .where ((np .nan_to_num (psfSigmas ) > 0 ) & (np .nan_to_num (pixelScales ) > 0 ))
297
308
if goodSigma .size > 2 :
298
- psfSigma = np .median (summary ['psfSigma' ][goodSigma ])
309
+ psfSigma = np .median (psfSigmas [goodSigma ])
310
+ psfFwhm = np .median (psfSigmas [goodSigma ] * pixelScales [goodSigma ]) * np .sqrt (8. * np .log (2. ))
299
311
elif goodSigma .size > 0 :
300
- psfSigma = summary ['psfSigma' ][goodSigma [0 ]]
312
+ psfSigma = psfSigmas [goodSigma [0 ]]
313
+ psfFwhm = psfSigmas [goodSigma [0 ]] * pixelScales [goodSigma [0 ]] * np .sqrt (8. )* np .log (2. )
301
314
else :
302
315
self .log .warning ("Could not find any good summary psfSigma for visit %d" , visit )
303
316
psfSigma = 0.0
317
+ psfFwhm = 0.0
304
318
# Compute median background if possible
305
319
goodBackground , = np .where (np .nan_to_num (summary ['skyBg' ]) > 0.0 )
306
320
if goodBackground .size > 2 :
@@ -332,6 +346,7 @@ def _fillVisitCatalog(self, visitCat, groupedHandles):
332
346
# Median delta aperture, to be measured from stars
333
347
rec ['deltaAper' ] = 0.0
334
348
rec ['psfSigma' ] = psfSigma
349
+ rec ['psfFwhm' ] = psfFwhm
335
350
rec ['skyBackground' ] = skyBackground
336
351
rec ['used' ] = 1
337
352
@@ -559,7 +574,8 @@ def _makeFgcmVisitSchema(self, nCcd):
559
574
schema .addField ('mjd' , type = np .float64 , doc = "MJD of visit" )
560
575
schema .addField ('exptime' , type = np .float32 , doc = "Exposure time" )
561
576
schema .addField ('pmb' , type = np .float32 , doc = "Pressure (millibar)" )
562
- schema .addField ('psfSigma' , type = np .float32 , doc = "PSF sigma (reference CCD)" )
577
+ schema .addField ('psfSigma' , type = np .float32 , doc = "PSF sigma (median); pixels" )
578
+ schema .addField ('psfFwhm' , type = np .float32 , doc = "PSF FWHM (median); arcseconds" )
563
579
schema .addField ('deltaAper' , type = np .float32 , doc = "Delta-aperture" )
564
580
schema .addField ('skyBackground' , type = np .float32 , doc = "Sky background (ADU) (reference CCD)" )
565
581
# the following field is not used yet
0 commit comments