Skip to content

Commit

Permalink
Merge pull request #1361 from OpenGeoscience/update-hurricanes
Browse files Browse the repository at this point in the history
docs: Update hurricane data
  • Loading branch information
manthey authored Jan 27, 2025
2 parents 43f6135 + 2a743b5 commit 5c1a2c8
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/datastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var registry = {
'earthquakes.json': 'f098b6437411384b552419b4a36264c1bb3fed816ccfe9545145175e0b92a0b7ad5ebdcb9dddd0a12a90499143ffa471c02f6e049be5b973db607ff066892500',
'earthquakes-video.webm': '834a9d05f5fb00145e529fa4b217398db0df188c69d751f3869128b6e9c92d3000f85378752c56d9d9b5fa0870437dd9bdfeb5d62f6c87c2c03a7f1a20ee8523',
'grid.jpg': '60d201a14c7d31e7881301e6784e0372ddf27f26e5e4eafba9ba39158dfd050e3683faaa660fcde47e6c994dd3ee64c5a5231474ca75090053ef9207fedd9029',
'hurricanes.json': '012f15036bfc9ac3abb81a2a61e2c7b602ef3d8f7bd3b3f0fb66972ee69034730655f69febb2df5d657f22cd2b1e69170f6568bcbb03d7ebdecdfbafb80cc3b7',
'hurricanes.json': '0c44cca72c76ead45a2d8084acb3597db4827a880637e5957f1d986f7c2b57986d2bada824756a87e1de730e4078af0a0b6462539bb9d4f764271596a4965773',
'land_polygons.json': '30a828392d58678599130e0dca6d7f27e7e07e4e5b5d7f7a37871eb395d53d97b76134c0a07e805fbdfac0f42e6d3ca6e287c9727815a9dc711d541b1c8f68a1',
'land_shallow_topo_2048.png': '8a8330dba5bacdb511038ad0f6ee5a764a40aa7a8868a445749f653ae5d85d8317684ac706e7a9f049590170df6bc3fefc2912d52124d1b3b17aa43c529ff2a8',
'noaa_prcp.json': '07b4e12f0a31c0f48ca42545e61324941be7df24bd521541250969dd3f14f4400a362601ea9ecb4220d9d3b731f01d75cf9a998682c43afbc63cc4a16c2cba2e',
Expand Down
66 changes: 66 additions & 0 deletions scripts/update_hurricane_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# run this script and pipe to hurricanes.json; upload to CI server and change
# hash in scripts/datastore.js

import datetime
import json
import sys
import time

import pandas

basins = {
'NA': 'North Atlantic',
'EP': 'Eastern North Pacific',
'WP': 'Western North Pacific',
'NI': 'North Indian',
'SI': 'South Indian',
'SP': 'Southern Pacific',
'SA': 'South Atlantic',
}

url = 'https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r01/access/csv/ibtracs.since1980.list.v04r01.csv' # noqa

lastlog = time.time()
storms = {}
df = pandas.read_csv(url, keep_default_na=False)
for row in df.itertuples():
try:
sid = row.SID
name = row.NAME.title()
basin = basins[row.BASIN]
dist2land = float(row.DIST2LAND)
lon = float(row.LON)
lat = float(row.LAT)
pressure = float(row.WMO_PRES)
wind = float(row.WMO_WIND)
when = int(datetime.datetime.strptime(
row.ISO_TIME, '%Y-%m-%d %H:%M:%S').timestamp() * 1000)
except Exception:
continue
if wind <= 0 or pressure <= 0:
continue
if sid not in storms:
storms[sid] = {
'name': name, 'basin': basin, 'land': False,
'dist2land': [],
'longitude': [],
'latitude': [],
'pressure': [],
'wind': [],
'time': [],
}
storms[sid]['land'] = storms[sid]['land'] or dist2land <= 0
storms[sid]['dist2land'].append(dist2land)
storms[sid]['longitude'].append(lon)
storms[sid]['latitude'].append(lat)
storms[sid]['pressure'].append(pressure)
storms[sid]['wind'].append(wind)
storms[sid]['time'].append(when)
if time.time() - lastlog > 10:
sys.stderr.write(f'{len(storms)}\n')
lastlog = time.time()
sys.stderr.write(f'{len(storms)}\n')
results = [storm for storm in storms.values() if len(storm['time']) > 1]
sys.stderr.write(f'{len(results)}\n')
sys.stderr.write(f'NA {len([r for r in results if r["basin"] == "North Atlantic"])}\n')
print(json.dumps(results))

0 comments on commit 5c1a2c8

Please sign in to comment.