lon2d = f('longitude', **zone)
lat2d = f('latitude', **zone)
hs = MV2.masked_values(f('HS', squeeze=1, **zone), f['HS']._FillValue)
dlon = float(f.longitude_resolution)
dlat = float(f.latitude_resolution)
f.close()

# Affectation de la grille curvilineaire à la variable
from vacumm.misc.grid import curv_grid, set_grid
cgridi = curv_grid(lon2d, lat2d)
hs = set_grid(hs, cgridi)

# Rotation de la grid
from vacumm.misc.grid import rotate_grid
import numpy as N
cgrido = rotate_grid(hs.getGrid(), -30)


print 'Regrillage'
from vacumm.misc.grid.regridding import regrid2d
print ' - par SCRIP/conservative'
hs_scripcons = regrid2d(hs, cgrido, 'conservative')
print ' - par SCRIP/bilineaire'
hs_scripbilin = regrid2d(hs, cgrido, 'bilinear')


print 'Plots'
from matplotlib import rcParams ; rcParams['font.size'] = 10
import pylab as P
from vacumm.misc.plot import map2, savefigs, xhide, yhide, add_grid
P.figure(figsize=(4, 7))
lon2d = f('longitude', **zone)
lat2d = f('latitude', **zone)
hs = MV2.masked_values(f('HS', squeeze=1, **zone), f['HS']._FillValue)
dlon = float(f.longitude_resolution)
dlat = float(f.latitude_resolution)
f.close()

# Affectation de la grille curvilineaire à la variable
from vacumm.misc.grid import curv_grid, set_grid
cgridi = curv_grid(lon2d, lat2d)
hs = set_grid(hs, cgridi)

# Rotation de la grid
from vacumm.misc.grid import rotate_grid
import numpy as N
cgrido = rotate_grid(hs.getGrid(), -30)


print 'Regrillage'
from vacumm.misc.grid.regridding import regrid2d
print ' - par natgrid'
hs_nat = regrid2d(hs, cgrido, 'nat')
print ' - par SCRIP/conservative'
hs_scripcons = regrid2d(hs, cgrido, 'conservative')
print ' - par SCRIP/bilineaire'
hs_scripbilin = regrid2d(hs, cgrido, 'bilinear')


print 'Plots'
from matplotlib import rcParams ; rcParams['font.size'] = 10
import pylab as P
Esempio n. 3
0
# Imports
from vcmq import MV2, create_grid2d, code_file_name, os, CDATRegridder, N, set_grid, psinfo
from vacumm.misc.grid import rotate_grid
from time import time

# Input
nx = ny = 300
vari = MV2.array(N.arange(nx*ny*1.).reshape(ny, nx))
gridi = create_grid2d(vari.getAxis(1)[:]*50/nx,  vari.getAxis(0)[:]*50/nx)
set_grid(vari, gridi)

# Output grid
gridor = create_grid2d(vari.getAxis(1)[:]*0.09*50/nx,  
    vari.getAxis(0)[:]*0.09*50/nx)
gridoc = rotate_grid(gridi, 30)

# Log
logfile = code_file_name(ext='log')
if os.path.exists(logfile): os.remove(logfile)
f = open(logfile, 'w')
print >>f, 'NY=%(ny)i, NX=%(nx)i'%locals()

# Loop on methods
for tool, methods in config.items():
    for method in methods:
#        print tool.upper(), method
        print >>f, tool.upper(), method
        
        # rect...
        t0 = time()