SourceForge logo
SourceForge logo
Menu

matplotlib-users

Any good tutorials or examples that people could point me to on
creating a netcdf file for a grid projected with a stereographic
projection? It's not clear to me how you would create the lat / lon
dimensions.
Thanks,
john
-- 
Configuration
``````````````````````````
Basemap: 1.0
Matplotlib: 1.0.0
On Fri, Oct 29, 2010 at 7:04 PM, John <was...@gm...> wrote:
> Any good tutorials or examples that people could point me to on
> creating a netcdf file for a grid projected with a stereographic
> projection? It's not clear to me how you would create the lat / lon
> dimensions.
>
> Thanks,
> john
>
>
>
Be careful of saying "irregular" grid when what you really mean is
non-rectilinear. If the data can be represented in a matrix, then chances
are it is regular in some way.
There are a number of schemes for how to organize your data in netcdf. One
way I have seen is to represent the data in a 1D array and then have
parallel arrays of lat and lon coordinates. This works no matter how
irregular the data grid is (particularly nice with sparse data).
If the data can be represented in a regular grid, then you can represent the
data in 2D in the netcdf file, and have parallel arrays of 2-D lat and lon
arrays. The key point of these two methods is that you would have all three
arrays use an index (or two) as the common dimension.
Does that help?
Ben Root
 On 10/29/10 6:04 PM, John wrote:
> Any good tutorials or examples that people could point me to on
> creating a netcdf file for a grid projected with a stereographic
> projection? It's not clear to me how you would create the lat / lon
> dimensions.
>
> Thanks,
> john
>
>
>
John: The nice thing about netcdf is there are conventions for almost 
any kind of geophysical variable and/or grid.
See http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.4/apf.html
-Jeff
I have a file now, that I created from a NCEP grib file. I'm trying to
get the land sea mask and the veg types into 0.5x0.5 lat/lon regular
grids. However, they are still in Gaussian Grids, but at least I have
it assembled into netcdf files! I'll follow up on a post about the
conversion. but I would be interested in knowing if what I have done
below fits the 'Convention 1.4' definitions:
In [64]: vegtype = grbs.select(name='Vegetation Type')[0]
In [65]: vlats,vlons = vegtype.latlons()
In [67]: vtypes = vegtype.values
In [70]: vtypes.shape
Out[70]: (880, 1760)
In [89]: nco = NetCDFFile('/wrk/jfb/DATASETS_TEMPLATES/JFB_vegtypes.nc','w',format='NETCDF4',zlib=True)
In [91]: nco.createDimension('nrows', 880)
Out[91]: <netCDF4.Dimension object at 0x8365550>
In [92]: nco.createDimension('ncols',1760)
Out[92]: <netCDF4.Dimension object at 0x8365b50>
In [93]: lat = nco.createVariable('lat','f8',('nrows','ncols'),zlib=True)
In [94]: lat[:] = vlats
In [95]: lon = nco.createVariable('lon','f8',('nrows','ncols'),zlib=True)
In [96]: lon[:] = vlons
In [97]: data = nco.createVariable('data','int',('nrows','ncols'),zlib=True)
In [98]: data[:] = vtypes
In [99]: nco.history="Creating a vegetation types mask from the NCEP
ncep.sfluxgrbf03.grb file"
In [100]: nco.units="Integer(0-13)"
In [101]: nco.close()
In [102]: nco =
NetCDFFile('/wrk/jfb/DATASETS_TEMPLATES/JFB_vegtypes.nc',format='NETCDF4',zlib=True)
In [103]: nco.variables.keys()
Out[103]: ['lat', 'lon', 'data']
In [104]: nco.close()
I guess officially, I should add something along the lines of:
float lat(lat) ;
 lat:long_name = "latitude" ;
 lat:units = "degrees_north" ;
 lat:standard_name = "latitude" ;
Thank you,
john
-- 
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001年09月10日
Basemap: 1.0
Matplotlib: 1.0.0
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /