Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 1103ffe

Browse files
author
Aodhan Sweeney
committed
adding final changes to modulo formatting.
Deleting images.json and BM.jpeg images because it was not conducive to actual example, now Hurricanes are plotted on a basic Cartopy image Deleting Blue Marble feature of HurricaneTracker.py
1 parent 369454b commit 1103ffe

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

examples/BM.jpeg

-2.35 MB
Binary file not shown.

examples/HurricaneTracker.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import gzip
1515
from io import BytesIO
1616
from io import StringIO
17-
import os
1817

1918
import cartopy.crs as ccrs
2019
import ipywidgets as widgets
@@ -149,11 +148,11 @@ def get_tracks(self, track_button):
149148
data_dictionary = {}
150149
# Current year data is stored in a different location
151150
if year == '2019':
152-
urlf = 'http://ftp.nhc.noaa.gov/atcf/aid_public/a%8s.dat.gz' % (filename)
153-
urlb = 'http://ftp.nhc.noaa.gov/atcf/btk/b%8s.dat' % (filename)
151+
urlf = 'http://ftp.nhc.noaa.gov/atcf/aid_public/a{}.dat.gz'.format(filename)
152+
urlb = 'http://ftp.nhc.noaa.gov/atcf/btk/b{}.dat'.format(filename)
154153
else:
155-
urlf = 'http://ftp.nhc.noaa.gov/atcf/archive/%4s/a%8s.dat.gz' % (year, filename)
156-
urlb = 'http://ftp.nhc.noaa.gov/atcf/archive/%4s/b%8s.dat.gz' % (year, filename)
154+
urlf = 'http://ftp.nhc.noaa.gov/atcf/archive/{}/a{}.dat.gz'.format(year, filename)
155+
urlb = 'http://ftp.nhc.noaa.gov/atcf/archive/{}/b{}.dat.gz'.format(year, filename)
157156

158157
url_links = [urlf, urlb]
159158
url_count = 0
@@ -202,7 +201,7 @@ def get_tracks(self, track_button):
202201
data_dictionary['best_track'] = storm_data_frame
203202

204203
else:
205-
print('url %s was not valid, select different storm.' % url)
204+
print('url {} was not valid, select different storm.'.format(url))
206205
track_button = False
207206

208207
url_count += 1
@@ -255,7 +254,6 @@ def plotting(self, plot_slider):
255254
selected models. These tracks are then plotted on the Blue Marble projection. """
256255

257256
if self.plot_slider.disabled is False:
258-
259257
# Identifying the time associated with the models for time text box
260258
year = self.date_times[plot_slider][0: 4]
261259
month = self.date_times[plot_slider][4: 6]
@@ -271,26 +269,21 @@ def plotting(self, plot_slider):
271269
min_best_lon = min(self.best_lons)
272270
max_best_lon = max(self.best_lons)
273271

274-
# Plotting the track above a NASA Blue Marble projection
275-
current_path = os.getcwd()
276-
os.environ['CARTOPY_USER_BACKGROUNDS'] = current_path
272+
# Plotting the track on a cartopy stock image
277273
self.fig = plt.figure(figsize=(14, 11))
278274
self.ax = self.fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
279-
self.ax.background_img(name='BM', resolution='low')
280-
275+
self.ax.stock_img()
281276
self.data_projection = ccrs.PlateCarree()
282277
self.ax.plot(self.best_lons, self.best_lats, marker='o', color='white',
283278
label='Best Track', transform=self.data_projection)
284279
self.ax.set_extent([(min_best_lon - 30), (max_best_lon + 30),
285280
(min_best_lat - 30), (max_best_lat + 30)])
286-
287281
jet = plt.get_cmap('jet')
288282
colors = iter(jet(np.linspace(0.2, 1, (len(self.model_select.value)+1))))
289283
left = .1
290284
bottom = .1
291285
self.ax.text(left, bottom, time_string, transform=self.ax.transAxes,
292-
fontsize=14, color='white')
293-
286+
fontsize=14, color='black')
294287
for model_type in self.model_table:
295288
one_model_time = model_type[model_type['WarnDT'] ==
296289
self.date_times[plot_slider]]
@@ -300,7 +293,6 @@ def plotting(self, plot_slider):
300293
model_list = model_type['Model'].tolist()
301294
self.ax.plot(lons, lats, marker='o', color=next(colors),
302295
label=model_list[0])
303-
304296
plt.title('Storm Name: {0} Year: {1}'.format(self.storm_names.value,
305297
str(self.year_slider.value)))
306298
plt.legend()

examples/images.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)