Changeset 4576
- Timestamp:
- Jul 2, 2007, 5:25:38 PM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/fit.py
r4572 r4576 325 325 assert point_origin is None, msg 326 326 filename = point_coordinates_or_filename 327 328 for i, geo_block in enumerate(Geospatial_data(filename, 329 max_read_lines=max_read_lines, 330 load_file_now=False, 331 verbose=verbose)): 327 328 G_data = Geospatial_data(filename, 329 max_read_lines=max_read_lines, 330 load_file_now=False, 331 verbose=verbose) 332 for i, geo_block in enumerate(G_data): 332 333 if verbose is True and 0 == i%200: # round every 5 minutes 333 334 # But this is dependant on the # of Triangles, so it 334 335 #isn't every 5 minutes. 335 print 'Block %i' %i 336 337 print 'Processing Block %d' %i 338 # FIXME (Ole): It would be good to say how many blocks 339 # there are here. But this is no longer necessary 340 # for pts files as they are reported in geospatial_data 341 # I suggest deleting this verbose output and make 342 # Geospatial_data more informative for txt files. 343 344 345 336 346 # build the array 337 347 points = geo_block.get_data_points(absolute=True) -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r4575 r4576 165 165 # attributes etc are provided!! 166 166 # if file name then all provided info will be removed! 167 168 #if verbose is True: 169 # if file_name is not None: 170 # print 'Loading Geospatial data from file: %s' %file_name 171 167 172 self.import_points_file(file_name, delimiter, verbose) 168 173 … … 172 177 self.set_default_attribute_name(default_attribute_name) 173 178 179 174 180 #Why? 175 181 #assert self.attributes is None or isinstance(self.attributes, DictType) 176 182 #This is a hassle when blocking, so I've removed it. 177 183 184 185 if verbose is True: 186 if file_name is not None: 187 print 'Geospatial data created from file: %s' %file_name 188 if load_file_now is False: 189 print 'Data will be loaded blockwise on demand' 190 191 if file_name.endswith('csv') or file_name.endswith('txt'): 192 print 'ASCII formats are not that great for ' 193 print 'blockwise reading. Consider storing this' 194 print 'data as a pts NetCDF format' 178 195 179 196 def __len__(self): … … 255 272 if verbose in [False, True]: 256 273 self.verbose = verbose 257 258 if verbose is True:259 print 'Geospatial_data.verbose = True'260 274 else: 261 275 msg = 'Illegal value: %s' %str(verbose) … … 759 773 #FIXME - what to do if the file isn't there 760 774 775 # FIXME (Ole): Shouldn't this go into the constructor? 776 # ... and shouldn't it be called block_size? 777 if self.max_read_lines is None: 778 self.max_read_lines = MAX_READ_LINES 779 780 761 781 if self.file_name[-4:] == ".xya": 762 782 # FIXME (Ole): shouldn't the xya format be replaced by txt/csv? … … 774 794 self.fid = NetCDFFile(self.file_name, 'r') 775 795 776 self.blocking_georef, self.blocking_keys, self.last_row = \ 777 _read_pts_file_header(self.fid, self.verbose) 796 self.blocking_georef, self.blocking_keys, self.number_of_points =\ 797 _read_pts_file_header(self.fid, 798 self.verbose) 778 799 self.start_row = 0 800 self.last_row = self.number_of_points 779 801 self.show_verbose = 0 780 802 self.verbose_block_size = (self.last_row + 10)/10 803 self.block_number = 0 804 self.number_of_blocks = self.number_of_points/self.max_read_lines 805 # This computes the number of full blocks. The last block may be 806 # smaller and won't be ircluded in this estimate. 781 807 782 808 if self.verbose is True: 783 print 'Reading %d points (blocking) from file %s'\ 784 %(self.last_row, 785 self.file_name) 809 print 'Reading %d points (in ~%d blocks) from file %s. '\ 810 %(self.number_of_points, 811 self.number_of_blocks, 812 self.file_name), 813 print 'Each block consists of %d data points'\ 814 %self.max_read_lines 786 815 787 816 else: … … 791 820 _read_csv_file_header(file_pointer) 792 821 self.blocking_georef = None # Used for reconciling zones 793 794 if self.max_read_lines is None: 795 self.max_read_lines = MAX_READ_LINES 822 796 823 return self 824 797 825 798 826 def next(self): … … 828 856 fin_row = self.last_row 829 857 830 858 831 859 832 860 if self.verbose is True: 833 861 if self.show_verbose >= self.start_row and \ 834 862 self.show_verbose < fin_row: 835 print 'Doing %d of %d' %(self.start_row, self.last_row+10) 836 self.show_verbose += max(self.max_read_lines, 837 self.verbose_block_size) 838 #call stuff 863 864 865 #print 'Doing %d of %d' %(self.start_row, self.last_row+10) 866 867 print 'Reading block %d (points %d to %d) out of %d'\ 868 %(self.block_number, 869 self.start_row, 870 fin_row, 871 self.number_of_blocks) 872 873 874 self.show_verbose += max(self.max_read_lines, 875 self.verbose_block_size) 876 877 878 # Read next block 839 879 pointlist, att_dict, = \ 840 _read_pts_file_blocking(self.fid,841 self.start_row,842 fin_row,843 self.blocking_keys)880 _read_pts_file_blocking(self.fid, 881 self.start_row, 882 fin_row, 883 self.blocking_keys) 844 884 845 885 geo = Geospatial_data(pointlist, att_dict, self.blocking_georef) 846 886 self.start_row = fin_row 887 888 self.block_number += 1 847 889 848 890 else:
Note: See TracChangeset
for help on using the changeset viewer.