xr = .4 yr = .15 noise = N.random.random(n) a = N.random.random(n) * N.pi * 2 r = N.random.random(n) x = xc + r * xr * N.cos(a) y = yc + r * yr * N.sin(a) bathy = N.asarray([ x, y, N.exp(-(x - xc)**2 / xr**2 - (y - yc)**2 / yr**2) * 30. + noise ]).transpose() fbathy = __file__[:-2] + 'xyz' N.savetxt(fbathy, bathy) # %% Load XYZ with undersampling xyz = XYZBathy(fbathy, long_name='My XYZ', rsamp=0.01) # on aurait pu charger directement : # >>> xyz = XYZBathy(bathy) # %% Add a selection zone # -> triangulaire, par coordonnees [[x1,y1],...] xyz.select([[-5.4, 48.1], [-4.8, 48.1], [-5.1, 48.5]]) # %% Add an exclusion zone # -> rectangulaire, par coins [xmin,ymin,xmax,ymax] xyz.exclude([-5.2, 48., -5, 48.25]) # %% Info print xyz # %% Get data
# Creation de fausses bathymetries xyz # - fonction generatrice def gene_bathy(xc, yc, xr, yr, n=500, amp=30.): noise = N.random.random(n) a = N.random.random(n) * N.pi * 2 r = N.random.random(n) x = xc + xr * r * N.cos(a) y = yc + yr * r * N.sin(a) return N.asarray([ x, y, N.exp(-(x - xc)**2 / xr**2 - (y - yc)**2 / yr**2) * amp + noise ]) # - creations xyz1 = XYZBathy(gene_bathy(-5, 48.3, .3, .15)) # top right xyz2 = XYZBathy(gene_bathy(-5.45, 48.1, .45, .25, n=1000, amp=20), transp=False) # bot left # Recuperation de donnees x = xyz1.x y = xyz1.y z = xyz1.z # Exclusions/selections xyz1.select([[-5.4, 48.1], [-4.8, 48.1], [-5.1, 48.5]]) xyz1.exclude([-5.2, 48., -5, 48.25]) # Infos print xyz1.xmin # -> essayer get_xmin avec mask print xyz1.resol() # -> essayer avec deg=...
# - fonction generatrice def gene_bathy(xc, yc, xr, yr, n=500, amp=30.): noise = N.random.random(n) a = N.random.random(n) * N.pi * 2 r = N.random.random(n) x = xc + xr * r * N.cos(a) y = yc + yr * r * N.sin(a) return N.asarray([ x, y, N.exp(-(x - xc)**2 / xr**2 - (y - yc)**2 / yr**2) * amp + noise ]) # - creations xyz1 = XYZBathy(gene_bathy(-5, 48.3, .3, .15)) # top right xyz2 = XYZBathy(gene_bathy(-5.45, 48.3, .2, .1, amp=10)) # top left xyz3 = XYZBathy(gene_bathy(-5.45, 48.1, .45, .25, n=1000, amp=20), transp=False) # bot left xyz4 = XYZBathy(gene_bathy(-5., 48.1, .14, .08, n=300)) # bot right fxyz5 = __file__[:-2] + 'xyz5.xyz' N.savetxt(fxyz5, gene_bathy(-5.15, 48.2, .2, .1, amp=15).transpose()) # center # Fusion directe xyz = xyz1 + xyz2 + xyz3 + xyz4 + fxyz5 # Plot import pylab as P P.figure(figsize=(5., 8.5)) P.subplot(311)