Пример #1
0
vari = (N.sin(xxi*N.pi/6)*N.sin(yyi*N.pi/6) +
    N.exp(-((xxi-7.)**2+(yyi-7.)**2)/4.**2))*100.
vminmax=dict(vmin=vari.min(), vmax=vari.max())
vari = cdms.createVariable(vari)
vari.setAxis(-2, cdms.createAxis(yi))
vari.setAxis(-1, cdms.createAxis(xi))
vari[3:4, 3:7] = MV.masked

# Output grid
xo = cdms.createAxis(N.linspace(-3., 23., 70))
yo = cdms.createAxis(N.linspace(-3., 13., 40))

# Interpolation
from vacumm.misc.grid.regridding import interp2d
# - bilinear
varob = interp2d(vari, (xo, yo), method='bilinear')
# - nearest
varon = interp2d(vari, (xo, yo), method='nearest')

# Plot
import pylab as P
from vacumm.misc.plot import savefigs, add_grid
xob, yob = meshbounds(xo[:], yo[:])
lims = [xob.min(), xob.max(), yob.min(), yob.max()]
# -
P.figure(figsize=(5.5, 7))
P.subplots_adjust(bottom=.07, hspace=.35)
P.subplot(311)
P.pcolor(xib, yib, vari, **vminmax)
P.axis(lims)
add_grid((xo, yo), linewidth=.3)
Пример #2
0
                                   units='m.s-1',
                                   valid_min='-100.',
                                   valid_max='100.'))
    Vis = cdms2.createVariable(
        Vis,
        typecode='f',
        id='VZ',
        axes=axes,
        attributes=dict(long_name='3d meridional velocity',
                        standard_name='northward_sea_water_velocity',
                        units='m.s-1',
                        valid_min='-100.',
                        valid_max='100.'))

    for iz, dep in enumerate(U.getLevel()):
        Ui2 = interp2d(U[0, iz, :, :], (xo, yo), method='bilinear')
        Vi2 = interp2d(V[0, iz, :, :], (xo, yo), method='bilinear')

        Uis[iz, :, :] = Ui2
        Vis[iz, :, :] = Vi2

    date = strftime('_%Y%m%d%H0000', c1)
    file_out = 'MARS_MENOR_' + date + '.nc'
    f = cdms2.open(os.path.join(dir_model, file_out), 'w')
    #f.write(LATITUDE)
    #f.write(LONGITUDE)
    #f.write(TIME)
    #f.write(DEPTH)

    f.write(Uis)  # ecriture d'une variable
    f.write(Vis)
Пример #3
0
    DEPTH = create_dep(z,attributes=dict(long_name='sea water depth',standard_name='depth',units='m',valid_min='0.',valid_max='12000.'))

    #axes = [TIME,DEPTH,LATITUDE,LONGITUDE]
    axes = [DEPTH,LATITUDE,LONGITUDE]

    Uis=np.arange(U.getLevel().__len__()*yo.__len__()*xo.__len__()).reshape(U.getLevel().__len__(),yo.__len__(),xo.__len__())
    Vis=np.arange(U.getLevel().__len__()*yo.__len__()*xo.__len__()).reshape(U.getLevel().__len__(),yo.__len__(),xo.__len__())


    Uis = cdms2.createVariable(Uis, typecode='f',id='UZ', axes=axes, attributes=dict(long_name='3d zonal velocity',standard_name='eastward_sea_water_velocity',units='m.s-1',valid_min='-100.',valid_max='100.'))
    Vis = cdms2.createVariable(Vis, typecode='f',id='VZ', axes=axes, attributes=dict(long_name='3d meridional velocity',standard_name='northward_sea_water_velocity',units='m.s-1',valid_min='-100.',valid_max='100.'))



    for iz, dep in enumerate(U.getLevel()):
        Ui2 = interp2d(U[0,iz,:,:], (xo,yo), method='bilinear')
        Vi2 = interp2d(V[0,iz,:,:], (xo,yo), method='bilinear')
 
        Uis[iz,:,:]=Ui2
        Vis[iz,:,:]=Vi2



    date=strftime('_%Y%m%d%H0000',c1)
    file_out = 'MARS_MENOR_'+date+'.nc'
    f = cdms2.open(os.path.join(dir_model,file_out), 'w')
    #f.write(LATITUDE)
    #f.write(LONGITUDE)
    #f.write(TIME)
    #f.write(DEPTH)