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

Update LSST schemas for v7 #70

Merged
merged 21 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Added

- Support for LSST schema versions 7.2, 7.3, and 7.4
- README.md describing where the new LSST alert schemas were obtained.
- Add '\_\_package_path__' as a package-level variable.
- Add test data for LSST and ZTF.
- Add unit tests for:
Expand All @@ -21,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Changed

- `schema.py` now specifies all schema versions that are available for LSST
- Schema mappings for new LSST alert versions incorporated into `schemas.yml`
- Implement `schema._ConfluentWireAvroSchema.serialize`.

## \[v0.3.11\] - 2024-07-22
Expand Down
67 changes: 59 additions & 8 deletions pittgoogle/registry_manifests/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,73 @@
path: 'schemas/elasticc/elasticc.v0_9_1.brokerClassification.avsc'
#
# LSST alerts
# [FIXME] Hacking in v7.1 for now. Need to figure out install lsst-alert-packet to use lsst_auto_schema_helper
# [FIXME] Hacking in v7.x for now. Need to figure out install lsst-alert-packet to use lsst_auto_schema_helper
# - name: 'lsst.v<MAJOR>_<MINOR>.alert'
# helper: 'lsst_auto_schema_helper'
- name: 'lsst.v7_4.alert'
path: 'schemas/lsst/7/4/lsst.v7_4.alert.avsc'
description: 'Schema for LSST alerts.'
origin: 'https://github.com/lsst/alert_packet/tree/main/python/lsst/alert/packet/schema'
helper: 'lsst_schema_helper'
filter_map:
1: 'u'
2: 'g'
3: 'r'
4: 'i'
5: 'z'
6: 'y'
#
- name: 'lsst.v7_3.alert'
path: 'schemas/lsst/7/3/lsst.v7_3.alert.avsc'
description: 'Schema for LSST alerts.'
origin: 'https://github.com/lsst/alert_packet/tree/main/python/lsst/alert/packet/schema'
helper: 'lsst_schema_helper'
filter_map:
1: 'u'
2: 'g'
3: 'r'
4: 'i'
5: 'z'
6: 'y'
#
- name: 'lsst.v7_2.alert'
path: 'schemas/lsst/7/2/lsst.v7_2.alert.avsc'
description: 'Schema for LSST alerts.'
origin: 'https://github.com/lsst/alert_packet/tree/main/python/lsst/alert/packet/schema'
helper: 'lsst_schema_helper'
filter_map:
1: 'u'
2: 'g'
3: 'r'
4: 'i'
5: 'z'
6: 'y'
#
- name: 'lsst.v7_1.alert'
path: 'schemas/lsst/7/1/lsst.v7_1.alert.avsc'
description: 'Schema for LSST alerts.'
origin: 'https://github.com/lsst/alert_packet/tree/main/python/lsst/alert/packet/schema'
helper: 'lsst_schema_helper'
# [FIXME] filter_map is probably int -> {u, g, r, i, z, y}. Check for sure and fill in below
filter_map:
1: ''
2: ''
3: ''
4: ''
5: ''
6: ''
1: 'u'
2: 'g'
3: 'r'
4: 'i'
5: 'z'
6: 'y'
#
- name: 'lsst.v7_0.alert'
path: 'schemas/lsst/7/0/lsst.v7_0.alert.avsc'
description: 'Schema for LSST alerts.'
origin: 'https://github.com/lsst/alert_packet/tree/main/python/lsst/alert/packet/schema'
helper: 'lsst_schema_helper'
filter_map:
1: 'u'
2: 'g'
3: 'r'
4: 'i'
5: 'z'
6: 'y'
#
# ZTF alerts
- name: 'ztf'
Expand Down
16 changes: 13 additions & 3 deletions pittgoogle/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,22 @@ def elasticc_schema_helper(schema_dict: dict) -> "_SchemalessAvroSchema":

@staticmethod
def lsst_schema_helper(schema_dict: dict) -> "_ConfluentWireAvroSchema":
"""Load the Avro schema definition for lsst.v7_1.alert."""
"""Load the Avro schema definition for lsst.v7_x.alert."""
# [FIXME] This is hack to get the latest schema version into pittgoogle-client
# until we can get :meth:`SchemaHelpers.lsst_auto_schema_helper` working.

if not schema_dict["name"] == "lsst.v7_1.alert":
raise NotImplementedError("Only 'lsst.v7_1.alert' is supported for LSST.")
supported_versions = [
"lsst.v7_0.alert",
"lsst.v7_1.alert",
"lsst.v7_2.alert",
"lsst.v7_3.alert",
"lsst.v7_4.alert",
]

if schema_dict.get("name") not in supported_versions:
raise exceptions.SchemaError(
f"Only {', '.join(supported_versions)} are supported for LSST."
)

schema = _ConfluentWireAvroSchema(**schema_dict)

Expand Down
24 changes: 24 additions & 0 deletions pittgoogle/schemas/lsst/7/2/lsst.v7_2.alert.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"namespace": "lsst.v7_2",
"type": "record",
"name": "alert",
"doc": "Rubin Avro alert schema v7.2",
"fields": [
{"name": "alertId", "type": "long", "doc": "unique alert identifer"},
{"name": "diaSource", "type": "lsst.v7_2.diaSource"},
{"name": "prvDiaSources", "type": ["null", {
"type": "array",
"items": "lsst.v7_2.diaSource"}], "default": null},
{"name": "prvDiaForcedSources", "type": ["null", {
"type": "array",
"items": "lsst.v7_2.diaForcedSource"}], "default": null},
{"name": "prvDiaNondetectionLimits", "type": ["null", {
"type": "array",
"items": "lsst.v7_2.diaNondetectionLimit"}], "default": null},
{"name": "diaObject", "type": ["null", "lsst.v7_2.diaObject"], "default": null},
{"name": "ssObject", "type": ["null", "lsst.v7_2.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 pittgoogle/schemas/lsst/7/2/lsst.v7_2.diaForcedSource.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"type": "record",
"namespace": "lsst.v7_2",
"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"
},
{
"default": null,
"doc": "Point Source model flux.",
"name": "psfFlux",
"type": [
"null",
"float"
]
},
{
"default": null,
"doc": "Uncertainty of psfFlux.",
"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"
},
{
"default": null,
"doc": "Filter band this source was observed with.",
"name": "band",
"type": [
"null",
"string"
]
}
]
}
11 changes: 11 additions & 0 deletions pittgoogle/schemas/lsst/7/2/lsst.v7_2.diaNondetectionLimit.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"namespace": "lsst.v7_2",
"name": "diaNondetectionLimit",
"type": "record",
"fields": [
{"name": "ccdVisitId", "type": "long"},
{"name": "midpointMjdTai", "type": "double"},
{"name": "band", "type": "string"},
{"name": "diaNoise", "type": "float"}
]
}
Loading