Skip to content

Commit 8789738

Browse files
committed
update notebook and solutions
1 parent 714f501 commit 8789738

File tree

7 files changed

+33
-34
lines changed

7 files changed

+33
-34
lines changed

pages/workshop/MetPy_Case_Study/MetPy Case Study.ipynb

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
"outputs": [],
172172
"source": [
173173
"# Read NARR Data from THREDDS server\n",
174-
"base_url = 'https://www.ncei.noaa.gov/thredds/catalog/narr-a-files/'\n",
174+
"base_url = 'https://www.ncdc.noaa.gov/thredds/catalog/narr-a-files/'\n",
175175
"\n",
176176
"# Programmatically generate the URL to the day of data we want\n",
177177
"cat = TDSCatalog(f'{base_url}{dt:%Y%m}/{dt:%Y%m%d}/catalog.xml')\n",
@@ -272,7 +272,7 @@
272272
"metadata": {},
273273
"outputs": [],
274274
"source": [
275-
"# %load solutions/extract.py"
275+
"# %load solutions/extract.py\n"
276276
]
277277
},
278278
{
@@ -383,7 +383,7 @@
383383
"metadata": {},
384384
"outputs": [],
385385
"source": [
386-
"# %load solutions/get_850_500_300.py"
386+
"# %load solutions/get_850_500_300.py\n"
387387
]
388388
},
389389
{
@@ -449,7 +449,7 @@
449449
"metadata": {},
450450
"outputs": [],
451451
"source": [
452-
"# %load solutions/advection_850.py"
452+
"# %load solutions/advection_850.py\n"
453453
]
454454
},
455455
{
@@ -523,7 +523,8 @@
523523
"metadata": {},
524524
"outputs": [],
525525
"source": [
526-
"# %load solutions/vort.py"
526+
"# %load solutions/vort.py\n",
527+
"\n"
527528
]
528529
},
529530
{
@@ -542,11 +543,11 @@
542543
"outputs": [],
543544
"source": [
544545
"# Vorticity Advection\n",
545-
"f_adv = mpcalc.advection(f, [uwnd_500, vwnd_500], (dx, dy), dim_order='yx')\n",
546+
"f_adv = mpcalc.advection(f, [uwnd_500, vwnd_500], (dx, dy))\n",
546547
"\n",
547-
"relvort_adv = mpcalc.advection(vor_500, [uwnd_500, vwnd_500], (dx, dy), dim_order='yx')\n",
548+
"relvort_adv = mpcalc.advection(vor_500, [uwnd_500, vwnd_500], (dx, dy))\n",
548549
"\n",
549-
"absvort_adv = mpcalc.advection(avor_500, [uwnd_500, vwnd_500], (dx, dy), dim_order='yx')"
550+
"absvort_adv = mpcalc.advection(avor_500, [uwnd_500, vwnd_500], (dx, dy))"
550551
]
551552
},
552553
{
@@ -573,7 +574,7 @@
573574
"outputs": [],
574575
"source": [
575576
"# Stretching Vorticity\n",
576-
"div_500 = mpcalc.divergence(uwnd_500, vwnd_500, dx, dy, dim_order='yx')\n",
577+
"div_500 = mpcalc.divergence(uwnd_500, vwnd_500, dx, dy)\n",
577578
"\n",
578579
"stretch_vort = -1 * avor_500 * div_500"
579580
]
@@ -615,8 +616,8 @@
615616
"# Divergence 300 hPa, Ageostrophic Wind\n",
616617
"wspd_300 = mpcalc.wind_speed(uwnd_300, vwnd_300).to('kts')\n",
617618
"\n",
618-
"div_300 = mpcalc.divergence(uwnd_300, vwnd_300, dx, dy, dim_order='yx')\n",
619-
"ugeo_300, vgeo_300 = mpcalc.geostrophic_wind(hght_300, f, dx, dy, dim_order='yx')\n",
619+
"div_300 = mpcalc.divergence(uwnd_300, vwnd_300, dx, dy)\n",
620+
"ugeo_300, vgeo_300 = mpcalc.geostrophic_wind(hght_300, f, dx, dy)\n",
620621
"\n",
621622
"uageo_300 = uwnd_300 - ugeo_300\n",
622623
"vageo_300 = vwnd_300 - vgeo_300"
@@ -728,7 +729,7 @@
728729
"metadata": {},
729730
"outputs": [],
730731
"source": [
731-
"# %load solutions/temp_adv_map_850.py"
732+
"# %load solutions/temp_adv_map_850.py\n"
732733
]
733734
},
734735
{
@@ -787,7 +788,6 @@
787788
" (1/s), and Wind Barbs (kts)', loc='left')\n",
788789
"plt.title(f'VALID: {vtime}', loc='right')\n",
789790
"\n",
790-
"plt.tight_layout()\n",
791791
"plt.show()"
792792
]
793793
},
@@ -806,7 +806,7 @@
806806
"metadata": {},
807807
"outputs": [],
808808
"source": [
809-
"# %load solutions/abs_vort_500.py"
809+
"# %load solutions/abs_vort_500.py\n"
810810
]
811811
},
812812
{
@@ -859,7 +859,6 @@
859859
" loc='left')\n",
860860
"plt.title(f'VALID: {vtime}', loc='right')\n",
861861
"\n",
862-
"plt.tight_layout()\n",
863862
"plt.show()"
864863
]
865864
},
@@ -878,7 +877,7 @@
878877
"metadata": {},
879878
"outputs": [],
880879
"source": [
881-
"# %load solutions/winds_300.py"
880+
"# %load solutions/winds_300.py\n"
882881
]
883882
},
884883
{
@@ -904,11 +903,12 @@
904903
"metadata": {},
905904
"outputs": [],
906905
"source": [
907-
"fig=plt.figure(1,figsize=(21.,16.))\n",
906+
"fig = plt.figure(1, figsize=(28.,20.))\n",
908907
"\n",
909908
"# Upper-Left Panel\n",
910-
"ax=plt.subplot(221,projection=plotproj)\n",
911-
"ax.set_extent([-125.,-73,25.,50.],ccrs.PlateCarree())\n",
909+
"ax = plt.subplot(221, projection=plotproj)\n",
910+
"plt.subplots_adjust(wspace=0.02, hspace=0.02)\n",
911+
"ax.set_extent([-125., -73, 25., 50.],ccrs.PlateCarree())\n",
912912
"ax.coastlines('50m', linewidth=0.75)\n",
913913
"ax.add_feature(cfeature.STATES,linewidth=0.5)\n",
914914
"\n",
@@ -1028,7 +1028,6 @@
10281028
"plt.title(r'500-hPa Geopotential Heights, Stretching Vorticity ($*10^{9}$ 1/s^2)',loc='left')\n",
10291029
"plt.title('VALID: %s' %(vtime),loc='right')\n",
10301030
"\n",
1031-
"plt.tight_layout()\n",
10321031
"plt.show()"
10331032
]
10341033
},
@@ -1108,7 +1107,6 @@
11081107
"# Title\n",
11091108
"plt.title('Geopotential (m; top), U-wind (m/s; Lower Left), V-wind (m/s; Lower Right)')\n",
11101109
"\n",
1111-
"plt.tight_layout()\n",
11121110
"plt.show()"
11131111
]
11141112
},
@@ -1127,8 +1125,15 @@
11271125
"metadata": {},
11281126
"outputs": [],
11291127
"source": [
1130-
"# %load solutions/markers.py"
1128+
"# %load solutions/markers.py\n"
11311129
]
1130+
},
1131+
{
1132+
"cell_type": "code",
1133+
"execution_count": null,
1134+
"metadata": {},
1135+
"outputs": [],
1136+
"source": []
11321137
}
11331138
],
11341139
"metadata": {
@@ -1148,7 +1153,7 @@
11481153
"name": "python",
11491154
"nbconvert_exporter": "python",
11501155
"pygments_lexer": "ipython3",
1151-
"version": "3.7.6"
1156+
"version": "3.8.2"
11521157
}
11531158
},
11541159
"nbformat": 4,

