From 1876749907f3573b71e7cb4a2316be6d3c131a4a Mon Sep 17 00:00:00 2001 From: XANTRONIX Industrial Date: Fri, 21 Feb 2025 00:10:49 -0500 Subject: [PATCH] Fully implement parsing of hydrological VTEC events --- db/nexrad.sql | 17 ++++++++++------- lib/nexrad/afos.py | 35 +++++++++++++++++++++++++---------- lib/nexrad/vtec.py | 20 +++++++++++--------- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/db/nexrad.sql b/db/nexrad.sql index b338651..b0f29b6 100644 --- a/db/nexrad.sql +++ b/db/nexrad.sql @@ -49,14 +49,17 @@ create table nexrad_afos_message ( timestamp_start TIMESTAMP NOT NULL, timestamp_end TIMESTAMP NOT NULL, serial INTEGER NOT NULL, - product TEXT NOT NULL, - vtec_type TEXT NOT NULL, - actions TEXT NOT NULL, - wfo TEXT NOT NULL, - phenom TEXT NOT NULL, - sig TEXT NOT NULL, - etn INTEGER NOT NULL, text_raw TEXT NOT NULL, + product TEXT NOT NULL, + wfo TEXT NOT NULL, + vtec_type TEXT, + actions TEXT, + phenom TEXT, + sig TEXT, + etn INTEGER, + hydro_severity TEXT, + hydro_cause TEXT, + hydro_record TEXT, azimuth FLOAT NOT NULL, speed FLOAT NOT NULL, forecaster TEXT NOT NULL diff --git a/lib/nexrad/afos.py b/lib/nexrad/afos.py index 2101036..23ccea8 100644 --- a/lib/nexrad/afos.py +++ b/lib/nexrad/afos.py @@ -5,7 +5,7 @@ import shapely from nexrad.db import DatabaseTable from nexrad.coord import COORD_SYSTEM -from nexrad.vtec import VTECEvent +from nexrad.vtec import VTECEvent, VTECHydroEvent RE_ID = re.compile(r'^(\d+)$') @@ -123,18 +123,24 @@ class AFOSMessage(DatabaseTable): timestamp_start: datetime.datetime timestamp_end: datetime.datetime - product: str - vtec_type: str - actions: str - wfo: str - phenom: str - sig: str - etn: int - text_raw: str + text_raw: str + product: str + wfo: str + + vtec_type: str + actions: str + phenom: str + sig: str + etn: int + + hydro_severity: str + hydro_cause: str + hydro_record: str + azimuth: int speed: int - location: shapely.Point forecaster: str + location: shapely.Point poly: shapely.Geometry def __init__(self): @@ -207,6 +213,15 @@ class AFOSMessageParser(): self.message.sig = vtec.sig self.message.etn = vtec.etn + vtec = VTECHydroEvent.parse(line) + + if vtec is not None: + self.message.timestamp_start = vtec.timestamp_start + self.message.timestamp_end = vtec.timestamp_end + self.message.hydro_severity = vtec.severity + self.message.hydro_cause = vtec.cause + self.message.hydro_record = vtec.record + def parse_serial(self, line: str): match = RE_ID.match(line) diff --git a/lib/nexrad/vtec.py b/lib/nexrad/vtec.py index c136a6b..f3400eb 100644 --- a/lib/nexrad/vtec.py +++ b/lib/nexrad/vtec.py @@ -60,12 +60,13 @@ class VTECEventType(enum.StrEnum): EXPERIMENTAL_VTEC = 'X' class VTECEvent(): - typeof: str - actions: str - wfo: str - phenom: str - sig: str - etn: int + typeof: str + actions: str + wfo: str + phenom: str + sig: str + etn: int + timestamp_start: datetime.datetime timestamp_end: datetime.datetime @@ -94,9 +95,10 @@ class VTECHydroEvent(): 'severity', 'cause', 'record', 'timestamp_start', 'timestamp_end' ) - severity: str - cause: str - record: str + severity: str + cause: str + record: str + timestamp_start: datetime.datetime timestamp_end: datetime.datetime