Compare commits
No commits in common. "fb078eb7c44b6902b917f67c3d6cb9f267f4d65b" and "e0438ac8f98347c7838c97843915817bb621cf02" have entirely different histories.
fb078eb7c4
...
e0438ac8f9
3 changed files with 5 additions and 59 deletions
|
@ -18,8 +18,6 @@ parser.add_argument('igra-sounding-file', nargs='+', help='IGRA sounding file')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
db = Database.connect(args.db)
|
db = Database.connect(args.db)
|
||||||
|
|
||||||
if not args.dry_run:
|
|
||||||
db.execute('begin transaction')
|
db.execute('begin transaction')
|
||||||
|
|
||||||
for path in getattr(args, 'igra-sounding-file'):
|
for path in getattr(args, 'igra-sounding-file'):
|
||||||
|
@ -36,5 +34,4 @@ for path in getattr(args, 'igra-sounding-file'):
|
||||||
sample.sounding_id = sounding.id
|
sample.sounding_id = sounding.id
|
||||||
db.add(sample)
|
db.add(sample)
|
||||||
|
|
||||||
if not args.dry_run:
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
#! /usr/bin/env python3
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
from xmet.db import Database
|
|
||||||
from xmet.raob import RAOBReader
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description = 'Ingest RAOB 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('raob-sounding-file', nargs='+', help='RAOB sounding file')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
db = Database.connect(args.db)
|
|
||||||
|
|
||||||
if not args.dry_run:
|
|
||||||
db.execute('begin transaction')
|
|
||||||
|
|
||||||
for path in getattr(args, 'raob-sounding-file'):
|
|
||||||
if not args.quiet:
|
|
||||||
print(f"Ingesting sounding file {path}")
|
|
||||||
|
|
||||||
for sounding in RAOBReader.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)
|
|
||||||
|
|
||||||
if not args.dry_run:
|
|
||||||
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 = meters_second(float(token[0:3]) + base_dir)
|
wind_dir = float(token[0:3]) + base_dir
|
||||||
|
|
||||||
if token[3:5] == '//':
|
if token[3:5] == '//':
|
||||||
wind_speed = None
|
wind_speed = None
|
||||||
else:
|
else:
|
||||||
wind_speed = meters_second(float(token[3:5]) + base_speed)
|
wind_speed = float(token[3:5]) + base_speed
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'dir': wind_dir,
|
'dir': wind_dir,
|
||||||
'speed': wind_speed
|
'speed': meters_second(wind_speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
TTAA_PRESSURES = {
|
TTAA_PRESSURES = {
|
||||||
|
@ -379,14 +379,3 @@ class RAOBReader():
|
||||||
def each_sounding(self):
|
def each_sounding(self):
|
||||||
for chunk in self.each_chunk():
|
for chunk in self.each_chunk():
|
||||||
yield from chunk.each_sounding()
|
yield from chunk.each_sounding()
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def each_sounding_from_fh(fh: io.TextIOBase):
|
|
||||||
reader = RAOBReader(fh)
|
|
||||||
|
|
||||||
yield from reader.each_sounding()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def each_sounding_from_file(path: str):
|
|
||||||
with open(path, 'r') as fh:
|
|
||||||
yield from RAOBReader.each_sounding_from_fh(fh)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue