Compare commits
3 commits
8acce6d76a
...
72574b1faf
Author | SHA1 | Date | |
---|---|---|---|
72574b1faf | |||
951ec6b48b | |||
60f5093c63 |
5 changed files with 29 additions and 16 deletions
|
@ -23,8 +23,8 @@ RUN sqlite3 -init /tmp/xmet.sql /var/lib/xmet/xmet.db .quit
|
||||||
|
|
||||||
RUN /var/opt/xmet/bin/xmet-db-init \
|
RUN /var/opt/xmet/bin/xmet-db-init \
|
||||||
/var/lib/xmet/xmet.db \
|
/var/lib/xmet/xmet.db \
|
||||||
/tmp/radars.tsv \
|
--radars-tsv /tmp/radars.tsv \
|
||||||
/tmp/wfo.tsv \
|
--wfo-tsv /tmp/wfo.tsv \
|
||||||
/tmp/igra2-station-list.txt
|
--igra-stations /tmp/igra2-station-list.txt
|
||||||
|
|
||||||
ENTRYPOINT ["/var/opt/xmet/bin/xmet-nexrad-archive", "/var/lib/xmet/xmet.db"]
|
ENTRYPOINT ["/var/opt/xmet/bin/xmet-nexrad-archive", "/var/lib/xmet/xmet.db"]
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -9,7 +9,6 @@ DB_INIT = ./bin/xmet-db-init
|
||||||
DB_INIT_RADARS = doc/radars.tsv
|
DB_INIT_RADARS = doc/radars.tsv
|
||||||
DB_INIT_WFO = doc/wfo.tsv
|
DB_INIT_WFO = doc/wfo.tsv
|
||||||
DB_INIT_IGRA = doc/igra2-station-list.txt
|
DB_INIT_IGRA = doc/igra2-station-list.txt
|
||||||
DB_INIT_FILES = $(DB_INIT_RADARS) $(DB_INIT_WFO) $(DB_INIT_IGRA)
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(DOCKER) image build --tag $(DOCKER_TAG) .
|
$(DOCKER) image build --tag $(DOCKER_TAG) .
|
||||||
|
@ -17,7 +16,9 @@ all:
|
||||||
db-init:
|
db-init:
|
||||||
$(RM) $(SQLITE_DB)
|
$(RM) $(SQLITE_DB)
|
||||||
$(SQLITE) -init $(SQLITE_SCHEMA) $(SQLITE_DB) .quit
|
$(SQLITE) -init $(SQLITE_SCHEMA) $(SQLITE_DB) .quit
|
||||||
$(DB_INIT) $(SQLITE_DB) $(DB_INIT_FILES)
|
$(DB_INIT) $(SQLITE_DB) --radars-tsv $(DB_INIT_RADARS) \
|
||||||
|
--wfo-tsv $(DB_INIT_WFO) \
|
||||||
|
--igra-stations $(DB_INIT_IGRA)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(DOCKER) rmi $(DOCKER_TAG)
|
$(DOCKER) rmi $(DOCKER_TAG)
|
||||||
|
|
|
@ -12,9 +12,10 @@ parser = argparse.ArgumentParser(
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('db', help='Path to SQLite3 database')
|
parser.add_argument('db', help='Path to SQLite3 database')
|
||||||
parser.add_argument('radars-tsv', help='Path to NEXRAD radar station TSV file')
|
|
||||||
parser.add_argument('wfo-tsv', help='Path to forecast office TSV file')
|
parser.add_argument('--radars-tsv', type=str, help='Path to NEXRAD radar station TSV file')
|
||||||
parser.add_argument('igra-stations', help='Path to IGRA station list')
|
parser.add_argument('--wfo-tsv', type=str, help='Path to forecast office TSV file')
|
||||||
|
parser.add_argument('--igra-stations', type=str, help='Path to IGRA station list')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -22,13 +23,16 @@ db = Database.connect(args.db)
|
||||||
|
|
||||||
db.execute('begin transaction')
|
db.execute('begin transaction')
|
||||||
|
|
||||||
for radar in Radar.each_from_tsv(getattr(args, 'radars-tsv')):
|
if args.radars_tsv is not None:
|
||||||
|
for radar in Radar.each_from_tsv(args.radars_tsv):
|
||||||
db.add(radar)
|
db.add(radar)
|
||||||
|
|
||||||
for wfo in WFO.each_from_tsv(getattr(args, 'wfo-tsv')):
|
if args.wfo_tsv is not None:
|
||||||
|
for wfo in WFO.each_from_tsv(args.wfo_tsv):
|
||||||
db.add(wfo)
|
db.add(wfo)
|
||||||
|
|
||||||
for station in IGRAStation.each_from_file(getattr(args, 'igra-stations')):
|
if args.igra_stations is not None:
|
||||||
|
for station in IGRAStation.each_from_file(args.igra_stations):
|
||||||
db.add(station)
|
db.add(station)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
|
@ -95,7 +95,7 @@ create table xmet_igra_station (
|
||||||
year_start INTEGER NOT NULL,
|
year_start INTEGER NOT NULL,
|
||||||
year_end INTEGER NOT NULL,
|
year_end INTEGER NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
state TEXT NOT NULL,
|
state TEXT,
|
||||||
elevation FLOAT NOT NULL
|
elevation FLOAT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -113,6 +113,9 @@ create table xmet_sounding (
|
||||||
data_source_other TEXT NOT NULL
|
data_source_other TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create index xmet_sounding_station_idx on xmet_sounding (station);
|
||||||
|
create index xmet_sounding_timestamp_observed_released_idx on xmet_sounding (timestamp_observed, timestamp_released);
|
||||||
|
|
||||||
select AddGeometryColumn('xmet_sounding', 'location', 4326, 'POINT'),
|
select AddGeometryColumn('xmet_sounding', 'location', 4326, 'POINT'),
|
||||||
CreateSpatialIndex('xmet_sounding', 'location');
|
CreateSpatialIndex('xmet_sounding', 'location');
|
||||||
|
|
||||||
|
@ -134,4 +137,6 @@ create table xmet_sounding_sample (
|
||||||
FOREIGN KEY (sounding_id) REFERENCES xmet_sounding (id)
|
FOREIGN KEY (sounding_id) REFERENCES xmet_sounding (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create index xmet_sounding_sample_sounding_id_idx on xmet_sounding_sample (sounding_id);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
|
@ -243,6 +243,9 @@ class IGRAStation(DatabaseTable):
|
||||||
station.elevation = float(cols(line, 32, 37))
|
station.elevation = float(cols(line, 32, 37))
|
||||||
station.location = shapely.Point(lon, lat)
|
station.location = shapely.Point(lon, lat)
|
||||||
|
|
||||||
|
if station.state == '':
|
||||||
|
station.state = None
|
||||||
|
|
||||||
return station
|
return station
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Add table
Reference in a new issue