-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorm.py
827 lines (748 loc) · 42.8 KB
/
storm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
#Import necessary packages:
import numpy as np
import matplotlib.pyplot as plt
import cartopy as ccrs
import cartopy.feature as cfeature
from datetime import datetime, timedelta
import cartopy.io.shapereader as shpreader
import geopandas as gpd
import matplotlib.patches as mpatches
import pandas as pd
import warnings
from wedgj import wedgj_utils
###########################################
# #
# storm #
# #
###########################################
class storm:
def __init__(self):
self.date = datetime.utcnow()
###--------- Storm Reports Function ---------###
def storm_reports(self, date = None, spath = None, domain = 'CONUS', report_type = 'All', data = None, data_cint = None, data_levels = None):
if date == None:
date = self.date
#Ignore download warnings for cartopy shapefiles:
warnings.filterwarnings("ignore")
### Get Data:
tornado_reports = pd.read_csv(f'https://spc.noaa.gov/climo/reports/{date.strftime("%y%m%d")}_rpts_torn.csv')
wind_reports = pd.read_csv(f'https://spc.noaa.gov/climo/reports/{date.strftime("%y%m%d")}_rpts_wind.csv')
hail_reports = pd.read_csv(f'https://spc.noaa.gov/climo/reports/{date.strftime("%y%m%d")}_rpts_hail.csv')
figsize_table = wedgj_utils.figsize_table(self)
#Make figure:
fig, ax = plt.subplots(figsize = figsize_table[domain], subplot_kw = {'projection' : ccrs.crs.PlateCarree()})
extent_table = wedgj_utils.extent_table(self)
#Add cartopy boundaries::
try:
ax.set_extent(extent_table[domain])
except:
ax.set_extent(extent_table['CONUS'])
print('Invalid Domain Input. Setting extent to CONUS.')
#Count total reports in domain:
extent = extent_table[domain]
torn_total = np.sum((tornado_reports['Lon'] > extent[0]) & (tornado_reports['Lon'] < extent[1]) & (tornado_reports['Lat'] > extent[2]) & (tornado_reports['Lat'] < extent[3]))
wind_total = np.sum((wind_reports['Lon'] > extent[0]) & (wind_reports['Lon'] < extent[1]) & (wind_reports['Lat'] > extent[2]) & (wind_reports['Lat'] < extent[3]))
hail_total = np.sum((hail_reports['Lon'] > extent[0]) & (hail_reports['Lon'] < extent[1]) & (hail_reports['Lat'] > extent[2]) & (hail_reports['Lat'] < extent[3]))
#Add legend:
patch_torn = mpatches.Patch(edgecolor = 'black', label = f'Tornado Reports ({torn_total})', facecolor='tab:red')
patch_wind = mpatches.Patch(edgecolor = 'black', label = f'Wind Reports ({wind_total})', facecolor='tab:blue')
patch_hail = mpatches.Patch(edgecolor= 'black', label = f'Hail Reports ({hail_total})', facecolor='tab:green')
if report_type == 'All':
ax.legend(handles = [patch_torn, patch_wind, patch_hail], loc = (0.01,0.01), ncol = 3, fontsize = 8)
elif report_type == 'Tornado':
ax.legend(handles = [patch_torn], loc = (0.01,0.01), fontsize = 8)
elif report_type == 'Wind':
ax.legend(handles = [patch_wind], loc = (0.01,0.01), fontsize = 8)
elif report_type == 'Hail':
ax.legend(handles = [patch_hail], loc = (0.01,0.01), fontsize = 8)
### Add data ###
if data != None:
ax.contourf(data['lons'], data['lats'], data['values'], cmap='turbo', extend = 'max', levels = data_levels)
data_plot = ax.contour(data['lons'], data['lats'], data['values'], data_cint, colors = 'black', linewidths = 0.75, linestyles = '-')
ax.clabel(data_plot, fontsize = 10, inline = 1, inline_spacing = 5, fmt = '%i', rightside_up = True, use_clabeltext = True)
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles, labels, loc='lower right', ncol=1)
#Add reports:
if report_type == 'All':
try:
ax.scatter(hail_reports['Lon'], hail_reports['Lat'], color = 'tab:green', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Hail Reports', zorder = 10)
except:
pass
try:
ax.scatter(wind_reports['Lon'], wind_reports['Lat'], color = 'tab:blue', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Wind Reports', zorder = 10)
except:
pass
try:
ax.scatter(tornado_reports['Lon'], tornado_reports['Lat'], color = 'tab:red', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Tornado Reports', zorder = 10)
except:
pass
elif report_type == 'Tornado':
try:
ax.scatter(tornado_reports['Lon'], tornado_reports['Lat'], color = 'tab:red', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Tornado Reports', zorder = 10)
except:
pass
elif report_type == 'Wind':
try:
ax.scatter(wind_reports['Lon'], wind_reports['Lat'], color = 'tab:blue', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Wind Reports', zorder = 10)
except:
pass
elif report_type == 'Hail':
try:
ax.scatter(hail_reports['Lon'], hail_reports['Lat'], color = 'tab:green', linewidths = 0.5, edgecolor = 'black', s = 20, transform = ccrs.crs.PlateCarree(), label = 'Hail Reports', zorder = 10)
except:
pass
else:
print('Invalid report_type input.')
#Add counties if not CONUS:
if domain != 'CONUS':
wedgj_utils.plot_counties(self, ax)
#Add cities to state plots:
if domain == 'Ohio':
wedgj_utils.plot_oh_cities(self, ax)
elif domain == 'Indiana':
wedgj_utils.plot_in_cities(self, ax)
elif domain == 'Alabama':
wedgj_utils.plot_al_cities(self, ax)
else:
pass
#Add cartopy boundaries:
wedgj_utils.add_geog_ref(self, ax)
#Get end of valid time:
end_date = date + timedelta(days=1)
plt.tight_layout()
plt.title('SPC Storm Reports: {} Domain\n(Valid {} - {})'.format(domain, date.strftime("%Y%m%d 1200 UTC"), end_date.strftime("%Y%m%d 1159 UTC")), fontweight = 'bold', fontsize = 14)
if spath != None:
plt.savefig('{}/{}_{}_storm_reports.png'.format(spath, date.strftime("%Y%m%d"), domain), dpi = 300)
else:
pass
###---------Storm-Based Warning Function---------###
def sbw(self, start_date = None, end_date = None, spath = None, domain = 'CONUS', warn_type = 'All'):
if start_date == None:
start_date = self.date - timedelta(days = 1, hours = 12)
if end_date == None:
end_date = self.date - timedelta(hours = 12)
if start_date.year < 2002:
raise ValueError('Input start_year must be 2002 or later.')
#Ignore download warnings for cartopy shapefiles:
warnings.filterwarnings("ignore")
### Get Data:
#Check if selection is multi-year or single year:
if end_date.year - start_date.year >= 1:
years = np.arange(start_date.year, end_date.year + 1, 1)
warns_gdf = gpd.GeoDataFrame()
try:
for year in years:
link = "https://mesonet.agron.iastate.edu/pickup/wwa/{}_tsmf_sbw.zip".format(year)
warns = gpd.read_file(link)
warns_gdf_yrs = gpd.GeoDataFrame(warns, geometry=warns['geometry'])
warns_gdf_yrs.to_crs(4326)
warns_gdf_yrs['ISSUED'] = warns_gdf_yrs['ISSUED'].astype('datetime64')
warns_gdf = pd.concat([warns_gdf_yrs, warns_gdf])
except:
raise ValueError('Multi-year selection failed.')
else:
link = "https://mesonet.agron.iastate.edu/pickup/wwa/{}_tsmf_sbw.zip".format(start_date.strftime("%Y"))
warns = gpd.read_file(link)
warns_gdf = gpd.GeoDataFrame(warns, geometry=warns['geometry'])
warns_gdf.to_crs(4326)
warns_gdf['ISSUED'] = warns_gdf['ISSUED'].astype('datetime64')
#Define each type of warning:
tor_warns = warns_gdf[(warns_gdf['PHENOM'] == 'TO') & (warns_gdf['STATUS'] == 'NEW') & (warns_gdf['ISSUED'] >= start_date.strftime('%Y%m%d%H%M')) & (warns_gdf['ISSUED'] <= end_date.strftime('%Y%m%d%H%M'))]
flood_warns = warns_gdf[(warns_gdf['PHENOM'] == 'FF') & (warns_gdf['STATUS'] == 'NEW') & ((warns_gdf['ISSUED'] >= start_date.strftime('%Y%m%d%H%M')) & (warns_gdf['ISSUED'] <= end_date.strftime('%Y%m%d%H%M')))]
svr_warns = warns_gdf[(warns_gdf['PHENOM'] == 'SV') & (warns_gdf['STATUS'] == 'NEW') & ((warns_gdf['ISSUED'] >= start_date.strftime('%Y%m%d%H%M')) & (warns_gdf['ISSUED'] <= end_date.strftime('%Y%m%d%H%M')))]
figsize_table = wedgj_utils.figsize_table(self)
#Make figure:
fig, ax = plt.subplots(figsize = figsize_table[domain], subplot_kw = {'projection' : ccrs.crs.PlateCarree()})
extent_table = wedgj_utils.extent_table(self)
#Add cartopy boundaries::
try:
ax.set_extent(extent_table[domain])
except:
ax.set_extent(extent_table['CONUS'])
print('Invalid Domain Input. Setting extent to CONUS.')
#Count total warnings in domain:
extent = extent_table[domain]
#Determine centroids of warnings within the domain:
tor_warn_lons = np.array(tor_warns['geometry'].centroid.x)
tor_warn_lats = np.array(tor_warns['geometry'].centroid.y)
svr_warn_lons = np.array(svr_warns['geometry'].centroid.x)
svr_warn_lats = np.array(svr_warns['geometry'].centroid.y)
fld_warn_lons = np.array(flood_warns['geometry'].centroid.x)
fld_warn_lats = np.array(flood_warns['geometry'].centroid.y)
if len(set(tor_warns['ISSUED'])) > 0:
for index,row in tor_warns.iterrows():
tor_total = np.sum((tor_warn_lons > (extent[0])) & (tor_warn_lons < (extent[1])) & (tor_warn_lats > (extent[2])) & (tor_warn_lats < (extent[3])))
else:
tor_total = 0
if len(set(svr_warns['ISSUED'])) > 0:
for index,row in svr_warns.iterrows():
svr_total = np.sum((svr_warn_lons > (extent[0])) & (svr_warn_lons < (extent[1])) & (svr_warn_lats > (extent[2])) & (svr_warn_lats < (extent[3])))
else:
svr_total = 0
if len(set(flood_warns['ISSUED'])) > 0:
for index,row in flood_warns.iterrows():
fld_total = np.sum((fld_warn_lons > (extent[0])) & (fld_warn_lons < (extent[1])) & (fld_warn_lats > (extent[2])) & (fld_warn_lats < (extent[3])))
else:
fld_total = 0
#Add legend:
patch_tor = mpatches.Patch(edgecolor = 'black', label = f'Tornado Warning ({tor_total})', facecolor='tab:red')
patch_svr = mpatches.Patch(edgecolor = 'black', label = f'Severe Thunderstorm Warning ({svr_total})', facecolor='goldenrod')
patch_fld = mpatches.Patch(edgecolor= 'black', label = f'Flash Flood Warning ({fld_total})', facecolor='tab:green')
if warn_type == 'All':
ax.legend(handles = [patch_tor, patch_svr, patch_fld], loc = (0.01,0.01), ncol = 3, fontsize = 8)
elif warn_type == 'TOR':
ax.legend(handles = [patch_tor], loc = (0.01,0.01), fontsize = 8)
elif warn_type == 'SVR':
ax.legend(handles = [patch_svr], loc = (0.01,0.01), fontsize = 8)
elif warn_type == 'FFW':
ax.legend(handles = [patch_fld], loc = (0.01,0.01), fontsize = 8)
#Add warnings:
if warn_type == 'All':
try:
flood_warns['geometry'].plot(ax = ax, color = 'tab:green', edgecolor = 'darkgreen', alpha = 0.5)
except:
pass
try:
svr_warns['geometry'].plot(ax = ax, color = 'goldenrod', edgecolor = 'darkgoldenrod', alpha = 0.5)
except:
pass
try:
tor_warns['geometry'].plot(ax = ax, color = 'tab:red', edgecolor = 'maroon', alpha = 0.5)
except:
pass
elif warn_type == 'TOR':
try:
tor_warns['geometry'].plot(ax = ax, color = 'tab:red', edgecolor = 'maroon', alpha = 0.5)
except:
pass
elif warn_type == 'SVR':
try:
svr_warns['geometry'].plot(ax = ax, color = 'goldenrod', edgecolor = 'darkgoldenrod', alpha = 0.5)
except:
pass
elif warn_type == 'FFW':
try:
flood_warns['geometry'].plot(ax = ax, color = 'tab:green', edgecolor = 'darkgreen', alpha = 0.5)
except:
pass
else:
print('Invalid warn_type input.')
#Add counties if not CONUS:
if domain != 'CONUS':
wedgj_utils.plot_counties(self, ax)
#Add cities to state plots:
if domain == 'Ohio':
wedgj_utils.plot_oh_cities(self, ax)
elif domain == 'Indiana':
wedgj_utils.plot_in_cities(self, ax)
elif domain == 'Alabama':
wedgj_utils.plot_al_cities(self, ax)
else:
pass
#Add cartopy boundaries:
wedgj_utils.add_geog_ref(self, ax)
plt.tight_layout()
plt.title('NWS Storm-Based Warnings: {} Domain\n(Valid {} - {})'.format(domain, start_date.strftime("%Y%m%d %H%M UTC"), end_date.strftime("%Y%m%d %H%M UTC")), fontweight = 'bold', fontsize = 14)
if spath != None:
plt.savefig('{}/{}_to_{}_{}_{}_warnings.png'.format(spath, start_date.strftime("%Y%m%d_%H%M"), end_date.strftime("%Y%m%d_%H%M"), domain, warn_type), dpi = 300)
else:
pass
###---------Tornado Path Function---------###
def tor_plot(self, start_date, end_date, spath = None, domain = 'CONUS', tor_type = 'Both', rating = 'All'):
if start_date.year < 1950:
raise ValueError('Input start_year must be 1950 or later.')
if end_date.year > 2022:
raise ValueError('Input end_year must be 2022 or earlier.')
#Ignore download warnings for cartopy shapefiles:
warnings.filterwarnings("ignore")
### Get Data:
tor_paths = "https://www.spc.noaa.gov/gis/svrgis/zipped/1950-2022-torn-aspath.zip!1950-2022-torn-aspath/1950-2022-torn-aspath.shp"
tor_pts = "https://www.spc.noaa.gov/gis/svrgis/zipped/1950-2022-torn-initpoint.zip!1950-2022-torn-initpoint/1950-2022-torn-initpoint.shp"
tor_paths = gpd.read_file(tor_paths)
tor_pts = gpd.read_file(tor_pts)
tor_paths_gdf = gpd.GeoDataFrame(tor_paths, geometry=tor_paths['geometry'])
tor_paths_gdf.to_crs(4326)
tor_pts_gdf = gpd.GeoDataFrame(tor_pts, geometry=tor_pts['geometry'])
tor_pts_gdf.to_crs(4326)
tor_paths_gdf['date'] = tor_paths_gdf['date'].astype('datetime64')
tor_pts_gdf['date'] = tor_pts_gdf['date'].astype('datetime64')
#Define each rating:
#Paths:
tor_paths_UNK = tor_paths_gdf[(tor_paths_gdf['mag'] == -9) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F0 = tor_paths_gdf[(tor_paths_gdf['mag'] == 0) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F1 = tor_paths_gdf[(tor_paths_gdf['mag'] == 1) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F2 = tor_paths_gdf[(tor_paths_gdf['mag'] == 2) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F3 = tor_paths_gdf[(tor_paths_gdf['mag'] == 3) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F4 = tor_paths_gdf[(tor_paths_gdf['mag'] == 4) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_F5 = tor_paths_gdf[(tor_paths_gdf['mag'] == 5) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_FAT = tor_paths_gdf[(tor_paths_gdf['fat'] >= 1) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_paths_INJ = tor_paths_gdf[(tor_paths_gdf['inj'] >= 1) & (tor_paths_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_paths_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
#Points:
tor_points_UNK = tor_pts_gdf[(tor_pts_gdf['mag'] == -9) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F0 = tor_pts_gdf[(tor_pts_gdf['mag'] == 0) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F1 = tor_pts_gdf[(tor_pts_gdf['mag'] == 1) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F2 = tor_pts_gdf[(tor_pts_gdf['mag'] == 2) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F3 = tor_pts_gdf[(tor_pts_gdf['mag'] == 3) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F4 = tor_pts_gdf[(tor_pts_gdf['mag'] == 4) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_F5 = tor_pts_gdf[(tor_pts_gdf['mag'] == 5) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_FAT = tor_pts_gdf[(tor_pts_gdf['fat'] >= 1) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
tor_points_INJ = tor_pts_gdf[(tor_pts_gdf['inj'] >= 1) & (tor_pts_gdf['date'] >= start_date.strftime('%Y-%m-%d')) & (tor_pts_gdf['date'] <= end_date.strftime('%Y-%m-%d'))]
figsize_table = wedgj_utils.figsize_table(self)
#Make figure:
fig, ax = plt.subplots(figsize = figsize_table[domain], subplot_kw = {'projection' : ccrs.crs.PlateCarree()})
extent_table = wedgj_utils.extent_table(self)
#Add cartopy boundaries::
try:
ax.set_extent(extent_table[domain])
except:
ax.set_extent(extent_table['CONUS'])
print('Invalid Domain Input. Setting extent to CONUS.')
###Count total tornadoes in domain by rating:
extent = extent_table[domain]
#Determine centroids of tornadoes within the domain:
tor_paths_UNK_lons = np.array(tor_paths_UNK['geometry'].centroid.x)
tor_paths_UNK_lats = np.array(tor_paths_UNK['geometry'].centroid.y)
tor_paths_F0_lons = np.array(tor_paths_F0['geometry'].centroid.x)
tor_paths_F0_lats = np.array(tor_paths_F0['geometry'].centroid.y)
tor_paths_F1_lons = np.array(tor_paths_F1['geometry'].centroid.x)
tor_paths_F1_lats = np.array(tor_paths_F1['geometry'].centroid.y)
tor_paths_F2_lons = np.array(tor_paths_F2['geometry'].centroid.x)
tor_paths_F2_lats = np.array(tor_paths_F2['geometry'].centroid.y)
tor_paths_F3_lons = np.array(tor_paths_F3['geometry'].centroid.x)
tor_paths_F3_lats = np.array(tor_paths_F3['geometry'].centroid.y)
tor_paths_F4_lons = np.array(tor_paths_F4['geometry'].centroid.x)
tor_paths_F4_lats = np.array(tor_paths_F4['geometry'].centroid.y)
tor_paths_F5_lons = np.array(tor_paths_F5['geometry'].centroid.x)
tor_paths_F5_lats = np.array(tor_paths_F5['geometry'].centroid.y)
tor_paths_FAT_lons = np.array(tor_paths_FAT['geometry'].centroid.x)
tor_paths_FAT_lats = np.array(tor_paths_FAT['geometry'].centroid.y)
tor_paths_INJ_lons = np.array(tor_paths_INJ['geometry'].centroid.x)
tor_paths_INJ_lats = np.array(tor_paths_INJ['geometry'].centroid.y)
if len(set(tor_paths_UNK['date'])) > 0:
for index,row in tor_paths_UNK.iterrows():
UNK_total = np.sum((tor_paths_UNK_lons > (extent[0])) & (tor_paths_UNK_lons < (extent[1])) & (tor_paths_UNK_lats > (extent[2])) & (tor_paths_UNK_lats < (extent[3])))
else:
UNK_total = 0
if len(set(tor_paths_F0['date'])) > 0:
for index,row in tor_paths_F0.iterrows():
F0_total = np.sum((tor_paths_F0_lons > (extent[0])) & (tor_paths_F0_lons < (extent[1])) & (tor_paths_F0_lats > (extent[2])) & (tor_paths_F0_lats < (extent[3])))
else:
F0_total = 0
if len(set(tor_paths_F1['date'])) > 0:
for index,row in tor_paths_F1.iterrows():
F1_total = np.sum((tor_paths_F1_lons > (extent[0])) & (tor_paths_F1_lons < (extent[1])) & (tor_paths_F1_lats > (extent[2])) & (tor_paths_F1_lats < (extent[3])))
else:
F1_total = 0
if len(set(tor_paths_F2['date'])) > 0:
for index,row in tor_paths_F2.iterrows():
F2_total = np.sum((tor_paths_F2_lons > (extent[0])) & (tor_paths_F2_lons < (extent[1])) & (tor_paths_F2_lats > (extent[2])) & (tor_paths_F2_lats < (extent[3])))
else:
F2_total = 0
if len(set(tor_paths_F3['date'])) > 0:
for index,row in tor_paths_F3.iterrows():
F3_total = np.sum((tor_paths_F3_lons > (extent[0])) & (tor_paths_F3_lons < (extent[1])) & (tor_paths_F3_lats > (extent[2])) & (tor_paths_F3_lats < (extent[3])))
else:
F3_total = 0
if len(set(tor_paths_F4['date'])) > 0:
for index,row in tor_paths_F4.iterrows():
F4_total = np.sum((tor_paths_F4_lons > (extent[0])) & (tor_paths_F4_lons < (extent[1])) & (tor_paths_F4_lats > (extent[2])) & (tor_paths_F4_lats < (extent[3])))
else:
F4_total = 0
if len(set(tor_paths_F5['date'])) > 0:
for index,row in tor_paths_F5.iterrows():
F5_total = np.sum((tor_paths_F5_lons.isnull() > (extent[0])) & (tor_paths_F5_lons.isnull() < (extent[1])) & (tor_paths_F5_lats.isnull() > (extent[2])) & (tor_paths_F5_lats.isnull() < (extent[3])))
else:
F5_total = 0
if len(set(tor_paths_FAT['date'])) > 0:
for index,row in tor_paths_FAT.iterrows():
FAT_total = np.sum(tor_paths_FAT['fat'][(tor_paths_FAT_lons > (extent[0])) & (tor_paths_FAT_lons < (extent[1])) & (tor_paths_FAT_lats > (extent[2])) & (tor_paths_FAT_lats < (extent[3]))])
else:
FAT_total = 0
if len(set(tor_paths_INJ['date'])) > 0:
for index,row in tor_paths_INJ.iterrows():
INJ_total = np.sum(tor_paths_INJ['inj'][(tor_paths_INJ_lons > (extent[0])) & (tor_paths_INJ_lons < (extent[1])) & (tor_paths_INJ_lats > (extent[2])) & (tor_paths_INJ_lats < (extent[3]))])
else:
INJ_total = 0
#Get total tornado count:
tor_total_array = [UNK_total, F0_total, F1_total, F2_total, F3_total, F4_total, F5_total]
tor_total = np.sum(tor_total_array)
#Set colors:
tor_colors = {'FUNK': 'lightgrey', 'F0': 'deepskyblue', 'F1': 'lime', 'F2': 'gold', 'F3': 'darkorange', 'F4': 'firebrick', 'F5': 'deeppink'}
#Add tornadoes:
if tor_type == 'Both':
if rating == 'All':
try:
tor_paths_UNK['geometry'].plot(ax = ax, color = tor_colors['UNK'], lw = 2.5)
ax.scatter(tor_points_UNK['slon'], tor_points_UNK['slat'], color = tor_colors['FUNK'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F0['geometry'].plot(ax = ax, color = tor_colors['F0'], lw = 2.5)
ax.scatter(tor_points_F0['slon'], tor_points_F0['slat'], color = tor_colors['F0'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F1['geometry'].plot(ax = ax, color = tor_colors['F1'], lw = 2.5)
ax.scatter(tor_points_F1['slon'], tor_points_F1['slat'], color = tor_colors['F1'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'Significant':
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'Violent':
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'FAT':
try:
colors = []
for index,row in tor_paths_FAT.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
tor_paths_FAT['geometry'].plot(ax = ax, color = colors, lw = 2.5)
ax.scatter(tor_points_FAT['slon'], tor_points_FAT['slat'], color = colors, linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'INJ':
try:
colors = []
for index,row in tor_paths_INJ.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
tor_paths_INJ['geometry'].plot(ax = ax, color = colors, lw = 2.5)
ax.scatter(tor_points_INJ['slon'], tor_points_INJ['slat'], color = colors, linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='UNK':
try:
tor_paths_UNK['geometry'].plot(ax = ax, color = tor_colors['UNK'], lw = 2.5)
ax.scatter(tor_points_UNK['slon'], tor_points_UNK['slat'], color = tor_colors['FUNK'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='0':
try:
tor_paths_F0['geometry'].plot(ax = ax, color = tor_colors['F0'], lw = 2.5)
ax.scatter(tor_points_F0['slon'], tor_points_F0['slat'], color = tor_colors['F0'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='1':
try:
tor_paths_F1['geometry'].plot(ax = ax, color = tor_colors['F1'], lw = 2.5)
ax.scatter(tor_points_F1['slon'], tor_points_F1['slat'], color = tor_colors['F1'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='2':
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='3':
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='4':
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='5':
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif tor_type == 'Paths':
if rating == 'All':
try:
tor_paths_UNK['geometry'].plot(ax = ax, color = tor_colors['FUNK'], lw = 2.5)
except:
pass
try:
tor_paths_F0['geometry'].plot(ax = ax, color = tor_colors['F0'], lw = 2.5)
except:
pass
try:
tor_paths_F1['geometry'].plot(ax = ax, color = tor_colors['F1'], lw = 2.5)
except:
pass
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
except:
pass
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
except:
pass
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
except:
pass
elif rating == 'Significant':
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
except:
pass
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
except:
pass
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
except:
pass
elif rating == 'Violent':
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
except:
pass
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
except:
pass
elif rating == 'FAT':
try:
colors = []
for index,row in tor_paths_FAT.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
tor_paths_FAT['geometry'].plot(ax = ax, color = colors, lw = 2.5)
except:
pass
elif rating == 'INJ':
try:
colors = []
for index,row in tor_paths_INJ.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
tor_paths_INJ['geometry'].plot(ax = ax, color = colors, lw = 2.5)
except:
pass
elif rating =='UNK':
try:
tor_paths_UNK['geometry'].plot(ax = ax, color = tor_colors['FUNK'], lw = 2.5)
except:
pass
elif rating =='0':
try:
tor_paths_F0['geometry'].plot(ax = ax, color = tor_colors['F0'], lw = 2.5)
except:
pass
elif rating =='1':
try:
tor_paths_F1['geometry'].plot(ax = ax, color = tor_colors['F1'], lw = 2.5)
except:
pass
elif rating =='2':
try:
tor_paths_F2['geometry'].plot(ax = ax, color = tor_colors['F2'], lw = 2.5)
except:
pass
elif rating =='3':
try:
tor_paths_F3['geometry'].plot(ax = ax, color = tor_colors['F3'], lw = 2.5)
except:
pass
elif rating =='4':
try:
tor_paths_F4['geometry'].plot(ax = ax, color = tor_colors['F4'], lw = 2.5)
except:
pass
elif rating =='5':
try:
tor_paths_F5['geometry'].plot(ax = ax, color = tor_colors['F5'], lw = 2.5)
except:
pass
elif tor_type == 'Points':
if rating == 'All':
try:
ax.scatter(tor_points_UNK['slon'], tor_points_UNK['slat'], color = tor_colors['FUNK'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F0['slon'], tor_points_F0['slat'], color = tor_colors['F0'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F1['slon'], tor_points_F1['slat'], color = tor_colors['F1'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'Significant':
try:
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'Violent':
try:
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
try:
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'FAT':
try:
colors = []
for index,row in tor_paths_FAT.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
ax.scatter(tor_points_FAT['slon'], tor_points_FAT['slat'], color = colors, linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating == 'INJ':
try:
colors = []
for index,row in tor_paths_INJ.iterrows():
colors.append(tor_colors["F{0}".format(row['mag'])])
ax.scatter(tor_points_INJ['slon'], tor_points_INJ['slat'], color = colors, linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='UNK':
try:
ax.scatter(tor_points_UNK['slon'], tor_points_UNK['slat'], color = tor_colors['FUNK'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='0':
try:
ax.scatter(tor_points_F0['slon'], tor_points_F0['slat'], color = tor_colors['F0'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='1':
try:
ax.scatter(tor_points_F1['slon'], tor_points_F1['slat'], color = tor_colors['F1'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='2':
try:
ax.scatter(tor_points_F2['slon'], tor_points_F2['slat'], color = tor_colors['F2'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='3':
try:
ax.scatter(tor_points_F3['slon'], tor_points_F3['slat'], color = tor_colors['F3'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='4':
try:
ax.scatter(tor_points_F4['slon'], tor_points_F4['slat'], color = tor_colors['F4'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
elif rating =='5':
try:
ax.scatter(tor_points_F5['slon'], tor_points_F5['slat'], color = tor_colors['F5'], linewidths = 0.5, edgecolor = 'black', s = 20, marker = 'v', transform = ccrs.crs.PlateCarree(), zorder = 10)
except:
pass
else:
print('Invalid tor_type input.')
#Add legend:
patch_UNK = mpatches.Patch(edgecolor = 'black', label = f'F/EF UNK ({UNK_total})', facecolor=tor_colors['FUNK'])
patch_F0 = mpatches.Patch(edgecolor = 'black', label = f'F/EF 0 ({F0_total})', facecolor=tor_colors['F0'])
patch_F1 = mpatches.Patch(edgecolor = 'black', label = f'F/EF 1 ({F1_total})', facecolor=tor_colors['F1'])
patch_F2 = mpatches.Patch(edgecolor= 'black', label = f'F/EF 2 ({F2_total})', facecolor=tor_colors['F2'])
patch_F3 = mpatches.Patch(edgecolor = 'black', label = f'F/EF 3 ({F3_total})', facecolor=tor_colors['F3'])
patch_F4 = mpatches.Patch(edgecolor = 'black', label = f'F/EF 4 ({F4_total})', facecolor=tor_colors['F4'])
patch_F5 = mpatches.Patch(edgecolor= 'black', label = f'F/EF 5 ({F5_total})', facecolor=tor_colors['F5'])
patch_TOT = mpatches.Patch(edgecolor= 'None', label = f'Total: {tor_total}', facecolor='None')
patch_FAT = mpatches.Patch(edgecolor= 'None', label = f'Fatalities: {FAT_total}', facecolor='None')
patch_INJ = mpatches.Patch(edgecolor= 'None', label = f'Injuries: {INJ_total}', facecolor='None')
ax.legend(handles = [patch_UNK, patch_F0, patch_F1, patch_F2, patch_F3, patch_F4, patch_F5, patch_TOT, patch_FAT, patch_INJ], loc = (0.01,0.01), ncol = 2, fontsize = 8)
#Add counties if not CONUS:
if domain != 'CONUS':
wedgj_utils.plot_counties(self, ax)
#Add cities to state plots:
if domain == 'Ohio':
wedgj_utils.plot_oh_cities(self, ax)
elif domain == 'Indiana':
wedgj_utils.plot_in_cities(self, ax)
elif domain == 'Alabama':
wedgj_utils.plot_al_cities(self, ax)
else:
pass
#Add cartopy boundaries:
wedgj_utils.add_geog_ref(self, ax)
plt.tight_layout()
plt.title('Confirmed Tornadoes (NWS/SPC): {} Domain\n(Valid {} - {})'.format(domain, start_date.strftime("%Y%m%d"), end_date.strftime("%Y%m%d")), fontweight = 'bold', fontsize = 14)
if spath != None:
plt.savefig('{}/{}_to_{}_{}_tornadoes.png'.format(spath, start_date.strftime("%Y%m%d_%H%M"), end_date.strftime("%Y%m%d_%H%M"), domain), dpi = 300)
else:
pass