Skip to content

Commit

Permalink
wind gust graph
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpus committed Mar 13, 2022
1 parent e9dbb41 commit 916e6e6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
3 changes: 0 additions & 3 deletions eht_met_forecast/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ def read_wind(vex, gfs_cycle, basedir='.'):
data = pd.read_csv(f, **kwargs)
data['date'] = data['date_temp']
del data['date_temp']
if 'surface_wind' in data: # XXX remove me eventually
print('GREG fixup')
data['10m_wind'] = data['surface_wind']

return data

Expand Down
33 changes: 23 additions & 10 deletions scripts/lindy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def get_all_work(datadir, plotdir, gfs_cycles, stations, force=False):
me['00'].append(outname)
outname = '{}/{}/lindy_{}_{}.png'.format(plotdir, gfs_cycle, '00w', gfs_cycle)
me['00'].append(outname)
outname = '{}/{}/lindy_{}_{}.png'.format(plotdir, gfs_cycle, '00wg', gfs_cycle)
me['00'].append(outname)
outname = '{}/{}/lindy_{}_{}.png'.format(plotdir, gfs_cycle, '01', gfs_cycle)
me['00'].append(outname)
outname = '{}/{}/forecast.csv'.format(plotdir, gfs_cycle)
Expand Down Expand Up @@ -307,11 +309,9 @@ def do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=False, in

eu_data = None
if allest is None:
if name == '00w':
print('GREG 1')
if name in {'00w', '00wg'}:
wind_data = {}
for site in stations:
print('GREG 2')
wind_data[site] = eht_met_forecast.data.read_wind(site, gfs_cycle, basedir=datadir)
else:
eu_data = eht_met_forecast.data.read_eu() # ./tau255.txt
Expand Down Expand Up @@ -355,14 +355,22 @@ def do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=False, in
plt.plot(est.date.values, est.est_mean, label=label, alpha=0.75, lw=1.5, ls=ls)
some = True
elif name == '00w':
print('GREG 3')
if wind_data is not None and site in wind_data:
print('GREG 4')
wd = wind_data[site]
if wd is not None and '10m_wind' in wd:
print('GREG 5')
plt.plot(wd.date.values, wd['10m_wind'], ls=ls, label=label + ' 10m wind')
some = True
elif name == '00wg':
if wind_data is not None and site in wind_data:
wd = wind_data[site]
if wd is not None and 'wgust' in wd:
wd['wgust'].mask(wd['wgust'] < 10., np.NAN, inplace=True)
# always do the plot so that the colors/styles are consistent with the wind speed
label = label + ' wind gust'
if wd['wgust'].count() == 0:
label = None # but disappear the label if empty
plt.plot(wd.date.values, wd['wgust'], ls=ls, label=label)
some = True
else:
if eu_data is not None and site in eu_data:
plt.plot(eu_data.date.values, eu_data[site], ls=ls, label=label + ' EU')
Expand All @@ -381,11 +389,13 @@ def do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=False, in
plt.axvspan(d+pd.Timedelta(schedule_start), d+pd.Timedelta(schedule_end), color='black', alpha=0.05, zorder=-10)

# formatting
if name != '00w':
if name == '00w':
plt.ylim(0, 40.0) # 40 meters/sec ~ 90 mph
elif name == '00wg':
plt.ylim(0, 40.0) # 40 meters/sec ~ 90 mph
else:
plt.ylim(0, 1.0)
plt.yticks(np.arange(0, 1.0, .1))
else:
plt.ylim(0, 40.0) # 40 meters/sec ~ 90 mph
plt.gca().xaxis.set_major_locator(mdates.DayLocator())
plt.gca().fmt_xdata = mdates.DateFormatter('%Y-%m-%d')
# plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d')) # Lindy said this was needed on cloud machines?!
Expand All @@ -398,12 +408,14 @@ def do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=False, in
label = 'GFS ' + gfs_cycle
elif name == '00w':
label = 'GFS wind ' + gfs_cycle
elif name == '00wg':
label = 'GFS wind gust ' + gfs_cycle
else:
label = 'EU'
plt.gca().add_artist(AnchoredText(label, loc=2))

plt.xlabel('UT date')
if name == '00w':
if name in {'00w', '00wg'}:
plt.ylabel('meters/sec')
else:
plt.ylabel('tau225')
Expand Down Expand Up @@ -482,6 +494,7 @@ def get_one(s):
do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=args.force, include=emphasize, name='00')
do_00_plot(gfs_cycle, None, start, end, plotdir, stations, force=args.force, include=emphasize, name='00e')
do_00_plot(gfs_cycle, None, start, end, plotdir, stations, force=args.force, include=emphasize, name='00w', datadir=datadir)
do_00_plot(gfs_cycle, None, start, end, plotdir, stations, force=args.force, include=emphasize, name='00wg', datadir=datadir)
do_00_plot(gfs_cycle, allest, start, end, plotdir, stations, force=args.force, exclude=emphasize, name='01')

do_forecast_csv(gfs_cycle, allest, start, plotdir, emphasize=emphasize, force=args.force)
Expand Down
8 changes: 7 additions & 1 deletion scripts/make-jumbo-webpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
emphasize.add('00e')
if '00w' not in emphasize:
emphasize.add('00w')
if '00wg' not in emphasize:
emphasize.add('00wg')

stations = read_stations(args.stations)
stations['00'] = {'name': 'Current stations GFS weather'}
stations['00e'] = {'name': 'Current stations EU weather'}
stations['00w'] = {'name': 'Current stations GFS 10m wind'}
stations['00wg'] = {'name': 'Current stations GFS wind gusts > 10 m/s'}
stations['01'] = {'name': 'Future stations'}

for e in emphasize:
if e not in stations and e not in {'00', '00e', '00w'}:
if e not in stations and e not in {'00', '00e', '00w', '00wg'}:
raise ValueError('emphasized station {} is not known'.format(e))

env = Environment(
Expand Down Expand Up @@ -74,6 +77,9 @@
if f == 'lindy_00w.png':
# a symlink
continue
if f == 'lindy_00wg.png':
# a symlink
continue
parts = f.split('_')
if parts[0] in prefixes:
groups[parts[1]].append(f)
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<h2>{{ stuff.year }} Stations {{ stuff.gfs_cycle}}</h2>

{% for s, files in now.items() %}
<h3>{{ s }} {{ stuff.stations[s].name }}</h3>
<h3>{{ s }} {{ stuff.stations[s].name|escape }}</h3>
{%- for f in files -%}
{% if f.startswith('lindy') %}
<img style="width:1050px;" src="{{ f }}">
Expand Down

0 comments on commit 916e6e6

Please sign in to comment.