# Interpolation
from vacumm.misc.grid.regridding import grid2xy
vo = grid2xy(v, xo, yo, method='bilinear')

# Plot
# - variable interpolee
from vacumm.misc.plot import hov2 as hov, savefigs, map2 as map
hov(vo,
    cmap='jet',
    show=False,
    top=.9,
    date_fmt='%H',
    colorbar_shrink=.5,
    left=.13)
# - carte + diagonal
import pylab as P
m = map(v[0],
        xhide=True,
        yhide=True,
        contour=False,
        title=False,
        autoresize=0,
        cmap='cmap_bwr',
        colorbar=False,
        axes_rect=[.78, .78, .2, .2],
        show=False)
m.map.plot(xo, yo, 'r-', lw=2)
savefigs(__file__)
P.close()
Exemple #2
0
                 lat=(mila, mala),
                 nofill=True,
                 quiverkey_value=2,
                 quiver_scale=35,
                 quiver_norm=3,
                 contour=False,
                 quiver_alpha=.9,
                 quiver_width=7.,
                 title='Wind - ' + strftime(
                     '%d/%m/%Y - %H:%M:%S',
                     cdtime.reltime(u10.getTime().getValue()[it],
                                    u10.getTime().units).tocomp()),
                 show=False,
                 levels=levels,
                 colorbar_shrink=.7,
                 right=1,
                 quiver_samp=1,
                 cmap='cmap_jete')
    # => Practice : change map parameters.

    print strftime(
        '%d/%m/%Y - %H:%M:%S',
        cdtime.reltime(u10.getTime().getValue()[it],
                       u10.getTime().units).tocomp())

    m = map((u10[it, 0, :, :], v10[it, 0, :, :]), **kwarg)
    # => Practice: instead of a quiver map, generate a map with current amplitude.

    P.show()
    # savefigs('Wind_'+strftime('%Y%m%d_%H%M%S',cdtime.reltime(u10.getTime().getValue()[it],u10.getTime().units).tocomp())+'.png',dpi=200)
temp.long_name = 'Original'

# On crée un trou
temp[15:60, 40:80] = MV2.masked

# On rempli des trous
from vacumm.misc.grid.regridding import fill2d
tempf = fill2d(temp, method='carg')
tempf.long_name = 'Rempli'

# On masque la terre
from vacumm.misc.grid.masking import masked_polygon
tempf[:] = masked_polygon(tempf, 'h', copy=0)

# Plots
from vacumm.misc.plot import map2 as map, P
P.rc('font', size=9)
kw = dict(vmin=9, vmax=13)
map(temp,
    show=False,
    subplot=211,
    hspace=.2,
    bottom=.05,
    left=.08,
    top=.97,
    figsize=(4.5, 8),
    nmax=10,
    **kw)
map(tempf, show=False, subplot=212, savefigs=code_base_name(ext='png'), **kw)
P.close()
# Lecture et masquage de la SST
import cdms2
from vacumm.config import data_sample
f = cdms2.open(data_sample('mars3d.xy.nc'))
sst = f('temp', time=slice(0, 1),  lat=(47.8, 48.6), lon=(-5.2, -4.25),  squeeze=1) 
f.close()
import pylab as P
# Trace de la carte
from vacumm.misc.plot import map2 as map
m = map(sst, title='SST en iroise', 
    vmin=9, top=.9, figsize=(6, 5), clabel_glow=True, contour_alpha=1, 
    show=False, savefigs=__file__)
xo = N.linspace(lon[0], lon[-1], nd)
yo = N.linspace(lat[0], lat[-1], nd)

# Interpolation
from vacumm.misc.grid.regridding import grid2xy

vo = grid2xy(v, xo, yo, method="bilinear")

# Plot
# - variable interpolee
from vacumm.misc.plot import hov2 as hov, savefigs, map2 as map

hov(vo, cmap="jet", show=False, top=0.9, date_fmt="%H", colorbar_shrink=0.5, left=0.13)
# - carte + diagonal
import pylab as P

m = map(
    v[0],
    xhide=True,
    yhide=True,
    contour=False,
    title=False,
    autoresize=0,
    cmap="cmap_bwr",
    colorbar=False,
    axes_rect=[0.78, 0.78, 0.2, 0.2],
    show=False,
)
m.map.plot(xo, yo, "r-", lw=2)
savefigs(__file__)
    levels = auto_scale(mod, nmax=10, vmin=0.0, vmax=10.0)
    kwarg = dict(
        m=m,
        lon=(milo, malo),
        lat=(mila, mala),
        nofill=True,
        quiverkey_value=2,
        quiver_scale=35,
        quiver_norm=3,
        contour=False,
        quiver_alpha=0.9,
        quiver_width=7.0,
        title="Wind - "
        + strftime("%d/%m/%Y - %H:%M:%S", cdtime.reltime(u10.getTime().getValue()[it], u10.getTime().units).tocomp()),
        show=False,
        levels=levels,
        colorbar_shrink=0.7,
        right=1,
        quiver_samp=1,
        cmap="cmap_jete",
    )
    # => Practice : change map parameters.

    print strftime("%d/%m/%Y - %H:%M:%S", cdtime.reltime(u10.getTime().getValue()[it], u10.getTime().units).tocomp())

    m = map((u10[it, 0, :, :], v10[it, 0, :, :]), **kwarg)
    # => Practice: instead of a quiver map, generate a map with current amplitude.

    P.show()
    # savefigs('Wind_'+strftime('%Y%m%d_%H%M%S',cdtime.reltime(u10.getTime().getValue()[it],u10.getTime().units).tocomp())+'.png',dpi=200)
