Initial implementation of parsing PPBB blocks
This commit is contained in:
parent
ae57b24954
commit
ecdaf35c49
1 changed files with 38 additions and 0 deletions
|
@ -372,6 +372,44 @@ class RAOBObs():
|
|||
'samples': samples
|
||||
}
|
||||
|
||||
def parse_ppbb_samples(self, tokens: list[str]) -> dict:
|
||||
heights = tokens[0]
|
||||
|
||||
if heights[0] != '9':
|
||||
return dict()
|
||||
|
||||
tens = int(heights[1])
|
||||
h1 = (10000 * tens) + (1000 * int(heights[2]))
|
||||
h2 = (10000 * tens) + (1000 * int(heights[3]))
|
||||
h3 = (10000 * tens) + (1000 * int(heights[4]))
|
||||
|
||||
return {
|
||||
h1: self.parse_wind(tokens[1]),
|
||||
h2: self.parse_wind(tokens[2]),
|
||||
h3: self.parse_wind(tokens[3])
|
||||
}
|
||||
|
||||
def parse_ppbb(self) -> dict:
|
||||
timestamp = self.tokens[0]
|
||||
station = self.tokens[1]
|
||||
samples = list()
|
||||
|
||||
for i in range(2, len(self.tokens), 4):
|
||||
data = self.parse_ppbb_samples(self.tokens[i:i+4])
|
||||
|
||||
for height in data:
|
||||
samples.append({
|
||||
'height': height,
|
||||
'wind_speed': data[height]['speed'],
|
||||
'wind_dir': data[height]['dir']
|
||||
})
|
||||
|
||||
return {
|
||||
'station': station,
|
||||
'timestamp': timestamp,
|
||||
'samples': samples
|
||||
}
|
||||
|
||||
class RAOBChunk():
|
||||
def __init__(self,
|
||||
wfo: str,
|
||||
|
|
Loading…
Add table
Reference in a new issue