Changeset 4104
- Timestamp:
- Dec 20, 2006, 2:08:58 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r4103 r4104 70 70 2.7, 2.4, 5.2, 0.3 71 71 72 The first two columns are always implicitly assumed to be x, y coordinates. 72 The first two columns are always implicitly assumed to be x, y 73 coordinates. 73 74 Use the same delimiter for the attribute names and the data 74 75 … … 89 90 The format for a Points dictionary is: 90 91 91 ['pointlist'] a 2 column array describing points. 1st column x, 2nd column y. 92 ['attributelist'], a dictionary of 1D arrays, representing attribute values 93 at the point. The dictionary key is the attribute header. 94 ['geo_reference'] a Geo_refernece object. Use if the point information 95 is relative. This is optional. 92 ['pointlist'] a 2 column array describing points. 1st column x, 93 2nd column y. 94 ['attributelist'], a dictionary of 1D arrays, representing 95 attribute values at the point. The dictionary key is the attribute 96 header. 97 ['geo_reference'] a Geo_refernece object. Use if the point 98 information is relative. This is optional. 96 99 eg 97 100 dic['pointlist'] = [[1.0,2.0],[3.0,5.0]] … … 132 135 133 136 else: 134 # watch for case where file name and points, attributes etc are provided!! 137 # watch for case where file name and points, 138 # attributes etc are provided!! 135 139 # if file name then all provided info will be removed! 136 140 self.import_points_file(file_name, delimiter, verbose) … … 500 504 try: 501 505 fd = open(file_name) 502 data_points, attributes, geo_reference = _read_xya_file(fd, ',') 506 data_points, attributes, geo_reference =\ 507 _read_xya_file(fd, ',') 503 508 except TitleError: 504 509 fd.close() 505 510 fd = open(file_name) 506 data_points, attributes, geo_reference = _read_xya_file(fd, ' ') 511 data_points, attributes, geo_reference =\ 512 _read_xya_file(fd, ' ') 507 513 else: 508 514 fd = open(file_name) 509 data_points, attributes, geo_reference = _read_xya_file(fd, delimiter) 515 data_points, attributes, geo_reference =\ 516 _read_xya_file(fd, delimiter) 510 517 fd.close() 511 518 except (IndexError,ValueError,SyntaxError): … … 516 523 fd.close() 517 524 # Catch this to add an error message 518 msg = 'Could not open file or incorrect file format %s:%s' %(file_name, e) 525 msg = 'Could not open file or incorrect file format %s:%s'\ 526 %(file_name, e) 519 527 raise IOError, msg 520 528 521 529 elif file_name[-4:]== ".pts": 522 530 try: 523 data_points, attributes, geo_reference = _read_pts_file(file_name, verbose) 531 data_points, attributes, geo_reference =\ 532 _read_pts_file(file_name, verbose) 524 533 except IOError, e: 525 534 msg = 'Could not open file %s ' %file_name … … 530 539 # 531 540 try: 532 data_points, attributes, geo_reference = _read_csv_file(file_name, verbose) 541 data_points, attributes, geo_reference =\ 542 _read_csv_file(file_name, verbose) 533 543 except IOError, e: 534 544 msg = 'Could not open file %s ' %file_name … … 682 692 return Geospatial_data(pointlist, att_dict) 683 693 684 def _read_pts_file(file_name, verbose =False):694 def _read_pts_file(file_name, verbose=False): 685 695 """Read .pts NetCDF file 686 696 … … 737 747 738 748 739 def _read_csv_file(file_name, verbose =False):749 def _read_csv_file(file_name, verbose=False): 740 750 """Read .csv file 741 751 … … 765 775 766 776 CSV_DELIMITER = ',' 767 def _read_csv_file_header(file_pointer, delimiter=CSV_DELIMITER, 777 def _read_csv_file_header(file_pointer, 778 delimiter=CSV_DELIMITER, 768 779 verbose=False): 769 780 … … 777 788 def _read_csv_file_blocking(file_pointer, header, 778 789 delimiter=CSV_DELIMITER, 779 max_read_lines =500,780 verbose =False):790 max_read_lines=500, 791 verbose=False): 781 792 782 793 … … 977 988 978 989 for key in point_atts['attributelist'].keys(): 979 point_atts['attributelist'][key]= array(point_atts['attributelist'][key]).astype(Float) 990 point_atts['attributelist'][key]=\ 991 array(point_atts['attributelist'][key]).astype(Float) 980 992 return point_atts 981 993
Note: See TracChangeset
for help on using the changeset viewer.