forked from 3rdparty/wrf-python
Browse Source
Fixed indexing bug. Fixed incorrect computation of optical depth when cloud ice is not available. Users can use fill values for cloud free areas. Users can now specify the optical depth threshold that triggers the calculation. Fixes #45.lon0
14 changed files with 565 additions and 44 deletions
@ -1,2 +1,2 @@
@@ -1,2 +1,2 @@
|
||||
__version__ = "1.1.2" |
||||
__version__ = "1.1.3" |
||||
|
||||
|
@ -0,0 +1,214 @@
@@ -0,0 +1,214 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"ctt = getvar(ncfile, \"ctt\", fill_nocloud=False)\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(-80, 20, 5)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Top Temperature (degC)\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"ctt = getvar(ncfile, \"ctt\", fill_nocloud=True, opt_thresh=1.0)\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(-80, 20, 5)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Top Temperature (degC)\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"cfrac = getvar(ncfile, \"cfrac\")[2, :]\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(0, 1.1, .1)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(cfrac), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys_r\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Fraction\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 2", |
||||
"language": "python", |
||||
"name": "python2" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 2 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython2", |
||||
"version": "2.7.13" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
@ -0,0 +1,214 @@
@@ -0,0 +1,214 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"ctt = getvar(ncfile, \"ctt\")\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(-80, 20, 5)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Top Temperature (degC)\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"ctt = getvar(ncfile, \"ctt\")\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(-80, 20, 5)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(ctt), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Top Temperature (degC)\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import numpy as np\n", |
||||
"from netCDF4 import Dataset\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from matplotlib.cm import get_cmap\n", |
||||
"import cartopy.crs as crs\n", |
||||
"from cartopy.feature import NaturalEarthFeature\n", |
||||
"\n", |
||||
"from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords\n", |
||||
"\n", |
||||
"# Open the NetCDF file\n", |
||||
"ncfile = Dataset(\"/Users/ladwig/Documents/wrf_files/wrf_vortex_multi/wrfout_d01_2005-08-28_12:00:00\")\n", |
||||
"\n", |
||||
"# Get the sea level pressure\n", |
||||
"cfrac = getvar(ncfile, \"cfrac\")[2, :]\n", |
||||
"slp = getvar(ncfile, \"slp\")\n", |
||||
"\n", |
||||
"\n", |
||||
"# Get the latitude and longitude points\n", |
||||
"lats, lons = latlon_coords(ctt)\n", |
||||
"\n", |
||||
"# Get the cartopy mapping object\n", |
||||
"cart_proj = get_cartopy(ctt)\n", |
||||
"\n", |
||||
"# Create a figure\n", |
||||
"fig = plt.figure(figsize=(12,9))\n", |
||||
"# Set the GeoAxes to the projection used by WRF\n", |
||||
"ax = plt.axes(projection=cart_proj)\n", |
||||
"\n", |
||||
"# Download and add the states and coastlines\n", |
||||
"states = NaturalEarthFeature(category='cultural', scale='50m', facecolor='none',\n", |
||||
" name='admin_1_states_provinces_shp')\n", |
||||
"ax.add_feature(states, linewidth=.5)\n", |
||||
"ax.coastlines('50m', linewidth=0.8)\n", |
||||
"\n", |
||||
"# Make the contour outlines and filled contours for the smoothed sea level pressure.\n", |
||||
"levels = np.arange(0, 1.1, .1)\n", |
||||
"plt.contour(to_np(lons), to_np(lats), to_np(slp), 10, colors=\"black\",\n", |
||||
" transform=crs.PlateCarree())\n", |
||||
"plt.contourf(to_np(lons), to_np(lats), to_np(cfrac), levels=levels, transform=crs.PlateCarree(),\n", |
||||
" cmap=get_cmap(\"Greys_r\"))\n", |
||||
"\n", |
||||
"# Add a color bar\n", |
||||
"plt.colorbar(ax=ax, shrink=.88)\n", |
||||
"\n", |
||||
"# Set the map limits. Not really necessary, but used for demonstration.\n", |
||||
"ax.set_xlim(cartopy_xlim(ctt))\n", |
||||
"ax.set_ylim(cartopy_ylim(ctt))\n", |
||||
"\n", |
||||
"# Add the gridlines\n", |
||||
"ax.gridlines(color=\"black\", linestyle=\"dotted\")\n", |
||||
"\n", |
||||
"plt.title(\"Cloud Fraction\")\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 2", |
||||
"language": "python", |
||||
"name": "python2" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 2 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython2", |
||||
"version": "2.7.14" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
Loading…
Reference in new issue