This example is just awesome! I really appreciate the time you put into this but it's way way over my head... There are a couple issues I have especially that I just started using python and matplotlib a couple days ago. First, the direct reading of the grib file is great but I am not able to download Nio. The link they sent me to confirm the registration goes to a page that is not available...
Anton: I downloaded and installed it this morning and it worked fine. If you're having problems, I'd suggest emailing them - they are quite responsive.
Also, because I figured out the data I need and already have the scripts in place to extract the CSV files I would really like to keep it that way. Would it be possible to just show me how to get from the csv file to the plot?
It's a matter of reading the CSV files into 2D arrays (lons,lats,data). I don't have time right now to work that out for your data. Anyway, I think you'll be happier in the long run if you bite the bullet now and learn how to use PyNIO to read the data.
Thanks a lot!
Jeff Whitaker wrote:
Better yet, here is the file that I am using on my testing but keep in
that it's a 33mb file:
Anton: I had already downloaded a file from the ftp site, so here's an example script:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
f = Nio.open_file('akw.t00z.grib.grib2')
lons = f.variables['lon_0'][:]
# flip latitudes so data goes S-->N
lats = f.variables['lat_0'][::-1]
times = f.variables['forecast_time0'][:]
datavar = f.variables['WWSWHGT_P0_L1_GLL0']
ntime = 10
data = datavar[ntime,::-1]
print data.min(), data.max()
m = Basemap(projection='cyl',llcrnrlat=lats,llcrnrlon=lons,\
x, y = m(*np.meshgrid(lons, lats))
levels = np.arange(0,9.1,0.5)
plt.title(datavar.long_name+' %s hr fcst'%(times[ntime]),fontsize=12)
The resulting plot is attached.
Note you will need the Basemap toolkit (available from the matplotlib download site). If you don't want to plot the coastlines, you can just use plt.contourf. You'll also need PyNIO (http://www.pyngl.ucar.edu/Nio.shtml) to read the GRIB file.
The png produced by this script is attached.
Let me know if you have any questions.
Here is the link to the folder that has the grib files. They are updated
every 3 hours:
Any of the files there would have the same info only at different times
Matplotlib-users mailing list
Quoted from: http://www.nabble.com/Plotting-NOAA-data…-tp21139727p21149409.html