|
|
@ -27,7 +27,8 @@ |
|
|
|
"from wrf import getvar, npvalues\n", |
|
|
|
"from wrf import getvar, npvalues\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
|
|
|
|
"filename = \"wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
@ -60,7 +61,8 @@ |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
|
|
|
|
"filename = \"wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
@ -88,9 +90,9 @@ |
|
|
|
"fig = plt.figure(figsize=(16,16))\n", |
|
|
|
"fig = plt.figure(figsize=(16,16))\n", |
|
|
|
"ax = fig.add_axes([0.1,0.1,0.8,0.8])\n", |
|
|
|
"ax = fig.add_axes([0.1,0.1,0.8,0.8])\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Draw filled contours from 200 to 3000 m, every 200 meters.\n", |
|
|
|
"# Draw filled contours from 100 to 3000 m, every 200 meters.\n", |
|
|
|
"levels = np.arange(250, 3000, 200)\n", |
|
|
|
"levels = np.arange(100, 3000, 200)\n", |
|
|
|
"bm.contourf(x, y, terrain_data, levels=levels, extend=\"max\")\n", |
|
|
|
"bm.contourf(x, y, terrain_data, levels=levels, extend=\"max\", cmap=get_cmap(\"terrain\"))\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Draw the coastlines and country borders.\n", |
|
|
|
"# Draw the coastlines and country borders.\n", |
|
|
|
"bm.drawcoastlines()\n", |
|
|
|
"bm.drawcoastlines()\n", |
|
|
@ -121,8 +123,9 @@ |
|
|
|
"from wrf import getvar, npvalues\n", |
|
|
|
"from wrf import getvar, npvalues\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
|
|
|
|
"filename = \"wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
@ -153,13 +156,14 @@ |
|
|
|
"fig = plt.figure(figsize=(16,16))\n", |
|
|
|
"fig = plt.figure(figsize=(16,16))\n", |
|
|
|
"ax = fig.add_axes([0.1,0.1,0.8,0.8])\n", |
|
|
|
"ax = fig.add_axes([0.1,0.1,0.8,0.8])\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Draw filled contours from 200 to 3000 m, every 200 meters.\n", |
|
|
|
"# Draw filled contours from -20 C to 40 C, every 5 C.\n", |
|
|
|
"levels = np.arange(-40, 40, 5)\n", |
|
|
|
"levels = np.arange(-20, 40, 5)\n", |
|
|
|
"bm.contourf(x, y, dewpoint_ndarray, levels=levels, extend=\"both\")\n", |
|
|
|
"bm.contourf(x, y, dewpoint_ndarray, levels=levels, extend=\"both\", cmap=get_cmap(\"RdYlGn\"))\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Draw the coastlines and country borders.\n", |
|
|
|
"# Draw the coastlines, country borders, and states.\n", |
|
|
|
"bm.drawcoastlines()\n", |
|
|
|
"bm.drawcoastlines()\n", |
|
|
|
"bm.drawcountries()\n", |
|
|
|
"bm.drawcountries()\n", |
|
|
|
|
|
|
|
"bm.drawstates()\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Draw the color bar\n", |
|
|
|
"# Draw the color bar\n", |
|
|
|
"plt.colorbar(ax=ax, shrink=.7)\n", |
|
|
|
"plt.colorbar(ax=ax, shrink=.7)\n", |
|
|
@ -187,7 +191,8 @@ |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Open the output netcdf file\n", |
|
|
|
"# Open the output netcdf file\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
|
|
|
|
"filename = \"wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
@ -201,7 +206,7 @@ |
|
|
|
"pivot_point = (z.shape[-1] / 2, z.shape[-2] / 2) \n", |
|
|
|
"pivot_point = (z.shape[-1] / 2, z.shape[-2] / 2) \n", |
|
|
|
"angle = 90.0\n", |
|
|
|
"angle = 90.0\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Compute the vertical cross-section interpolation. Include the lat/lon points along the cross-section.\n", |
|
|
|
"# Compute the vertical cross-section interpolation. Also, include the lat/lon points along the cross-section.\n", |
|
|
|
"p_vertx = vertcross(p, z, pivot_point=pivot_point, angle=angle, include_latlon=True)\n", |
|
|
|
"p_vertx = vertcross(p, z, pivot_point=pivot_point, angle=angle, include_latlon=True)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Extract the numpy array\n", |
|
|
|
"# Extract the numpy array\n", |
|
|
@ -224,7 +229,7 @@ |
|
|
|
"coord_pairs = npvalues(p_vertx.coords[\"xy_loc\"])\n", |
|
|
|
"coord_pairs = npvalues(p_vertx.coords[\"xy_loc\"])\n", |
|
|
|
"x_ticks = np.arange(coord_pairs.shape[0])\n", |
|
|
|
"x_ticks = np.arange(coord_pairs.shape[0])\n", |
|
|
|
"x_labels = [pair.latlon_str() for pair in npvalues(coord_pairs)]\n", |
|
|
|
"x_labels = [pair.latlon_str() for pair in npvalues(coord_pairs)]\n", |
|
|
|
"plt.xticks(xy_vals[::100], x_labels[::100]) # Only use every 100th tick.\n", |
|
|
|
"plt.xticks(x_ticks[::100], x_labels[::100]) # Only use every 100th tick.\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Set the y-ticks to be height.\n", |
|
|
|
"# Set the y-ticks to be height.\n", |
|
|
|
"vert_vals = npvalues(p_vertx.coords[\"vertical\"])\n", |
|
|
|
"vert_vals = npvalues(p_vertx.coords[\"vertical\"])\n", |
|
|
@ -257,20 +262,23 @@ |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Open the output netcdf file\n", |
|
|
|
"# Open the output netcdf file\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2016-02-25_18_00_00\"\n", |
|
|
|
"filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"#filename = \"/Users/ladwig/Documents/wrf_files/wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
|
|
|
|
"filename = \"wrfout_d01_2010-06-13_21:00:00\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"pynio_filename = filename + \".nc\"\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"ncfile = open_file(pynio_filename)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Extract pressure, model height, destaggered u and v winds\n", |
|
|
|
"# Extract pressure, model height, u and v winds on mass points\n", |
|
|
|
"p = getvar(ncfile, \"pressure\")\n", |
|
|
|
"p = getvar(ncfile, \"pressure\")\n", |
|
|
|
"z = getvar(ncfile, \"z\", units=\"dm\")\n", |
|
|
|
"z = getvar(ncfile, \"z\", units=\"dm\")\n", |
|
|
|
"ua = getvar(ncfile, \"ua\", units=\"kts\")\n", |
|
|
|
"ua = getvar(ncfile, \"ua\", units=\"kts\")\n", |
|
|
|
"va = getvar(ncfile, \"va\", units=\"kts\")\n", |
|
|
|
"va = getvar(ncfile, \"va\", units=\"kts\")\n", |
|
|
|
|
|
|
|
"wspd = getvar(ncfile, \"wspd_wdir\", units=\"kts\")[0,...]\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Interpolate height, u, and v to to 500 hPa\n", |
|
|
|
"# Interpolate height, u, and v to to 500 hPa\n", |
|
|
|
"ht_500 = interplevel(z, p, 500)\n", |
|
|
|
"ht_500 = interplevel(z, p, 500)\n", |
|
|
|
"u_500 = interplevel(ua, p, 500)\n", |
|
|
|
"u_500 = interplevel(ua, p, 500)\n", |
|
|
|
"v_500 = interplevel(va, p, 500)\n", |
|
|
|
"v_500 = interplevel(va, p, 500)\n", |
|
|
|
|
|
|
|
"wspd_500 = interplevel(wspd, p, 500)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Get the projection\n", |
|
|
|
"# Get the projection\n", |
|
|
|
"wrf_proj = p.attrs[\"projection\"]\n", |
|
|
|
"wrf_proj = p.attrs[\"projection\"]\n", |
|
|
@ -291,8 +299,15 @@ |
|
|
|
"bm.drawcountries()\n", |
|
|
|
"bm.drawcountries()\n", |
|
|
|
"bm.drawstates()\n", |
|
|
|
"bm.drawstates()\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Make the height contours\n", |
|
|
|
"# Make the 500 hPa height contours\n", |
|
|
|
"bm.contour(x, y, npvalues(ht_500), 10)\n", |
|
|
|
"ht_contours = bm.contour(x, y, npvalues(ht_500), 10, linewidths=2.0, colors=\"black\")\n", |
|
|
|
|
|
|
|
"\n", |
|
|
|
|
|
|
|
"# Use contour labels for height\n", |
|
|
|
|
|
|
|
"plt.clabel(ht_contours, inline=True, fontsize=12, fmt=\"%i\")\n", |
|
|
|
|
|
|
|
"\n", |
|
|
|
|
|
|
|
"# Make the wind speed filled contours\n", |
|
|
|
|
|
|
|
"levels = np.arange(40, 120, 10)\n", |
|
|
|
|
|
|
|
"bm.contourf(x, y, npvalues(wspd_500), levels=levels, extend=\"max\", cmap=get_cmap(\"rainbow\"))\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Make the wind barbs. Only use every 50th in each direction.\n", |
|
|
|
"# Make the wind barbs. Only use every 50th in each direction.\n", |
|
|
|
"bm.barbs(x[::50,::50], y[::50,::50], npvalues(u_500[::50, ::50]), npvalues(v_500[::50, ::50]))\n", |
|
|
|
"bm.barbs(x[::50,::50], y[::50,::50], npvalues(u_500[::50, ::50]), npvalues(v_500[::50, ::50]))\n", |
|
|
@ -301,7 +316,7 @@ |
|
|
|
"plt.colorbar(ax=ax, shrink=.7)\n", |
|
|
|
"plt.colorbar(ax=ax, shrink=.7)\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"# Make the title\n", |
|
|
|
"# Make the title\n", |
|
|
|
"plt.title(\"500 MB Heights (dm) and Wind Barbs (kts)\", {\"fontsize\" : 20})\n", |
|
|
|
"plt.title(\"500 MB Heights (dm), Wind Speed (kts), and Wind Barbs (kts)\", {\"fontsize\" : 20})\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
"plt.show()" |
|
|
|
"plt.show()" |
|
|
|
] |
|
|
|
] |
|
|
|