Ensure all samples are added to sounding

Ensure all samples are added to sounding, even if the sample lacks
either a pressure or a height
This commit is contained in:
XANTRONIX 2025-03-29 13:53:13 -04:00
parent 650718a00b
commit 8bea18af4d

View file

@ -60,8 +60,19 @@ class RAOBSounding():
sounding.timestamp_observed = timestamp sounding.timestamp_observed = timestamp
sounding.timestamp_released = timestamp - datetime.timedelta(minutes=45) sounding.timestamp_released = timestamp - datetime.timedelta(minutes=45)
seen = dict()
for pressure in sorted(self.samples_by_pressure.keys(), reverse=True): for pressure in sorted(self.samples_by_pressure.keys(), reverse=True):
sounding.samples.append(self.samples_by_pressure[pressure]) sample = self.samples_by_pressure[pressure]
seen[sample] = True
sounding.samples.append(sample)
for height in sorted(self.samples_by_height.keys()):
sample = self.samples_by_height[height]
if sample not in seen:
sounding.samples.append(sample)
return sounding return sounding
@ -94,7 +105,7 @@ class RAOBSounding():
return sample return sample
def record_height(self, pressure: float, height: float): def record_height(self, pressure: float, height: float):
if pressure is None: if height is None or pressure is None:
return return
sample = self.sample_by_pressure(pressure) sample = self.sample_by_pressure(pressure)