s/station/radar/g
This commit is contained in:
parent
420456f028
commit
12ead19918
3 changed files with 16 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
||||||
begin transaction;
|
begin transaction;
|
||||||
|
|
||||||
create table nexrad_station (
|
create table nexrad_radar (
|
||||||
id INTEGER PRIMARY KEY NOT NULL,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
wban INTEGER,
|
wban INTEGER,
|
||||||
call TEXT NOT NULL,
|
call TEXT NOT NULL,
|
||||||
|
@ -10,7 +10,7 @@ create table nexrad_station (
|
||||||
);
|
);
|
||||||
|
|
||||||
select AddGeometryColumn(
|
select AddGeometryColumn(
|
||||||
'nexrad_station', 'coord', 4326, 'POINT', 'XY'
|
'nexrad_radar', 'coord', 4326, 'POINT', 'XY'
|
||||||
);
|
);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import re
|
||||||
from nexrad.coord import Coord, COORD_SYSTEM
|
from nexrad.coord import Coord, COORD_SYSTEM
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Implements a parser and wrapper class for the WSR-88D station list
|
Implements a parser and wrapper class for the WSR-88D radar list
|
||||||
available at the following location (accessed 10 Feb 2025):
|
available at the following location (accessed 10 Feb 2025):
|
||||||
|
|
||||||
https://apollo.nvu.vsc.edu/classes/remote/lecture_notes/radar/88d/88D_locations.html
|
https://apollo.nvu.vsc.edu/classes/remote/lecture_notes/radar/88d/88D_locations.html
|
||||||
|
@ -38,7 +38,7 @@ def parse(text: str):
|
||||||
|
|
||||||
return Coord(sign_lat * lat, sign_lon * lon)
|
return Coord(sign_lat * lat, sign_lon * lon)
|
||||||
|
|
||||||
class Station():
|
class Radar():
|
||||||
__slots__ = 'wban', 'call', 'name', 'coord', 'site_elevation', 'tower_height',
|
__slots__ = 'wban', 'call', 'name', 'coord', 'site_elevation', 'tower_height',
|
||||||
|
|
||||||
wban: int
|
wban: int
|
||||||
|
@ -50,15 +50,15 @@ class Station():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_tsv_row(row: list):
|
def from_tsv_row(row: list):
|
||||||
station = Station()
|
radar = Radar()
|
||||||
station.wban = int(row[0]) if row[0] != 'PENDING' else None
|
radar.wban = int(row[0]) if row[0] != 'PENDING' else None
|
||||||
station.call = row[1]
|
radar.call = row[1]
|
||||||
station.name = row[2]
|
radar.name = row[2]
|
||||||
station.coord = parse(row[3])
|
radar.coord = parse(row[3])
|
||||||
station.site_elevation = 0.3048 * float(row[4])
|
radar.site_elevation = 0.3048 * float(row[4])
|
||||||
station.tower_height = float(row[5])
|
radar.tower_height = float(row[5])
|
||||||
|
|
||||||
return station
|
return radar
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def each_from_tsv(file: str):
|
def each_from_tsv(file: str):
|
||||||
|
@ -69,11 +69,11 @@ class Station():
|
||||||
for i in range(0, len(row)):
|
for i in range(0, len(row)):
|
||||||
row[i] = row[i].rstrip()
|
row[i] = row[i].rstrip()
|
||||||
|
|
||||||
yield Station.from_tsv_row(row)
|
yield Radar.from_tsv_row(row)
|
||||||
|
|
||||||
def add_to_db(self, db):
|
def add_to_db(self, db):
|
||||||
sql = """
|
sql = """
|
||||||
insert into nexrad_station (
|
insert into nexrad_radar (
|
||||||
wban, call, name, site_elevation, tower_height, coord
|
wban, call, name, site_elevation, tower_height, coord
|
||||||
) values (
|
) values (
|
||||||
?, ?, ?, ?, ?, MakePoint(?, ?, %d)
|
?, ?, ?, ?, ?, MakePoint(?, ?, %d)
|
|
@ -113,14 +113,14 @@ class StormReport():
|
||||||
def is_radar_significant(self):
|
def is_radar_significant(self):
|
||||||
return self.event_type in self.RADAR_SIGNIFICANT_EVENT_TYPES
|
return self.event_type in self.RADAR_SIGNIFICANT_EVENT_TYPES
|
||||||
|
|
||||||
def nearest_station(self, db):
|
def nearest_radars(self, db):
|
||||||
sql = """
|
sql = """
|
||||||
select
|
select
|
||||||
id,
|
id,
|
||||||
call,
|
call,
|
||||||
ST_Distance(coord, MakePoint(?, ?, %d), true) as distance
|
ST_Distance(coord, MakePoint(?, ?, %d), true) as distance
|
||||||
from
|
from
|
||||||
nexrad_station
|
nexrad_radar
|
||||||
where
|
where
|
||||||
distance <= 460000
|
distance <= 460000
|
||||||
order by
|
order by
|
||||||
|
|
Loading…
Add table
Reference in a new issue