Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions pages/gallery/500hPa_Vorticity_Advection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"outputs": [],
"source": [
"# Open the example netCDF data\n",
"ncss = NCSS('https://www.ncei.noaa.gov/thredds/ncss/grid/namanl/'\n",
"ncss = NCSS('https://www.ncei.noaa.gov/thredds/ncss/grid/model-namanl/'\n",
" '201604/20160416/namanl_218_20160416_1800_000.grb')\n",
"now = datetime.utcnow()\n",
"\n",
Expand Down Expand Up @@ -111,11 +111,11 @@
"\n",
"f = mpcalc.coriolis_parameter(np.deg2rad(lat)).to(units('1/sec'))\n",
"\n",
"avor = mpcalc.vorticity(uwnd_500, vwnd_500, dx, dy, dim_order='yx') + f\n",
"avor = mpcalc.vorticity(uwnd_500, vwnd_500, dx, dy) + f\n",
"\n",
"avor = ndimage.gaussian_filter(avor, sigma=3, order=0) * units('1/s')\n",
"\n",
"vort_adv = mpcalc.advection(avor, [uwnd_500, vwnd_500], (dx, dy), dim_order='yx') * 1e9"
"vort_adv = mpcalc.advection(avor, [uwnd_500, vwnd_500], (dx, dy)) * 1e9"
]
},
{
Expand Down Expand Up @@ -146,9 +146,7 @@
" standard_parallels=[30, 60])\n",
"\n",
"fig = plt.figure(1, figsize=(14., 12))\n",
"gs = gridspec.GridSpec(2, 1, height_ratios=[1, .02], bottom=.07, top=.99,\n",
" hspace=0.01, wspace=0.01)\n",
"ax = plt.subplot(gs[0], projection=plotcrs)\n",
"ax = plt.subplot(111, projection=plotcrs)\n",
"\n",
"# Plot Titles\n",
"plt.title(r'500-hPa Heights (m), AVOR$*10^5$ ($s^{-1}$), AVOR Adv$*10^8$ ($s^{-2}$)',\n",
Expand Down Expand Up @@ -178,15 +176,23 @@
"clev_avoradv = np.arange(-30, 31, 5)\n",
"cf = ax.contourf(lon, lat, vort_adv.m, clev_avoradv[clev_avoradv != 0], extend='both',\n",
" cmap='bwr', transform=ccrs.PlateCarree())\n",
"cax = plt.subplot(gs[1])\n",
"cb = plt.colorbar(cf, cax=cax, orientation='horizontal', extendrect='True', ticks=clev_avoradv)\n",
"\n",
"cb = plt.colorbar(cf, orientation='horizontal', extendrect='True', ticks=clev_avoradv,\n",
" pad=0, aspect=50)\n",
"cb.set_label(r'$1/s^2$', size='large')\n",
"\n",
"# Plot Wind Barbs\n",
"# Transform Vectors and plot wind barbs.\n",
"ax.barbs(lon, lat, uwnd_500.m, vwnd_500.m, length=6, regrid_shape=20,\n",
"ax.barbs(lon, lat, uwnd_500.to('kt').m, vwnd_500.to('kt').m, length=6, regrid_shape=20,\n",
" pivot='middle', transform=ccrs.PlateCarree())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -210,7 +216,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
30 changes: 18 additions & 12 deletions pages/gallery/850hPa_Temperature_Advection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/gfs-g4-anl-files/'\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/model-gfs-g4-anl-files/'\n",
"dt = datetime(2017, 4, 5, 12)\n",
"ncss = NCSS('{}{dt:%Y%m}/{dt:%Y%m%d}/gfsanl_4_{dt:%Y%m%d}_'\n",
" '{dt:%H}00_000.grb2'.format(base_url, dt=dt))\n",
Expand Down Expand Up @@ -121,7 +121,9 @@
"v_wind = units.Quantity(v_wind_var[:].squeeze(), v_wind_var.units)\n",
"\n",
"# Convert number of hours since the reference time into an actual date\n",
"time = num2date(time_var[:].squeeze(), time_var.units)\n",
"time = num2date(time_var[:].squeeze(), time_var.units,\n",
" only_use_cftime_datetimes=False,\n",
" only_use_python_datetimes=True)\n",
"\n",
"lev_850 = np.where(data.variables['isobaric'][:] == 850*100)[0][0]\n",
"hght_850 = hght[lev_850]\n",
Expand Down Expand Up @@ -156,8 +158,7 @@
"dx, dy = mpcalc.lat_lon_grid_deltas(lon_var, lat_var)\n",
"\n",
"# Calculate temperature advection using metpy function\n",
"adv = mpcalc.advection(temp_850, [u_wind_850, v_wind_850],\n",
" (dx, dy), dim_order='yx')\n",
"adv = mpcalc.advection(temp_850, [u_wind_850, v_wind_850], (dx, dy))\n",
"\n",
"# Smooth heights and advection a little\n",
"# Be sure to only put in a 2D lat/lon or Y/X array for smoothing\n",
Expand Down Expand Up @@ -188,12 +189,10 @@
"plotcrs = ccrs.LambertConformal(central_latitude=[30, 60], central_longitude=-100)\n",
"\n",
"# Create new figure\n",
"fig = plt.figure(figsize=(11, 8.5))\n",
"gs = gridspec.GridSpec(2, 1, height_ratios=[1, .02], bottom=.07, top=.99,\n",
" hspace=0.01, wspace=0.01)\n",
"fig = plt.figure(figsize=(15, 12))\n",
"\n",
"# Add the map and set the extent\n",
"ax = plt.subplot(gs[0], projection=plotcrs)\n",
"ax = plt.subplot(111, projection=plotcrs)\n",
"plt.title('850mb Temperature Advection for {0:%d %B %Y %H:%MZ}'.format(time), fontsize=16)\n",
"ax.set_extent([235., 290., 20., 55.])\n",
"\n",
Expand All @@ -220,14 +219,21 @@
"cint = np.arange(-8, 9)\n",
"cf = ax.contourf(lon_2d, lat_2d, 3*adv.to(units('delta_degC/hour')), cint[cint != 0],\n",
" extend='both', cmap='bwr', transform=datacrs)\n",
"cax = plt.subplot(gs[1])\n",
"cb = plt.colorbar(cf, cax=cax, orientation='horizontal', extendrect=True, ticks=cint)\n",
"\n",
"cb = plt.colorbar(cf, orientation='horizontal', extendrect=True, ticks=cint, pad=0, aspect=50)\n",
"cb.set_label(r'$^{o}C/3h$', size='large')\n",
"\n",
"# Plot Wind Barbs\n",
"ax.barbs(lon_2d, lat_2d, u_wind_850.magnitude, v_wind_850.magnitude,\n",
"ax.barbs(lon_2d, lat_2d, u_wind_850.to('kt').magnitude, v_wind_850.to('kt').magnitude,\n",
" length=6, regrid_shape=20, pivot='middle', transform=datacrs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -251,7 +257,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
17 changes: 13 additions & 4 deletions pages/gallery/Ageostrophic_Wind_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"outputs": [],
"source": [
"# Create NCSS object to access the NetcdfSubset\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/gfs-g4-anl-files/'\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/model-gfs-g4-anl-files/'\n",
"dt = datetime(2016, 8, 22, 18)\n",
"ncss = NCSS('{}{dt:%Y%m}/{dt:%Y%m%d}/gfsanl_4_{dt:%Y%m%d}_'\n",
" '{dt:%H}00_003.grb2'.format(base_url, dt=dt))\n",
Expand Down Expand Up @@ -105,7 +105,9 @@
"v_wind = v_wind_var[0, 0, :, :].squeeze() * units('m/s')\n",
"\n",
"# Convert number of hours since the reference time into an actual date\n",
"time = num2date(time_var[:].squeeze(), time_var.units)\n",
"time = num2date(time_var[:].squeeze(), time_var.units,\n",
" only_use_cftime_datetimes=False,\n",
" only_use_python_datetimes=True)\n",
"\n",
"# Combine 1D latitude and longitudes into a 2D grid of locations\n",
"lon_2d, lat_2d = np.meshgrid(lon, lat)\n",
Expand Down Expand Up @@ -171,9 +173,16 @@
"\n",
"# Add a title to the plot\n",
"plt.title('1000mb Geopotential Heights(m), Wind(blue), Geostrophic Wind(purple), and \\n'\n",
" 'Ageostrophic Wind(green) for {0:%d %B %Y %H:%MZ}'.format(time),\n",
" f'Ageostrophic Wind(green) for {time:%d %B %Y %H:%MZ}',\n",
" color='white', size=14)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -197,7 +206,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
11 changes: 9 additions & 2 deletions pages/gallery/HILO_Symbol_Plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"source": [
"dattim = datetime(1999, 1, 3, 0)\n",
"\n",
"ncss = NCSS('https://www.ncei.noaa.gov/thredds/ncss/grid/narr-a-files/{0:%Y%m}/{0:%Y%m%d}/'\n",
"ncss = NCSS('https://www.ncei.noaa.gov/thredds/ncss/grid/model-narr-a-files/{0:%Y%m}/{0:%Y%m%d}/'\n",
" 'narr-a_221_{0:%Y%m%d}_{0:%H}00_000.grb'.format(dattim))\n",
"query = ncss.query()\n",
"query.all_times().variables('Pressure_reduced_to_MSL_msl',\n",
Expand Down Expand Up @@ -245,6 +245,13 @@
"plt.title('MSLP (hPa) with Highs and Lows, 1000-500 hPa Thickness (m)', loc='left')\n",
"plt.title('VALID: {}'.format(vtime[0]), loc='right')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -268,7 +275,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
15 changes: 12 additions & 3 deletions pages/gallery/MSLP_temp_winds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/gfs-g4-anl-files/'\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/model-gfs-g4-anl-files/'\n",
"dt = datetime(2018, 1, 4, 12)\n",
"ncss = NCSS('{}{dt:%Y%m}/{dt:%Y%m%d}/gfsanl_4_{dt:%Y%m%d}'\n",
" '_{dt:%H}00_000.grb2'.format(base_url, dt=dt))\n",
Expand Down Expand Up @@ -140,7 +140,9 @@
"v_wind.ito('kt')\n",
"\n",
"# Convert number of hours since the reference time into an actual date\n",
"time = num2date(time_var[:].squeeze(), time_var.units)\n",
"time = num2date(time_var[:].squeeze(), time_var.units,\n",
" only_use_cftime_datetimes=False,\n",
" only_use_python_datetimes=True)\n",
"\n",
"lev_10m = np.where(data.variables['height_above_ground3'][:] == 10)[0][0]\n",
"u_wind_10m = u_wind[lev_10m]\n",
Expand Down Expand Up @@ -217,6 +219,13 @@
"ax.barbs(lon_2d, lat_2d, u_wind_10m.magnitude, v_wind_10m.magnitude,\n",
" length=6, regrid_shape=20, pivot='middle', transform=datacrs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -240,7 +249,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
41 changes: 25 additions & 16 deletions pages/gallery/Satellite_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,17 @@
"outputs": [],
"source": [
"# Scan the catalog and download the data\n",
"satcat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/satellite/'\n",
" 'WV/WEST-CONUS_4km/current/catalog.xml')\n",
"satcat = TDSCatalog('https://thredds.ucar.edu/thredds/catalog/satellite/goes/west/'\n",
" 'products/CloudAndMoistureImagery/CONUS/Channel09/current/catalog.xml')\n",
"dataset = satcat.datasets[0]\n",
"f = GiniFile(dataset.remote_open())\n",
"gini_ds = xr.open_dataset(f)\n",
"gini_ds = xr.open_dataset(dataset.access_urls['OPENDAP'])\n",
"\n",
"# Pull parts out of the data file\n",
"dat = gini_ds.metpy.parse_cf('WV')\n",
"data_var = gini_ds.variables['WV']\n",
"x = gini_ds.variables['x'][:]\n",
"y = gini_ds.variables['y'][:]\n",
"timestamp = f.prod_desc.datetime"
"dat = gini_ds.metpy.parse_cf('Sectorized_CMI')\n",
"data_var = gini_ds.variables['Sectorized_CMI']\n",
"x = dat.x\n",
"y = dat.y\n",
"timestamp = dat.time.values.astype('datetime64[ms]').astype('O')"
]
},
{
Expand Down Expand Up @@ -159,7 +158,7 @@
"outputs": [],
"source": [
"# Create the figure\n",
"fig = plt.figure(figsize=(10, 10))\n",
"fig = plt.figure(figsize=(15, 15))\n",
"ax = fig.add_subplot(1, 1, 1, projection=dat.metpy.cartopy_crs)\n",
"\n",
"# Add mapping information\n",
Expand All @@ -168,8 +167,8 @@
"ax.add_feature(cfeature.BORDERS, linewidth=2)\n",
"\n",
"# Plot the image with our colormapping choices\n",
"wv_norm, wv_cmap = registry.get_with_range('WVCIMSS', 100, 260)\n",
"im = ax.imshow(data_var[:], extent=(x[0], x[-1], y[0], y[-1]), origin='upper',\n",
"wv_norm, wv_cmap = registry.get_with_range('WVCIMSS_r', 175, 290)\n",
"im = ax.imshow(data_var[:], extent=(x.min(), x.max(), y.min(), y.max()), origin='upper',\n",
" cmap=wv_cmap, norm=wv_norm)\n",
"\n",
"# Add the text, complete with outline\n",
Expand All @@ -184,12 +183,22 @@
"ax.clabel(cs, fontsize=12, colors='k', inline=1, inline_spacing=8,\n",
" fmt='%i', rightside_up=True, use_clabeltext=True)\n",
"\n",
"ax.barbs(lon, lat, U_300.to('knots').m, V_300.to('knots').m, color='tab:red',\n",
" length=7, regrid_shape=15, pivot='middle', transform=ccrs.PlateCarree())\n",
"wind_slice = slice(None, None, 8)\n",
"ax.barbs(lon[wind_slice], lat[wind_slice],\n",
" U_300[wind_slice, wind_slice].to('knots').m,\n",
" V_300[wind_slice, wind_slice].to('knots').m, color='tab:red',\n",
" length=7, pivot='middle', transform=ccrs.PlateCarree())\n",
"\n",
"ax.set_title('300-hPa Geo Heights (m; black) and Wind Barbs (kt)', loc='left')\n",
"ax.set_title('Valid: {}'.format(vtime[0]), loc='right');"
"ax.set_title(f'Valid: {vtime[0]}', loc='right');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -213,7 +222,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
11 changes: 9 additions & 2 deletions pages/gallery/Smoothing_Contours.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"outputs": [],
"source": [
"dt = datetime(2016, 4, 16, 18)\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/namanl/'\n",
"base_url = 'https://www.ncei.noaa.gov/thredds/ncss/grid/model-namanl/'\n",
"ncss = NCSS('{}{dt:%Y%m}/{dt:%Y%m%d}/namanl_218_{dt:%Y%m%d}_'\n",
" '{dt:%H}00_000.grb'.format(base_url, dt=dt))\n",
"\n",
Expand Down Expand Up @@ -212,6 +212,13 @@
"cl = plt.clabel(cs, fontsize=12, colors='k', inline=1, inline_spacing=8,\n",
" fmt='%i', rightside_up=True, use_clabeltext=True);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -235,7 +242,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
Loading