Beispiel #1
0
#estimate lead fraction
tmp = val_cut.compressed()
mask_lead = (tmp == leadval[0]) | (tmp == leadval[1]) | (tmp == leadval[2]) | (tmp == leadval[3])| (tmp == leadval[4])
tmp1 = np.ma.array(tmp,mask=~mask_lead)
lead_grids =  np.ma.count(tmp1)
nolead_grids = np.ma.count_masked(tmp1)
#print lead_grids, nolead_grids
lead_fraction = float(lead_grids)/float(lead_grids+nolead_grids)
print 'lead fraction: ',lead_fraction

#estimate volume
def PolyArea(x,y):
    return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1)))

poly = shpol(bmap.poly[polyid])
px,py = poly.exterior.coords.xy
area = PolyArea(px,py)

old_ice_vol_max = area*(1-lead_fraction)*1.5
old_ice_vol_min = area*(1-lead_fraction)*1
new_ice_vol = area*lead_fraction*.28                            #estimated from lead observations 5 days after the storm (average of level ice, rafted ice excluded)

new_ice_fraction_max = new_ice_vol/(old_ice_vol_max+new_ice_vol)
new_ice_fraction_min = new_ice_vol/(old_ice_vol_min+new_ice_vol)

print 'total polygon area', area
print 'new ice volume at 1.5m old ice', new_ice_fraction_max
print 'new ice volume at 1m old ice', new_ice_fraction_min

exit()
fig1 = plt.figure(figsize=(10, 10))
ax = fig1.add_subplot(111)
ax.set_title(title1, fontsize=28)

m1 = pr.plot.area_def2basemap(area_def2)
m1.drawcoastlines()

#virtual buoys
ax.plot(x1, y1, 'o', linewidth=2, color='purple')

mask = np.ones_like(als1, dtype=bool)
mask = False
group = []
#separate triangles
for i in range(len(gtri1)):
    poly = shpol(gtri1[i])
    patch = PolygonPatch(poly, edgecolor='orchid', alpha=1, fill=False)
    ax.add_patch(patch)
    group.append(poly)

    #make mask
    px, py = poly.exterior.coords.xy
    pverts = np.vstack((px, py)).T
    path = Path(pverts)
    grid = path.contains_points(points1)
    grid = grid.reshape((xx1.shape[0], xx1.shape[1]))
    mask = np.logical_or(mask, grid)

###unified triangles
#area1 = cascaded_union(group)
#patch = PolygonPatch(area1, edgecolor='k', alpha=1, fill=False)
Beispiel #3
0
print als_map.shape
x,y = np.meshgrid(np.arange(bmap1.xmin,bmap1.xmax-1,5),np.arange(bmap1.ymax,bmap1.ymin+1,-5))
print x.shape
if title =='b':
  #fix specular reflections
  #get the open water polygons
  bmap1.readshapefile(ow,'ow', drawbounds=False)

  x,y = np.meshgrid(np.arange(bmap1.xmin,bmap1.xmax-1,5),np.arange(bmap1.ymax,bmap1.ymin+1,-5))
  gx2, gy2 = x.flatten(), y.flatten()
  points2 = np.vstack((gx2,gy2)).T

  mask = np.ones_like(als_map, dtype=bool)
  mask = False
  for xy in bmap1.ow:
      poly = shpol(xy)

      #extract a mask
      px,py = poly.exterior.coords.xy
      pverts = np.vstack((px,py)).T
      path = Path(pverts)
      grid = path.contains_points(points2)
      grid = grid.reshape((x.shape[0],x.shape[1]))
      mask = np.logical_or(mask,grid)

  #print mask
  #mask[0,0] = True
  #print np.min(mask), np.max(mask)
  #print mask.shape, grid.shape, als_map.shape

  #fix the mv in inside the survied area (specular reflections) and add the 'lead bias'
Beispiel #4
0
    #ellps = 'WGS84', projection='laea', lat_0=90., lon_0=10.,
    llcrnrlon=llcrnrlon2,
    llcrnrlat=llcrnrlat2,
    urcrnrlon=urcrnrlon2,
    urcrnrlat=urcrnrlat2)

#get the open water polygons
m2.readshapefile(ow2, 'ow')

gx2, gy2 = xx2.flatten(), yy2.flatten()
points2 = np.vstack((gx2, gy2)).T

mask = np.ones_like(als2.T, dtype=bool)
mask = False
for xy in m2.ow:
    poly = shpol(xy)
    patch = PolygonPatch(poly, edgecolor='orchid', alpha=1, fill=False)
    bx.add_patch(patch)

    #extract a mask
    px, py = poly.exterior.coords.xy
    pverts = np.vstack((px, py)).T
    path = Path(pverts)
    grid = path.contains_points(points2)
    grid = grid.reshape((xx2.shape[0], xx2.shape[1]))
    mask = np.logical_or(mask, grid)

print mask

#fix the mv in inside the survied area (specular reflections)
als2_fixed = np.where((als2.T == mv) & (mask == True), 0, als2.T)