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()
m = map2(lat=(48.41, 48.49), lon=(-5.15, -5), show=False,
    fillcontinents=False, drawcoastlines=False, figsize=(5.5, 4), 
     bgcolor=ocean, left=.12, top=.9)

# Fichier au 1/25000eme avec selection de la zone de la carte
from vacumm.bathy.shorelines import Histolitt
coast = Histolitt(m=m) # Chargement
coast.plot(show=False) # Trace

# On travail maintenant sur l'ile
# - creation d'un polygone (voir le tutoriel (*@\ref{lst:misc.grid.polygons}@*))
from _geoslib import Polygon
import numpy as N
select = Polygon(N.array([[-5.1, 48.41], [-5, 48.41], \
    [-5, 48.49], [-5.1, 48.49]]))
# - recuperation de l'ile
island = coast.greatest_polygon()
# - sauvegarde de l'ile complete dans un fichier ascii
f = N.savetxt('bathy.shorelines.dat', island.boundary)
# - boucle sur les intersections
import pylab as P
for poly in island.intersection(select):
    xx, yy = poly.boundary.transpose() # coordonnees
    P.fill(xx, yy, alpha=.5, facecolor='g', linewidth=0) # coloriage

# Fin du trace 
from pylab import show, title
from vacumm.misc.plot import savefigs
title('Trait de cote SHOM/IGN 1/25000')
savefigs(code_base_name(ext='png'), pdf=True)
Beispiel #3
0
    fillcontinents=False, drawcoastlines=False, figsize=(5.5, 4),
     bgcolor=ocean, left=.12, top=.9)

# Fichier au 1/25000eme avec selection de la zone de la carte
from vacumm.bathy.shorelines import Histolitt
coast = Histolitt(m=m) # Chargement
coast.plot(show=False) # Trace

# On travail maintenant sur l'ile
# - creation d'un polygone (voir le tutoriel (*@\ref{lst:misc.grid.polygons}@*))
from _geoslib import Polygon
import numpy as N
select = Polygon(N.array([[-5.1, 48.41], [-5, 48.41], \
    [-5, 48.49], [-5.1, 48.49]]))
# - recuperation de l'ile
island = coast.greatest_polygon()
# - sauvegarde de l'ile complete dans un fichier ascii
f = N.savetxt('bathy.shorelines.dat', island.boundary)
# - boucle sur les intersections
import pylab as P
for poly in island.intersection(select):
    xx, yy = poly.boundary.transpose() # coordonnees
    P.fill(xx, yy, alpha=.5, facecolor='g', linewidth=0) # coloriage

# Fin du trace
from pylab import show, title, close
from vacumm.misc.plot import savefigs
title('Trait de cote SHOM/IGN 1/25000')
savefigs(code_base_name(ext='png'), pdf=True)
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)
Beispiel #5
0
# -*- coding: utf8 -*-
# %% Imports
from vcmq import cdms2, MV2, data_sample, code_base_name, map2

# %% Read Hs
f = cdms2.open(data_sample('swan.four.nc'))
lon = f('longitude')
lat = f('latitude')
hs = f('HS', squeeze=1)
f.close()

# %% Plot it specifying its irregular grid
map2(hs,
     xaxis=lon,
     yaxis=lat,
     figsize=(6, 4),
     cmap='cmocean_amp',
     long_name='Significant wave height',
     fill='pcolormesh',
     contour=False,
     savefigs=code_base_name(ext='png'),
     left=.12,
     right=1,
     show=False)
# -*- coding: utf8 -*-
# Lecture et masquage de Hs
from vcmq import cdms2, MV2, data_sample, code_base_name

f = cdms2.open(data_sample("swan.four.nc"))
lon = f("longitude")
lat = f("latitude")
missing_value = f["HS"]._FillValue
hs = f("HS", squeeze=1)
f.close()
hs[:] = cdms2.MV.masked_object(hs, missing_value, copy=0)

# Trace sur grille irrégulière
from vacumm.misc.plot import map2

map2(
    hs,
    xaxis=lon,
    yaxis=lat,
    figsize=(6, 4),
    long_name="Significant wave height",
    fill="pcolormesh",
    contour=False,
    savefigs=code_base_name(ext="png"),
    left=0.12,
    right=1,
    show=False,
)