Store probabilities as floats

This commit is contained in:
XANTRONIX 2025-03-16 01:45:55 -04:00
parent 12442ad084
commit dc3e915c19
2 changed files with 13 additions and 6 deletions

View file

@ -154,7 +154,8 @@ create table xmet_spc_outlook_probability_area (
id INTEGER PRIMARY KEY NOT NULL, id INTEGER PRIMARY KEY NOT NULL,
outlook_id INTEGER NOT NULL, outlook_id INTEGER NOT NULL,
hazard TEXT NOT NULL, hazard TEXT NOT NULL,
probability INTEGER NOT NULL, probability FLOAT,
sig BOOLEAN NOT NULL DEFAULT FALSE,
FOREIGN KEY (outlook_id) REFERENCES xmet_spc_outlook (id) FOREIGN KEY (outlook_id) REFERENCES xmet_spc_outlook (id)
); );

View file

@ -112,14 +112,14 @@ class SPCOutlookArea(DatabaseTable):
class SPCOutlookProbabilityArea(SPCOutlookArea): class SPCOutlookProbabilityArea(SPCOutlookArea):
__slots__ = ( __slots__ = (
'hazard', 'probability', 'hazard', 'probability', 'sig',
) )
__table__ = 'xmet_spc_outlook_probability_area' __table__ = 'xmet_spc_outlook_probability_area'
__key__ = 'id' __key__ = 'id'
__columns__ = ( __columns__ = (
'id', 'outlook_id', 'hazard', 'probability', 'poly' 'id', 'outlook_id', 'hazard', 'probability', 'sig', 'poly'
) )
class SPCOutlookCategoryArea(SPCOutlookArea): class SPCOutlookCategoryArea(SPCOutlookArea):
@ -293,9 +293,15 @@ class SPCOutlookParser():
for poly in each_poly(self.points): for poly in each_poly(self.points):
if self.area_type == 'PROBABILISTIC': if self.area_type == 'PROBABILISTIC':
area = SPCOutlookProbabilityArea() area = SPCOutlookProbabilityArea()
area.hazard = self.hazard area.hazard = self.hazard
area.probability = self.category area.poly = poly
area.poly = poly
if self.category == 'SIGN':
area.probability = None
area.sig = True
else:
area.probability = float(self.category)
area.sig = False
self.outlook.probabilities.append(area) self.outlook.probabilities.append(area)
elif self.area_type == 'CATEGORICAL': elif self.area_type == 'CATEGORICAL':