Exemplo n.º 1
0
map2(mvmask, fillcontinents=False, drawcoastlines_color='r', drawcoastlines_zorder=100,
    res=resolution, proj='merc', fill='pcolor', drawcoastlines_linewidth=2,
    cmap=cmap_rs(['1', '0.6']), contour=False, colorbar=False,
    savefig ='courses_masking_0.png', show=True)


# Cote via mask
indices = get_coastal_indices(mask)
dist = get_dist_to_coast(grid, mask)


# Erosion de la cote
f = cdms2.open(data_sample('mars3d.xy.nc'))
temp = f('temp')
f.close()
temp2 = erode_coast(temp, maxiter=3)                # changez maxiter et tracez


# Enveloppe de points
xy = P.randn(2, 500)*0.5+N.array([-5,48]).reshape(2,-1)
xe, ye = convex_hull(xy, method='delaunay')         # changez la methode


# Creer des plolygones
xpoly = [-5.8, -5, -5, -5.8]
ypoly = [48, 48, 48.5, 48.5]
polys = polygons([[xpoly, ypoly]])                  # meme chose avec des min/max + tracez
# -> appliquez a polygon_mask


# Selection de points
Exemplo n.º 2
0
     drawcoastlines_linewidth=2,
     cmap=cmap_rs(['1', '0.6']),
     contour=False,
     colorbar=False,
     savefig='courses_masking_0.png',
     show=True)

# Cote via mask
indices = get_coastal_indices(mask)
dist = get_dist_to_coast(grid, mask)

# Erosion de la cote
f = cdms2.open(data_sample('mars3d.xy.nc'))
temp = f('temp')
f.close()
temp2 = erode_coast(temp, maxiter=3)  # changez maxiter et tracez

# Enveloppe de points
xy = P.randn(2, 500) * 0.5 + N.array([-5, 48]).reshape(2, -1)
xe, ye = convex_hull(xy, method='delaunay')  # changez la methode

# Creer des plolygones
xpoly = [-5.8, -5, -5, -5.8]
ypoly = [48, 48, 48.5, 48.5]
polys = polygons([[xpoly, ypoly]])  # meme chose avec des min/max + tracez
# -> appliquez a polygon_mask

# Selection de points
xsel, ysel = polygon_select(xy[0], xy[1], polys)  # essay l'option mask
P.plot(xy[0], xy[1], 'o')
P.plot(xpoly, ypoly, 'k-', lw=2)
Exemplo n.º 3
0
xx, yy = N.indices((50, 100), 'f')
x0 = y0 = 25
dxy = 30
var = MV2.exp(-((xx - x0)**2 + (yy - y0)**2) / dxy**2)

# Masques
# - reference
mask = var.filled() > .9
mask[:, 50:] = True
mask[15:35, 65:85] = False
# - variable
var[:] = MV2.masked_greater(var, .8)
var[:, 50:] = MV2.masked

# Erode
vare = erode_coast(var, mask)

# Plots
P.figure(figsize=(6, 9))
P.subplots_adjust(hspace=.2)
P.subplot(311)
P.pcolormesh(var.asma())
P.title('Original variable')
add_key(1, color='w')
P.subplot(312)
P.pcolormesh(mask)
P.title('Reference mask')
add_key(2, color='w')
P.subplot(313)
P.pcolormesh(vare.asma())
P.title('With coastal erosion')
xx, yy = N.indices((50, 100), 'f')
x0 = y0 = 25
dxy = 30
var = MV2.exp(-((xx-x0)**2+(yy-y0)**2)/dxy**2)

# Masques
# - reference
mask = var.filled()>.9
mask[:, 50:] = True
mask[15:35, 65:85] = False
# - variable
var[:] = MV2.masked_greater(var, .8)
var[:, 50:] = MV2.masked

# Erode
vare = erode_coast(var, mask)

# Plots
P.figure(figsize=(6, 9))
P.subplots_adjust(hspace=.2)
P.subplot(311)
P.pcolormesh(var.asma())
P.title('Original variable') ; add_key(1, color='w')
P.subplot(312)
P.pcolormesh(mask)
P.title('Reference mask') ; add_key(2, color='w')
P.subplot(313)
P.pcolormesh(vare.asma())
P.title('With coastal erosion') ; add_key(3, color='w')
savefigs(__file__)