Changeset 1097
- Timestamp:
- Mar 17, 2005, 10:23:53 AM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/least_squares.py
r1091 r1097 115 115 116 116 point_coordinates = point_dict['pointlist'] 117 title_list,point_attributes = concatinate_attributelist(point_dict['attributelist']) 117 title_list,point_attributes = concatinate_attributelist(point_dict['attributelist']) 118 119 if point_dict.has_key('geo_reference')and not point_dict['geo_reference'] is None: 120 data_origin = point_dict['geo_reference'].get_origin() 121 else: 122 data_origin = (56, 0, 0) #FIXME(DSG-DSG) 123 124 if mesh_dict.has_key('geo_reference')and not mesh_dict['geo_reference'] is None: 125 mesh_origin = mesh_dict['geo_reference'].get_origin() 126 else: 127 mesh_origin = (56, 0, 0) #FIXME(DSG-DSG) 128 118 129 if verbose: print "points file loaded" 119 130 if verbose:print "fitting to mesh" … … 146 157 147 158 #FIXME (Ole): Remember to output mesh_origin as well 159 if verbose: print "exporting to file ",mesh_output_file 148 160 export_mesh_file(mesh_output_file, mesh_dict) 149 161 -
inundation/ga/storm_surge/pyvolution/test_least_squares.py
r1096 r1097 9 9 from least_squares import * 10 10 from Numeric import allclose, array, transpose 11 12 from coordinate_transforms.geo_reference import Geo_reference 11 13 12 14 def distance(x, y): … … 1104 1106 os.remove(mesh_output_file) 1105 1107 1108 def test_fit_to_mesh_file3(self): 1109 from load_mesh.loadASCII import mesh_file_to_mesh_dictionary, \ 1110 export_mesh_file 1111 import tempfile 1112 import os 1113 1114 # create a .tsh file, no user outline 1115 mesh_dic = {} 1116 mesh_dic['vertices'] = [[0.76, 0.76], 1117 [0.76, 5.76], 1118 [5.76, 0.76]] 1119 mesh_dic['triangles'] = [[0, 2, 1]] 1120 mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]] 1121 mesh_dic['triangle_tags'] = [['']] 1122 mesh_dic['vertex_attributes'] = [[], [], []] 1123 mesh_dic['vertiex_attribute_titles'] = [] 1124 mesh_dic['triangle_neighbors'] = [[-1, -1, -1]] 1125 mesh_dic['segment_tags'] = ['external', 1126 'external', 1127 'external'] 1128 mesh_dic['geo_reference'] = Geo_reference(56,-0.76,-0.76) 1129 mesh_file = tempfile.mktemp(".tsh") 1130 export_mesh_file(mesh_file,mesh_dic) 1131 1132 #FIXME - make this test the georef in the points file as well. 1133 # create an .xya file 1134 point_file = tempfile.mktemp(".xya") 1135 fd = open(point_file,'w') 1136 fd.write("elevation, stage \n 1.0, 1.0,2.,4 \n 1.0, 3.0,4,8 \n 3.0,1.0,4.,8 \n") 1137 fd.close() 1138 1139 mesh_output_file = "new_trianlge.tsh" 1140 fit_to_mesh_file(mesh_file, 1141 point_file, 1142 mesh_output_file, 1143 alpha = 0.0) 1144 # load in the .tsh file we just wrote 1145 mesh_dic = mesh_file_to_mesh_dictionary(mesh_output_file) 1146 #print "mesh_dic",mesh_dic 1147 ans =[[0.0, 0.0], 1148 [5.0, 10.0], 1149 [5.0,10.0]] 1150 assert allclose(mesh_dic['vertex_attributes'],ans) 1151 1152 self.failUnless(mesh_dic['vertex_attribute_titles'] == 1153 ['elevation','stage'], 1154 'test_fit_to_mesh_file failed') 1155 1156 #clean up 1157 os.remove(mesh_file) 1158 os.remove(point_file) 1159 os.remove(mesh_output_file) 1160 1106 1161 def test_fit_to_mesh_fileII(self): 1107 1162 from load_mesh.loadASCII import mesh_file_to_mesh_dictionary, \
Note: See TracChangeset
for help on using the changeset viewer.