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()
# -*- 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)
from vacumm.config import data_sample f = cdms2.open(data_sample('mars3d.t.nc')) xe = f('xe') f.close() xe.long_name = 'Original' # On crée des trous # - petits xe[:4] = MV2.masked xe[12:16] = MV2.masked # - gros xe[40:46] = MV2.masked # On rempli les petits trous (5 heures max) par interpolation cubique from vacumm.misc.grid.regridding import fill1d import time t0 = time.time() xef = fill1d(xe, method='cubic', maxgap=5) print time.time() - t0 xef.long_name = 'Rempli' xef[:] += xef.max() / 5. # on décalle pour les plots # Plots from vacumm.misc.plot import curve2, P, savefigs P.rc('font', size=9) curve2(xe, show=False, linewidth=1.5, figsize=(6, 3), top=.88, bottom=.15) curve2(xef, show=False, linewidth=1.5, title='Niveau de la mer') P.legend() savefigs(__file__, pdf=True) P.close()
# Lecture du niveau de la mer horaire import cdms2, MV2 from vacumm.config import data_sample f =cdms2.open(data_sample('mars3d.t.nc')) xe = f('xe') f.close() xe.long_name = 'Original' # On crée des trous # - petits xe[:4] = MV2.masked xe[12:16] = MV2.masked # - gros xe[40:46] = MV2.masked # On rempli les petits trous (5 heures max) par interpolation cubique from vacumm.misc.grid.regridding import fill1d import time ; t0=time.time() xef = fill1d(xe, method='cubic', maxgap=5) print time.time()-t0 xef.long_name = 'Rempli' xef[:] += xef.max()/5. # on décalle pour les plots # Plots from vacumm.misc.plot import curve2, P, savefigs P.rc('font', size=9) curve2(xe, show=False, linewidth=1.5, figsize=(6, 3), top=.88, bottom=.15) curve2(xef, show=False, linewidth=1.5, title='Niveau de la mer') P.legend() savefigs(__file__, pdf=True)