Get better at parsing heights at different pressures
This commit is contained in:
parent
16693a686b
commit
d1269d0e2f
1 changed files with 50 additions and 21 deletions
|
@ -110,36 +110,61 @@ class RawinsObs():
|
||||||
'speed': wind_speed
|
'speed': wind_speed
|
||||||
}
|
}
|
||||||
|
|
||||||
TTAA_HEIGHTS = {
|
TTAA_PRESSURES = {
|
||||||
'00': 1000, '92': 925, '85': 850,
|
'00': 1000, '92': 925, '85': 850,
|
||||||
'70': 700, '50': 500, '40': 400,
|
'70': 700, '50': 500, '40': 400,
|
||||||
'30': 300, '25': 250, '20': 200,
|
'30': 300, '25': 250, '20': 200,
|
||||||
'15': 150, '10': 100,
|
'15': 150, '10': 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
def calc_1000mb_height(self, num: float):
|
def code_to_pressure(self, code: str):
|
||||||
if num >= 500:
|
if code in self.TTAA_PRESSURES:
|
||||||
return 0 - (num - 500)
|
return self.TTAA_PRESSURES[code]
|
||||||
|
|
||||||
return num
|
return None
|
||||||
|
|
||||||
|
def calc_1000mb_height(self, height: float) -> float:
|
||||||
|
if height >= 500:
|
||||||
|
return 0 - (height - 500)
|
||||||
|
|
||||||
|
return height
|
||||||
|
|
||||||
|
def calc_850mb_height(self, height: float) -> float:
|
||||||
|
return 1000.0 + height
|
||||||
|
|
||||||
|
def calc_500mb_height(self, height: float) -> float:
|
||||||
|
print(f"Calculating 500mb height")
|
||||||
|
return 10 * height
|
||||||
|
|
||||||
def parse_height_pressure(self, value: str):
|
def parse_height_pressure(self, value: str):
|
||||||
token = value[0:2]
|
code = value[0:2]
|
||||||
num = value[2:5]
|
num = value[2:5]
|
||||||
|
|
||||||
if num == '///':
|
if num == '///':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if token == '00':
|
#
|
||||||
return {
|
# Ignore the tropopause or height of max wind velocity.
|
||||||
'height': self.calc_1000mb_height(float(num)),
|
#
|
||||||
'pressure': 1000
|
if code == '77' or code == '88':
|
||||||
}
|
return None
|
||||||
|
|
||||||
|
pressure = self.code_to_pressure(code)
|
||||||
|
|
||||||
|
if pressure is None:
|
||||||
|
return None
|
||||||
|
elif pressure == 1000:
|
||||||
|
height = self.calc_1000mb_height(float(num))
|
||||||
|
elif pressure <= 500:
|
||||||
|
height = self.calc_500mb_height(float(num))
|
||||||
|
elif pressure <= 850:
|
||||||
|
height = self.calc_850mb_height(float(num))
|
||||||
|
else:
|
||||||
|
height = float(num)
|
||||||
|
|
||||||
if token in self.TTAA_HEIGHTS:
|
|
||||||
return {
|
return {
|
||||||
'height': float(num),
|
'pressure': pressure,
|
||||||
'pressure': self.TTAA_HEIGHTS[token]
|
'height': height
|
||||||
}
|
}
|
||||||
|
|
||||||
PRESSURE_SIG = {
|
PRESSURE_SIG = {
|
||||||
|
@ -148,17 +173,21 @@ class RawinsObs():
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_significant_pressure(self, value: str):
|
def parse_significant_pressure(self, value: str):
|
||||||
if value[0:2] in self.PRESSURE_SIG:
|
code, pressure = value[0:2], value[2:5]
|
||||||
|
|
||||||
|
if code in self.PRESSURE_SIG:
|
||||||
return {
|
return {
|
||||||
'height': None,
|
'height': None,
|
||||||
'pressure': float(value[2:5])
|
'pressure': float(pressure)
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_surface_pressure(self, value: str):
|
def parse_surface_pressure(self, value: str):
|
||||||
if value[0:2] == '99':
|
code, pressure = value[0:2], value[2:5]
|
||||||
|
|
||||||
|
if code == '99':
|
||||||
return {
|
return {
|
||||||
'height': None,
|
'height': None,
|
||||||
'pressure': float(value[2:5])
|
'pressure': float(pressure)
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_sample_values(self, values: list[str]) -> RawinsSample:
|
def parse_sample_values(self, values: list[str]) -> RawinsSample:
|
||||||
|
|
Loading…
Add table
Reference in a new issue