pages/workshop/MetPy_Case_Study/solutions/abs_vort_500.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@
3434
(1/s), and Wind Barbs (kts)', loc='left')
3535
plt.title(f'VALID: {vtime}', loc='right')
3636

37-
plt.tight_layout()
3837
plt.show()
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# Temperature Advection
2-
tmpc_adv_850 = mpcalc.advection(tmpk_850, [uwnd_850, vwnd_850],
3-
(dx, dy), dim_order='yx').to('degC/s')
2+
tmpc_adv_850 = mpcalc.advection(tmpk_850, [uwnd_850, vwnd_850], (dx, dy)).to('degC/s')

pages/workshop/MetPy_Case_Study/solutions/markers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
# Plot markers then data around marker for calculation purposes
1515
ax.scatter(lon[::3, ::3].ravel()[mask], lat[::3, ::3].ravel()[mask],
1616
marker='o', transform=dataproj)
17-
stationplot.plot_parameter((0, 1), hght_500[::3, ::3].ravel()[mask])
18-
stationplot.plot_parameter((-1.5, -1), uwnd_500[::3, ::3].ravel()[mask],
17+
stationplot.plot_parameter((0, 1), hght_500[::3, ::3].ravel()[mask].m)
18+
stationplot.plot_parameter((-1.5, -1), uwnd_500[::3, ::3].ravel()[mask].m,
1919
formatter='.1f')
20-
stationplot.plot_parameter((1.5, -1), vwnd_500[::3, ::3].ravel()[mask],
20+
stationplot.plot_parameter((1.5, -1), vwnd_500[::3, ::3].ravel()[mask].m,
2121
formatter='.1f')
2222

2323
# Title
2424
plt.title('Geopotential (m; top), U-wind (m/s; Lower Left), \
2525
V-wind (m/s; Lower Right)')
2626

27-
plt.tight_layout()
2827
plt.show()

pages/workshop/MetPy_Case_Study/solutions/temp_adv_map_850.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@
3131
Temp Adv (C/h), and Wind Barbs (kts)', loc='left')
3232
plt.title(f'VALID: {vtime}', loc='right')
3333

34-
plt.tight_layout()
3534
plt.show()

pages/workshop/MetPy_Case_Study/solutions/vort.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
f = mpcalc.coriolis_parameter(np.deg2rad(lat)).to('1/s')
55

66
# Relative Vorticity
7-
vor_500 = mpcalc.vorticity(uwnd_500, vwnd_500, dx, dy,
8-
dim_order='yx')
7+
vor_500 = mpcalc.vorticity(uwnd_500, vwnd_500, dx, dy)
98

109
# Abosolute Vorticity
1110
avor_500 = vor_500 + f

pages/workshop/MetPy_Case_Study/solutions/winds_300.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@
2929
loc='left')
3030
plt.title(f'VALID: {vtime}', loc='right')
3131

32-
plt.tight_layout()
3332
plt.show()

0 commit comments

Comments
 (0)