Allow fetching soundings by station ID
This commit is contained in:
parent
1ddc343487
commit
cda1413f2c
1 changed files with 12 additions and 10 deletions
|
@ -572,16 +572,13 @@ class RAOBReader():
|
|||
self.soundings = dict()
|
||||
|
||||
def sounding(self, station: str, timestamp: str) -> RAOBSounding:
|
||||
key = station + '.' + timestamp
|
||||
if station not in self.soundings:
|
||||
self.soundings[station] = dict()
|
||||
|
||||
if key in self.soundings:
|
||||
return self.soundings[key]
|
||||
if timestamp not in self.soundings[station]:
|
||||
self.soundings[station][timestamp] = RAOBSounding(station, timestamp)
|
||||
|
||||
sounding = RAOBSounding(station, timestamp)
|
||||
|
||||
self.soundings[key] = sounding
|
||||
|
||||
return sounding
|
||||
return self.soundings[station][timestamp]
|
||||
|
||||
def parse_chunk(self, text: str) -> RAOBChunk:
|
||||
meta = {
|
||||
|
@ -667,12 +664,17 @@ class RAOBReader():
|
|||
data.get('wind_speed'),
|
||||
data.get('wind_dir'))
|
||||
|
||||
for key in self.soundings:
|
||||
sounding = self.soundings[key].finish()
|
||||
def each_sounding_by_station(self, station: str):
|
||||
for timestamp in self.soundings[station]:
|
||||
sounding = self.soundings[station][timestamp].finish()
|
||||
|
||||
if sounding is not None:
|
||||
yield sounding
|
||||
|
||||
def each_sounding(self):
|
||||
for station in self.soundings:
|
||||
yield from self.each_sounding_by_station(station)
|
||||
|
||||
@staticmethod
|
||||
def each_sounding_from_fh(fh: io.TextIOBase):
|
||||
reader = RAOBReader(fh)
|
||||
|
|
Loading…
Add table
Reference in a new issue