Beispiel #1
0
# para generar las matrices de GEFS de lat lon segui los siguientes pasos en ipython:
#Martin Iglesias Github SudestadaARG
import numpy as np
from grads import GrADS

ga = GrADS(Bin='grads', Echo=False, Port=True, Window=False)

CTL = ga.open('gens_20151201_0000_012_01.ctl')

ga('set lev 1000')
t = ga.exp('TMPPRS')

lats = t.grid.lat[:]  # (181,)
lons = t.grid.lon[:]  # (361,)

np.save('lon_gefs.npy', lons)
np.save('lat_gefs.npy', lats)

# Para generar las 2D con dimension (181,361):
lat2d = np.empty((181, 361))
for i in range(0, 361):
    lat2d[:, i] = lats

lon2d = np.empty((181, 361))
for i in range(0, 181):
    lon2d[i, :] = lons

np.save('lon2d_gefs.npy', lon2d)
np.save('lat2d_gefs.npy', lat2d)
Beispiel #2
0
#!/usr/bin/env python
#
# Simple script testing the ext()/expr() methods
#

from pylab import *
from grads import GrADS

# Start GrADS and open the data file
# ----------------------------------
ga = GrADS(Bin='grads', Echo=False, Port=True, Window=False)
ga.open('../data/model.ctl')

# XY slices
# ---------
ts1 = ga.exp('ts')
ts2 = ga.expr('ts')
print "XY Skin temperature: "
print ts1.data - ts2.data

# XYT slices
# ----------
ga('set t 2 3')
ts1 = ga.exp('ts')
ts2 = ga.expr('ts')
print "XYT Skin temperature: "
print ts1.data - ts2.data

# XYZ slices
# ----------
ga('set t 3')
Beispiel #3
0
# gridpoint.
#

from pylab import *
from numpy import float32
from grads import GrADS, GaField

# Start GrADS and open the data file
# ----------------------------------
ga = GrADS(Bin='gradsnc',Echo=False,Port=True)
ga.open('../data/slp_djf.nc')

# Extract a timeseries
# --------------------
ga('set t 1 41')         
x = ga.exp('djfslp/100')
g = x.grid

# Transpose spatial/temporal dimensions
# -------------------------------------
(nt,ny,nx) = x.shape;
x = transpose(x.reshape((nt,nx*ny)))

# Compute percentiles using Matlab compatible prctile function
# ------------------------------------------------------------
p = ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 )
y = zeros((nx*ny,10),dtype=float32)
for i in range(nx*ny):
    y[i,:] = prctile(x[i,:],p)
y = transpose(y);
y = y.reshape((10,ny,nx)) # save the pecentile dimension as time