Skip to content

Instantly share code, notes, and snippets.

@j08lue
Created November 26, 2013 10:33
Show Gist options
  • Save j08lue/7656301 to your computer and use it in GitHub Desktop.
Save j08lue/7656301 to your computer and use it in GitHub Desktop.
Simple function for reading data copied from the Gaussian grid descriptions on http://www.ecmwf.int/publications/manuals/libraries/interpolation/gaussianGridsFIS.html
def gaussian_grid_from_ecmwf_data(fname,name=None):
"""Read data copied from the Gaussian grid descriptions on
http://www.ecmwf.int/publications/manuals/libraries/interpolation/gaussianGridsFIS.html
Returns
-------
lon,lat : 1D arrays
"""
dtype = np.dtype(dict(names=['latnr','nreduced','nregular','lat'],formats=['i4','i4','i4','f8']))
data = np.genfromtxt(fname,dtype=dtype,skiprows=3)
lat = data['lat']
nlon = data['nregular'][0]
lon = np.linspace(0,360,nlon+1)[:-1]
if name is None:
name = os.path.splitext(os.path.basename(fname))[0]
return lon,lat,name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment