Changeset 6360 for branches/numpy/anuga/load_mesh/loadASCII.py
- Timestamp:
- Feb 18, 2009, 2:44:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/load_mesh/loadASCII.py
r6304 r6360 53 53 Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 54 54 """ 55 55 56 ##FIXME (DSG-DSG) Is the dict format mentioned above a list of a numeric array? 56 57 # Needs to be defined … … 58 59 59 60 from string import find, rfind 60 import numpy as num61 61 from os.path import splitext 62 import exceptions 62 63 63 64 from anuga.coordinate_transforms.geo_reference import Geo_reference, TITLE, \ 64 65 TitleError 65 66 from Scientific.IO.NetCDF import NetCDFFile67 66 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 68 67 from anuga.config import netcdf_float, netcdf_char, netcdf_int 69 68 70 import exceptions 69 from Scientific.IO.NetCDF import NetCDFFile 70 71 import numpy as num 71 72 72 73 … … 87 88 88 89 Note: will throw an IOError if it can't load the file. 89 Catch these!90 90 """ 91 91 … … 149 149 # @brief Read a mesh file into a dictionary. 150 150 # @param ofile Path of the file to read. 151 # @return Datadictionary from the mesh (.tsh) file.151 # @return Points dictionary from the mesh (.tsh) file. 152 152 def _read_tsh_file(ofile): 153 153 """Read the text file format for meshes""" … … 164 164 165 165 ## 166 # @brief ??166 # @brief Read triangulation data from a file, leave file open. 167 167 # @param fd An open descriptor of the file to read. 168 168 # @return A dictionary ... … … 264 264 265 265 ## 266 # @brief 266 # @brief Read a mesh outline file. 267 267 # @param fd An open descriptor of the file to read. 268 # @return A dictionary ...268 # @return A Points dictionary. 269 269 # @note If file has no mesh info, an empty dict will be returned. 270 270 def _read_outline(fd): … … 393 393 394 394 return meshDict 395 396 397 ##398 # @brief Clean up a line with delimited fields.399 # @param line The string to be cleaned.400 # @param delimiter String used a delimiter when splitting 'line'.401 # @return A list of delimited fields with white-space removed from ends.402 # @note Will also remove any field that was originally ''.403 def clean_line(line, delimiter):404 """Clean up a line - return fields with end space removed."""405 406 line = line.strip()407 numbers = line.split(delimiter)408 i = len(numbers) - 1409 while i >= 0:410 if numbers[i] == '':411 numbers.pop(i)412 else:413 numbers[i] = numbers[i].strip()414 415 i += -1416 417 return numbers418 395 419 396 … … 649 626 num.array(mesh['vertex_attribute_titles'], num.character) 650 627 mesh['segments'] = num.array(mesh['segments'], IntType) 628 print ("Before num.array(), mesh['segment_tags']=%s" 629 % str(mesh['segment_tags'])) 651 630 mesh['segment_tags'] = num.array(mesh['segment_tags'], num.character) 631 print ("After num.array(), mesh['segment_tags']=%s" 632 % str(mesh['segment_tags'])) 633 print "mesh['segment_tags'].shape=%s" % str(mesh['segment_tags'].shape) 652 634 mesh['triangles'] = num.array(mesh['triangles'], IntType) 653 635 mesh['triangle_tags'] = num.array(mesh['triangle_tags']) … … 967 949 fd.close() 968 950 969 970 951 ################################################################################ 971 952 # IMPORT/EXPORT POINTS FILES
Note: See TracChangeset
for help on using the changeset viewer.