Changeset 1394 for inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
- Timestamp:
- May 16, 2005, 11:06:22 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
r1377 r1394 5 5 6 6 for example: 7 elevation 8 0.6 0.7 4.99 1.9 2.8 510 2.7 2.4 5.27 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 11 12 12 The first two columns are always implicitly assumed to be x, y coordinates. 13 13 Use the same delimiter for the attribute names and the data 14 14 15 15 The format for a Points dictionary is: … … 97 97 Note: This might throw a can't load file error 98 98 """ 99 100 if ofile[-4:]== ".tsh": 101 dict = _read_tsh_file(ofile) 102 elif ofile[-4:]== ".msh": 103 dict = _read_msh_file(ofile) 104 else: 105 msg = 'Extension %s is unknown' %ofile[-4:] 106 raise IOError, msg 99 try: 100 if ofile[-4:]== ".tsh": 101 dict = _read_tsh_file(ofile) 102 elif ofile[-4:]== ".msh": 103 dict = _read_msh_file(ofile) 104 else: 105 msg = 'Extension %s is unknown' %ofile[-4:] 106 raise IOError, msg 107 except SyntaxError: 108 msg = 'File could not be opened' 109 raise IOError, msg 110 except IndexError: 111 msg = 'File could not be opened' 112 raise IOError, msg 113 107 114 return dict 108 115 … … 1052 1059 msg = 'Could not open file %s ' %ofile 1053 1060 raise IOError, msg 1061 except SyntaxError: 1062 msg = 'File could not be opened' 1063 raise IOError, msg 1064 except IndexError: 1065 msg = 'File could not be opened' 1066 raise IOError, msg 1054 1067 1055 1068 elif ofile[-4:]== ".pts": … … 1260 1273 if len(att_names) != len(numbers): 1261 1274 fd.close() 1262 raise TitleAmountError 1263 1275 # It might not be a problem with the title 1276 #raise TitleAmountError 1277 raise IOError 1264 1278 for i,num in enumerate(numbers): 1265 1279 num.strip() … … 1311 1325 1312 1326 #FIXME (DSG) need an export_points_file method.. 1313 def export_xya_file( file_name, xya_dict, title, delimiter = ','):1327 def _write_xya_file( file_name, xya_dict, delimiter = ','): 1314 1328 """ 1315 1329 export a file, ofile, with the format … … 1324 1338 #FIXME, move the test for this from meshharness to loadasciiharness 1325 1339 points = xya_dict['pointlist'] 1326 pointattributes = xya_dict[' pointattributelist']1340 pointattributes = xya_dict['attributelist'] 1327 1341 1328 1342 fd = open(file_name,'w') 1329 1330 fd.write(title+"\n") 1343 1344 titlelist = "" 1345 for title in pointattributes.keys(): 1346 titlelist = titlelist + title + delimiter 1347 titlelist = titlelist[0:-len(delimiter)] # remove the last delimiter 1348 fd.write(titlelist+"\n") 1331 1349 #<vertex #> <x> <y> [attributes] 1332 for vert, vertatts in map(None, points, pointattributes): 1350 for i,vert in enumerate( points): 1351 1333 1352 attlist = "" 1334 for att in vertatts:1335 attlist = attlist + str( att)+ delimiter1353 for att in pointattributes.keys(): 1354 attlist = attlist + str(pointattributes[att][i])+ delimiter 1336 1355 attlist = attlist[0:-len(delimiter)] # remove the last delimiter 1337 1356 attlist.strip()
Note: See TracChangeset
for help on using the changeset viewer.