Exemplo n.º 1
0
#Step 2 read data and locate coherent regions ########################################################
nc = Dataset(datafile)
latv = nc.variables['lat_vertices'][:,:] + np.pi/2 # shift range to (0,pi)
lonv = nc.variables['lon_vertices'][:,:]
indat = nc.variables['lsm'][:,:,:]
indat = indat.reshape((1,indat.shape[2])) #drop unused dimension on lsm (format for aggregate() is 2D with time as shape[0])
nc.close()

#build map of nearest neighbours
nn = structure.nind(datafile,1) #with thresh=0.5 this gives blobs of size [406, 127, 89, 70, 39, 3, 3, 3, 2, 2, 1, 1]
#nn = structure.nind(datafile,10) #enormous radius gives one big blob

#set thresh (land are coded as 1 and sea is 0 in 'lsm' variable.
thresh = 0.5
morethan = True
blobs = structure.aggregate(indat, nn, thresh, morethan=morethan, verbose=True)


#Step 3 plot the results ############################################################################
#create colormap (and normalisation funtion for lookups on blob size)
#cmap = mpc.LinearSegmentedColormap.from_list(name='mycmap', colors=['m','r','y','w','g','c','b'])
#cnorm = mpc.Normalize(vmin=np.min(blobs[1]), vmax=np.max(blobs[1]))
#
#simple lookup works better if we're just plotting the first n-largest blobs
cmap = mpc.ListedColormap(['b','r','y','w','g','c','k'])
n = 7
reload(plotting)
ib = np.arange(0,n)
s = plotting.blobplotMayvi(blobs, latv, lonv, cmap, ib, opacity=1)
mlab.show()
Exemplo n.º 2
0
lonv = nc.variables['lon_vertices'][:, :]
indat = nc.variables['lsm'][:, :, :]
indat = indat.reshape(
    (1, indat.shape[2])
)  #drop unused dimension on lsm (format for aggregate() is 2D with time as shape[0])
nc.close()

#build map of nearest neighbours
nn = structure.nind(
    datafile, 1
)  #with thresh=0.5 this gives blobs of size [406, 127, 89, 70, 39, 3, 3, 3, 2, 2, 1, 1]
#nn = structure.nind(datafile,10) #enormous radius gives one big blob

#set thresh (land are coded as 1 and sea is 0 in 'lsm' variable.
thresh = 0.5
morethan = True
blobs = structure.aggregate(indat, nn, thresh, morethan=morethan, verbose=True)

#Step 3 plot the results ############################################################################
#create colormap (and normalisation funtion for lookups on blob size)
#cmap = mpc.LinearSegmentedColormap.from_list(name='mycmap', colors=['m','r','y','w','g','c','b'])
#cnorm = mpc.Normalize(vmin=np.min(blobs[1]), vmax=np.max(blobs[1]))
#
#simple lookup works better if we're just plotting the first n-largest blobs
cmap = mpc.ListedColormap(['b', 'r', 'y', 'w', 'g', 'c', 'k'])
n = 7
reload(plotting)
ib = np.arange(0, n)
s = plotting.blobplotMayvi(blobs, latv, lonv, cmap, ib, opacity=1)
mlab.show()
Exemplo n.º 3
0
#simple patch (close but not touching the ring)
wpt = structure.phitheta2cell(0, 90, latc, lonc)
nni = nn[wpt]  #nb nn3
for ni in nni:
    indat[0:3, ni] = 1.0

#########################################################################

#Detect structures

#set thresh
thresh = 0.5
morethan = True
blobs = structure.aggregate(
    indat, nn, thresh, morethan=morethan,
    verbose=True)  #should give sizes [1210,  617,  210,   21]

#create colormap (and normalisation funtion for lookups on blob size)
#cmap = mpc.LinearSegmentedColormap.from_list(name='mycmap', colors=['m','r','y','w','g','c','b'])
#cnorm = mpc.Normalize(vmin=np.min(blobs[1]), vmax=np.max(blobs[1]))
#
#simple lookup works better if we're just plotting the first n-largest blobs
cmap = mpc.ListedColormap(['b', 'r', 'y', 'w', 'g', 'c', 'k'])
cmap2 = mpc.ListedColormap(['#909090', '#bbbbbb'])
n = 5

reload(plotting)
ib = np.arange(1, n)
#ib = [3]
Rd = plotting.blobplotMayvi(blobs, latv, lonv, cmap, ib, R=1)
Exemplo n.º 4
0
wpt = structure.phitheta2cell(0, 90, latc, lonc)
nni = nn[wpt] #nb nn3
for ni in nni:
    indat[0:3,ni] = 1.0




#########################################################################

#Detect structures

#set thresh
thresh = 0.5
morethan = True
blobs = structure.aggregate(indat, nn, thresh, morethan=morethan, verbose=True)#should give sizes [1210,  617,  210,   21]



#create colormap (and normalisation funtion for lookups on blob size)
#cmap = mpc.LinearSegmentedColormap.from_list(name='mycmap', colors=['m','r','y','w','g','c','b'])
#cnorm = mpc.Normalize(vmin=np.min(blobs[1]), vmax=np.max(blobs[1]))
#
#simple lookup works better if we're just plotting the first n-largest blobs
cmap = mpc.ListedColormap(['b','r','y','w','g','c','k'])
cmap2 = mpc.ListedColormap(['#909090','#bbbbbb'])
n = 5

reload(plotting)
ib = np.arange(1,n)
#ib = [3]