PackageAlertsTask#

class lsst.ap.association.PackageAlertsTask(**kwargs)#

Bases: Task

Tasks 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#

imagelsst.afw.image.ExposureF

Image to pull cutout from.

skyCenterlsst.geom.SpherePoint

Center point of DiaSource on the sky.

pixelCenterlsst.geom.Point2D

Pixel center of DiaSource on the sky.

extentlsst.geom.Extent2I

Bounding box to cutout from the image.

photoCaliblsst.afw.image.PhotoCalib

Calibrate object of the image the cutout is cut from.

srcIdint

Unique id of DiaSource. Used for when an error occurs extracting a cutout.

averagePsfnumpy.array, optional

Average PSF to attach to the cutout. Used if self.config.useAveragePsf is set. cutoutType : str, optional

Type of cutout being created (‘difference’, ‘template’, or ‘science’)

Returns#

ccdDataastropy.nddata.CCDData or None

CCDData object storing the calibrate information from the input difference or template 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#

bboxSizeint

Size of a side of the square bounding box in pixels.

Returns#

extentlsst.geom.Extent2I

Geom object representing the size of the bounding box.

makeAlertDict(diaSourceId, observationReason, targetName, diaSource, diaObject, objDiaSrcHistory, objDiaForcedSources, diffImCutout, calexpCutout, templateCutout, ssSource=None)#

Convert data and package into a dictionary alert.

Parameters#

diaSourceIdint

Unique identifier of the triggering diaSource

diaSourcepandas.DataFrame

New single DiaSource to package.

observationReasonstr

Scheduler reason for the image containing this diaSource.

targetNamestr

Scheduler target for the image containing this diaSource.

diaObjectpandas.DataFrame

DiaObject that diaSource is matched to.

objDiaSrcHistorypandas.DataFrame

12 month history of diaObject excluding the latest DiaSource.

objDiaForcedSourcespandas.DataFrame

12 month history of diaObject forced measurements.

diffImCutoutastropy.nddata.CCDData or None

Cutout of the difference image around the location of diaSource with a min size set by the cutoutSize configurable.

calexpCutoutastropy.nddata.CCDData or None

Cutout of the calexp around the location of diaSource with a min size set by the cutoutSize configurable.

templateCutoutastropy.nddata.CCDData or None

Cutout of the template image around the location of diaSource with a min size set by the cutoutSize configurable.

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#

wcslsst.afw.geom.SkyWcs

Wcs to approximate

centerlsst.geom.Point2D

Point at which to evaluate the LocalWcs.

skyCenterlsst.geom.SpherePoint

Point on sky to approximate the Wcs.

Returns#

localMatrixnumpy.ndarray

Matrix representation the local wcs approximation with units degrees.

produceAlerts(alerts, visit, detector, midpoint_unix, exposure_time)#

Serialize alerts and send them to the alert stream using confluent_kafka’s producer.

Parameters#

alertsdict

Dictionary of alerts to be sent to the alert stream.

visit, detectorint

Visit and detector ids of these alerts. Used to write out alerts which fail to be sent to the alert stream.

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 doProduceAlerts is set and written to disk if doWriteAlerts is set. Both can be set at the same time, and are independent of one another.

Writes Avro alerts to a location determined by the alertWriteLocation configurable.

Parameters#

diaSourceCatpandas.DataFrame

New DiaSources to package. DataFrame should be indexed on ["diaObjectId", "band", "diaSourceId"]

diaObjectCatpandas.DataFrame

New and updated DiaObjects matched to the new DiaSources. DataFrame is indexed on ["diaObjectId"]

diaSrcHistorypandas.DataFrame

12 month history of DiaSources matched to the DiaObjects. Excludes the newest DiaSource and is indexed on ["diaObjectId", "band", "diaSourceId"]

diaForcedSourcespandas.DataFrame

12 month history of DiaForcedSources matched to the DiaObjects. ["diaObjectId"]

diffImlsst.afw.image.ExposureF

Difference image the sources in diaSourceCat were detected in.

calexplsst.afw.image.ExposureF

Calexp used to create the diffIm.

templatelsst.afw.image.ExposureF or None

Template image used to create the diffIm.

ssSrcastropy.table.Table, optional

Solar system specific information for diaSources associated to ssObjects.

doRunForcedMeasurementbool, 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.

forcedSourceHistoryThresholdint, optional

Minimum number of detections of a diaObject required to run forced photometry. Set to 1 to include all diaObjects.

streamCcdDataToBytes(cutout)#

Serialize a cutout into bytes.

Parameters#

cutoutastropy.nddata.CCDData

Cutout to serialize.

Returns#

coutputBytesbytes

Input cutout serialized into byte data.