Changeset 4663
- Timestamp:
- Aug 7, 2007, 2:20:57 PM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r4647 r4663 949 949 950 950 return texfile, elev_output 951 952 953 954 #Fixme - Use geospatial to read this file - it's an xya file 955 #Need to include other information into this filename, so xya + Name - required for report 951 956 952 def get_gauges_from_file(filename): 957 953 """ Read in gauge information from file -
anuga_core/source/anuga/alpha_shape/alpha_shape.py
r4165 r4663 39 39 40 40 Inputs: 41 point_file: File location of the input file, points format (. xyaor .pts)41 point_file: File location of the input file, points format (.csv or .pts) 42 42 boundary_file: File location of the generated output file 43 43 alpha: The alpha value can be optionally specified. If it is not specified … … 676 676 Save the boundary to a file. 677 677 678 usage: alpha_shape.py point_file. xyaboundary_file.bnd [alpha]678 usage: alpha_shape.py point_file.csv boundary_file.bnd [alpha] 679 679 680 680 The alpha value is optional. … … 682 682 683 683 import os, sys 684 usage = "usage: %s point_file. xyaboundary_file.bnd [alpha]"%os.path.basename(sys.argv[0])684 usage = "usage: %s point_file.csv boundary_file.bnd [alpha]"%os.path.basename(sys.argv[0]) 685 685 if len(sys.argv) < 3: 686 686 print usage -
anuga_core/source/anuga/alpha_shape/test_alpha_shape.py
r3514 r4663 173 173 import tempfile 174 174 175 fileName = tempfile.mktemp(".xya") 176 #(h,fileName) = tempfile.mkstemp(".xya") 175 fileName = tempfile.mktemp(".csv") 177 176 file = open(fileName,"w") 178 file.write(" \n\177 file.write("x,y\n\ 179 178 0.0, 0.0\n\ 180 179 1.0, 0.0\n\ -
anuga_core/source/anuga/coordinate_transforms/geo_reference.py
r4470 r4663 15 15 16 16 DEFAULT_ZONE = -1 17 TITLE = '#geo reference' + "\n" #this title is referred to in the .xyaformat17 TITLE = '#geo reference' + "\n" #this title is referred to in the test format 18 18 19 19 DEFAULT_PROJECTION = 'UTM' … … 149 149 print "ANUGA does not correct for differences in units." 150 150 151 151 ### ASCII files with geo-refs are currently not used 152 152 def write_ASCII(self, fd): 153 153 fd.write(TITLE) -
anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py
r4391 r4663 8 8 from geo_reference import * 9 9 from Numeric import allclose,array 10 11 # Ignore these warnings, since we still want to test .xya code.12 import warnings13 warnings.filterwarnings(action = 'ignore',14 message='.xya format is deprecated. Please use .txt.',15 category=DeprecationWarning)16 17 warnings.filterwarnings(action = 'ignore',18 message='Text file format is moving to comma se',19 category=DeprecationWarning)20 10 21 11 … … 312 302 313 303 def test_bad_ASCII_title(self): 314 # create an .xyafile315 point_file = tempfile.mktemp(".x ya")304 # create an text file 305 point_file = tempfile.mktemp(".xxx") 316 306 fd = open(point_file,'w') 317 307 fd.write("# hey! \n") … … 388 378 self.failUnless(g == new_g, 'test_read_write_ASCII failed') 389 379 390 def xxtest_good_title(self):391 # create an .x yafile392 point_file = tempfile.mktemp(".x ya")380 def test_good_title(self): 381 # create an .xxx file 382 point_file = tempfile.mktemp(".xxx") 393 383 fd = open(point_file,'w') 394 384 fd.write("#Geo crap \n 56\n ") … … 402 392 fd.close() 403 393 os.remove(point_file) 404 except TitleError:394 except ValueError: 405 395 fd.close() 406 396 os.remove(point_file) -
anuga_core/source/anuga/fit_interpolate/fit.py
r4650 r4663 316 316 List of coordinate pairs [x, y] of 317 317 data points or an nx2 Numeric array or a Geospatial_data object 318 or filename (txt, csv, pts?)318 or points file filename 319 319 z: Single 1d vector or array of data at the point_coordinates. 320 320 … … 568 568 display_errors = True): 569 569 """ 570 Given a mesh file (tsh) and a point attribute file (xya), fit570 Given a mesh file (tsh) and a point attribute file, fit 571 571 point attributes to the mesh and write a mesh file with the 572 572 results. 573 573 574 Note: the .xya files needtitles. If you want anuga to use the tsh file,574 Note: the points file needs titles. If you want anuga to use the tsh file, 575 575 make sure the title is elevation. 576 576 -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r4651 r4663 324 324 The results are written to a csv file. 325 325 326 In the future let points be a csv or xyafile.326 In the future let points be a points file. 327 327 And the user choose the quantities. 328 328 -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r4661 r4663 130 130 self.geo_reference=None #create the attribute 131 131 self.file_name = file_name 132 self.max_read_lines = max_read_lines 132 133 if max_read_lines is None: 134 self.max_read_lines = MAX_READ_LINES 135 else: 136 self.max_read_lines = max_read_lines 133 137 134 138 if file_name is None: … … 545 549 546 550 """ 547 write a points file, file_name, as a text (. xya) or binary (.pts) file551 write a points file, file_name, as a text (.csv) or binary (.pts) file 548 552 file_name is the file name, including the extension 549 553 The point_dict is defined at the top of this file. … … 715 719 716 720 # FIXME (Ole): Shouldn't this go into the constructor? 721 # This method acts like the constructor when blcoking. 717 722 # ... and shouldn't it be called block_size? 723 # 718 724 if self.max_read_lines is None: 719 725 self.max_read_lines = MAX_READ_LINES -
anuga_core/source/anuga/load_mesh/loadASCII.py
r4496 r4663 1 1 """ 2 The format for a .xya file is: 3 1st line: [attribute names] 4 other lines: x y [attributes] 5 6 for example: 7 elevation, friction 8 0.6, 0.7, 4.9, 0.3 9 1.9, 2.8, 5, 0.3 10 2.7, 2.4, 5.2, 0.3 11 12 The first two columns are always implicitly assumed to be x, y coordinates. 13 Use the same delimiter for the attribute names and the data 14 15 An xya file can optionally end with 16 #geo reference 17 56 18 466600.0 19 8644444.0 20 21 When the 1st # is the zone, 22 2nd # the xllcorner and 23 3rd # the yllcorner 2 24 3 The format for a Points dictionary is: 25 4 … … 42 21 segment_tags : [tag,tag,...] list of strings 43 22 triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points 44 triangle_tags: [s1,s2,...] A list of list of strings (probably not neccecary. a list of string should be ok) 23 triangle_tags: [s1,s2,...] A list of list of strings (probably not 24 neccecary. a list of string should be ok) 45 25 triangle_neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles 46 26 … … 58 38 is relative. This is optional. 59 39 60 Points files are . xyafor ascii and .pts for NetCDF40 Points files are .csv for ascii and .pts for NetCDF 61 41 Mesh files are .tsh for ascii and .msh for NetCDF 62 42 -
anuga_core/source/anuga/pmesh/graphical_mesh_generator.py
r3514 r4663 119 119 120 120 self.menuBar.addmenuitem('File', 'command', 121 'Export ASCII xyafile',122 label='Export ASCII xyafile...',121 'Export ASCII csv file', 122 label='Export ASCII csv file...', 123 123 command=self.exportPointsFile) 124 124 … … 1189 1189 1190 1190 except SyntaxError: 1191 # this is assuming that the SyntaxError is thrown in1192 # loadxyafile1191 # This is assuming that the SyntaxError is thrown in 1192 # importUngenerateFile 1193 1193 showerror('File error', 1194 1194 ofile + ' is not in the correct format.') … … 1226 1226 ofile = tkFileDialog.asksaveasfilename(initialdir=self.currentPath, 1227 1227 filetypes=[("point files", 1228 "*. xya*.pts"),1228 "*.csv *.txt *.pts"), 1229 1229 ("All Files", "*")]) 1230 1230 if ofile: 1231 # . xyais the default file format1232 if (ofile[-4:] == ". xya" or ofile[-4:] == ".pts"):1231 # .csv is the default file format 1232 if (ofile[-4:] == ".csv" or ofile[-4:] == ".pts"): 1233 1233 self.currentFilePathName = ofile 1234 1234 else: 1235 self.currentFilePathName = ofile + ". xya"1235 self.currentFilePathName = ofile + ".csv" 1236 1236 1237 1237 try: … … 1248 1248 ofile = tkFileDialog.askopenfilename(initialdir=self.currentPath, 1249 1249 filetypes=[ ("text Mesh", "*.tsh *.msh"), 1250 ("points", "*. xya*.pts"),1250 ("points", "*.csv *.txt *.pts"), 1251 1251 ("All Files", "*")]) 1252 1252 if ofile == "": -
anuga_core/source/anuga/pmesh/mesh.py
r4458 r4663 1214 1214 del v.dupindex 1215 1215 return Vertices,counter 1216 1216 1217 # FIXME (DSG-DSG) Move this to geospatial 1217 1218 def thinoutVertices(self, delta): 1218 1219 """Pre-condition: There are no user segments … … 2015 2016 def exportPointsFile(self,ofile): 2016 2017 """ 2017 export a points (.xya or .pts)file, ofile.2018 export a points file, ofile. 2018 2019 2019 2020 """ … … 2999 3000 3000 3001 def importMeshFromFile(ofile): 3001 """returns a mesh object, made from a .xya/.ptsor .tsh/.msh file3002 """returns a mesh object, made from a points file or .tsh/.msh file 3002 3003 Often raises IOError,RuntimeError 3003 3004 """ 3004 3005 newmesh = None 3005 if (ofile[-4:]== ". xya" or ofile[-4:]== ".pts" or ofile[-4:]== ".txt" or \3006 if (ofile[-4:]== ".pts" or ofile[-4:]== ".txt" or \ 3006 3007 ofile[-4:]== ".csv"): 3007 3008 geospatial = Geospatial_data(ofile) -
anuga_core/source/anuga/pmesh/test_all.py
r3193 r4663 77 77 78 78 if __name__ == '__main__': 79 80 from os import sep 81 82 #Attempt to compile all extensions 83 execfile('..' + sep + 'utilities' + sep + 'compile.py') 84 85 #FIXME: Temporary measure 86 os.chdir('..' + sep + 'utilities') 87 execfile('compile.py') 88 os.chdir('..' + sep + 'pmesh') 79 # Assume everything is compiled 89 80 90 #FIXME: Temporary measure91 os.chdir('..' + sep + 'mesh_engine')92 execfile('compile.py')93 os.chdir('..' + sep + 'pmesh')94 95 #os.system('python compile.py')96 97 81 #print regressionTest() 98 82 unittest.main(defaultTest='regressionTest') -
anuga_core/source/anuga/pmesh/test_mesh.py
r4165 r4663 979 979 980 980 981 def test_load xy(self):981 def test_load_csv(self): 982 982 """ 983 To test the mesh side of loading xyafiles.984 Not the loading of xyafiles983 To test the mesh side of loading csv files. 984 Not the loading of csv files 985 985 """ 986 986 import os … … 1010 1010 # 'loadxy, test 5 failed') 1011 1011 1012 def exportPointsFile(self):1012 def test_exportPointsFile(self): 1013 1013 a = Vertex (0,0) 1014 1014 b = Vertex (0,3) … … 1031 1031 1032 1032 fileName = tempfile.mktemp(".txt") 1033 #fileName = 't. xya'1033 #fileName = 't.csv' 1034 1034 #os.remove(fileName) 1035 1035 m.exportPointsFile(fileName) … … 1037 1037 lFile = file.read().split('\n') 1038 1038 file.close() 1039 1040 1039 os.remove(fileName) 1041 self.failUnless(lFile[0] == "x,y " and1042 lFile[1] == "0 ,0" and1043 lFile[2] == "0 ,3" and1044 lFile[3] == "3 ,3"1040 self.failUnless(lFile[0] == "x,y," and 1041 lFile[1] == "0.0,0.0" and 1042 lFile[2] == "0.0,3.0" and 1043 lFile[3] == "3.0,3.0" 1045 1044 , 1046 'exported Ascii xyafile is wrong')1047 self.failUnless(lFile[4] == "1 ,2" and1048 lFile[5] == "3 ,1"1045 'exported Ascii csv file is wrong') 1046 self.failUnless(lFile[4] == "1.0,2.0" and 1047 lFile[5] == "3.0,1.0" 1049 1048 , 1050 'exported Ascii xyafile is wrong')1049 'exported Ascii csv file is wrong') 1051 1050 1052 1051 # vertex e is outside of the outline, so 1053 1052 # it is a loner and it is removed. 1054 1053 m.generateMesh("Q", maxArea = 2.1) 1055 fileName = tempfile.mktemp(". xya")1056 #fileName = 't. xya'1054 fileName = tempfile.mktemp(".txt") 1055 #fileName = 't.csv' 1057 1056 #m.export_mesh_file('m.tsh') 1058 1057 m.exportPointsFile(fileName) … … 1062 1061 os.remove(fileName) 1063 1062 1064 self.failUnless(lFile[0] == " " and1063 self.failUnless(lFile[0] == "x,y," and 1065 1064 lFile[1] == "0.0,0.0" and 1066 1065 lFile[2] == "0.0,3.0" and … … 1068 1067 lFile[4] == "1.0,2.0" 1069 1068 , 1070 'exported Ascii xyafile is wrong')1069 'exported Ascii csv file is wrong') 1071 1070 1072 1071 def to_be_test_lone_vert_in_mesh_gen_c_layer(self): … … 1092 1091 1093 1092 fileName = tempfile.mktemp(".csv") 1094 #fileName = 't. xya'1093 #fileName = 't.csv' 1095 1094 #os.remove(fileName) 1096 1095 m.exportPointsFile(fileName) … … 1105 1104 lFile[3] == "3,3" 1106 1105 , 1107 'exported Ascii xyafile is wrong')1106 'exported Ascii csv file is wrong') 1108 1107 self.failUnless(lFile[4] == "1,2" and 1109 1108 lFile[5] == "3,1" 1110 1109 , 1111 'exported Ascii xyafile is wrong')1110 'exported Ascii csv file is wrong') 1112 1111 1113 1112 # vertex e is outside of the outline, so … … 1115 1114 m.generateMesh("Q", maxArea = 2.1) 1116 1115 fileName = tempfile.mktemp(".csv") 1117 #fileName = 't. xya'1116 #fileName = 't.csv' 1118 1117 #m.export_mesh_file('m.tsh') 1119 1118 m.exportPointsFile(fileName) … … 1129 1128 lFile[4] == "1.0,2.0" 1130 1129 , 1131 'exported Ascii xyafile is wrong')1130 'exported Ascii csv file is wrong') 1132 1131 1133 1132 def NOT_test_exportPointsFilefile2(self): … … 1147 1146 self.failUnless(lFile[0] == "" 1148 1147 , 1149 'exported Ascii xyafile is wrong')1148 'exported Ascii csv file is wrong') 1150 1149 1151 1150 def test_strings2ints(self): … … 2339 2338 if __name__ == "__main__": 2340 2339 suite = unittest.makeSuite(meshTestCase,'test') 2341 #suite = unittest.makeSuite(meshTestCase,'test_export ASCIIsegmentoutlinefile')2342 #suite = unittest.makeSuite(meshTestCase,'test_e ')2343 runner = unittest.TextTestRunner() # verbosity=2)2340 #suite = unittest.makeSuite(meshTestCase,'test_exportoutlinefile') 2341 #suite = unittest.makeSuite(meshTestCase,'test_exportPointsFile') 2342 runner = unittest.TextTestRunner() # verbosity=2) 2344 2343 runner.run(suite) 2345 2344 -
anuga_core/source/anuga/shallow_water/data_manager.py
r4636 r4663 11 11 .tms: Netcdf format for storing time series f(t) 12 12 13 . xya: ASCII format for storing arbitrary points and associated attributes13 .csv: ASCII format for storing arbitrary points and associated attributes 14 14 .pts: NetCDF format for storing arbitrary points and associated attributes 15 15 … … 1817 1817 format = 'ers'): 1818 1818 1819 """Read SWW file and convert to Digitial Elevation model format (.asc or .ers) 1819 """Read SWW file and convert to Digitial Elevation model format 1820 (.asc or .ers) 1820 1821 1821 1822 Example (ASC): … … 1859 1860 1860 1861 import sys 1861 from Numeric import array, Float, concatenate, NewAxis, zeros, reshape, sometrue 1862 from Numeric import array, Float, concatenate, NewAxis, zeros, reshape, \ 1863 sometrue 1862 1864 from Numeric import array2string 1863 1865 1864 from anuga.utilities.polygon import inside_polygon, outside_polygon, separate_points_by_polygon 1865 from anuga.abstract_2d_finite_volumes.util import apply_expression_to_dictionary 1866 from anuga.utilities.polygon import inside_polygon, outside_polygon, \ 1867 separate_points_by_polygon 1868 from anuga.abstract_2d_finite_volumes.util import \ 1869 apply_expression_to_dictionary 1866 1870 1867 1871 msg = 'Format must be either asc or ers' … … 1930 1934 1931 1935 1932 # FIXME: Refactor using code from Interpolation_function.statistics (in interpolate.py) 1936 # FIXME: Refactor using code from Interpolation_function.statistics 1937 # (in interpolate.py) 1933 1938 # Something like print swwstats(swwname) 1934 1939 if verbose:
Note: See TracChangeset
for help on using the changeset viewer.