Skip to content

Commit

Permalink
Merge pull request #580 from akrherz/231107-2
Browse files Browse the repository at this point in the history
mnt: expand SCAN processing
  • Loading branch information
akrherz authored Nov 9, 2023
2 parents d8040db + c5e5487 commit 4772028
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
3 changes: 1 addition & 2 deletions scripts/RUN_40_AFTER.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ cd ../iemplot
cd ../ingestors/squaw
python ingest_squaw.py

cd ../scan
python scan_ingest.py
python /opt/iem/scripts/scan/scan_ingest.py &

cd ../madis
python extract_madis.py
Expand Down
51 changes: 51 additions & 0 deletions scripts/scan/init_stations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Pull in what NRCS has for stations."""

import requests
from pyiem.database import get_dbconnc
from pyiem.network import Table as NetworkTable
from pyiem.util import convert_value


def main():
"""Go Main Go."""
mesosite, mcursor = get_dbconnc("mesosite")
nt = NetworkTable("SCAN", only_online=False)
entries = requests.get(
"https://wcc.sc.egov.usda.gov/awdbRestApi/services/v1/stations?"
"activeOnly=true&returnForecastPointMetadata=false&"
"returnReservoirMetadata=false&returnStationElements=false",
timeout=30,
).json()
for meta in entries:
if meta["networkCode"] != "SCAN":
continue
station = f"S{int(meta['stationId']):04d}"
if station in nt.sts:
continue
print(f"Adding {station} {meta['name']}")
mcursor.execute(
"INSERT into stations(id, name, network, online, country, "
"state, plot_name, elevation, metasite, geom) "
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, "
"ST_Point(%s, %s, 4326))",
(
station,
meta["name"],
"SCAN",
"t",
"US",
meta["stateCode"],
meta["name"],
convert_value(meta["elevation"], "foot", "meter"),
"f",
meta["longitude"],
meta["latitude"],
),
)
mcursor.close()
mesosite.commit()
mesosite.close()


if __name__ == "__main__":
main()
File renamed without changes.

0 comments on commit 4772028

Please sign in to comment.