Created
November 26, 2013 10:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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