# 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()
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)
# Ligne de points et intersection # - coordonnees xy = N.array([[2., 7., 20., 26.], [2., 2., 28., 28.]]) # - LineString line = LineString(xy.transpose()) # - plot P.plot(xy[0], xy[1], '-r') # - intersection (via 'intersects()') ? print line.intersects(poly) # -> True # - plot des intersections (via intersection) for subline in line.intersection(poly): # = poly.intersection(line) xyl = subline.boundary P.plot(xyl[:, 0], xyl[:, 1], '-', color=(0, 1, 0)) # Autre polygone # - creation et plot xyp = N.array([[22., 3], [25., 7], [28, 3]]) triangle = Polygon(xyp) P.fill(xyp[:, 0], xyp[:, 1], facecolor='b', alpha=.5) # - intersections if triangle.intersects(poly): for pol in triangle.intersection(poly): xyp = pol.boundary P.fill(xyp[:, 0], xyp[:, 1], facecolor='y', alpha=.5) # Trace from vacumm.misc.plot import savefigs P.axis([0, 30, 0, 30]) savefigs(__file__, pdf=True)
precip.long_name = 'Original' # Nouvel echantillonnage / 2h hours2 = create_time((10, 30., 2), 'hours since 2000') # Regrillage 1D conservatif from vacumm.misc.grid.regridding import regrid1d precip2 = regrid1d(precip, hours2, 'conservative') precip2.long_name = 'Regridded' # Verifications print 'Total precip.:' print '- original =', precip.sum() print '- remapped =', precip2.sum() # > Total precip.: # > - original = 89.957242832779755 # > - remapped = 89.957237 # Plots from vacumm.misc.plot import savefigs from vacumm.misc.plot import bar2 kwplot = dict(color='#00ffff',edgecolor='#55aaaa', width=.9, date_fmt='%Hh', show=False) b = bar2(precip, figsize=(5.5, 6), xhide=True, subplot=211, top=.9, **kwplot) b.figtext('Precipitations', style='italic') bar2(precip2, subplot=212, **kwplot) savefigs(__file__, pdf=True) b.close()
# - natgrid from vacumm.misc.grid.regridding import griddata zirn = griddata(xi, yi, zi, (xr, yr), method='nat', ext=True, sub=6) # - krigeage zirk = griddata(xi, yi, zi, (xr, yr), method='carg') # Plot de verif import pylab as P from vacumm.misc.plot import savefigs P.figure(1, figsize=(6, 8)) P.subplots_adjust(hspace=.3, bottom=.05, top=.95, left=.06) # - regulier P.subplot(311) P.pcolor(xrb, yrb, zzr, **vminmax) P.xlim(xrb.min(), xrb.max()) ; P.ylim(yrb.min(), yrb.max()) P.title('Original') stdref = zzr.std() # - irregulier via natgrid P.subplot(312) P.pcolor(xrb, yrb, zirn, **vminmax) P.plot(xi, yi, 'ko') P.xlim(xrb.min(), xrb.max()) ; P.ylim(yrb.min(), yrb.max()) P.title('Natgrid (err = %02i%%)'%((zzr-zirn).std()*100/stdref)) # - irregulier via cargen P.subplot(313) P.pcolor(xrb, yrb, zirk, **vminmax) P.plot(xi, yi, 'ko') P.xlim(xrb.min(), xrb.max()) ; P.ylim(yrb.min(), yrb.max()) P.title('Minicargen (err = %02i%%)'%((zzr-zirk).std()*100/stdref)) savefigs(__file__)
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()
colorbar_shrink=.7, right=1, quiver_samp=2, figsize=(6, 4.5), proj='merc', title='Courants Bretagne sud') # Progress P.text(.98 * m.xmax, .98 * m.ymax, '%i / %i' % (it + 1, nt), ha='right', va='top', zorder=200, size=12, family='monospace') # Save P.savefig('quiver%02i.png' % it) if it == 0: savefigs(__file__[:-3] + '_png.png') P.close() gc.collect() # Animations outbase = __file__[:-3].replace('.', '-') # - gif anime make_movie('quiver*.png', outbase + '.gif') # - video compatible windows #make_movie('quiver*.png', outbase+'_mpg.mpg', clean=True) print 'Done'
quiver_samp=2, figsize=(6, 4.5), proj="merc", title="Courants Bretagne sud", ) # Indicateur de progression P.text( 0.98 * m.xmax, 0.98 * m.ymax, "%i / %i" % (it + 1, nt), ha="right", va="top", zorder=200, size=12, family="monospace", ) # Savegardes P.savefig("quiver%02i.png" % it) if it == 0: savefigs(__file__[:-3] + "_png.png") P.close() gc.collect() # Creation des animations outbase = __file__[:-3].replace(".", "-") # - gif anime make_movie("quiver*.png", outbase + ".gif") # - video compatible windows # make_movie('quiver*.png', outbase+'_mpg.mpg', clean=True) print "Done"