# -*- coding: utf8 -*-
from vacumm.misc.grid.regridding import regrid2d
import MV2
from vacumm.misc.grid import create_grid
from vacumm.misc.plot import map2 as map
import pylab as P
gmax=40
ggi = create_grid((0., gmax, 1.), (0., gmax, 1.))
ggo = create_grid((0.01, gmax, .5), (0.01, gmax, .5))

vari = MV2.reshape(MV2.arange(ggi.size(), dtype='f'), ggi.shape)
vari.setGrid(ggi)
varo = regrid2d(vari, ggo, 'bilinear')
map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__)
Exemple #8
0
from vacumm.misc.plot import map2 as map, savefigs, make_movie
from vacumm.misc import auto_scale
import gc, pylab as P
m = None
levels = auto_scale(mod, nmax=10, vmin=0.)
nt = len(u)
for it in xrange(nt):
    print it

    # Bathymetry
    m = map(
        h0,
        show=False,
        close=False,
        nofill=True,
        linewidth=.3,
        proj='merc',
        fmt='%i m',
        m=m,
        contour_colors='#555555',
    )

    # Currents
    map((u[it], v[it]),
        m=m,
        nofill=True,
        quiverkey_value=1,
        quiver_scale=.05,
        quiver_units='dots',
        quiver_scale_units='dots',
        quiver_norm=3,
# -*- coding: utf8 -*-
# Lecture de la temperature
import cdms2, MV2
from vacumm.config import data_sample
from vcmq import code_base_name
f = cdms2.open(data_sample('mars3d.xy.nc'))
temp = f('temp', lon=(-5.5, -4), lat=(47, 49))
f.close()
temp.long_name = 'Original'

# On crée un trou
temp[15:60, 40:80] = MV2.masked

# On rempli des trous
from vacumm.misc.grid.regridding import fill2d
tempf = fill2d(temp, method='carg')
tempf.long_name = 'Rempli'

# On masque la terre
from vacumm.misc.grid.masking import masked_polygon
tempf[:] = masked_polygon(tempf, 'h', copy=0)

# Plots
from vacumm.misc.plot import map2 as map, P
P.rc('font', size=9)
kw = dict(vmin=9, vmax=13)
map(temp, show=False, subplot=211, hspace=.2, bottom=.05, 
    left=.08, top=.97, figsize=(4.5, 8), nmax=10, **kw)
map(tempf, show=False, subplot=212, savefigs=code_base_name(ext='png'), **kw)
# -*- coding: utf8 -*-
from vacumm.misc.grid.regridding import regrid2d
import MV2
from vacumm.misc.grid import create_grid
from vacumm.misc.plot import map2 as map
import pylab as P
gmax=40
ggi = create_grid((0., gmax, 1.), (0., gmax, 1.))
ggo = create_grid((0.01, gmax, .5), (0.01, gmax, .5))

vari = MV2.reshape(MV2.arange(ggi.size(), dtype='f'), ggi.shape)
vari.setGrid(ggi)
varo = regrid2d(vari, ggo, 'bilinear')
map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__,
    close=True)
Exemple #11
0
# ==> Practice: Create cdarr with depth/lat axes. - see doc Vacumm -
# # - depth
# ax1 = create_dep(N.linspace(-1000,0,10))
# # - latitude
# ax2 = create_lat(N.arange(15)*.5+44.)


# ==> Practice: Create cdarr with time/lat axes. - see doc Vacumm -
# # - time
# ax1 = create_time(N.arange(10.),
    # 'days since 2006-10-01',long_name='Mon axe de temps')
# # - latitude
# ax2 = create_lat(N.arange(15)*.5+44.)

# - cdms2 variable creation
cdarr = cdms2.createVariable(marr,axes=[ax1,ax2],id='test',attributes=dict(long_name='the main test',units='$m^3 s^{-1}$'))
print 'Array type - cdarr - :',type(cdarr)
print 'Variable :',cdarr.id
# print 'Longitude :',cdarr.getLongitude()
# print 'Latitude :',cdarr.getLatitude()
# print cdarr

# - Result snapshot
if islon(cdarr.getAxis(0)):
    map(cdarr, contour=False)
if isdep(cdarr.getAxis(0)):
    section2(cdarr, contour=False)
if istime(cdarr.getAxis(0)):
    hov2(cdarr, contour=False)
# Plots
from matplotlib import rc

rc("font", size=9)
from vacumm.misc.plot import map2 as map, savefigs, make_movie
from vacumm.misc import auto_scale
import gc, pylab as P

m = None
levels = auto_scale(mod, nmax=10, vmin=0.0)
nt = len(u)
for it in xrange(nt):
    print it
    # Bathymetrie
    m = map(h0, show=False, close=False, nofill=True, proj="merc", fmt="%i m", m=m, contour_colors="#555555")
    # Courants
    map(
        (u[it], v[it]),
        m=m,
        nofill=True,
        quiverkey_value=1,
        quiver_scale=10,
        quiver_norm=3,
        contour=False,
        quiver_linewidth=0.5,
        quiver_alpha=0.9,
        quiver_width=7.0,
        quiver_headwidth=2.5,
        quiver_headlength=2.5,
        quiver_headaxislength=2,