PackageAlertsTask#
- class lsst.ap.association.PackageAlertsTask(**kwargs)#
Bases:
TaskTasks for packaging Dia and Pipelines data into Avro alert packages.
Methods Summary
createCcdDataCutout(image, skyCenter, ...[, ...])Grab an image as a cutout and return a calibrated CCDData image.
createDiaSourceExtent(bboxSize)Create an extent for a box for the cutouts given the size of the square BBox that covers the source footprint.
makeAlertDict(diaSourceId, ...[, ssSource])Convert data and package into a dictionary alert.
makeLocalTransformMatrix(wcs, center, skyCenter)Create a local, linear approximation of the wcs transformation matrix.
produceAlerts(alerts, visit, detector, ...)Serialize alerts and send them to the alert stream using confluent_kafka's producer.
run(diaSourceCat, diaObjectCat, ...[, ...])Package DiaSources/Object and exposure data into Avro alerts.
streamCcdDataToBytes(cutout)Serialize a cutout into bytes.
Methods Documentation
- createCcdDataCutout(image, skyCenter, pixelCenter, extent, photoCalib, srcId, averagePsf=None, rotPa=None)#
Grab an image as a cutout and return a calibrated CCDData image.
Parameters#
- image
lsst.afw.image.ExposureF Image to pull cutout from.
- skyCenter
lsst.geom.SpherePoint Center point of DiaSource on the sky.
- pixelCenter
lsst.geom.Point2D Pixel center of DiaSource on the sky.
- extent
lsst.geom.Extent2I Bounding box to cutout from the image.
- photoCalib
lsst.afw.image.PhotoCalib Calibrate object of the image the cutout is cut from.
- srcId
int Unique id of DiaSource. Used for when an error occurs extracting a cutout.
- averagePsf
numpy.array, optional Average PSF to attach to the cutout. Used if
self.config.useAveragePsfis set. cutoutType : str, optional
Type of cutout being created (‘difference’, ‘template’, or ‘science’)
Returns#
- ccdData
astropy.nddata.CCDDataorNone CCDData object storing the calibrate information from the input difference or template image.
- image
- createDiaSourceExtent(bboxSize)#
Create an extent for a box for the cutouts given the size of the square BBox that covers the source footprint.
Parameters#
- bboxSize
int Size of a side of the square bounding box in pixels.
Returns#
- extent
lsst.geom.Extent2I Geom object representing the size of the bounding box.
- bboxSize
- makeAlertDict(diaSourceId, observationReason, targetName, diaSource, diaObject, objDiaSrcHistory, objDiaForcedSources, diffImCutout, calexpCutout, templateCutout, ssSource=None)#
Convert data and package into a dictionary alert.
Parameters#
- diaSourceId
int Unique identifier of the triggering diaSource
- diaSource
pandas.DataFrame New single DiaSource to package.
- observationReason
str Scheduler reason for the image containing this diaSource.
- targetName
str Scheduler target for the image containing this diaSource.
- diaObject
pandas.DataFrame DiaObject that
diaSourceis matched to.- objDiaSrcHistory
pandas.DataFrame 12 month history of
diaObjectexcluding the latest DiaSource.- objDiaForcedSources
pandas.DataFrame 12 month history of
diaObjectforced measurements.- diffImCutout
astropy.nddata.CCDDataorNone Cutout of the difference image around the location of
diaSourcewith a min size set by thecutoutSizeconfigurable.- calexpCutout
astropy.nddata.CCDDataorNone Cutout of the calexp around the location of
diaSourcewith a min size set by thecutoutSizeconfigurable.- templateCutout
astropy.nddata.CCDDataorNone Cutout of the template image around the location of
diaSourcewith a min size set by thecutoutSizeconfigurable.
- diaSourceId
- makeLocalTransformMatrix(wcs, center, skyCenter)#
Create a local, linear approximation of the wcs transformation matrix.
The approximation is created as if the center is at RA=0, DEC=0. All comparing x,y coordinate are relative to the position of center. Matrix is initially calculated with units arcseconds and then converted to degrees. This yields higher precision results due to quirks in AST.
Parameters#
- wcs
lsst.afw.geom.SkyWcs Wcs to approximate
- center
lsst.geom.Point2D Point at which to evaluate the LocalWcs.
- skyCenter
lsst.geom.SpherePoint Point on sky to approximate the Wcs.
Returns#
- localMatrix
numpy.ndarray Matrix representation the local wcs approximation with units degrees.
- wcs
- produceAlerts(alerts, visit, detector, midpoint_unix, exposure_time)#
Serialize alerts and send them to the alert stream using confluent_kafka’s producer.
Parameters#
- alerts
dict Dictionary of alerts to be sent to the alert stream.
- visit, detector
int Visit and detector ids of these alerts. Used to write out alerts which fail to be sent to the alert stream.
- alerts
- run(diaSourceCat, diaObjectCat, diaSrcHistory, diaForcedSources, diffIm, calexp, template, ssSrc=None, doRunForcedMeasurement=True, forcedSourceHistoryThreshold=0)#
Package DiaSources/Object and exposure data into Avro alerts.
Alerts can be sent to the alert stream if
doProduceAlertsis set and written to disk ifdoWriteAlertsis set. Both can be set at the same time, and are independent of one another.Writes Avro alerts to a location determined by the
alertWriteLocationconfigurable.Parameters#
- diaSourceCat
pandas.DataFrame New DiaSources to package. DataFrame should be indexed on
["diaObjectId", "band", "diaSourceId"]- diaObjectCat
pandas.DataFrame New and updated DiaObjects matched to the new DiaSources. DataFrame is indexed on
["diaObjectId"]- diaSrcHistory
pandas.DataFrame 12 month history of DiaSources matched to the DiaObjects. Excludes the newest DiaSource and is indexed on
["diaObjectId", "band", "diaSourceId"]- diaForcedSources
pandas.DataFrame 12 month history of DiaForcedSources matched to the DiaObjects.
["diaObjectId"]- diffIm
lsst.afw.image.ExposureF Difference image the sources in
diaSourceCatwere detected in.- calexp
lsst.afw.image.ExposureF Calexp used to create the
diffIm.- template
lsst.afw.image.ExposureForNone Template image used to create the
diffIm.- ssSrc
astropy.table.Table, optional Solar system specific information for diaSources associated to ssObjects.
- doRunForcedMeasurement
bool, optional Flag to indicate whether forced measurement was run. This should only be turned off for debugging purposes. Added to allow disabling forced sources for performance reasons during the ops rehearsal.
- forcedSourceHistoryThreshold
int, optional Minimum number of detections of a diaObject required to run forced photometry. Set to 1 to include all diaObjects.
- diaSourceCat