Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-48437: Update alert packet for adding "is_negative" to APDB schema #46

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions python/lsst/alert/packet/schema/7/3/lsst.v7_3.alert.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"namespace": "lsst.v7_3",
"type": "record",
"name": "alert",
"doc": "Rubin Avro alert schema v7.3",
"fields": [
{"name": "alertId", "type": "long", "doc": "unique alert identifer"},
{"name": "diaSource", "type": "lsst.v7_3.diaSource"},
{"name": "prvDiaSources", "type": ["null", {
"type": "array",
"items": "lsst.v7_3.diaSource"}], "default": null},
{"name": "prvDiaForcedSources", "type": ["null", {
"type": "array",
"items": "lsst.v7_3.diaForcedSource"}], "default": null},
{"name": "prvDiaNondetectionLimits", "type": ["null", {
"type": "array",
"items": "lsst.v7_3.diaNondetectionLimit"}], "default": null},
{"name": "diaObject", "type": ["null", "lsst.v7_3.diaObject"], "default": null},
{"name": "ssObject", "type": ["null", "lsst.v7_3.ssObject"], "default": null},
{"name": "cutoutDifference", "type": ["null", "bytes"], "default": null},
{"name": "cutoutScience", "type": ["null", "bytes"], "default": null},
{"name": "cutoutTemplate", "type": ["null", "bytes"], "default": null}
]
}
69 changes: 69 additions & 0 deletions python/lsst/alert/packet/schema/7/3/lsst.v7_3.diaForcedSource.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"type": "record",
"namespace": "lsst.v7_3",
"name": "diaForcedSource",
"fields": [
{
"doc": "Unique id.",
"name": "diaForcedSourceId",
"type": "long"
},
{
"doc": "Id of the DiaObject that this DiaForcedSource was associated with.",
"name": "diaObjectId",
"type": "long"
},
{
"doc": "Right ascension coordinate of the position of the DiaObject at time radecMjdTai.",
"name": "ra",
"type": "double"
},
{
"doc": "Declination coordinate of the position of the DiaObject at time radecMjdTai.",
"name": "dec",
"type": "double"
},
{
"doc": "Id of the visit where this forcedSource was measured.",
"name": "visit",
"type": "long"
},
{
"doc": "Id of the detector where this forcedSource was measured. Datatype short instead of byte because of DB concerns about unsigned bytes.",
"name": "detector",
"type": "int"
},
{
"doc": "Point Source model flux.",
"default": null,
"name": "psfFlux",
"type": [
"null",
"float"
]
},
{
"doc": "Uncertainty of psfFlux.",
"default": null,
"name": "psfFluxErr",
"type": [
"null",
"float"
]
},
{
"doc": "Effective mid-visit time for this diaForcedSource, expressed as Modified Julian Date, International Atomic Time.",
"name": "midpointMjdTai",
"type": "double"
},
{
"doc": "Filter band this source was observed with.",
"default": null,
"name": "band",
"type": [
"null",
"string"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "lsst.v7_3",
"name": "diaNondetectionLimit",
"type": "record",
"fields": [
{"name": "ccdVisitId", "type": "long"},
{"name": "midpointMjdTai", "type": "double"},
{"name": "band", "type": "string"},
{"name": "diaNoise", "type": "float"}
]
}
733 changes: 733 additions & 0 deletions python/lsst/alert/packet/schema/7/3/lsst.v7_3.diaObject.avsc

Large diffs are not rendered by default.

1,217 changes: 1,217 additions & 0 deletions python/lsst/alert/packet/schema/7/3/lsst.v7_3.diaSource.avsc

Large diffs are not rendered by default.

471 changes: 471 additions & 0 deletions python/lsst/alert/packet/schema/7/3/lsst.v7_3.ssObject.avsc

Large diffs are not rendered by default.

109 changes: 109 additions & 0 deletions python/lsst/alert/packet/schema/7/3/sample_data/alert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"alertId": 1231321321,
"l1dbId": 222222222,
"diaSource":
{
"diaSourceId": 281323062375219200,
"time_processed": 0,
"visit": 1,
"detector": 42,
"midpointMjdTai": 1480360995,
"band": "r",
"programId": 1,
"ra": 351.570546978,
"dec": 0.126243049656,
"raErr": 0.00028,
"decErr": 0.00028,
"ra_dec_Cov": 0.00029,
"x": 112.1,
"y": 121.1,
"xErr": 1.2,
"yErr": 1.1,
"x_y_Cov": 1.2,
"apFlux": 1241.0,
"apFluxErr": 12.0,
"snr": 41.1,
"trailNdata": 5,
"psfFlux": 1241.0,
"psfFluxErr": 12.0
},
"prvDiaSources": [
{
"diaSourceId": 281323062375219198,
"time_processed": 0,
"visit": 2,
"detector": 43,
"midpointMjdTai": 1480360995,
"band": "r",
"programId": 1,
"ra": 351.570546978,
"dec": 0.126243049656,
"raErr": 0.00028,
"decErr": 0.00028,
"ra_dec_Cov": 0.00029,
"x": 112.1,
"y": 121.1,
"xErr": 1.2,
"yErr": 1.1,
"x_y_Cov": 1.2,
"apFlux": 1241.0,
"apFluxErr": 12.0,
"snr": 41.1,
"trailNdata": 5,
"psfFlux": 1241.0,
"psfFluxErr": 12.0
},
{
"diaSourceId": 281323062375219199,
"time_processed": 0,
"visit": 1,
"detector": 42,
"midpointMjdTai": 1480360995,
"band": "r",
"programId": 1,
"ra": 351.570546978,
"dec": 0.126243049656,
"raErr": 0.00028,
"decErr": 0.00028,
"ra_dec_Cov": 0.00029,
"x": 112.1,
"y": 121.1,
"xErr": 1.2,
"yErr": 1.1,
"x_y_Cov": 1.2,
"apFlux": 1241.0,
"apFluxErr": 12.0,
"snr": 41.1,
"trailNdata": 5,
"psfFlux": 1241.0,
"psfFluxErr": 12.0
}
],
"diaObject": {
"diaObjectId": 281323062375219201,
"validityStart": 0,
"ra": 351.570546978,
"dec": 0.126243049656,
"raErr": 0.00028,
"decErr": 0.00028,
"ra_dec_Cov": 0.00029,
"radecMjdTai": 1480360995,
"pmRa": 0.00013,
"pmDec": 0.00014,
"parallax": 2.124124,
"pmRaErr": 0.00013,
"pmDecErr": 0.00013,
"pmParallaxNdata": 0,
"parallaxErr": 0.00013,
"pmRa_pmDec_Cov": 0.00013,
"pmRa_parallax_Cov": 0.00013,
"pmDec_parallax_Cov": 0.00013,
"pmParallaxLnL": 0.00013,
"pmParallaxChi2": 0.00013,
"pmParallaxNdata": 1214
},
"ssObject": {
"ssObjectId":5364546,
"numObs": 10
}
}

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions python/lsst/alert/packet/schema/7/3/sample_data/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
import json
import lsst.alert.packet as packet
from datetime import datetime
import pandas as pd

with open("alert.json", "r") as f:
data = json.load(f)

data_time = datetime.now()

data['diaSource']['time_processed'] = pd.Timestamp(data_time)
data['diaObject']['validityStart'] = pd.Timestamp(data_time)

schema = packet.SchemaRegistry.from_filesystem(schema_root="lsst.v7_3.alert").get_by_version("7.3")
with open("fakeAlert.avro", "wb") as f:
schema.store_alerts(f, [data])
2 changes: 1 addition & 1 deletion python/lsst/alert/packet/schema/latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2
7.3
2 changes: 1 addition & 1 deletion python/lsst/alert/packet/schemaRegistry.py
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ def known_ids(self):
return set(self._ids)

@classmethod
def from_filesystem(cls, root=None, schema_root="lsst.v7_2.alert"):
def from_filesystem(cls, root=None, schema_root="lsst.v7_3.alert"):
"""Populate a schema registry based on the filesystem.
Walk the directory tree from the root provided, locating files named