def build_matched_dataset(repo, dataIds, matchRadius=None, safeSnr=50., useJointCal=False, skipTEx=False): blob = Blob('MatchedMultiVisitDataset') if not matchRadius: matchRadius = afwGeom.Angle(1, afwGeom.arcseconds) # Extract single filter blob['filterName'] = Datum(quantity=set([dId['filter'] for dId in dataIds]).pop(), description='Filter name') # Record important configuration blob['useJointCal'] = Datum( quantity=useJointCal, description='Whether jointcal/meas_mosaic calibrations were used') # Match catalogs across visits blob._catalog, blob._matchedCatalog = \ _loadAndMatchCatalogs(repo, dataIds, matchRadius, useJointCal=useJointCal, skipTEx=False) blob.magKey = blob._matchedCatalog.schema.find("base_PsfFlux_mag").key # Reduce catalogs into summary statistics. # These are the serialiable attributes of this class. _reduceStars(blob, blob._matchedCatalog, safeSnr) return blob
def build_matched_dataset(repo, dataIds, matchRadius=None, safeSnr=50., useJointCal=False, skipTEx=False): """Construct a container for matched star catalogs from multple visits, with filtering, summary statistics, and modelling. `lsst.verify.Blob` instances are serializable to JSON. Parameters ---------- repo : `str` or `Butler` A Butler instance or a repository URL that can be used to construct one. dataIds : `list` of `dict` List of `butler` data IDs of Image catalogs to compare to reference. The `calexp` cpixel image is needed for the photometric calibration. matchRadius : afwGeom.Angle(), optional Radius for matching. Default is 1 arcsecond. safeSnr : `float`, optional Minimum median SNR for a match to be considered "safe". useJointCal : `bool`, optional Use jointcal/meas_mosaic outputs to calibrate positions and fluxes. skipTEx : `bool`, optional Skip TEx calculations (useful for older catalogs that don't have PsfShape measurements). Attributes of returned Blob ---------- filterName : `str` Name of filter used for all observations. mag : `astropy.units.Quantity` Mean PSF magnitudes of stars over multiple visits (magnitudes). magerr : `astropy.units.Quantity` Median 1-sigma uncertainty of PSF magnitudes over multiple visits (magnitudes). magrms : `astropy.units.Quantity` RMS of PSF magnitudes over multiple visits (magnitudes). snr : `astropy.units.Quantity` Median signal-to-noise ratio of PSF magnitudes over multiple visits (dimensionless). dist : `astropy.units.Quantity` RMS of sky coordinates of stars over multiple visits (milliarcseconds). *Not serialized.* goodMatches all good matches, as an afw.table.GroupView; good matches contain only objects whose detections all have 1. a PSF Flux measurement with S/N > 1 2. a finite (non-nan) PSF magnitude. This separate check is largely to reject failed zeropoints. 3. and do not have flags set for bad, cosmic ray, edge or saturated *Not serialized.* safeMatches safe matches, as an afw.table.GroupView. Safe matches are good matches that are sufficiently bright and sufficiently compact. *Not serialized.* magKey Key for `"base_PsfFlux_mag"` in the `goodMatches` and `safeMatches` catalog tables. *Not serialized.* """ blob = Blob('MatchedMultiVisitDataset') if not matchRadius: matchRadius = afwGeom.Angle(1, afwGeom.arcseconds) # Extract single filter blob['filterName'] = Datum(quantity=set([dId['filter'] for dId in dataIds]).pop(), description='Filter name') # Record important configuration blob['useJointCal'] = Datum( quantity=useJointCal, description='Whether jointcal/meas_mosaic calibrations were used') # Match catalogs across visits blob._catalog, blob._matchedCatalog = \ _loadAndMatchCatalogs(repo, dataIds, matchRadius, useJointCal=useJointCal, skipTEx=skipTEx) blob.magKey = blob._matchedCatalog.schema.find("base_PsfFlux_mag").key # Reduce catalogs into summary statistics. # These are the serialiable attributes of this class. _reduceStars(blob, blob._matchedCatalog, safeSnr) return blob
def build_matched_dataset(repo, dataIds, matchRadius=None, brightSnrMin=None, brightSnrMax=None, faintSnrMin=None, faintSnrMax=None, doApplyExternalPhotoCalib=False, externalPhotoCalibName=None, doApplyExternalSkyWcs=False, externalSkyWcsName=None, skipTEx=False, skipNonSrd=False): """Construct a container for matched star catalogs from multple visits, with filtering, summary statistics, and modelling. `lsst.verify.Blob` instances are serializable to JSON. Parameters ---------- repo : `str` or `lsst.daf.persistence.Butler` A Butler instance or a repository URL that can be used to construct one. dataIds : `list` of `dict` List of `butler` data IDs of Image catalogs to compare to reference. The `calexp` cpixel image is needed for the photometric calibration. matchRadius : `lsst.geom.Angle`, optional Radius for matching. Default is 1 arcsecond. brightSnrMin : `float`, optional Minimum median SNR for a source to be considered bright; passed to `filterSources`. brightSnrMax : `float`, optional Maximum median SNR for a source to be considered bright; passed to `filterSources`. faintSnrMin : `float`, optional Minimum median SNR for a source to be considered faint; passed to `filterSources`. faintSnrMax : `float`, optional Maximum median SNR for a source to be considered faint; passed to `filterSources`. doApplyExternalPhotoCalib : bool, optional Apply external photoCalib to calibrate fluxes. externalPhotoCalibName : str, optional Type of external `PhotoCalib` to apply. Currently supported are jointcal, fgcm, and fgcm_tract. Must be set if "doApplyExternalPhotoCalib" is True. doApplyExternalSkyWcs : bool, optional Apply external wcs to calibrate positions. externalSkyWcsName : str, optional: Type of external `wcs` to apply. Currently supported is jointcal. Must be set if "doApplyExternalSkyWcs" is True. skipTEx : `bool`, optional Skip TEx calculations (useful for older catalogs that don't have PsfShape measurements). skipNonSrd : `bool`, optional Skip any metrics not defined in the LSST SRD; default False. Attributes of returned Blob ---------- filterName : `str` Name of filter used for all observations. mag : `astropy.units.Quantity` Mean PSF magnitudes of stars over multiple visits (magnitudes). magerr : `astropy.units.Quantity` Median 1-sigma uncertainty of PSF magnitudes over multiple visits (magnitudes). magrms : `astropy.units.Quantity` RMS of PSF magnitudes over multiple visits (magnitudes). snr : `astropy.units.Quantity` Median signal-to-noise ratio of PSF magnitudes over multiple visits (dimensionless). dist : `astropy.units.Quantity` RMS of sky coordinates of stars over multiple visits (milliarcseconds). *Not serialized.* matchesFaint : `afw.table.GroupView` Faint matches containing only objects that have: 1. A PSF Flux measurement with sufficient S/N. 2. A finite (non-nan) PSF magnitude. This separate check is largely to reject failed zeropoints. 3. No flags set for bad, cosmic ray, edge or saturated. 4. Extendedness consistent with a point source. *Not serialized.* matchesBright : `afw.table.GroupView` Bright matches matching a higher S/N threshold than matchesFaint. *Not serialized.* magKey Key for `"base_PsfFlux_mag"` in the `matchesFaint` and `matchesBright` catalog tables. *Not serialized.* Raises ------ RuntimeError: Raised if "doApplyExternalPhotoCalib" is True and "externalPhotoCalibName" is None, or if "doApplyExternalSkyWcs" is True and "externalSkyWcsName" is None. """ if doApplyExternalPhotoCalib and externalPhotoCalibName is None: raise RuntimeError( "Must set externalPhotoCalibName if doApplyExternalPhotoCalib is True." ) if doApplyExternalSkyWcs and externalSkyWcsName is None: raise RuntimeError( "Must set externalSkyWcsName if doApplyExternalSkyWcs is True.") blob = Blob('MatchedMultiVisitDataset') if not matchRadius: matchRadius = geom.Angle(1, geom.arcseconds) # Extract single filter blob['filterName'] = Datum(quantity=set([dId['filter'] for dId in dataIds]).pop(), description='Filter name') # Record important configuration blob['doApplyExternalPhotoCalib'] = Datum( quantity=doApplyExternalPhotoCalib, description=('Whether external photometric ' 'calibrations were used.')) blob['externalPhotoCalibName'] = Datum( quantity=externalPhotoCalibName, description='Name of external PhotoCalib dataset used.') blob['doApplyExternalSkyWcs'] = Datum( quantity=doApplyExternalSkyWcs, description='Whether external wcs calibrations were used.') blob['externalSkyWcsName'] = Datum( quantity=externalSkyWcsName, description='Name of external wcs dataset used.') # Match catalogs across visits blob._catalog, blob._matchedCatalog = \ _loadAndMatchCatalogs(repo, dataIds, matchRadius, doApplyExternalPhotoCalib=doApplyExternalPhotoCalib, externalPhotoCalibName=externalPhotoCalibName, doApplyExternalSkyWcs=doApplyExternalSkyWcs, externalSkyWcsName=externalSkyWcsName, skipTEx=skipTEx, skipNonSrd=skipNonSrd) blob.magKey = blob._matchedCatalog.schema.find("base_PsfFlux_mag").key # Reduce catalogs into summary statistics. # These are the serializable attributes of this class. filterResult = filterSources( blob._matchedCatalog, brightSnrMin=brightSnrMin, brightSnrMax=brightSnrMax, faintSnrMin=faintSnrMin, faintSnrMax=faintSnrMax, ) blob['brightSnrMin'] = Datum( quantity=filterResult.brightSnrMin * u.Unit(''), label='Bright SNR Min', description='Minimum median SNR for a source to be considered bright') blob['brightSnrMax'] = Datum( quantity=filterResult.brightSnrMax * u.Unit(''), label='Bright SNR Max', description='Maximum median SNR for a source to be considered bright') summarizeSources(blob, filterResult) return blob