Don't try to convert None to meters/second
This commit is contained in:
parent
e0438ac8f9
commit
5dc8c90d17
2 changed files with 40 additions and 3 deletions
37
bin/xmet-raob-ingest
Executable file
37
bin/xmet-raob-ingest
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from xmet.db import Database
|
||||||
|
from xmet.igra import IGRAReader
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description = 'Ingest IGRA soundings'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument('--quiet', action='store_true', help='Suppress output')
|
||||||
|
parser.add_argument('--dry-run', action='store_true', help='Do not actually ingest data')
|
||||||
|
|
||||||
|
parser.add_argument('db', help='XMET SQLite3 database')
|
||||||
|
parser.add_argument('igra-sounding-file', nargs='+', help='IGRA sounding file')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
db = Database.connect(args.db)
|
||||||
|
db.execute('begin transaction')
|
||||||
|
|
||||||
|
for path in getattr(args, 'igra-sounding-file'):
|
||||||
|
if not args.quiet:
|
||||||
|
print(f"Ingesting sounding file {path}")
|
||||||
|
|
||||||
|
for sounding in IGRAReader.each_sounding_from_file(path):
|
||||||
|
if args.dry_run:
|
||||||
|
continue
|
||||||
|
|
||||||
|
db.add(sounding)
|
||||||
|
|
||||||
|
for sample in sounding.samples:
|
||||||
|
sample.sounding_id = sounding.id
|
||||||
|
db.add(sample)
|
||||||
|
|
||||||
|
db.commit()
|
|
@ -86,16 +86,16 @@ class RAOBObs():
|
||||||
if token[0:2] == '//':
|
if token[0:2] == '//':
|
||||||
wind_dir = None
|
wind_dir = None
|
||||||
else:
|
else:
|
||||||
wind_dir = float(token[0:3]) + base_dir
|
wind_dir = meters_second(float(token[0:3]) + base_dir)
|
||||||
|
|
||||||
if token[3:5] == '//':
|
if token[3:5] == '//':
|
||||||
wind_speed = None
|
wind_speed = None
|
||||||
else:
|
else:
|
||||||
wind_speed = float(token[3:5]) + base_speed
|
wind_speed = meters_second(float(token[3:5]) + base_speed)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'dir': wind_dir,
|
'dir': wind_dir,
|
||||||
'speed': meters_second(wind_speed)
|
'speed': wind_speed
|
||||||
}
|
}
|
||||||
|
|
||||||
TTAA_PRESSURES = {
|
TTAA_PRESSURES = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue