def draw_acc(index, boundary, dx): acc = acc_array() acc1 = acc[0:18,:] acc2 = acc[19:,:] print acc1 print acc2 gmsh.gmsh_geo_comment(output, 'ACC') index.start = index.point + 1 loopstartpoint = index.start for i in range(len(acc1[:,0])): index.point += 1 location = project(acc1[i,:]) gmsh.gmsh_geo_draw_point(output, index.point, location, 0.0) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, False, True) #index.start = index.point + 1 #loopstartpoint = index.start for i in range(len(acc2[:,0])): index.point += 1 location = project(acc2[i,:]) gmsh.gmsh_geo_draw_point(output, index.point, location, 0.0) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, True, True) return index
def output_open_boundaries(index, boundary, dx): parallel = arguments.bounding_lat index.start = index.point + 1 loopstartpoint = index.start index = draw_parallel_explicit([ -1.0, parallel], [ 179.0, parallel], index, None, dx) index = draw_parallel_explicit([-179.0, parallel], [ 1.0, parallel], index, None, dx) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, True, True) return index
def array_to_gmsh_points(num, index, location, minarea, region, dx, latitude_max): gmsh.gmsh_geo_comment(output, 'Ice-Land mass number %s' % (num)) count = 0 pointnumber = len(location[:,0]) valid = [False]*pointnumber validnumber = 0 loopstart = None loopend = None flag = 0 #location[:, 0] = - location[:, 0] - 90.0 for point in range(pointnumber): longitude = location[point, 0] latitude = location[point, 1] if ( check_point_required(region, location[point, :]) ): valid[point] = True validnumber += 1 if (flag == 0): loopstart = point flag = 1 elif (flag == 1): loopend = point #print latitude, valid[point] if (loopend is None): printvv('Path %i skipped (no points found in region)' % ( num )) gmsh.gmsh_geo_comment(output, ' Skipped (no points found in region)\n') return index closelast=False if (compare_points(location[loopstart,:], location[loopend,:], dx)): # Remove duplicate line at end # Note loopend no longer valid valid[loopend] = False validnumber -= 1 closelast=True validlocation = zeros( (validnumber, 2) ) close = [False]*validnumber count = 0 closingrequired = False closingrequirednumber = 0 for point in range(pointnumber): if (valid[point]): validlocation[count,:] = location[point,:] if ((closingrequired) and (count > 0)): if (compare_points(validlocation[count-1,:], validlocation[count,:], dx)): closingrequired = False close[count] = closingrequired count += 1 closingrequired = False else: if (not closingrequired): closingrequired = True closingrequirednumber += 1 if (closelast): close[-1] = True closingrequirednumber += 1 if (closingrequirednumber == 0): closingtext = '' elif (closingrequirednumber == 1): closingtext = ' (required closing in %i part of the path)' % (closingrequirednumber) else: closingtext = ' (required closing in %i parts of the path)' % (closingrequirednumber) area = area_enclosed(validlocation) if (area < minarea): printvv('Path %i skipped (area too small)' % ( num )) gmsh.gmsh_geo_comment(output, ' Skipped (area too small)\n') return index printv('Path %i points %i/%i area %g%s' % ( num, validnumber, pointnumber, area_enclosed(validlocation), closingtext )) # if (closingrequired and closewithparallel): # latitude_max = None # index_start = index + 1 # for point in range(validnumber - 1): # longitude = validlocation[point,0] # latitude = validlocation[point,1] # index += 1 # loc = project(longitude, latitude) # gmsh.gmsh_geo_draw_point(output, index, loc, 0) ) # if (latitude_max is None): # latitude_max = latitude # else: # latitude_max = max(latitude_max, latitude) # gmsh.gmsh_geo_draw_parallel(output, index, index_start, [ validlocation[point,0], max(latitude_max, validlocation[point,1]) ], [ validlocation[0,0], max(latitude_max, validlocation[0,1]) ], points=200) # index += 200 # # index += 1 # gmsh.gmsh_geo_draw_point(output, index, project(validlocation[0,0], validlocation[0,1]), 0) ) # # else: if (close[0]): close[-1] = close[0] index.start = index.point + 1 loopstartpoint = index.start for point in range(validnumber): #longitude = validlocation[point,0] #latitude = validlocation[point,1] if ((close[point]) and (point == validnumber - 1) and (not (compare_points(validlocation[point], validlocation[0], dx)))): gmsh.gmsh_geo_comment(output, '**** END ' + str(point) + '/' + str(validnumber-1) + str(close[point])) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, False, False) index = draw_parallel_explicit(validlocation[point], validlocation[0], index, latitude_max, dx) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, True, True) gmsh.gmsh_geo_comment(output, '**** END end of loop ' + str(closelast) + str(point) + '/' + str(validnumber-1) + str(close[point])) elif ((close[point]) and (point > 0) and (not (compare_points(validlocation[point], validlocation[0], dx)))): gmsh.gmsh_geo_comment(output, '**** NOT END ' + str(point) + '/' + str(validnumber-1) + str(close[point])) gmsh.gmsh_geo_comment(output, str(validlocation[point,:]) + str(validlocation[point,:])) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, False, False) index = draw_parallel_explicit(validlocation[point - 1], validlocation[point], index, latitude_max, dx) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, False, True) gmsh.gmsh_geo_comment(output, '**** NOT END end of loop ' + str(point) + '/' + str(validnumber-1) + str(close[point])) else: index.point += 1 gmsh.gmsh_geo_draw_point(output, index.point, project(validlocation[point,:]), 0) index.contournodes.append(index.point) index = gmsh.gmsh_geo_draw_loop(output, boundary, index, loopstartpoint, (closelast and (point == validnumber - 1)), False) return index