from anuga.geospatial_data.geospatial_data import * from os import sep, environ, getenv, getcwd,umask from anuga.pmesh.mesh_interface import create_mesh_from_regions from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.shallow_water.data_manager import export_grid from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files from math import sqrt from time import localtime, strftime, gmtime from anuga.utilities.polygon import number_mesh_triangles umask(002) time = strftime('%Y%m%d_%H%M%S',gmtime()) home = getenv('INUNDATIONHOME') + sep +'data'+sep #output_dir = home + 'anuga_validation'+sep+'cocos'+sep+'anuga'+sep+'outputs'+sep+time+sep output_dir = '/d/ehn/4/ehn/tsunami/data/bathymetry/Cocos/bathymetry'+sep+time+sep #copy_code_files(output_dir,__file__) #start_screen_catcher(output_dir,verbose=True) print'testing' data_dir='/d/ehn/4/ehn/tsunami/data/bathymetry/Cocos/bathymetry/' data_dir_name = data_dir + 'new_edited_cocos_final' data_dir_name_small=data_dir_name+'_small' data_dir_name_smaller=data_dir_name+'_smaller' data_dir_name_small_clip=data_dir_name+'_small_clip' data_dir_name_clip=data_dir_name+'_clip' #print'create Geospatial data2 objects from coast' #G = Geospatial_data(file_name = data_dir_name + '.txt') #print'start split' #G_small, G_other = G.split(factor=0.1, verbose=True) #print'start export' #G_small.export_points_file(data_dir_name_smaller + '.txt') mesh_file=data_dir+'cocos_alpha.msh' sww_file='test_final' poly1 = [[439850.00,8565314.80],[439850.00, 8783110.00], [156494.00,8783110.00],[156494.00,8565314.80]] # 68450m2 grid1_res=370.4 poly2 = [[294652.80,8625096.92],[294652.80,8713178.04], [224424.96,8713178.04],[224424.96,8625096.92]] # 2738m2 grid2_res=74.08 poly3 = [[274295.91,8657346.91],[274295.91,8665112.56], [266767.44,8665112.56],[266767.44,8657346.91]] # 110m2 grid3_res=14.82 poly4 = [[270900.24,8659120.05],[270900.24,8660170.84], [269701.45,8660170.84],[269701.45,8659120.05]] # 4.3m2 grid4_res=2.96 res = 100 #G = Geospatial_data(file_name = data_dir_name + '.txt') #G1=G.clip(poly1) #G1.export_points_file(data_dir_name_clip + '.txt') interior_polys = [[poly2,(grid2_res**2/2)*res],[poly3,(grid3_res**2/2)*res],[poly4,(grid4_res**2/2)*res]] trigs_min = number_mesh_triangles(interior_polys, poly1, (grid1_res**2/2)*res) create_mesh_from_regions(poly1, boundary_tags={'side': [0,1,2,3]}, maximum_triangle_area=(grid1_res**2/2)*res, interior_regions=interior_polys, filename=mesh_file, use_cache=True, verbose=True) #value, alpha = find_optimal_smoothing_parameter(data_file=data_dir_name_clip + '.txt', value, alpha = find_optimal_smoothing_parameter(data_file=data_dir_name_small + '.txt', # alpha_list=[0.0001,0.001,0.01,0.1,1.0], alpha_list=[0.01,0.05,0.1,0.5,1.0], # alpha_list=[0.1], boundary_poly=poly1, mesh_file=mesh_file, plot_name=None, split_factor=0.001, cache=True, verbose=True)