Compare commits

...

3 commits

2 changed files with 35 additions and 21 deletions

View file

@ -33,14 +33,14 @@ for path in getattr(args, 'raob-sounding-file'):
if station is not None: if station is not None:
sounding.station = station.code sounding.station = station.code
if args.dry_run: if not args.dry_run:
continue db.add(sounding)
db.add(sounding)
for sample in sounding.samples: for sample in sounding.samples:
sample.sounding_id = sounding.id sample.sounding_id = sounding.id
db.add(sample)
if not args.dry_run:
db.add(sample)
if not args.dry_run: if not args.dry_run:
db.commit() db.commit()

View file

@ -111,26 +111,32 @@ class RAOBObs():
return None return None
def calc_1000mb_height(self, height: float) -> float: def calc_1000mb_height(self, value: float) -> float:
if height >= 500: if value >= 500:
return 0 - (height - 500) return 0 - (value - 500)
return height return value
def calc_850mb_height(self, height: float) -> float: def calc_850mb_height(self, value: float) -> float:
return 1000.0 + height return 1000.0 + value
def calc_500mb_height(self, height: float) -> float: def calc_700mb_height(self, value: float) -> float:
return 10.0 * height if value >= 500:
return 2000.0 + value
def calc_250mb_height(self, height: float) -> float:
if height >= 500:
return height * 10
else: else:
return 10.0 * (1000.0 + height) return 3000.0 + value
def calc_100mb_height(self, height: float) -> float: def calc_500mb_height(self, value: float) -> float:
return 10.0 * (1000.0 + height) return 10.0 * value
def calc_250mb_height(self, value: float) -> float:
if value >= 500:
return value * 10
else:
return 10.0 * (1000.0 + value)
def calc_100mb_height(self, value: float) -> float:
return 10.0 * (1000.0 + value)
def parse_height_pressure(self, token: str): def parse_height_pressure(self, token: str):
code = token[0:2] code = token[0:2]
@ -154,8 +160,10 @@ class RAOBObs():
return None return None
elif pressure == 1000: elif pressure == 1000:
height = self.calc_1000mb_height(float(num)) height = self.calc_1000mb_height(float(num))
elif pressure <= 850 and pressure > 500: elif pressure <= 850 and pressure > 700:
height = self.calc_850mb_height(float(num)) height = self.calc_850mb_height(float(num))
elif pressure <= 700 and pressure > 500:
height = self.calc_700mb_height(float(num))
elif pressure <= 500 and pressure > 250: elif pressure <= 500 and pressure > 250:
height = self.calc_500mb_height(float(num)) height = self.calc_500mb_height(float(num))
elif pressure <= 250 and pressure > 100: elif pressure <= 250 and pressure > 100:
@ -254,6 +262,12 @@ class RAOBObs():
if len(self.tokens) < i+3 or self.tokens[i][-1] == '=': if len(self.tokens) < i+3 or self.tokens[i][-1] == '=':
break break
#
# Stop parsing tokens at the tropopause.
#
if self.tokens[i][0:2] == '88':
break
sample = self.parse_sample_tokens(self.tokens[i:i+3]) sample = self.parse_sample_tokens(self.tokens[i:i+3])
if sample is None: if sample is None: