Changeset 7317
- Timestamp:
- Jul 22, 2009, 9:22:11 AM (14 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r7276 r7317 32 32 from anuga.abstract_2d_finite_volumes.util import get_textual_float 33 33 from quantity import Quantity 34 import anuga.utilities.log as log 34 35 35 36 import numpy as num … … 144 145 self.geo_reference = self.mesh.geo_reference 145 146 146 if verbose: print 'Initialising Domain'147 if verbose: log.critical('Initialising Domain') 147 148 148 149 # List of quantity names entering the conservation equations … … 186 187 187 188 # Setup Communication Buffers 188 if verbose: print 'Domain: Set up communication buffers (parallel)' 189 if verbose: log.critical('Domain: Set up communication buffers ' 190 '(parallel)') 189 191 self.nsys = len(self.conserved_quantities) 190 192 for key in self.full_send_dict: … … 212 214 if not num.allclose(self.tri_full_flag[:self.number_of_full_nodes], 1): 213 215 if self.numproc>1: 214 print ('WARNING:'215 'Not all full triangles are store beforeghost triangles')216 log.critical('WARNING: Not all full triangles are store before ' 217 'ghost triangles') 216 218 217 219 # Defaults … … 275 277 # If the mesh file passed any quantity values, 276 278 # initialise with these values. 277 if verbose: print 'Domain: Initialising quantity values'279 if verbose: log.critical('Domain: Initialising quantity values') 278 280 self.set_quantity_vertices_dict(vertex_quantity_dict) 279 281 280 if verbose: print 'Domain: Done'282 if verbose: log.critical('Domain: Done') 281 283 282 284 ###### … … 831 833 # @param track_speeds If True, print smallest track speed. 832 834 def write_time(self, track_speeds=False): 833 print self.timestepping_statistics(track_speeds)835 log.critical(self.timestepping_statistics(track_speeds)) 834 836 835 837 ## … … 981 983 # @param tags A name or list of names of tags to report. 982 984 def write_boundary_statistics(self, quantities=None, tags=None): 983 print self.boundary_statistics(quantities, tags)985 log.critical(self.boundary_statistics(quantities, tags)) 984 986 985 987 # @brief Get a string containing boundary forcing stats at each timestep. … … 1613 1615 for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 1614 1616 if B is None: 1615 print 'WARNING: Ignored boundary segment (None)'1617 log.critical('WARNING: Ignored boundary segment (None)') 1616 1618 else: 1617 1619 q = B.evaluate(vol_id, edge_id) … … 1652 1654 hist[4] == hist[5] == hist[6] == hist[7] == hist[8] == 0: 1653 1655 # Danger of isolated degenerate triangles 1654 # print self.timestepping_statistics(track_speeds=True)1655 1656 1656 1657 # Find triangles in last bin … … 1665 1666 self.max_speed[i]) 1666 1667 1667 # print 'Found offending triangle', i,1668 # self.max_speed[i]1669 1668 self.get_quantity('xmomentum').\ 1670 1669 set_values(0.0, indices=[i]) … … 1695 1694 msg += 'even after %d steps of 1 order scheme' \ 1696 1695 % self.max_smallsteps 1697 print msg1696 log.critical(msg) 1698 1697 timestep = min_timestep # Try enforcing min_step 1699 1698 1700 print self.timestepping_statistics(track_speeds=True)1699 log.critical(self.timestepping_statistics(track_speeds=True)) 1701 1700 1702 1701 raise Exception, msg … … 1830 1829 # Psyco isn't supported on 64 bit systems, but it doesn't matter 1831 1830 else: 1832 msg = ('WARNING: psyco (speedup) could not be imported, ' 1833 'you may want to consider installing it') 1834 print msg 1831 log.critical('WARNING: psyco (speedup) could not be imported, ' 1832 'you may want to consider installing it') 1835 1833 else: 1836 1834 psyco.bind(Domain.update_boundary) -
anuga_core/source/anuga/abstract_2d_finite_volumes/ermapper_grids.py
r7276 r7317 1 1 #!/usr/bin/env python 2 2 3 # from os import open, write, read4 3 import numpy as num 5 4 … … 134 133 # Write the registration coordinate information 135 134 fid.write('\t\tRegistrationCoord Begin\n') 136 ###print X_Class137 135 fid.write('\t\t\t' + X_Class + '\t\t\t = ' + header[X_Class.lower()] + '\n') 138 136 fid.write('\t\t\t' + Y_Class + '\t\t\t = ' + header[Y_Class.lower()] + '\n') -
anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py
r7276 r7317 3 3 4 4 from anuga.coordinate_transforms.geo_reference import Geo_reference 5 import anuga.utilities.log as log 5 6 6 7 class General_mesh: … … 89 90 """ 90 91 91 if verbose: print 'General_mesh: Building basic mesh structure in ANUGA domain' 92 if verbose: log.critical('General_mesh: Building basic mesh structure ' 93 'in ANUGA domain') 92 94 93 95 self.triangles = num.array(triangles, num.int) … … 147 149 # Initialise each triangle 148 150 if verbose: 149 print 'General_mesh: Computing areas, normals and edgelengths' 151 log.critical('General_mesh: Computing areas, normals ' 152 'and edgelengths') 150 153 151 154 for i in range(N): 152 if verbose and i % ((N+10)/10) == 0: print '(%d/%d)' % (i, N)155 if verbose and i % ((N+10)/10) == 0: log.critical('(%d/%d)' % (i, N)) 153 156 154 157 x0, y0 = V[3*i, :] … … 195 198 196 199 # Build structure listing which triangles belong to which node. 197 if verbose: print 'Building inverted triangle structure'200 if verbose: log.critical('Building inverted triangle structure') 198 201 self.build_inverted_triangle_structure() 199 202 -
anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r7276 r7317 7 7 from anuga.fit_interpolate.interpolate import Modeltime_too_late 8 8 from anuga.fit_interpolate.interpolate import Modeltime_too_early 9 import anuga.utilities.log as log 9 10 10 11 import numpy as num … … 176 177 %str(self.default_boundary) 177 178 msg += 'Note: Further warnings will be supressed' 178 print msg179 log.critical(msg) 179 180 180 181 # FIXME (Ole): Replace this crude flag with … … 240 241 # any tagged boundary later on. 241 242 242 if verbose: print 'Find midpoint coordinates of entire boundary'243 if verbose: log.critical('Find midpoint coordinates of entire boundary') 243 244 self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float) 244 245 boundary_keys = domain.boundary.keys() … … 275 276 self.boundary_indices[(vol_id, edge_id)] = i 276 277 277 if verbose: print 'Initialise file_function'278 if verbose: log.critical('Initialise file_function') 278 279 self.F = file_function(filename, 279 280 domain, … … 315 316 msg += 'outside aren\'t used on the actual boundary segment.' 316 317 if verbose is True: 317 print msg318 log.critical(msg) 318 319 #raise Exception(msg) 319 320 … … 365 366 %str(self.default_boundary) 366 367 msg += 'Note: Further warnings will be supressed' 367 print msg368 log.critical(msg) 368 369 369 370 # FIXME (Ole): Replace this crude flag with … … 441 442 # any tagged boundary later on. 442 443 443 if verbose: print 'Find midpoint coordinates of entire boundary'444 if verbose: log.critical('Find midpoint coordinates of entire boundary') 444 445 self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float) 445 446 boundary_keys = domain.boundary.keys() … … 475 476 476 477 477 if verbose: print 'Initialise file_function'478 if verbose: log.critical('Initialise file_function') 478 479 self.F = file_function(filename, domain, 479 480 interpolation_points=self.midpoint_coordinates, … … 501 502 msg += 'outside aren\'t used on the actual boundary segment.' 502 503 if verbose is True: 503 print msg504 log.critical(msg) 504 505 #raise Exception(msg) 505 506 -
anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory.py
r7276 r7317 3 3 """ 4 4 5 import anuga.utilities.log as log 5 6 import numpy as num 6 7 … … 585 586 offending +=1 586 587 587 print 'Removed %d offending triangles out of %d' %(offending, len(lines)) 588 log.critical('Removed %d offending triangles out of %d' 589 % (offending, len(lines))) 588 590 return points, triangles, values 589 591 -
anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r7276 r7317 10 10 from general_mesh import General_mesh 11 11 from anuga.caching import cache 12 import anuga.utilities.log as log 13 12 14 from math import pi, sqrt 13 15 … … 91 93 verbose=verbose) 92 94 93 if verbose: print 'Initialising mesh'95 if verbose: log.critical('Initialising mesh') 94 96 95 97 N = len(self) #Number_of_triangles … … 111 113 112 114 #Initialise each triangle 113 if verbose: print 'Mesh: Computing centroids and radii'115 if verbose: log.critical('Mesh: Computing centroids and radii') 114 116 for i in range(N): 115 if verbose and i % ((N+10)/10) == 0: print '(%d/%d)' %(i, N)117 if verbose and i % ((N+10)/10) == 0: log.critical('(%d/%d)' % (i, N)) 116 118 117 119 x0, y0 = V[3*i, :] … … 166 168 167 169 #Build neighbour structure 168 if verbose: print 'Mesh: Building neigbour structure'170 if verbose: log.critical('Mesh: Building neigbour structure') 169 171 self.build_neighbour_structure() 170 172 171 173 #Build surrogate neighbour structure 172 if verbose: print 'Mesh: Building surrogate neigbour structure'174 if verbose: log.critical('Mesh: Building surrogate neigbour structure') 173 175 self.build_surrogate_neighbour_structure() 174 176 175 177 #Build boundary dictionary mapping (id, edge) to symbolic tags 176 if verbose: print 'Mesh: Building boundary dictionary'178 if verbose: log.critical('Mesh: Building boundary dictionary') 177 179 self.build_boundary_dictionary(boundary) 178 180 179 181 #Build tagged element dictionary mapping (tag) to array of elements 180 if verbose: print 'Mesh: Building tagged elements dictionary'182 if verbose: log.critical('Mesh: Building tagged elements dictionary') 181 183 self.build_tagged_elements_dictionary(tagged_elements) 182 184 … … 194 196 195 197 #FIXME check integrity? 196 if verbose: print 'Mesh: Done'198 if verbose: log.critical('Mesh: Done') 197 199 198 200 def __repr__(self): … … 365 367 366 368 #FIXME: Print only as per verbosity 367 #print msg368 369 369 370 #FIXME: Make this situation an error in the future … … 398 399 msg = 'Not all elements exist. ' 399 400 assert max(tagged_elements[tag]) < len(self), msg 400 #print "tagged_elements", tagged_elements401 401 self.tagged_elements = tagged_elements 402 402 … … 438 438 #FIXME: One would detect internal boundaries as follows 439 439 #if self.neighbours[id, edge] > -1: 440 # print 'Internal boundary'440 # log.critical('Internal boundary') 441 441 442 442 self.neighbours[id, edge] = index … … 536 536 537 537 if verbose: 538 print('Point %s has multiple candidates: %s'539 % (str(p0), candidate_list))538 log.critical('Point %s has multiple candidates: %s' 539 % (str(p0), candidate_list)) 540 540 541 541 # Check that previous are not in candidate list … … 566 566 # Give preference to angles on the right hand side 567 567 # of v_prev 568 # print 'pc = %s, changing angle from %f to %f'\569 # %(pc, ac*180/pi, (ac-2*pi)*180/pi)570 568 ac = ac-2*pi 571 569 … … 577 575 578 576 if verbose is True: 579 print ' Best candidate %s, angle %f'\580 %(p1, minimum_angle*180/pi)577 log.critical(' Best candidate %s, angle %f' 578 % (p1, minimum_angle*180/pi)) 581 579 else: 582 580 p1 = candidate_list[0] … … 587 585 # If it is the initial point, the polygon is complete. 588 586 if verbose is True: 589 print ' Stop criterion fulfilled at point %s' %p1 590 print polygon 587 log.critical(' Stop criterion fulfilled at point %s' 588 % str(p1)) 589 log.critical(str(polygon)) 591 590 592 591 # We have completed the boundary polygon - yeehaa … … 870 869 871 870 polygon = self.get_boundary_polygon() 872 #print polygon, point873 871 874 872 if is_outside_polygon(point, polygon): … … 882 880 for i, triangle in enumerate(self.triangles): 883 881 poly = V[3*i:3*i+3] 884 #print i, poly885 882 886 883 if is_inside_polygon(point, poly, closed=True): … … 1068 1065 1069 1066 status, value = intersection(line, edge) 1070 #if value is not None: print 'Triangle %d, Got' %i, status, value 1067 #if value is not None: log.critical('Triangle %d, status=%s, ' 1068 # 'value=%s' 1069 # % (i, str(status), str(value))) 1071 1070 1072 1071 if status == 1: … … 1190 1189 point1 = polyline[i+1] 1191 1190 if verbose: 1192 print 'Extracting mesh intersections from line:',1193 print '(%.2f, %.2f) - (%.2f, %.2f)' %(point0[0], point0[1],1194 point1[0], point1[1])1191 log.critical('Extracting mesh intersections from line:') 1192 log.critical('(%.2f, %.2f) - (%.2f, %.2f)' 1193 % (point0[0], point0[1], point1[0], point1[1])) 1195 1194 1196 1195 line = [point0, point1] -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r7276 r7317 24 24 from anuga.config import epsilon 25 25 from anuga.caching import cache 26 import anuga.utilities.log as log 26 27 27 28 import anuga.utilities.numerical_tools as aunt … … 234 235 235 236 if beta < 0.0: 236 print 'WARNING: setting beta < 0.0'237 log.critical('WARNING: setting beta < 0.0') 237 238 if beta > 2.0: 238 print 'WARNING: setting beta > 2.0'239 log.critical('WARNING: setting beta > 2.0') 239 240 240 241 self.beta = beta … … 737 738 y = V[:,1] 738 739 if use_cache is True: 739 #print 'Caching function'740 740 values = cache(f, (x, y), verbose=verbose) 741 741 else: 742 742 if verbose is True: 743 print 'Evaluating function in set_values'743 log.critical('Evaluating function in set_values') 744 744 values = f(x, y) 745 745 … … 914 914 # Call underlying method using array values 915 915 if verbose: 916 print 'Applying fitted data to domain'916 log.critical('Applying fitted data to domain') 917 917 self.set_values_from_array(vertex_attributes, location, 918 918 indices, use_cache=use_cache, … … 1167 1167 1168 1168 if verbose is True: 1169 print 'Getting values from %s' % location1169 log.critical('Getting values from %s' % location) 1170 1170 1171 1171 if interpolation_points is not None: -
anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py
r6145 r7317 16 16 Transmissive_boundary, Time_boundary 17 17 from anuga.shallow_water.shallow_water_domain import Weir_simple as Weir 18 import anuga.utilities.log as log 18 19 19 20 from mesh_factory import rectangular … … 26 27 N = 12 27 28 28 print 'Creating domain' 29 log.critical('Creating domain') 29 30 #Create basic mesh 30 31 points, vertices, boundary = rectangular(N, N/2, len1=1.2,len2=0.6, 31 32 origin=(-0.07, 0)) 32 33 33 print 'Number of elements', len(vertices)34 log.critical('Number of elements=%d' % len(vertices)) 34 35 #Create shallow water domain 35 36 domain = Domain(points, vertices, boundary) … … 45 46 Z = Weir(inflow_stage) 46 47 47 print 'Field values' 48 log.critical('Field values') 48 49 domain.set_quantity('elevation', Z) 49 50 domain.set_quantity('friction', manning) … … 53 54 # Boundary conditions 54 55 # 55 print 'Boundaries' 56 log.critical('Boundaries') 56 57 Br = Reflective_boundary(domain) 57 58 Bt = Transmissive_boundary(domain) … … 74 75 #Initial condition 75 76 # 76 print 'Initial condition' 77 log.critical('Initial condition') 77 78 domain.set_quantity('stage', Z) 78 79 … … 82 83 domain.write_boundary_statistics(['stage'],'left') 83 84 84 print 'Done' 85 log.critical('Done') 85 86 86 87 -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py
r7276 r7317 17 17 def set_bottom_friction(tag, elements, domain): 18 18 if tag == "bottom": 19 #print 'bottom - indices',elements20 19 domain.set_quantity('friction', 0.09, indices = elements) 21 20 22 21 def set_top_friction(tag, elements, domain): 23 22 if tag == "top": 24 #print 'top - indices',elements25 23 domain.set_quantity('friction', 1., indices = elements) 26 24 … … 347 345 A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], num.float) 348 346 B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], num.float) 349 350 #print A351 #print B352 #print A+B353 347 354 348 # Shorthands … … 721 715 722 716 domain.set_region([set_bottom_friction, set_top_friction]) 723 #print domain.quantities['friction'].get_values()724 717 assert num.allclose(domain.quantities['friction'].get_values(),\ 725 718 [[ 0.09, 0.09, 0.09], … … 731 724 732 725 domain.set_region([set_all_friction]) 733 #print domain.quantities['friction'].get_values()734 726 assert num.allclose(domain.quantities['friction'].get_values(), 735 727 [[ 10.09, 10.09, 10.09], … … 765 757 domain.set_region('bottom', 'friction', 0.09) 766 758 767 #print domain.quantities['friction'].get_values()768 759 msg = ("domain.quantities['friction'].get_values()=\n%s\n" 769 760 'should equal\n' … … 784 775 785 776 domain.set_region([set_bottom_friction, set_top_friction]) 786 #print domain.quantities['friction'].get_values()787 777 assert num.allclose(domain.quantities['friction'].get_values(), 788 778 [[ 0.09, 0.09, 0.09], … … 794 784 795 785 domain.set_region([set_all_friction]) 796 #print domain.quantities['friction'].get_values()797 786 assert num.allclose(domain.quantities['friction'].get_values(), 798 787 [[ 10.09, 10.09, 10.09], … … 815 804 assert num.allclose(full_send_dict[0][0] , [ 4, 5, 6, 7, 20, 21, 22, 23]) 816 805 817 #print 'HERE'818 819 806 conserved_quantities = ['quant1', 'quant2'] 820 807 domain = Domain(points, vertices, boundary, conserved_quantities, -
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r7282 r7317 26 26 27 27 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 28 import anuga.utilities.log as log 28 29 29 30 import numpy as num … … 114 115 msg = 'Quantities specified in file_function are None,' 115 116 msg += ' so I will use stage, xmomentum, and ymomentum in that order' 116 print msg117 log.critical(msg) 117 118 quantities = ['stage', 'xmomentum', 'ymomentum'] 118 119 … … 171 172 msg += ' Modifying domain starttime accordingly.' 172 173 173 if verbose: print msg174 if verbose: log.critical(msg) 174 175 175 176 domain.set_starttime(starttime) #Modifying model time 176 177 177 if verbose: print 'Domain starttime is now set to %f'\178 %domain.starttime178 if verbose: log.critical('Domain starttime is now set to %f' 179 % domain.starttime) 179 180 return f 180 181 … … 277 278 278 279 # Open NetCDF file 279 if verbose: print 'Reading', filename280 if verbose: log.critical('Reading %s' % filename) 280 281 281 282 fid = NetCDFFile(filename, netcdf_mode_r) … … 338 339 339 340 # Get variables 340 # if verbose: print 'Get variables'341 # if verbose: log.critical('Get variables' ) 341 342 time = fid.variables['time'][:] 342 343 # FIXME(Ole): Is time monotoneous? … … 348 349 349 350 if time_limit is not None: 350 #if verbose is True:351 # print '****** Time limit', time_limit352 # print '****** Start time', starttime353 # print '****** Time in ', time[0], time[-1]354 355 351 # Adjust given time limit to given start time 356 352 time_limit = time_limit - starttime … … 367 363 368 364 if time_limit < time[-1] and verbose is True: 369 print 'Limited time vector from %.2fs to %.2fs'\370 % (time[-1], time_limit)365 log.critical('Limited time vector from %.2fs to %.2fs' 366 % (time[-1], time_limit)) 371 367 372 368 time = time[:upper_time_index] … … 438 434 gauge_neighbour_id=None 439 435 440 #print gauge_neighbour_id441 442 436 if interpolation_points is not None: 443 437 # Adjust for georef … … 460 454 461 455 if verbose: 462 print 'File_function data obtained from: %s' %filename 463 print ' References:' 464 #print ' Datum ....' #FIXME 456 log.critical('File_function data obtained from: %s' % filename) 457 log.critical(' References:') 465 458 if spatial: 466 print ' Lower left corner: [%f, %f]'\467 %(xllcorner, yllcorner)468 print ' Start time: %f' %starttime459 log.critical(' Lower left corner: [%f, %f]' 460 % (xllcorner, yllcorner)) 461 log.critical(' Start time: %f' % starttime) 469 462 470 463 … … 490 483 491 484 if verbose: 492 print 'Calling interpolation function'485 log.critical('Calling interpolation function') 493 486 494 487 # Return Interpolation_function instance as well as … … 674 667 """Temporary Interface to new location""" 675 668 676 print 'inside_polygon has moved from util.py. ', 677 print 'Please use "from anuga.utilities.polygon import inside_polygon"' 669 log.critical('inside_polygon has moved from util.py.') 670 log.critical('Please use ' 671 '"from anuga.utilities.polygon import inside_polygon"') 678 672 679 673 return utilities.polygon.inside_polygon(*args, **kwargs) … … 684 678 """Temporary Interface to new location""" 685 679 686 print 'outside_polygon has moved from util.py. ', 687 print 'Please use "from anuga.utilities.polygon import outside_polygon"' 680 log.critical('outside_polygon has moved from util.py.') 681 log.critical('Please use ' 682 '"from anuga.utilities.polygon import outside_polygon"') 688 683 689 684 return utilities.polygon.outside_polygon(*args, **kwargs) … … 694 689 """Temporary Interface to new location""" 695 690 696 print 'separate_points_by_polygon has moved from util.py. ',697 print 'Please use "from anuga.utilities.polygon import ' \698 'separate_points_by_polygon"'691 log.critical('separate_points_by_polygon has moved from util.py.') 692 log.critical('Please use "from anuga.utilities.polygon import ' 693 'separate_points_by_polygon"') 699 694 700 695 return utilities.polygon.separate_points_by_polygon(*args, **kwargs) … … 705 700 """Temporary Interface to new location""" 706 701 707 print 'read_polygon has moved from util.py. ', 708 print 'Please use "from anuga.utilities.polygon import read_polygon"' 702 log.critical('read_polygon has moved from util.py.') 703 log.critical('Please use ' 704 '"from anuga.utilities.polygon import read_polygon"') 709 705 710 706 return utilities.polygon.read_polygon(*args, **kwargs) … … 715 711 """Temporary Interface to new location""" 716 712 717 print 'populate_polygon has moved from util.py. ', 718 print 'Please use "from anuga.utilities.polygon import populate_polygon"' 713 log.critical('populate_polygon has moved from util.py.') 714 log.critical('Please use ' 715 '"from anuga.utilities.polygon import populate_polygon"') 719 716 720 717 return utilities.polygon.populate_polygon(*args, **kwargs) … … 732 729 as dm_start_screen_catcher 733 730 734 print 'start_screen_catcher has moved from util.py. ',735 print 'Please use "from anuga.shallow_water.data_manager import ' \736 'start_screen_catcher"'731 log.critical('start_screen_catcher has moved from util.py.') 732 log.critical('Please use "from anuga.shallow_water.data_manager import ' 733 'start_screen_catcher"') 737 734 738 735 return dm_start_screen_catcher(dir_name, myid='', numprocs='', … … 872 869 msg += ' PLUS another new function to create graphs from csv files called ' 873 870 msg += 'csv2timeseries_graphs in anuga.abstract_2d_finite_volumes.util' 874 print msg871 log.critical(msg) 875 872 876 873 k = _sww2timeseries(swwfiles, … … 952 949 title_on = True 953 950 954 if verbose: print '\n Gauges obtained from: %s \n' %gauge_filename951 if verbose: log.critical('Gauges obtained from: %s' % gauge_filename) 955 952 956 953 gauges, locations, elev = get_gauges_from_file(gauge_filename) … … 973 970 974 971 if verbose: 975 print 'swwfile', swwfile972 log.critical('swwfile = %s' % swwfile) 976 973 977 974 # Extract parent dir name and use as label … … 979 976 _, label = os.path.split(path) 980 977 981 #print 'label', label982 978 leg_label.append(label) 983 979 … … 995 991 if f(0.0, point_id = k)[2] > 1.0e6: 996 992 count += 1 997 if count == 1: print 'Gauges not contained here:'998 print locations[k]993 if count == 1: log.critical('Gauges not contained here:') 994 log.critical(locations[k]) 999 995 else: 1000 996 gauge_index.append(k) 1001 997 1002 998 if len(gauge_index) > 0: 1003 print 'Gauges contained here: \n',999 log.critical('Gauges contained here:') 1004 1000 else: 1005 print 'No gauges contained here. \n'1001 log.critical('No gauges contained here.') 1006 1002 for i in range(len(gauge_index)): 1007 print locations[gauge_index[i]]1003 log.critical(locations[gauge_index[i]]) 1008 1004 1009 1005 index = swwfile.rfind(sep) … … 1032 1028 1033 1029 if verbose and len(gauge_index) > 0: 1034 print 'Inputs OK - going to generate figures'1030 log.critical('Inputs OK - going to generate figures') 1035 1031 1036 1032 if len(gauge_index) <> 0: … … 1236 1232 fid = open(texfilename, 'w') 1237 1233 1238 if verbose: print '\n Latex output printed to %s \n' %texfilename1234 if verbose: log.critical('Latex output printed to %s' % texfilename) 1239 1235 else: 1240 1236 texfile = texdir+reportname … … 1243 1239 fid = open(texfilename, 'w') 1244 1240 1245 if verbose: print '\n Latex output printed to %s \n' %texfilename1241 if verbose: log.critical('Latex output printed to %s' % texfilename) 1246 1242 else: 1247 1243 texfile = '' … … 1287 1283 ##### loop over each swwfile ##### 1288 1284 for j, f in enumerate(f_list): 1289 if verbose: print 'swwfile %d of %d' % (j, len(f_list))1285 if verbose: log.critical('swwfile %d of %d' % (j, len(f_list))) 1290 1286 1291 1287 starttime = f.starttime … … 1297 1293 ##### loop over each gauge ##### 1298 1294 for k in gauge_index: 1299 if verbose: print 'Gauge %d of %d' % (k, len(gauges))1295 if verbose: log.critical('Gauge %d of %d' % (k, len(gauges))) 1300 1296 1301 1297 g = gauges[k] … … 1381 1377 1382 1378 if surface is True: 1383 print 'Printing surface figure'1379 log.critical('Printing surface figure') 1384 1380 for i in range(2): 1385 1381 fig = p1.figure(10) … … 1696 1692 from anuga.shallow_water.data_manager import \ 1697 1693 copy_code_files as dm_copy_code_files 1698 print 'copy_code_files has moved from util.py. ',1699 print 'Please use "from anuga.shallow_water.data_manager \1700 import copy_code_files"'1694 log.critical('copy_code_files has moved from util.py.') 1695 log.critical('Please use "from anuga.shallow_water.data_manager import ' 1696 'copy_code_files"') 1701 1697 1702 1698 return dm_copy_code_files(dir_name, filename1, filename2) … … 1736 1732 from anuga.shallow_water.data_manager import \ 1737 1733 get_data_from_file as dm_get_data_from_file 1738 print 'get_data_from_file has moved from util.py'1739 print 'Please use "from anuga.shallow_water.data_manager \1740 import get_data_from_file"'1734 log.critical('get_data_from_file has moved from util.py') 1735 log.critical('Please use "from anuga.shallow_water.data_manager import ' 1736 'get_data_from_file"') 1741 1737 1742 1738 return dm_get_data_from_file(filename,separator_value = ',') … … 1754 1750 from anuga.shallow_water.data_manager \ 1755 1751 import store_parameters as dm_store_parameters 1756 print 'store_parameters has moved from util.py.'1757 print 'Please use "from anuga.shallow_water.data_manager \1758 import store_parameters"'1752 log.critical('store_parameters has moved from util.py.') 1753 log.critical('Please use "from anuga.shallow_water.data_manager ' 1754 'import store_parameters"') 1759 1755 1760 1756 return dm_store_parameters(verbose=False,**kwargs) … … 1813 1809 1814 1810 # Modify the triangles 1815 #print "loners", loners1816 #print "triangles before", triangles1817 1811 triangles = num.choose(triangles,loners) 1818 #print "triangles after", triangles1819 1812 return verts, triangles 1820 1813 … … 2064 2057 list_filenames=[] 2065 2058 all_csv_filenames=[] 2066 if verbose: print 'Determining files to access for axes ranges.'2059 if verbose: log.critical('Determining files to access for axes ranges.') 2067 2060 2068 2061 for i,directory in enumerate(directories_dic.keys()): … … 2083 2076 min_start_time = 100000 2084 2077 2085 if verbose: print 'Determining uniform axes'2078 if verbose: log.critical('Determining uniform axes') 2086 2079 2087 2080 #this entire loop is to determine the min and max range for the … … 2112 2105 directory_add_tide = directories_dic[directory][2] 2113 2106 2114 if verbose: print 'reading: %s.csv' %dir_filename2107 if verbose: log.critical('reading: %s.csv' % dir_filename) 2115 2108 2116 2109 #add time to get values … … 2189 2182 2190 2183 if verbose and (quantity != 'time' and quantity != 'elevation'): 2191 print 'axis for quantity %s are x:(%s to %s)%s and y:(%s to %s)%s' \2192 % (quantity,2193 quantities_axis[quantity][0],2194 quantities_axis[quantity][1],2195 quantities_label['time'],2196 quantities_axis[quantity][2],2197 quantities_axis[quantity][3],2198 quantities_label[quantity])2184 log.critical('axis for quantity %s are x:(%s to %s)%s ' 2185 'and y:(%s to %s)%s' 2186 % (quantity, quantities_axis[quantity][0], 2187 quantities_axis[quantity][1], 2188 quantities_label['time'], 2189 quantities_axis[quantity][2], 2190 quantities_axis[quantity][3], 2191 quantities_label[quantity])) 2199 2192 2200 2193 cstr = ['b', 'r', 'g', 'c', 'm', 'y', 'k'] 2201 2194 2202 if verbose: print 'Now start to plot \n'2195 if verbose: log.critical('Now start to plot') 2203 2196 2204 2197 i_max = len(directories_dic.keys()) … … 2206 2199 legend_list = [] 2207 2200 for i, directory in enumerate(directories_dic.keys()): 2208 if verbose: print 'Plotting in %s %s' % (directory, new_plot_numbers) 2201 if verbose: log.critical('Plotting in %s %s' 2202 % (directory, new_plot_numbers)) 2209 2203 2210 2204 # FIXME THIS SORT IS VERY IMPORTANT … … 2213 2207 list_filenames[i].sort() 2214 2208 for j, filename in enumerate(list_filenames[i]): 2215 if verbose: print 'Starting %s' % filename2209 if verbose: log.critical('Starting %s' % filename) 2216 2210 2217 2211 directory_name = directories_dic[directory][0] … … 2236 2230 2237 2231 if min_ele != max_ele: 2238 print "Note! Elevation changes in %s" %dir_filename2232 log.critical("Note! Elevation changes in %s" % dir_filename) 2239 2233 2240 2234 # creates a dictionary with keys that is the filename and attributes … … 2287 2281 extra_plot_name) 2288 2282 2289 if verbose: print 'saving figure here %s' %figname2283 if verbose: log.critical('saving figure here %s' % figname) 2290 2284 2291 2285 pylab.savefig(figname) 2292 2286 2293 if verbose: print 'Closing all plots'2287 if verbose: log.critical('Closing all plots') 2294 2288 2295 2289 pylab.close('all') 2296 2290 del pylab 2297 2291 2298 if verbose: print 'Finished closing plots'2292 if verbose: log.critical('Finished closing plots') 2299 2293 2300 2294 ## … … 2307 2301 """ 2308 2302 2309 if list == None: print 'List must be provided'2303 if list == None: log.critical('List must be provided') 2310 2304 2311 2305 return min(list), max(list) … … 2344 2338 easting = [float(x) for x in attribute_dic["x"]] 2345 2339 2346 print 'Reading %s' %sww_filename2340 log.critical('Reading %s' % sww_filename) 2347 2341 2348 2342 runup_locations=[] … … 2362 2356 2363 2357 if verbose: 2364 print 'maximum inundation runup near %s is %s meters' %(x_y,run_up) 2358 log.critical('maximum inundation runup near %s is %s meters' 2359 % (x_y, run_up)) 2365 2360 2366 2361 #writes to file … … 2445 2440 raise msg 2446 2441 2447 if verbose: print '\n Gauges obtained from: %s \n' %gauge_file2442 if verbose: log.critical('Gauges obtained from: %s' % gauge_file) 2448 2443 2449 2444 point_reader = reader(file(gauge_file)) … … 2477 2472 2478 2473 if access(sww_file,R_OK): 2479 if verbose: print 'File %s exists' %(sww_file)2474 if verbose: log.critical('File %s exists' % sww_file) 2480 2475 else: 2481 2476 msg = 'File "%s" could not be opened: no read permission' % sww_file … … 2485 2480 base_name=base, 2486 2481 verbose=verbose) 2487 #print 'sww files just after get_all_swwfiles()', sww_files 2482 2488 2483 # fudge to get SWW files in 'correct' order, oldest on the left 2489 2484 sww_files.sort() 2490 2485 2491 2486 if verbose: 2492 print 'sww files', sww_files2487 log.critical('sww files=%s' % sww_files) 2493 2488 2494 2489 #to make all the quantities lower case for file_function … … 2513 2508 points_writer[point_i].writerow(heading) 2514 2509 2515 if verbose: print 'Writing csv files'2510 if verbose: log.critical('Writing csv files') 2516 2511 2517 2512 quake_offset_time = None … … 2530 2525 for time in callable_sww.get_time(): 2531 2526 for point_i, point in enumerate(points_array): 2532 # print 'gauge_file = ', str(point_name[point_i])2533 #print 'point_i = ', str(point_i), ' point is = ', str(point)2534 2527 #add domain starttime to relative time. 2535 2528 quake_time = time + quake_offset_time 2536 2529 points_list = [quake_time, quake_time/3600.]# fudge around SWW time bug 2537 #print 'point list = ', str(points_list)2538 2530 point_quantities = callable_sww(time,point_i) 2539 #print 'point quantities = ', str(point_quantities)2540 2531 2541 2532 for quantity in quantities: 2542 2533 if quantity == NAN: 2543 print 'quantity does not exist in' % callable_sww.get_name 2534 log.critical('quantity does not exist in %s' 2535 % callable_sww.get_name) 2544 2536 else: 2545 2537 if quantity == 'stage': -
anuga_core/source/anuga/advection/advection.py
r7276 r7317 32 32 33 33 from anuga.abstract_2d_finite_volumes.domain import * 34 import anuga.utilities.log as log 34 35 35 36 import numpy as num … … 165 166 166 167 """ 167 print "======================================"168 print "BEFORE compute_fluxes"169 print "stage_update",Stage.explicit_update170 print "stage_edge",Stage.edge_values171 print "stage_bdry",Stage.boundary_values172 print "neighbours",self.neighbours173 print "neighbour_edges",self.neighbour_edges174 print "normals",self.normals175 print "areas",self.areas176 print "radii",self.radii177 print "edgelengths",self.edgelengths178 print "tri_full_flag",self.tri_full_flag179 print "huge_timestep",huge_timestep180 print "max_timestep",max_timestep181 print "velocity",self.velocity168 log.critical("======================================") 169 log.critical("BEFORE compute_fluxes") 170 log.critical("stage_update=%s" % str(Stage.explicit_update)) 171 log.critical("stage_edge=%s" % str(Stage.edge_values)) 172 log.critical("stage_bdry=%s" % str(Stage.boundary_values)) 173 log.critical("neighbours=%s" % str(self.neighbours)) 174 log.critical("neighbour_edges=%s" % str(self.neighbour_edges)) 175 log.critical("normals=%s" % str(self.normals)) 176 log.critical("areas=%s" % str(self.areas)) 177 log.critical("radii=%s" % str(self.radii)) 178 log.critical("edgelengths=%s" % str(self.edgelengths)) 179 log.critical("tri_full_flag=%s" % str(self.tri_full_flag)) 180 log.critical("huge_timestep=%s" % str(huge_timestep)) 181 log.critical("max_timestep=%s" % str(max_timestep)) 182 log.critical("velocity=%s" % str(self.velocity)) 182 183 """ 183 184 -
anuga_core/source/anuga/advection/test_all.py
r4978 r7317 29 29 if os.path.isdir(file): 30 30 sys.path.append(file) 31 #print 'Recursing into', file32 31 test_files += get_test_files(path + os.sep + file) 33 32 elif file[:5] == 'test_' and file[-2:] == 'py': 34 #print 'Appending', file35 33 test_files.append(file) 36 34 else: -
anuga_core/source/anuga/alpha_shape/alpha_shape.py
r7276 r7317 74 74 points: List of coordinate pairs [[x1, y1],[x2, y2]..] 75 75 """ 76 # print "setting points"77 76 if len (points) <= 2: 78 77 raise PointError, "Too few points to find an alpha shape" … … 96 95 Write the boundary to a file 97 96 """ 98 #print " this info will be in the file"99 97 export_boundary_file(file_name, self.get_boundary(), 100 98 OUTPUT_FILE_TITLE, delimiter = ',') … … 178 176 """ 179 177 180 #print "starting alpha shape algorithm"181 182 178 self.alpha = alpha 183 179 … … 194 190 pointattlist = [ [] for i in range(len(points)) ] 195 191 mode = "Qzcn" 196 #print "computing delaunay triangulation ... \n"197 192 tridata = generate_mesh(points,seglist,holelist,regionlist, 198 193 pointattlist,segattlist,mode) 199 #print tridata200 #print "point attlist: ", tridata['generatedpointattributelist'],"\n"201 #print "hull segments: ", tridata['generatedsegmentlist'], "\n"202 194 self.deltri = tridata['generatedtrianglelist'] 203 195 self.deltrinbr = tridata['generatedtriangleneighborlist'] 204 196 self.hulledges = tridata['generatedsegmentlist'] 205 206 #print "Number of delaunay triangles: ", len(self.deltri), "\n"207 #print "deltrinbrs: ", self.deltrinbr, "\n"208 197 209 198 ## Build Alpha table … … 211 200 ## triangles, edges, and vertices of the delaunay triangulation 212 201 self._tri_circumradius() 213 # print "Largest circumradius ", max(self.triradius)214 202 self._edge_intervals() 215 203 self._vertex_intervals() … … 221 209 self.optimum_alpha = max([iv[0] for iv in self.vertexinterval \ 222 210 if iv!=[] ]) 223 # print "optimum alpha ", self.optimum_alpha224 211 alpha = self.optimum_alpha 225 212 self.alpha = alpha 226 213 reg_edge = self.get_regular_edges(self.alpha) 227 214 self.boundary = [self.edge[k] for k in reg_edge] 228 #print "alpha boundary edges ", self.boundary229 215 self._init_boundary_triangles() 230 216 … … 258 244 259 245 denom = x21*y31 - x31*y21 260 #print "denom = ", denom261 246 262 247 # dx/2, dy/2 give circumcenter relative to x1,y1. … … 271 256 while zeroind!=[]: 272 257 random.seed() 273 print "Warning: degenerate triangles found in alpha_shape.py, results may be inaccurate."258 log.critical("Warning: degenerate triangles found in alpha_shape.py, results may be inaccurate.") 274 259 for d in zeroind: 275 260 x1[d] = x1[d]+delta*(random.random()-0.5) … … 296 281 297 282 self.triradius = 0.5*num.sqrt(dx*dx + dy*dy) 298 #print "triangle radii", self.triradius299 283 300 284 def _edge_intervals(self): … … 325 309 dy[(i+1)%3]*dy[(i+2)%3]) for i in [0,1,2]]) 326 310 327 #print "dx ",dx,"\n"328 #print "dy ",dy,"\n"329 #print "edge lengths of triangle ",t,"\t",elen,"\n"330 #print "angles ",angle,"\n"331 332 311 for i in [0,1,2]: 333 312 j = (i+1)%3 … … 351 330 self.edgenbr = edgenbrs 352 331 self.edgeinterval = edgeinterval 353 #print "edges: ",edges, "\n"354 #print "edge nbrs:", edgenbrs ,"\n"355 #print "edge intervals: ",edgeinterval , "\n"356 332 357 333 def _vertex_intervals(self): … … 381 357 self.vertexnbr = vertexnbrs 382 358 self.vertexinterval = vertexinterval 383 #print "vertex nbrs ", vertexnbrs, "\n"384 #print "vertex intervals ",vertexinterval, "\n"385 359 386 360 def get_alpha_triangles(self,alpha): … … 450 424 self.boundarytriangle = btri 451 425 452 #print "exterior triangles: ", extrind453 454 426 455 427 def _remove_holes(self,small): … … 458 430 The routine does this by implementing a union-find algorithm. 459 431 """ 460 461 #print "running _remove_holes \n"462 432 463 433 bdry = self.boundary … … 475 445 # get a list of unique vertex labels: 476 446 verts = self._vertices_from_edges(bdry) 477 #print "verts ", verts, "\n"478 447 479 448 # vptr represents the union-find tree. … … 486 455 EMPTY = -max(verts)-len(verts) 487 456 vptr = [EMPTY for k in range(len(verts))] 488 #print "vptr init: ", vptr, "\n"489 457 490 458 #add edges and maintain union tree 491 459 for i in range(len(bdry)): 492 #print "edge ",i,"\t",bdry[i]493 460 vl = verts.index(bdry[i][0]) 494 461 vr = verts.index(bdry[i][1]) 495 462 rvl = findroot(vl) 496 463 rvr = findroot(vr) 497 #print "roots: ",rvl, rvr498 464 if not(rvl==rvr): 499 465 if (vptr[vl]==EMPTY): … … 517 483 vptr[rvr] = rvl 518 484 vptr[vr] = rvl 519 #print "vptr: ", vptr, "\n"520 485 # end edge loop 521 486 … … 523 488 raise FlagError, "We didn't hit all the vertices in the boundary" 524 489 525 # print "number of vertices in the connected components: ", [-v for v in vptr if v<0], "\n"526 # print "largest component has: ", -min(vptr), " points. \n"527 490 # discard the edges in the little components 528 491 # (i.e. those components with less than 'small' fraction of bdry points) 529 492 cutoff = round(small*len(verts)) 530 # print "cutoff component size is ", cutoff, "\n"531 493 largest_component = -min(vptr) 532 494 if cutoff > largest_component: … … 568 530 """ 569 531 570 #print "running _smooth_indents \n"571 572 532 bdry = self.boundary 573 533 bdrytri = self.boundarytriangle … … 608 568 acutetri.append(tind[0]) 609 569 610 #print "acute boundary triangles ", acutetri611 612 570 # adjust the bdry edges and triangles by adding 613 571 #in the acutetri triangles … … 624 582 newbdry.append(ed) 625 583 626 #print "new boundary ", newbdry627 584 return newbdry 628 585 … … 632 589 Expand by adding back in associated triangles. 633 590 """ 634 #print "running _expand_pinch \n"635 591 636 592 bdry = self.boundary … … 643 599 probv = [v[k] for k in range(len(v)) \ 644 600 if (v[k]!=v[k-1] and v.count(v[k])>2) ] 645 #print "problem vertices: ", probv646 601 647 602 # find boundary triangles that have at least one vertex in probv … … 654 609 probtri.append(ind) 655 610 656 #print "problem boundary triangle indices ", probtri657 611 658 612 # "add in" the problem triangles … … 669 623 newbdry.append(ed) 670 624 671 #print "new boundary ", newbdry672 625 return newbdry 673 626 -
anuga_core/source/anuga/caching/caching.py
r7309 r7317 51 51 unix = True 52 52 53 import anuga.utilities.log as log 54 53 55 import numpy as num 54 56 … … 332 334 os.system('del '+fn) 333 335 if verbose is True: 334 print 'MESSAGE (caching): File %s deleted' %fn336 log.critical('MESSAGE (caching): File %s deleted' % fn) 335 337 ##else: 336 ## print '%s was not accessed' %fn338 ## log.critical('%s was not accessed' % fn) 337 339 return None 338 340 … … 468 470 import zlib 469 471 except: 470 print471 print '*** Could not find zlib, default to no-compression ***'472 print '*** Installing zlib will improve performance of caching ***'473 print472 log.critical() 473 log.critical('*** Could not find zlib, default to no-compression ***') 474 log.critical('*** Installing zlib will improve performance of caching ***') 475 log.critical() 474 476 compression = 0 475 477 set_option('compression', compression) 476 478 477 print 478 print_header_box('Testing caching module - please stand by') 479 print 479 log.critical('\nTesting caching module - please stand by\n') 480 480 481 481 # Define a test function to be cached … … 709 709 test_OK('Performance test: relative time saved = %s pct' \ 710 710 %str(round((t1-t2)*100/t1,2))) 711 #else:712 # print 'WARNING: Performance a bit low - this could be specific to current platform'713 711 else: 714 712 test_error('Basic caching failed for new problem') … … 742 740 cachestat() 743 741 except: 744 print 'cachestat() does not work here, because it'745 print 'relies on time.strptime() which is unavailable in Windows'742 log.critical('cachestat() does not work here, because it relies on ' 743 'time.strptime() which is unavailable in Windows') 746 744 747 print748 745 test_OK('Caching self test completed') 749 746 … … 841 838 # 842 839 if verbose: 843 print 'Caching: looking for cached files %s_{%s,%s,%s}.z'\844 %(CD+FN, file_types[0], file_types[1], file_types[2])840 log.critical('Caching: looking for cached files %s_{%s,%s,%s}.z' 841 % (CD+FN, file_types[0], file_types[1], file_types[2])) 845 842 (datafile,compressed0) = myopen(CD+FN+'_'+file_types[0],"rb",compression) 846 843 (argsfile,compressed1) = myopen(CD+FN+'_'+file_types[1],"rb",compression) … … 848 845 849 846 if verbose is True and deps is not None: 850 print 'Caching: Dependencies are', deps.keys()847 log.critical('Caching: Dependencies are %s' % deps.keys()) 851 848 852 849 if not (argsfile and datafile and admfile) or \ … … 890 887 if dependencies and not compare(depsref, deps): 891 888 if verbose: 892 print 'MESSAGE (caching.py): Dependencies', dependencies, \893 'have changed - recomputing' 889 log.critical('Dependencies %s have changed - recomputing' % dependencies) 890 894 891 # Don't use cached file - recompute 895 892 reason = 2 … … 899 896 # 900 897 bytecode = get_bytecode(my_F) 901 902 #print compare(argsref,args),903 #print compare(kwargsref,kwargs),904 #print compare(bytecode,coderef)905 898 906 899 # Check if arguments or bytecode have changed … … 921 914 922 915 if loadtime >= comptime: 923 print 'WARNING (caching.py): Caching did not yield any gain.'924 print ' Consider executing function ',925 print '('+funcname+') without caching.'916 log.critical('Caching did not yield any gain.') 917 log.critical('Consider executing function %s without caching.' 918 % funcname) 926 919 else: 927 920 … … 934 927 verbose, compression, dependencies) 935 928 936 # DEBUGGING937 # if not Retrieved:938 # print 'Arguments did not match'939 # else:940 # print 'Match found !'941 942 929 # The real reason is that args or bytecodes have changed. 943 930 # Not that the recursive seach has found an unused filename … … 983 970 funcname = get_funcname(my_F) 984 971 if verbose: 985 print 'MESSAGE (caching.py): Clearing', CD+funcname+'*'972 log.critical('Clearing %s' % CD+funcname+'*') 986 973 987 974 file_names = os.listdir(CD) … … 999 986 if len(file_names) > 0: 1000 987 if verbose: 1001 print 'MESSAGE (caching.py): Remove the following files:'988 log.critical('Remove the following files:') 1002 989 for file_name in file_names: 1003 print file_name990 log.critical(' ' + file_name) 1004 991 1005 992 A = raw_input('Delete (Y/N)[N] ?') … … 1041 1028 delfiles = numfiles-maxfiles+block 1042 1029 if verbose: 1043 print 'Deleting '+`delfiles`+' expired files:'1030 log.critical('Deleting %d expired files:' % delfiles) 1044 1031 os.system('ls -lur '+CD+'* | head -' + `delfiles`) # List them 1045 1032 os.system('ls -ur '+CD+'* | head -' + `delfiles` + ' | xargs /bin/rm') … … 1097 1084 if not datafile: 1098 1085 if verbose: 1099 print 'ERROR (caching): Could not open %s' %datafile.name1086 log.critical('ERROR: Could not open %s' % datafile.name) 1100 1087 raise IOError 1101 1088 1102 1089 if not admfile: 1103 1090 if verbose: 1104 print 'ERROR (caching): Could not open %s' %admfile.name1091 log.critical('ERROR: Could not open %s' % admfile.name) 1105 1092 raise IOError 1106 1093 … … 1246 1233 # Rs = zlib.decompress(RsC) 1247 1234 # zlib.error: Error -5 while decompressing data 1248 #print 'ERROR (caching): Could not decompress ', file.name1249 1235 #raise Exception 1250 1236 reason = 6 # Unreadable file … … 1266 1252 import sys 1267 1253 if options['verbose']: 1268 print 'ERROR (caching): Out of memory while loading %s, aborting' \1269 %(file.name)1254 log.critical('ERROR: Out of memory while loading %s, aborting' 1255 % file.name) 1270 1256 1271 1257 # Raise the error again for now … … 1291 1277 import zlib 1292 1278 except: 1293 print1294 print '*** Could not find zlib ***'1295 print '*** Try to run caching with compression off ***'1296 print "*** caching.set_option('compression', 0) ***"1279 log.critical() 1280 log.critical('*** Could not find zlib ***') 1281 log.critical('*** Try to run caching with compression off ***') 1282 log.critical("*** caching.set_option('compression', 0) ***") 1297 1283 raise Exception 1298 1284 … … 1440 1426 if (iA, iB) in ids: 1441 1427 # A and B have been compared already 1442 #print 'Found', (iA, iB), A, B1443 1428 return ids[(iA, iB)] 1444 1429 else: … … 1618 1603 import types 1619 1604 1620 #print 'Caching DEBUG: Dependencies are', dependencies1621 1605 d = {} 1622 1606 if dependencies: … … 1679 1663 # Hack to get the results anyway (works only on Unix at the moment) 1680 1664 # 1681 print 'Hack to get os.stat when files are too large'1665 log.critical('Hack to get os.stat when files are too large') 1682 1666 1683 1667 if unix: … … 1775 1759 else: 1776 1760 pass # FIXME: What about acces rights under Windows? 1777 if verbose: print 'MESSAGE: Directory', CD, 'created.'1761 if verbose: log.critical('MESSAGE: Directory %s created.' % CD) 1778 1762 except: 1779 1763 if warn is True: 1780 print 'WARNING: Directory', CD, 'could not be created.'1764 log.critical('WARNING: Directory %s could not be created.' % CD) 1781 1765 if unix: 1782 1766 CD = '/tmp/' … … 1784 1768 CD = 'C:' 1785 1769 if warn is True: 1786 print 'Using directory %s instead' %CD1770 log.critical('Using directory %s instead' % CD) 1787 1771 1788 1772 return(CD) … … 1823 1807 # pass 1824 1808 except: 1825 print 'Warning: Stat file could not be opened'1809 log.critical('Warning: Stat file could not be opened') 1826 1810 1827 1811 try: … … 1866 1850 statfile.close() 1867 1851 except: 1868 print 'Warning: Writing of stat file failed'1852 log.critical('Warning: Writing of stat file failed') 1869 1853 1870 1854 # ----------------------------------------------------------------------------- … … 1933 1917 for FN in SF: 1934 1918 input = open(SD+FN,'r') 1935 print 'Reading file ', SD+FN1919 log.critical('Reading file %s' % SD+FN) 1936 1920 1937 1921 while True: … … 1941 1925 for record in A: 1942 1926 record = tuple(split(rstrip(record),',')) 1943 #print record, len(record)1944 1927 1945 1928 if len(record) == 9: … … 1973 1956 compression = 0 1974 1957 else: 1975 print 'Unknown value of compression', record[4]1976 print record1958 log.critical('Unknown value of compression %s' % str(record[4])) 1959 log.critical(str(record)) 1977 1960 total_discarded = total_discarded + 1 1978 1961 continue … … 2002 1985 2003 1986 else: 2004 #print 'Record discarded'2005 #print record2006 1987 total_discarded = total_discarded + 1 2007 1988 … … 2013 1994 if total_read == 0: 2014 1995 printline(Widths,'=') 2015 print 'CACHING STATISTICS: No valid records read'1996 log.critical('CACHING STATISTICS: No valid records read') 2016 1997 printline(Widths,'=') 2017 1998 return 2018 1999 2019 print2000 log.critical() 2020 2001 printline(Widths,'=') 2021 print 'CACHING STATISTICS: '+ctime(firstday)+' to '+ctime(lastday)2002 log.critical('CACHING STATISTICS: '+ctime(firstday)+' to '+ctime(lastday)) 2022 2003 printline(Widths,'=') 2023 #print ' Period:', ctime(firstday), 'to', ctime(lastday) 2024 print ' Total number of valid records', total_read 2025 print ' Total number of discarded records', total_discarded 2026 print ' Total number of hits', total_hits 2027 print 2028 2029 print ' Fields', Fields[2:], 'are averaged over number of hits' 2030 print ' Time is measured in seconds and size in bytes' 2031 print ' Tables are sorted by', Fields[1:][sortidx] 2032 2033 # printline(Widths,'-') 2004 log.critical(' Total number of valid records %d' % total_read) 2005 log.critical(' Total number of discarded records %d' % total_discarded) 2006 log.critical(' Total number of hits %d' % total_hits) 2007 log.critical() 2008 2009 log.critical(' Fields %s are averaged over number of hits' % Fields[2:]) 2010 log.critical(' Time is measured in seconds and size in bytes') 2011 log.critical(' Tables are sorted by %s' % Fields[1:][sortidx]) 2034 2012 2035 2013 if showuser: … … 2053 2031 # Write Header 2054 2032 # 2055 print 2056 #print Dictnames[i], 'statistics:'; i=i+1 2033 log.critical() 2057 2034 printline(Widths,'-') 2058 2035 n = 0 … … 2060 2037 if s == Fields[0]: # Left justify 2061 2038 s = Dictnames[i] + ' ' + s; i=i+1 2062 exec "print '%-" + str(Widths[n]) + "s'%s,"; n=n+1 2039 #exec "print '%-" + str(Widths[n]) + "s'%s,"; n=n+1 2040 log.critical('%-*s' % (Widths[n], s)) 2041 n += 1 2063 2042 else: 2064 exec "print '%" + str(Widths[n]) + "s'%s,"; n=n+1 2065 print 2043 #exec "print '%" + str(Widths[n]) + "s'%s,"; n=n+1 2044 log.critical('%*s' % (Widths[n], s)) 2045 n += 1 2046 log.critical() 2066 2047 printline(Widths,'-') 2067 2048 … … 2072 2053 n = 0 2073 2054 if len(key) > Widths[n]: key = key[:Widths[n]-3] + '...' 2074 exec "print '%-" + str(Widths[n]) + Types[n]+"'%key,";n=n+1 2055 #exec "print '%-" + str(Widths[n]) + Types[n]+"'%key,";n=n+1 2056 log.critical('%-*s' % (Widths[n], str(key))) 2057 n += 1 2075 2058 for val in rec: 2076 exec "print '%" + str(Widths[n]) + Types[n]+"'%val,"; n=n+1 2077 print 2078 print 2059 #exec "print '%" + str(Widths[n]) + Types[n]+"'%val,"; n=n+1 2060 log.critical('%*s' % (Widths[n], str(key))) 2061 n += 1 2062 log.critical() 2063 log.critical() 2079 2064 2080 2065 #============================================================================== … … 2121 2106 2122 2107 if sortidx > len(rec)-1: 2123 if options['verbose']: 2124 print 'ERROR: Sorting index to large, sortidx = ', sortidx 2125 raise IndexError 2108 msg = 'ERROR: Sorting index too large, sortidx = %s' % str(sortidx) 2109 raise IndexError, msg 2126 2110 2127 2111 val = rec[sortidx] … … 2149 2133 s = s+char 2150 2134 2151 print s2135 log.critical(s) 2152 2136 2153 2137 #============================================================================== … … 2163 2147 2164 2148 import string 2165 #print 'MESSAGE (caching.py): Evaluating function', funcname,2166 2149 2167 2150 print_header_box('Evaluating function %s' %funcname) … … 2172 2155 print_footer() 2173 2156 2174 #2175 # Old message2176 #2177 #args_present = 02178 #if args:2179 # if len(args) == 1:2180 # print 'with argument', mkargstr(args[0], textwidth2),2181 # else:2182 # print 'with arguments', mkargstr(args, textwidth2),2183 # args_present = 12184 #2185 #if kwargs:2186 # if args_present:2187 # word = 'and'2188 # else:2189 # word = 'with'2190 #2191 # if len(kwargs) == 1:2192 # print word + ' keyword argument', mkargstr(kwargs, textwidth2)2193 # else:2194 # print word + ' keyword arguments', mkargstr(kwargs, textwidth2)2195 # args_present = 12196 #else:2197 # print # Newline when no keyword args present2198 #2199 #if not args_present:2200 # print '', # Default if no args or kwargs present2201 2202 2203 2204 2157 # ----------------------------------------------------------------------------- 2205 2158 … … 2224 2177 msg8(reason) 2225 2178 2226 print string.ljust('| CPU time:', textwidth1) + str(round(comptime,2)) + ' seconds' 2179 log.critical(string.ljust('| CPU time:', textwidth1) + 2180 str(round(comptime,2)) + ' seconds') 2227 2181 2228 2182 # ----------------------------------------------------------------------------- … … 2236 2190 2237 2191 import string 2238 print string.ljust('| Loading time:', textwidth1) + str(round(savetime,2)) + \2239 ' seconds (estimated)'2192 log.critical(string.ljust('| Loading time:', textwidth1) + 2193 str(round(savetime,2)) + ' seconds (estimated)') 2240 2194 msg5(CD,FN,deps,compression) 2241 2195 … … 2254 2208 2255 2209 msg6(funcname,args,kwargs) 2256 print string.ljust('| CPU time:', textwidth1) + str(round(comptime,2)) + ' seconds' 2257 print string.ljust('| Loading time:', textwidth1) + str(round(loadtime,2)) + ' seconds' 2258 print string.ljust('| Time saved:', textwidth1) + str(round(comptime-loadtime,2)) + \ 2259 ' seconds' 2210 log.critical(string.ljust('| CPU time:', textwidth1) + 2211 str(round(comptime,2)) + ' seconds') 2212 log.critical(string.ljust('| Loading time:', textwidth1) + 2213 str(round(loadtime,2)) + ' seconds') 2214 log.critical(string.ljust('| Time saved:', textwidth1) + 2215 str(round(comptime-loadtime,2)) + ' seconds') 2260 2216 msg5(CD,FN,deps,compression) 2261 2217 … … 2274 2230 import os, time, string 2275 2231 2276 print '|'2277 print string.ljust('| Caching dir: ', textwidth1) + CD2232 log.critical('|') 2233 log.critical(string.ljust('| Caching dir: ', textwidth1) + CD) 2278 2234 2279 2235 if compression: … … 2286 2242 for file_type in file_types: 2287 2243 file_name = FN + '_' + file_type + suffix 2288 print string.ljust('| ' + file_type + ' file: ', textwidth1) + file_name,2289 2244 stats = os.stat(CD+file_name) 2290 print '('+ str(stats[6]) + ' ' + bytetext + ')' 2291 2292 print '|' 2245 log.critical(string.ljust('| ' + file_type + ' file: ', textwidth1) + 2246 file_name + '('+ str(stats[6]) + ' ' + bytetext + ')') 2247 2248 log.critical('|') 2293 2249 if len(deps) > 0: 2294 print '| Dependencies: '2250 log.critical('| Dependencies: ') 2295 2251 dependencies = deps.keys() 2296 2252 dlist = []; maxd = 0 … … 2317 2273 s = string.rjust(slist[n], maxs) 2318 2274 2319 print '| ', d, t, ' ', s, 'bytes'2275 log.critical('| %s %s %s bytes' % (d, t, s)) 2320 2276 else: 2321 print '| No dependencies'2277 log.critical('| No dependencies') 2322 2278 print_footer() 2323 2279 … … 2332 2288 2333 2289 import string 2334 print string.ljust('| Function:', textwidth1) + funcname2290 log.critical(string.ljust('| Function:', textwidth1) + funcname) 2335 2291 2336 2292 msg7(args, kwargs) … … 2350 2306 if args: 2351 2307 if len(args) == 1: 2352 print string.ljust('| Argument:', textwidth1) + mkargstr(args[0], \2353 textwidth2)2308 log.critical(string.ljust('| Argument:', textwidth1) + 2309 mkargstr(args[0], textwidth2)) 2354 2310 else: 2355 print string.ljust('| Arguments:', textwidth1) + \2356 mkargstr(args, textwidth2)2311 log.critical(string.ljust('| Arguments:', textwidth1) + 2312 mkargstr(args, textwidth2)) 2357 2313 args_present = 1 2358 2314 2359 2315 if kwargs: 2360 2316 if len(kwargs) == 1: 2361 print string.ljust('| Keyword Arg:', textwidth1) + mkargstr(kwargs, \2362 textwidth2)2317 log.critical(string.ljust('| Keyword Arg:', textwidth1) + 2318 mkargstr(kwargs, textwidth2)) 2363 2319 else: 2364 print string.ljust('| Keyword Args:', textwidth1) + \2365 mkargstr(kwargs, textwidth2)2320 log.critical(string.ljust('| Keyword Args:', textwidth1) + 2321 mkargstr(kwargs, textwidth2)) 2366 2322 args_present = 1 2367 2323 2368 2324 if not args_present: 2369 print '| No arguments'# Default if no args or kwargs present2325 log.critical('| No arguments') # Default if no args or kwargs present 2370 2326 2371 2327 # ----------------------------------------------------------------------------- … … 2385 2341 R = 'Unknown' 2386 2342 2387 print string.ljust('| Reason:', textwidth1) + R2343 log.critical(string.ljust('| Reason:', textwidth1) + R) 2388 2344 2389 2345 # ----------------------------------------------------------------------------- … … 2406 2362 s = '+' + '-'*N + CR 2407 2363 2408 print s + '| ' + line + CR + s,2364 log.critical(s + '| ' + line + CR + s) 2409 2365 2410 2366 textwidth3 = N … … 2419 2375 s = '+' + '-'*N + CR 2420 2376 2421 print s2377 log.critical(s) 2422 2378 2423 2379 # ----------------------------------------------------------------------------- … … 2508 2464 import string 2509 2465 2510 print string.ljust(msg, textwidth4) + ' - OK'2466 log.critical(string.ljust(msg, textwidth4) + ' - OK' ) 2511 2467 2512 2468 #raise StandardError … … 2521 2477 """ 2522 2478 2523 print 'ERROR (caching.test): %s' %msg2524 print 'Please send this code example and output to '2525 print 'Ole.Nielsen@anu.edu.au'2526 print2527 print2479 log.critical('ERROR (caching.test): %s' % msg) 2480 log.critical('Please send this code example and output to ') 2481 log.critical('Ole.Nielsen@anu.edu.au') 2482 log.critical() 2483 log.critical() 2528 2484 2529 2485 raise StandardError -
anuga_core/source/anuga/caching/test_caching.py
r7309 r7317 50 50 51 51 def retrieve_cache(Dummy, verbose=False): 52 if verbose: print 'Check that cache is there'52 if verbose: print('Check that cache is there') 53 53 54 54 X = cache(Dummy, args=(9,10), test=1, … … 386 386 f2 = call(5, 7) 387 387 388 #print myhash(f1)389 #print myhash(f2)390 391 388 # Check that hash value of callable objects don't change 392 389 # FIXME (Ole): The hash values do appear to change when OS … … 411 408 bc2 = get_bytecode(f2) 412 409 413 #print 'bc1', bc1414 #print 'bc2', bc2415 416 410 msg = 'Byte code should be different' 417 411 assert bc1 != bc2, msg … … 631 625 632 626 T4 = cache(f, (a,b,c,N), {'x':x, 'y':y}, test=1) 633 #print 'T4', T4634 627 assert T4 is None, "Option 'test' when cache absent failed" 635 628 -
anuga_core/source/anuga/coordinate_transforms/geo_reference.py
r7276 r7317 14 14 ParsingError, ShapeError 15 15 from anuga.config import netcdf_float, netcdf_int, netcdf_float32 16 import anuga.utilities.log as log 16 17 17 18 import numpy as num … … 153 154 154 155 if self.false_easting != DEFAULT_FALSE_EASTING: 155 print "WARNING: False easting of %f specified." % self.false_easting 156 print "Default false easting is %f." % DEFAULT_FALSE_EASTING 157 print "ANUGA does not correct for differences in False Eastings." 156 log.critical("WARNING: False easting of %f specified." 157 % self.false_easting) 158 log.critical("Default false easting is %f." % DEFAULT_FALSE_EASTING) 159 log.critical("ANUGA does not correct for differences in " 160 "False Eastings.") 158 161 159 162 if self.false_northing != DEFAULT_FALSE_NORTHING: 160 print ("WARNING: False northing of %f specified." 161 % self.false_northing) 162 print "Default false northing is %f." % DEFAULT_FALSE_NORTHING 163 print "ANUGA does not correct for differences in False Northings." 163 log.critical("WARNING: False northing of %f specified." 164 % self.false_northing) 165 log.critical("Default false northing is %f." 166 % DEFAULT_FALSE_NORTHING) 167 log.critical("ANUGA does not correct for differences in " 168 "False Northings.") 164 169 165 170 if self.datum.upper() != DEFAULT_DATUM.upper(): 166 print "WARNING: Datum of %s specified." % self.datum167 print "Default Datum is %s." % DEFAULT_DATUM168 print "ANUGA does not correct for differences in datums."171 log.critical("WARNING: Datum of %s specified." % self.datum) 172 log.critical("Default Datum is %s." % DEFAULT_DATUM) 173 log.critical("ANUGA does not correct for differences in datums.") 169 174 170 175 if self.projection.upper() != DEFAULT_PROJECTION.upper(): 171 print "WARNING: Projection of %s specified." % self.projection 172 print "Default Projection is %s." % DEFAULT_PROJECTION 173 print "ANUGA does not correct for differences in Projection." 176 log.critical("WARNING: Projection of %s specified." 177 % self.projection) 178 log.critical("Default Projection is %s." % DEFAULT_PROJECTION) 179 log.critical("ANUGA does not correct for differences in " 180 "Projection.") 174 181 175 182 if self.units.upper() != DEFAULT_UNITS.upper(): 176 print "WARNING: Units of %s specified." % self.units177 print "Default units is %s." % DEFAULT_UNITS178 print "ANUGA does not correct for differences in units."183 log.critical("WARNING: Units of %s specified." % self.units) 184 log.critical("Default units is %s." % DEFAULT_UNITS) 185 log.critical("ANUGA does not correct for differences in units.") 179 186 180 187 ################################################################################ -
anuga_core/source/anuga/coordinate_transforms/lat_long_UTM_conversion.py
r4450 r7317 127 127 #UTMZone was originally returned here. I don't know what the 128 128 #letter at the end was for. 129 #print "UTMZone", UTMZone130 129 return (ZoneNumber, UTMEasting, UTMNorthing) 131 130 -
anuga_core/source/anuga/coordinate_transforms/redfearn.py
r6424 r7317 67 67 else: 68 68 K0 = scale_factor 69 #print 'scale', K070 69 zone_width = 6 #Degrees 71 70 -
anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py
r7276 r7317 121 121 lofl = [[3.0,311.0], [677.0,6.0]] 122 122 new_lofl = g.change_points_geo_ref(lofl) 123 #print "lofl",lofl124 #print "new_lofl",new_lofl125 123 126 124 self.failUnless(type(new_lofl) == types.ListType, ' failed') … … 137 135 lofl = [[3.0,388.0]] 138 136 new_lofl = g.change_points_geo_ref(lofl) 139 #print "lofl",lofl140 #print "new_lofl",new_lofl141 137 142 138 self.failUnless(type(new_lofl) == types.ListType, ' failed') … … 152 148 lofl = [3.0,345.0] 153 149 new_lofl = g.change_points_geo_ref(lofl) 154 #print "lofl",lofl155 #print "new_lofl",new_lofl156 150 157 151 self.failUnless(type(new_lofl) == types.ListType, ' failed') … … 168 162 lofl = num.array([[3.0,323.0], [6.0,645.0]]) 169 163 new_lofl = g.change_points_geo_ref(lofl) 170 #print "4 lofl",lofl171 #print "4 new_lofl",new_lofl172 164 173 165 self.failUnless(isinstance(new_lofl, num.ndarray), ' failed') … … 183 175 lofl = num.array([[3.0,323.0]]) 184 176 185 186 #print "5 lofl before",lofl187 177 new_lofl = g.change_points_geo_ref(lofl.copy()) 188 #print "5 lofl",lofl189 #print "5 new_lofl",new_lofl190 178 191 179 self.failUnless(isinstance(new_lofl, num.ndarray), ' failed') … … 203 191 lofl = num.array([355.0,3.0]) 204 192 new_lofl = g.change_points_geo_ref(lofl.copy()) 205 #print "lofl",lofl206 #print "new_lofl",new_lofl207 193 208 194 self.failUnless(isinstance(new_lofl, num.ndarray), ' failed') … … 221 207 lofl = [[3.0,30.0], [67.0,6.0]] 222 208 new_lofl = g.change_points_geo_ref(lofl,points_geo_ref=points_geo_ref) 223 #print "lofl",lofl224 #print "new_lofl",new_lofl225 209 226 210 self.failUnless(type(new_lofl) == types.ListType, ' failed') -
anuga_core/source/anuga/coordinate_transforms/test_lat_long_UTM_conversion.py
r7276 r7317 57 57 lat = degminsec2decimal_degrees(-37,57,03.7203) 58 58 lon = degminsec2decimal_degrees(144,25,29.5244) 59 #print lat, lon60 59 61 60 zone, easting, northing = LLtoUTM(lat,lon) … … 77 76 78 77 zone, easting, northing = LLtoUTM(lat,lon) 79 #print zone, easting, northing80 78 81 79 assert zone == 52 … … 112 110 zone, easting, northing = LLtoUTM(lat,lon) 113 111 114 #print zone, easting, northing115 112 116 113 assert zone == 56 -
anuga_core/source/anuga/coordinate_transforms/test_redfearn.py
r7276 r7317 71 71 lat = degminsec2decimal_degrees(-37,57,03.7203) 72 72 lon = degminsec2decimal_degrees(144,25,29.5244) 73 #print lat, lon74 73 75 74 zone, easting, northing = redfearn(lat,lon) … … 86 85 87 86 zone, easting, northing = redfearn(lat,lon) 88 #print zone, easting, northing89 87 90 88 assert zone == 52 … … 116 114 117 115 zone, easting, northing = redfearn(lat,lon) 118 119 #print zone, easting, northing120 116 121 117 assert zone == 56 … … 452 448 points = [[lat_gong, lon_gong], [lat_2, lon_2]] 453 449 points, zone = convert_from_latlon_to_utm(points=points) 454 #print "points",points455 450 assert num.allclose(points[0][0], 308728.009) 456 451 assert num.allclose(points[0][1], 6180432.601) -
anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py
r7276 r7317 11 11 12 12 """ 13 13 14 print 'Starting.... Importing Modules...' 15 14 16 #------------------------------------------------------------------------------ 15 17 # Import necessary modules -
anuga_core/source/anuga/culvert_flows/culvert_class.py
r7276 r7317 13 13 from anuga.config import g, epsilon 14 14 from anuga.config import minimum_allowed_height, velocity_protection 15 import anuga.utilities.log as log 15 16 16 17 import numpy as num … … 287 288 msg += ' does not match distance between specified' 288 289 msg += ' end points (%.2f m)' %self.length 289 print msg290 log.critical(msg) 290 291 291 292 self.verbose = verbose … … 441 442 msg += 'Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced) 442 443 if self.verbose is True: 443 print msg444 log.critical(msg) 444 445 445 446 if self.log_filename is not None: … … 506 507 delta_total_energy = openings[0].total_energy - openings[1].total_energy 507 508 if delta_total_energy > 0: 508 #print 'Flow U/S ---> D/S'509 509 inlet = openings[0] 510 510 outlet = openings[1] 511 511 else: 512 #print 'Flow D/S ---> U/S'513 512 inlet = openings[1] 514 513 outlet = openings[0] … … 530 529 # Flow will be purely controlled by uphill outlet face 531 530 if self.verbose is True: 532 print '%.2fs - WARNING: Flow is running uphill.' % time531 log.critical('%.2fs - WARNING: Flow is running uphill.' % time) 533 532 534 533 if self.log_filename is not None: … … 789 788 msg += ' does not match distance between specified' 790 789 msg += ' end points (%.2f m)' %self.length 791 print msg790 log.critical(msg) 792 791 793 792 self.verbose = verbose … … 906 905 V += d * domain.areas[i] 907 906 908 #Vsimple = mean(depth)*self.inlet.exchange_area # Current volume in exchange area909 #print 'Q', Q, 'dt', delta_t, 'Q*dt', Q*delta_t, 'V', V, 'Vsimple', Vsimple910 911 907 dt = delta_t 912 908 if Q*dt > V: … … 918 914 msg += ' Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced) 919 915 920 #print msg921 922 916 if self.verbose is True: 923 print msg917 log.critical(msg) 924 918 if hasattr(self, 'log_filename'): 925 919 log_to_file(self.log_filename, msg) … … 1313 1307 1314 1308 opening.total_energy = 0.5*(u*u + v*v)/g + stage 1315 #print 'Et = %.3f m' %opening.total_energy1316 1309 1317 1310 # Store current average stage and depth with each opening object … … 1330 1323 1331 1324 if delta_Et > 0: 1332 #print 'Flow U/S ---> D/S'1333 1325 inlet = openings[0] 1334 1326 outlet = openings[1] … … 1338 1330 1339 1331 else: 1340 #print 'Flow D/S ---> U/S'1341 1332 inlet = openings[1] 1342 1333 outlet = openings[0] … … 1361 1352 # Flow will be purely controlled by uphill outlet face 1362 1353 if self.verbose is True: 1363 print 'WARNING: Flow is running uphill. Watch Out!', inlet.elevation, outlet.elevation 1354 log.critical('WARNING: Flow is running uphill. Watch Out! ' 1355 'inlet.elevation=%s, outlet.elevation%s' 1356 % (str(inlet.elevation), str(outlet.elevation))) 1364 1357 1365 1358 -
anuga_core/source/anuga/culvert_flows/culvert_routines.py
r7276 r7317 86 86 if inlet_depth > 0.1: #this value was 0.01: 87 87 if local_debug =='true': 88 print 'Specific E & Deltat Tot E = ',inlet_specific_energy,delta_total_energy 89 print 'culvert typ = ',culvert_type 88 log.critical('Specific E & Deltat Tot E = %s, %s' 89 % (str(inlet_specific_energy), 90 str(delta_total_energy))) 91 log.critical('culvert type = %s' % str(culvert_type)) 90 92 # Water has risen above inlet 91 93 … … 138 140 flow_width= diameter 139 141 case = 'Inlet CTRL Outlet submerged Circular PIPE FULL' 140 if local_debug =='true': 141 print 'Inlet CTRL Outlet submerged Circular PIPE FULL' 142 if local_debug == 'true': 143 log.critical('Inlet CTRL Outlet submerged Circular ' 144 'PIPE FULL') 142 145 else: 143 146 #alpha = acos(1 - outlet_culvert_depth/diameter) # Where did this Come From ????/ … … 149 152 case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth' 150 153 if local_debug =='true': 151 print 'INLET CTRL Culvert is open channel flow we will for now assume critical depth' 152 print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,' ',alpha 154 log.critical('INLET CTRL Culvert is open channel flow ' 155 'we will for now assume critical depth') 156 log.critical('Q Outlet Depth and ALPHA = %s, %s, %s' 157 % (str(Q), str(outlet_culvert_depth), 158 str(alpha))) 153 159 if delta_total_energy < inlet_specific_energy: # OUTLET CONTROL !!!! 154 160 # Calculate flows for outlet control … … 162 168 case = 'Outlet submerged' 163 169 if local_debug =='true': 164 print 'Outlet submerged'170 log.critical('Outlet submerged') 165 171 else: # Culvert running PART FULL for PART OF ITS LENGTH Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 166 172 # IF outlet_depth < diameter … … 178 184 case = 'Outlet unsubmerged PIPE FULL' 179 185 if local_debug =='true': 180 print 'Outlet unsubmerged PIPE FULL'186 log.critical('Outlet unsubmerged PIPE FULL') 181 187 else: 182 188 alpha = acos(1-2*outlet_culvert_depth/diameter)*2 … … 185 191 perimeter = alpha*diameter/2.0 186 192 case = 'Outlet is open channel flow we will for now assume critical depth' 187 if local_debug =='true': 188 print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,' ',alpha 189 print 'Outlet is open channel flow we will for now assume critical depth' 190 if local_debug =='true': 191 print 'FLOW AREA = ',flow_area 192 print 'PERIMETER = ',perimeter 193 print 'Q Interim = ',Q 193 if local_debug == 'true': 194 log.critical('Q Outlet Depth and ALPHA = %s, %s, %s' 195 % (str(Q), str(outlet_culvert_depth), 196 str(alpha))) 197 log.critical('Outlet is open channel flow we ' 198 'will for now assume critical depth') 199 if local_debug == 'true': 200 log.critical('FLOW AREA = %s' % str(flow_area)) 201 log.critical('PERIMETER = %s' % str(perimeter)) 202 log.critical('Q Interim = %s' % str(Q)) 194 203 hyd_rad = flow_area/perimeter 195 204 … … 200 209 # Outlet control velocity using tail water 201 210 if local_debug =='true': 202 print 'GOT IT ALL CALCULATING Velocity'203 print 'HydRad = ',hyd_rad211 log.critical('GOT IT ALL CALCULATING Velocity') 212 log.critical('HydRad = %s' % str(hyd_rad)) 204 213 culvert_velocity = sqrt(delta_total_energy/((sum_loss/2/g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 205 214 Q_outlet_tailwater = flow_area * culvert_velocity 206 215 if local_debug =='true': 207 print 'VELOCITY = ',culvert_velocity208 print 'Outlet Ctrl Q = ',Q_outlet_tailwater216 log.critical('VELOCITY = %s' % str(culvert_velocity)) 217 log.critical('Outlet Ctrl Q = %s' % str(Q_outlet_tailwater)) 209 218 if log_filename is not None: 210 219 s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater … … 212 221 Q = min(Q, Q_outlet_tailwater) 213 222 if local_debug =='true': 214 print ('%s,%.3f,%.3f' %('dcrit 1 , dcit2 =',dcrit1,dcrit2)) 215 print ('%s,%.3f,%.3f,%.3f' %('Q and Velocity and Depth=',Q,culvert_velocity,outlet_culvert_depth)) 223 log.critical('%s,%.3f,%.3f' 224 % ('dcrit 1 , dcit2 =',dcrit1,dcrit2)) 225 log.critical('%s,%.3f,%.3f,%.3f' 226 % ('Q and Velocity and Depth=', Q, 227 culvert_velocity, outlet_culvert_depth)) 216 228 217 229 else: … … 221 233 222 234 #else.... 223 if culvert_type == 'box':224 if local_debug == 'true':225 print 'BOX CULVERT'235 if culvert_type == 'box': 236 if local_debug == 'true': 237 log.critical('BOX CULVERT') 226 238 # Box culvert (rectangle or square) ======================================================================================================================== 227 239 … … 318 330 culv_froude=sqrt(Q**2*flow_width/(g*flow_area**3)) 319 331 if local_debug =='true': 320 print 'FLOW AREA = ',flow_area321 print 'PERIMETER = ',perimeter322 print 'Q final = ',Q323 print 'FROUDE = ',culv_froude332 log.critical('FLOW AREA = %s' % str(flow_area)) 333 log.critical('PERIMETER = %s' % str(perimeter)) 334 log.critical('Q final = %s' % str(Q)) 335 log.critical('FROUDE = %s' % str(culv_froude)) 324 336 if log_filename is not None: 325 337 s = 'Froude in Culvert = %f' % culv_froude -
anuga_core/source/anuga/culvert_flows/test_culvert_class.py
r7276 r7317 135 135 if delta_w < min_delta_w: min_delta_w = delta_w 136 136 137 #print domain.timestepping_statistics()138 137 pass 139 138 … … 236 235 ref_volume = domain.get_quantity('stage').get_integral() 237 236 for t in domain.evolve(yieldstep = 1, finaltime = 25): 238 #print domain.timestepping_statistics()239 237 new_volume = domain.get_quantity('stage').get_integral() 240 238 … … 339 337 ref_volume = domain.get_quantity('stage').get_integral() 340 338 for t in domain.evolve(yieldstep = 0.1, finaltime = 25): 341 #print domain.timestepping_statistics()342 339 new_volume = domain.get_quantity('stage').get_integral() 343 340 344 msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\ 345 % (new_volume, ref_volume) 346 if not num.allclose(new_volume, ref_volume): 347 print msg 341 msg = ('Total volume has changed: Is %.2f m^3 should have been %.2f m^3' 342 % (new_volume, ref_volume)) 348 343 assert num.allclose(new_volume, ref_volume), msg 349 344 … … 360 355 ref_volume = domain.get_quantity('stage').get_integral() 361 356 for t in domain.evolve(yieldstep = 0.1, finaltime = 25): 362 #print domain.timestepping_statistics()363 357 new_volume = domain.get_quantity('stage').get_integral() 364 358 365 #print new_volume, ref_volume, new_volume-ref_volume366 359 msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\ 367 360 % (new_volume, ref_volume) … … 471 464 for t in domain.evolve(yieldstep = 1, finaltime = 25): 472 465 473 #print domain.timestepping_statistics()474 466 new_volume = domain.get_quantity('stage').get_integral() 475 467 … … 558 550 culvert(domain) 559 551 560 #print 'Inlet flow', culvert.inlet.rate561 #print 'Outlet flow', culvert.outlet.rate562 563 564 552 565 553 #------------------------------------------------------------- 554 566 555 if __name__ == "__main__": 567 556 suite = unittest.makeSuite(Test_Culvert, 'test') -
anuga_core/source/anuga/damage_modelling/inundation_damage.py
r7276 r7317 35 35 from anuga.geospatial_data.geospatial_data import ensure_absolute 36 36 from anuga.utilities.numerical_tools import NAN 37 import anuga.utilities.log as log 37 38 from config import epsilon 38 39 depth_epsilon = epsilon … … 102 103 '.' + split_name[-1] 103 104 csv.save(exposure_file_out) 104 if verbose: print '\n Augmented building file written to %s \n' %exposure_file_out 105 if verbose: log.critical('Augmented building file written to %s' 106 % exposure_file_out) 105 107 106 108 def add_depth_and_momentum2csv(sww_base_name, exposure_file_in, … … 141 143 """ 142 144 quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] 143 #print "points",points144 145 points = ensure_absolute(points) 145 146 point_count = len(points) … … 151 152 # How many sww files are there? 152 153 dir, base = os.path.split(sww_base_name) 153 #print "basename_in",basename_in154 154 if base[-4:] == '.sww': 155 155 base = base[:-4] 156 #print "base",base157 156 if dir == "": dir = "." # Unix compatibility 158 157 dir_ls = os.listdir(dir) … … 162 161 %(sww_base_name) 163 162 raise IOError, msg 164 #print "interate_over", interate_over165 163 from os import sep 166 164 for this_sww_file in interate_over: … … 323 321 self.shore_distances, 324 322 self.walls): 325 #print "i",i326 #print "max_depth",max_depth327 #print "shore_distance",shore_distance328 #print "wall",wall329 323 ## WARNING SKIP IF DEPTH < 0.0 330 324 if 0.0 > max_depth: … … 376 370 self.shore_distances, 377 371 self.walls): 378 #print "i",i379 #print "max_depth",max_depth380 #print "shore_distance",shore_distance381 #print "wall",wall382 372 # WARNING ASSUMING THE FIRST BIN OF DEPTHS GIVE A ZERO PROBABILITY 383 373 depth_upper_limits = self.depth_upper_limits … … 431 421 # Warning, the collapse_probability list now lists 432 422 # houses that did not collapse, (though not all of them) 433 #print "",self.collapse_csv_info434 423 435 424 ############################################################################# -
anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
r7276 r7317 143 143 num_of_points 144 144 ''' 145 #print "num_of_points",num_of_points146 #print "maxArea",maxArea147 #print "max_points_per_cell", max_points_per_cell148 145 if geo_ref is True: 149 146 geo = Geo_reference(xllcorner = 2.0, yllcorner = 2.0) … … 158 155 verbose=verbose) 159 156 160 #print "len(mesh_dict['triangles'])",len(mesh_dict['triangles'])161 157 if is_fit is True: 162 158 op = "Fit_" … … 187 183 if is_fit is True: 188 184 189 # print "Fit in Fit"190 185 if use_file_type == None: 191 186 points = geospatial … … 224 219 else: 225 220 # run an interploate problem. 226 #print "Interpolate!"227 221 228 222 if run_profile: -
anuga_core/source/anuga/fit_interpolate/fit.py
r7276 r7317 40 40 from anuga.utilities.numerical_tools import ensure_numeric, gradient 41 41 from anuga.config import default_smoothing_parameter as DEFAULT_ALPHA 42 import anuga.utilities.log as log 42 43 43 44 import exceptions … … 112 113 self.point_count = 0 113 114 if self.alpha <> 0: 114 if verbose: print 'Building smoothing matrix'115 if verbose: log.critical('Building smoothing matrix') 115 116 self._build_smoothing_matrix_D() 116 117 … … 129 130 130 131 if self.alpha <> 0: 131 #if verbose: print 'Building smoothing matrix'132 #if verbose: log.critical('Building smoothing matrix') 132 133 #self._build_smoothing_matrix_D() 133 134 self.B = self.AtA + self.alpha*self.D … … 275 276 for d, i in enumerate(inside_indices): 276 277 # For each data_coordinate point 277 # if verbose and d%((n+10)/10)==0: print 'Doing %d of %d' %(d, n) 278 # if verbose and d%((n+10)/10)==0: log.critical('Doing %d of %d' 279 # %(d, n)) 278 280 x = point_coordinates[i] 279 281 … … 291 293 for j in js: 292 294 self.Atz[j] += sigmas[j]*z[i] 293 #print "self.Atz building", self.Atz294 #print "self.Atz[j]", self.Atz[j]295 #print " sigmas[j]", sigmas[j]296 #print "z[i]",z[i]297 #print "result", sigmas[j]*z[i]298 295 299 296 for k in js: … … 356 353 # is dependant on the # of Triangles 357 354 358 print 'Processing Block %d' %i355 log.critical('Processing Block %d' % i) 359 356 # FIXME (Ole): It would be good to say how many blocks 360 357 # there are here. But this is no longer necessary … … 379 376 assert self.AtA is not None, msg 380 377 381 #print 'Matrix was built OK'382 383 384 378 point_coordinates = None 385 379 else: … … 387 381 388 382 if point_coordinates is None: 389 if verbose: print 'Warning: no data points in fit'383 if verbose: log.critical('Warning: no data points in fit') 390 384 msg = 'No interpolation matrix.' 391 385 assert self.AtA is not None, msg … … 422 416 msg += 'The following vertices are not part of a triangle;\n' 423 417 msg += str(loners) 424 print msg418 log.critical(msg) 425 419 #raise VertsWithNoTrianglesError(msg) 426 420 … … 591 585 geo_reference = mesh_origin) 592 586 593 if verbose: print 'FitInterpolate: Building mesh'587 if verbose: log.critical('FitInterpolate: Building mesh') 594 588 mesh = Mesh(vertex_coordinates, triangles) 595 589 mesh.check_integrity() … … 650 644 except IOError,e: 651 645 if display_errors: 652 print "Could not load bad file. ", e646 log.critical("Could not load bad file: %s" % str(e)) 653 647 raise IOError #Could not load bad mesh file. 654 648 … … 665 659 old_title_list = mesh_dict['vertex_attribute_titles'] 666 660 667 if verbose: print 'tsh file %s loaded' %mesh_file661 if verbose: log.critical('tsh file %s loaded' % mesh_file) 668 662 669 663 # load in the points file … … 672 666 except IOError,e: 673 667 if display_errors: 674 print "Could not load bad file. ", e668 log.critical("Could not load bad file: %s" % str(e)) 675 669 raise IOError #Re-raise exception 676 670 … … 685 679 mesh_origin = None 686 680 687 if verbose: print "points file loaded"688 if verbose: print "fitting to mesh"681 if verbose: log.critical("points file loaded") 682 if verbose: log.critical("fitting to mesh") 689 683 f = fit_to_mesh(point_coordinates, 690 684 vertex_coordinates, … … 696 690 data_origin = None, 697 691 mesh_origin = mesh_origin) 698 if verbose: print "finished fitting to mesh"692 if verbose: log.critical("finished fitting to mesh") 699 693 700 694 # convert array to list of lists … … 713 707 mesh_dict['vertex_attribute_titles'] = title_list 714 708 715 if verbose: print "exporting to file ", mesh_output_file709 if verbose: log.critical("exporting to file %s" % mesh_output_file) 716 710 717 711 try: … … 719 713 except IOError,e: 720 714 if display_errors: 721 print "Could not write file. ", e715 log.critical("Could not write file %s", str(e)) 722 716 raise IOError -
anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py
r7276 r7317 34 34 ensure_absolute 35 35 from anuga.fit_interpolate.search_functions import set_last_triangle 36 import anuga.utilities.log as log 36 37 37 38 import numpy as num … … 101 102 geo_reference = mesh_origin) 102 103 103 if verbose: print 'FitInterpolate: Building mesh'104 if verbose: log.critical('FitInterpolate: Building mesh') 104 105 self.mesh = Mesh(vertex_coordinates, triangles) 105 106 #self.mesh.check_integrity() # Time consuming … … 110 111 111 112 if self.mesh is not None: 112 if verbose: print 'FitInterpolate: Building quad tree'113 if verbose: log.critical('FitInterpolate: Building quad tree') 113 114 #This stores indices of vertices 114 115 t0 = time.time() 115 #print "self.mesh.get_extent(absolute=True)", \116 #self.mesh.get_extent(absolute=True)117 116 self.root = build_quadtree(self.mesh, 118 117 max_points_per_cell = max_vertices_per_cell) 119 #print "self.root",self.root.show()120 118 121 119 build_quadtree_time = time.time()-t0 -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r7276 r7317 39 39 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 40 40 from utilities.polygon import interpolate_polyline 41 41 import anuga.utilities.log as log 42 42 43 43 import numpy as num … … 262 262 # This has now been addressed through an attempt in interpolate_block 263 263 264 if verbose: print 'Build intepolation object'264 if verbose: log.critical('Build intepolation object') 265 265 if isinstance(point_coordinates, Geospatial_data): 266 266 point_coordinates = point_coordinates.get_data_points(absolute=True) … … 274 274 # if verbose, give warning 275 275 if verbose: 276 print 'WARNING: Recalculating A matrix, due to blocking.' 276 log.critical('WARNING: Recalculating A matrix, ' 277 'due to blocking.') 277 278 point_coordinates = self._point_coordinates 278 279 else: … … 445 446 """ 446 447 447 if verbose: print 'Building interpolation matrix'448 if verbose: log.critical('Building interpolation matrix') 448 449 449 450 # Convert point_coordinates to numeric arrays, in case it was a list. 450 451 point_coordinates = ensure_numeric(point_coordinates, num.float) 451 452 452 if verbose: print 'Getting indices inside mesh boundary'453 if verbose: log.critical('Getting indices inside mesh boundary') 453 454 454 455 inside_poly_indices, outside_poly_indices = \ … … 459 460 # Build n x m interpolation matrix 460 461 if verbose and len(outside_poly_indices) > 0: 461 print '\n WARNING: Points outside mesh boundary. \n'462 log.critical('WARNING: Points outside mesh boundary.') 462 463 463 464 # Since you can block, throw a warning, not an error. 464 465 if verbose and 0 == len(inside_poly_indices): 465 print '\n WARNING: No points within the mesh! \n'466 log.critical('WARNING: No points within the mesh!') 466 467 467 468 m = self.mesh.number_of_nodes # Nbr of basis functions (1/vertex) 468 469 n = point_coordinates.shape[0] # Nbr of data points 469 470 470 if verbose: print 'Number of datapoints: %d' %n471 if verbose: print 'Number of basis functions: %d' %m471 if verbose: log.critical('Number of datapoints: %d' % n) 472 if verbose: log.critical('Number of basis functions: %d' % m) 472 473 473 474 A = Sparse(n,m) … … 476 477 477 478 # Compute matrix elements for points inside the mesh 478 if verbose: print 'Building interpolation matrix from %d points' %n 479 if verbose: log.critical('Building interpolation matrix from %d points' 480 % n) 479 481 480 482 for d, i in enumerate(inside_poly_indices): 481 483 # For each data_coordinate point 482 if verbose and d%((n+10)/10)==0: print 'Doing %d of %d' %(d, n) 484 if verbose and d%((n+10)/10)==0: log.critical('Doing %d of %d' 485 %(d, n)) 483 486 484 487 x = point_coordinates[i] … … 760 763 761 764 if verbose is True: 762 print 'Interpolation_function: input checks'765 log.critical('Interpolation_function: input checks') 763 766 764 767 # Check temporal info … … 794 797 795 798 if verbose is True: 796 print 'Interpolation_function: thinning by %d' % time_thinning 799 log.critical('Interpolation_function: thinning by %d' 800 % time_thinning) 797 801 798 802 … … 805 809 806 810 if verbose is True: 807 print 'Interpolation_function: precomputing'811 log.critical('Interpolation_function: precomputing') 808 812 809 813 # Save for use with statistics … … 886 890 # be ignored leaving good points for continued processing. 887 891 if verbose: 888 print msg892 log.critical(msg) 889 893 #raise Exception(msg) 890 894 … … 919 923 920 924 if verbose is True: 921 print 'Build interpolator'925 log.critical('Build interpolator') 922 926 923 927 … … 929 933 % (vertex_coordinates.shape[0], 930 934 triangles.shape[0]) 931 print msg935 log.critical(msg) 932 936 933 937 # This one is no longer needed for STS files … … 938 942 elif triangles is None and vertex_coordinates is not None: 939 943 if verbose: 940 msg = 'Interpolation from STS file' 941 print msg 944 log.critical('Interpolation from STS file') 942 945 943 946 944 947 945 948 if verbose: 946 print 'Interpolating (%d interpolation points, %d timesteps).' \947 %(self.interpolation_points.shape[0], self.time.shape[0]),949 log.critical('Interpolating (%d interpolation points, %d timesteps).' 950 % (self.interpolation_points.shape[0], self.time.shape[0])) 948 951 949 952 if time_thinning > 1: 950 print 'Timesteps were thinned by a factor of %d' \951 % time_thinning953 log.critical('Timesteps were thinned by a factor of %d' 954 % time_thinning) 952 955 else: 953 print956 log.critical() 954 957 955 958 for i, t in enumerate(self.time): 956 959 # Interpolate quantities at this timestep 957 960 if verbose and i%((p+10)/10) == 0: 958 print ' time step %d of %d' %(i, p)961 log.critical(' time step %d of %d' % (i, p)) 959 962 960 963 for name in quantity_names: … … 965 968 966 969 if verbose and i%((p+10)/10) == 0: 967 print ' quantity %s, size=%d' %(name, len(Q))970 log.critical(' quantity %s, size=%d' % (name, len(Q))) 968 971 969 972 # Interpolate … … 985 988 # Report 986 989 if verbose: 987 print self.statistics()990 log.critical(self.statistics()) 988 991 else: 989 992 # Store quantitites as is … … 1186 1189 #open sww file 1187 1190 x, y, volumes, time, quantities = read_sww(sww_file) 1188 print "x",x1189 print "y",y1190 1191 print "time", time1192 print "quantities", quantities1191 log.critical("x=%s" % str(x)) 1192 log.critical("y=%s" % str(y)) 1193 1194 log.critical("time=%s" % str(time)) 1195 log.critical("quantities=%s" % str(quantities)) 1193 1196 1194 1197 #Add the x and y together -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r7276 r7317 26 26 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 27 27 from anuga.config import netcdf_float 28 import anuga.utilities.log as log 28 29 29 30 … … 170 171 if verbose is True: 171 172 if file_name is not None: 172 print 'Loading Geospatial data from file: %s' % file_name 173 log.critical('Loading Geospatial data from file: %s' 174 % file_name) 173 175 174 176 self.import_points_file(file_name, verbose=verbose) … … 181 183 if verbose is True: 182 184 if file_name is not None: 183 print 'Geospatial data created from file: %s' % file_name 185 log.critical('Geospatial data created from file: %s' 186 % file_name) 184 187 if load_file_now is False: 185 print 'Data will be loaded blockwise on demand'188 log.critical('Data will be loaded blockwise on demand') 186 189 187 190 if file_name.endswith('csv') or file_name.endswith('txt'): … … 437 440 438 441 if self.verbose is True: 439 print 'Using attribute %s' %attribute_name440 print 'Available attributes: %s' %(self.attributes.keys())442 log.critical('Using attribute %s' % attribute_name) 443 log.critical('Available attributes: %s' % (self.attributes.keys())) 441 444 442 445 msg = 'Attribute name %s does not exist in data set' % attribute_name … … 696 699 697 700 # Find unique random numbers 698 if verbose: print "make unique random number list and get indices" 701 if verbose: log.critical("make unique random number list " 702 "and get indices") 699 703 700 704 total = num.array(range(self_size), num.int) #array default# 701 705 total_list = total.tolist() 702 706 703 if verbose: print "total list len", len(total_list)707 if verbose: log.critical("total list len=%d" % len(total_list)) 704 708 705 709 # There will be repeated random numbers however will not be a … … 708 712 # still basically random 709 713 ## create list of non-unquie random numbers 710 if verbose: print "create random numbers list %s long" %new_size 714 if verbose: log.critical("create random numbers list %s long" 715 % str(new_size)) 711 716 712 717 # Set seed if provided, mainly important for unit test! … … 717 722 seed() 718 723 719 #if verbose: print "seed:", get_seed()720 721 724 random_num = randint(0, self_size-1, (int(new_size),)) 722 725 random_num = random_num.tolist() … … 726 729 random_num.reverse() 727 730 728 if verbose: print "make random number list and get indices"731 if verbose: log.critical("make random number list and get indices") 729 732 730 733 j = 0 … … 740 743 # prints progress 741 744 if verbose and round(random_num_len/10*k) == j: 742 print '(%s/%s)' % (j, random_num_len)745 log.critical('(%s/%s)' % (j, random_num_len)) 743 746 k += 1 744 747 … … 755 758 756 759 # Get new samples 757 if verbose: print "get values of indices for random list"760 if verbose: log.critical("get values of indices for random list") 758 761 G1 = self.get_sample(random_list) 759 if verbose: print "get values of indices for opposite of random list" 762 if verbose: log.critical("get values of indices for " 763 "opposite of random list") 760 764 G2 = self.get_sample(remainder_list) 761 765 … … 800 804 801 805 if self.verbose is True: 802 print('Reading %d points (in ~%d blocks) from file %s. '803 % (self.number_of_points, self.number_of_blocks,804 self.file_name)),805 print('Each block consists of %d data points'806 % self.max_read_lines)806 log.critical('Reading %d points (in ~%d blocks) from file %s. ' 807 % (self.number_of_points, self.number_of_blocks, 808 self.file_name)) 809 log.critical('Each block consists of %d data points' 810 % self.max_read_lines) 807 811 else: 808 812 # Assume the file is a csv file … … 837 841 if (self.show_verbose >= self.start_row 838 842 and self.show_verbose < fin_row): 839 print('Reading block %d (points %d to %d) out of %d'840 % (self.block_number, self.start_row,841 fin_row, self.number_of_blocks))843 log.critical('Reading block %d (points %d to %d) out of %d' 844 % (self.block_number, self.start_row, 845 fin_row, self.number_of_blocks)) 842 846 843 847 self.show_verbose += max(self.max_read_lines, … … 976 980 """ 977 981 978 if verbose: print 'Reading ', file_name982 if verbose: log.critical('Reading %s' % file_name) 979 983 980 984 # See if the file is there. Throw a QUIET IO error if it isn't … … 988 992 keys = fid.variables.keys() 989 993 990 if verbose: print 'Got %d variables: %s' % (len(keys), keys)994 if verbose: log.critical('Got %d variables: %s' % (len(keys), keys)) 991 995 992 996 try: … … 999 1003 attributes = {} 1000 1004 for key in keys: 1001 if verbose: print "reading attribute '%s'" % key1005 if verbose: log.critical("reading attribute '%s'" % key) 1002 1006 1003 1007 attributes[key] = num.array(fid.variables[key]) … … 1173 1177 raise IOError, msg 1174 1178 1175 if verbose: print 'Got %d variables: %s' % (len(keys), keys)1179 if verbose: log.critical('Got %d variables: %s' % (len(keys), keys)) 1176 1180 1177 1181 try: … … 1562 1566 1563 1567 if mesh_file is None: 1564 if verbose: print "building mesh"1568 if verbose: log.critical("building mesh") 1565 1569 mesh_file = 'temp.msh' 1566 1570 … … 1597 1601 1598 1602 # split topo data 1599 if verbose: print 'Reading elevation file: %s' % data_file1603 if verbose: log.critical('Reading elevation file: %s' % data_file) 1600 1604 G = Geospatial_data(file_name = data_file) 1601 if verbose: print 'Start split'1605 if verbose: log.critical('Start split') 1602 1606 G_small, G_other = G.split(split_factor, seed_num, verbose=verbose) 1603 if verbose: print 'Finish split'1607 if verbose: log.critical('Finish split') 1604 1608 points = G_small.get_data_points() 1605 1609 1606 if verbose: print "Number of points in sample to compare: ", len(points) 1610 if verbose: log.critical("Number of points in sample to compare: %d" 1611 % len(points)) 1607 1612 1608 1613 if alpha_list == None: … … 1628 1633 normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=num.float) 1629 1634 1630 if verbose: print 'Setup computational domains with different alphas' 1635 if verbose: log.critical('Setup computational domains with ' 1636 'different alphas') 1631 1637 1632 1638 for i, alpha in enumerate(alphas): 1633 1639 # add G_other data to domains with different alphas 1634 1640 if verbose: 1635 print '\nCalculating domain and mesh for Alpha =', alpha, '\n' 1641 log.critical('Calculating domain and mesh for Alpha=%s' 1642 % str(alpha)) 1636 1643 domain = Domain(mesh_file, use_cache=cache, verbose=verbose) 1637 if verbose: print domain.statistics()1644 if verbose: log.critical(domain.statistics()) 1638 1645 domain.set_quantity(attribute_smoothed, 1639 1646 geospatial_data=G_other, … … 1647 1654 # returns the predicted elevation of the points that were "split" out 1648 1655 # of the original data set for one particular alpha 1649 if verbose: print 'Get predicted elevation for location to be compared' 1656 if verbose: log.critical('Get predicted elevation for location ' 1657 'to be compared') 1650 1658 elevation_predicted = \ 1651 1659 domain.quantities[attribute_smoothed].\ … … 1660 1668 1661 1669 if verbose: 1662 print 'Covariance for alpha ', normal_cov[i][0], '= ', \1663 normal_cov[i][1]1664 print '-------------------------------------------- \n'1670 log.critical('Covariance for alpha %s=%s' 1671 % (normal_cov[i][0], normal_cov[i][1])) 1672 log.critical('--------------------------------------------') 1665 1673 1666 1674 normal_cov0 = normal_cov[:,0] … … 1678 1686 1679 1687 if verbose: 1680 print 'Final results:'1688 log.critical('Final results:') 1681 1689 for i, alpha in enumerate(alphas): 1682 print('covariance for alpha %s = %s '1683 % (normal_cov[i][0], normal_cov[i][1]))1684 print ('\nOptimal alpha is: %s '1685 % normal_cov_new[(num.argmin(normal_cov_new, axis=0))[1], 0])1690 log.critical('covariance for alpha %s = %s ' 1691 % (normal_cov[i][0], normal_cov[i][1])) 1692 log.critical('Optimal alpha is: %s ' 1693 % normal_cov_new[(num.argmin(normal_cov_new, axis=0))[1], 0]) 1686 1694 1687 1695 # covariance and optimal alpha … … 1802 1810 # split topo data 1803 1811 G = Geospatial_data(file_name=data_file) 1804 if verbose: print 'start split'1812 if verbose: log.critical('start split') 1805 1813 G_small, G_other = G.split(split_factor, seed_num, verbose=verbose) 1806 if verbose: print 'finish split'1814 if verbose: log.critical('finish split') 1807 1815 points = G_small.get_data_points() 1808 1816 1809 if verbose: print "Number of points in sample to compare: ", len(points) 1817 if verbose: log.critical("Number of points in sample to compare: %d" 1818 % len(points)) 1810 1819 1811 1820 if alpha_list == None: … … 1818 1827 domains = {} 1819 1828 1820 if verbose: print 'Setup computational domains with different alphas' 1829 if verbose: log.critical('Setup computational domains with ' 1830 'different alphas') 1821 1831 1822 1832 for alpha in alphas: 1823 1833 # add G_other data to domains with different alphas 1824 1834 if verbose: 1825 print '\nCalculating domain and mesh for Alpha =', alpha, '\n' 1835 log.critical('Calculating domain and mesh for Alpha = %s' % 1836 str(alpha)) 1826 1837 domain = Domain(mesh_file, use_cache=cache, verbose=verbose) 1827 if verbose: print domain.statistics()1838 if verbose: log.critical(domain.statistics()) 1828 1839 domain.set_quantity(attribute_smoothed, 1829 1840 geospatial_data=G_other, … … 1849 1860 1850 1861 if verbose: 1851 print 'Determine difference between predicted results and actual data' 1862 log.critical('Determine difference between predicted results ' 1863 'and actual data') 1852 1864 1853 1865 for i, alpha in enumerate(domains): … … 1867 1879 ele_cov = cov(elevation_sample - elevation_predicted) 1868 1880 normal_cov[i,:] = [alpha,ele_cov / sample_cov] 1869 print 'memory usage during compare', mem_usage() 1870 if verbose: print 'cov', normal_cov[i][0], '= ', normal_cov[i][1] 1881 log.critical('memory usage during compare: %s' % str(mem_usage())) 1882 if verbose: log.critical('cov %s = %s' 1883 % (normal_cov[i][0], normal_cov[i][1])) 1871 1884 1872 1885 normal_cov0 = normal_cov[:,0] -
anuga_core/source/anuga/load_mesh/loadASCII.py
r7276 r7317 67 67 from anuga.config import netcdf_float, netcdf_char, netcdf_int 68 68 from anuga.utilities.system_tools import * 69 import anuga.utilities.log as log 69 70 70 71 from Scientific.IO.NetCDF import NetCDFFile … … 1012 1013 1013 1014 while point_atts['pointlist'].shape[0] > max_points: 1014 if verbose: print "point_atts['pointlist'].shape[0]"1015 if verbose: log.critical("point_atts['pointlist'].shape[0]") 1015 1016 point_atts = half_pts(point_atts) 1016 1017 … … 1030 1031 outfiles = [] 1031 1032 1032 if verbose: print "# of points", point_atts['pointlist'].shape[0]1033 if verbose: log.critical("# of points", point_atts['pointlist'].shape[0]) 1033 1034 1034 1035 while point_atts['pointlist'].shape[0] > max_points: 1035 1036 point_atts = half_pts(point_atts) 1036 1037 1037 if verbose: print "# of points", point_atts['pointlist'].shape[0] 1038 if verbose: log.critical("# of points = %s" 1039 % str(point_atts['pointlist'].shape[0])) 1038 1040 1039 1041 outfile = root + delimiter + str(point_atts['pointlist'].shape[0]) + ext -
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r7276 r7317 54 54 raise ANUGAError, msg 55 55 56 #print "pointatts",pointatts57 56 # This is after points is numeric 58 57 if pointatts is None or pointatts == []: … … 112 111 raise ANUGAError, msg 113 112 114 #print "mode", mode115 113 if mode.find('n'): 116 114 #pass … … 122 120 # EG handles lone verts! 123 121 124 #print "points",points125 #print "segments", segments126 #print "segments.shape", segments.shape127 #print "holes", holes128 #print "regions", regions129 #print "pointatts", pointatts130 #print "segatts", segatts131 #print "mode", mode132 #print "yeah"133 # .copy()134 122 trianglelist, pointlist, pointmarkerlist, pointattributelist, triangleattributelist, segmentlist, segmentmarkerlist, neighborlist = triang.genMesh(points,segments,holes,regions, 135 123 pointatts,segatts, mode) … … 138 126 mesh_dict['generatedtrianglelist'] = trianglelist 139 127 mesh_dict['generatedpointlist'] = pointlist 140 #print "mesh engine mesh_dict['generatedpointlist']", mesh_dict['generatedpointlist']141 128 # WARNING - generatedpointmarkerlist IS UNTESTED 142 129 mesh_dict['generatedpointmarkerlist'] = pointmarkerlist … … 148 135 149 136 #mesh_dict['triangleattributelist'] = triangleattributelist 150 #print "mesh eng generatedtrianglelist", trianglelist151 #print "mesh eng mesh_dict['triangleattributelist'] ",mesh_dict['triangleattributelist']152 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist']153 137 if True: 154 138 mesh_dict['generatedtriangleattributelist'] = triangleattributelist … … 167 151 # this is used by urs_ungridded2sww 168 152 raise NoTrianglesError 169 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist']170 153 a = mesh_dict['generatedtriangleattributelist'] 171 #print 'mesh_dict', mesh_dict172 154 # the structure of generatedtriangleattributelist is an list of 173 155 # list of integers. It is transformed into a list of list of -
anuga_core/source/anuga/pmesh/graphical_mesh_generator.py
r5188 r7317 17 17 import load_mesh.loadASCII 18 18 from anuga.alpha_shape.alpha_shape import AlphaError 19 import anuga.utilities.log as log 19 20 20 21 # CONSTANTS … … 413 414 dialog = AddVertexDialog(self.canvas) 414 415 if dialog.xyValuesOk: 415 print dialog.x416 print dialog.y416 log.critical(str(dialog.x)) 417 log.critical(str(dialog.y)) 417 418 self.drawVertex(dialog.x*self.SCALE,dialog.y*self.SCALE,None) 418 419 #Since the new vertex may be off screen 419 420 self.ResizeToFit() 420 421 else: 421 print "bad values"422 log.critical("bad values") 422 423 423 424 def windowDefault (self, parent): … … 510 511 smooth_indents=dialog.smooth_indents.get(), 511 512 expand_pinch=dialog.expand_pinch.get()) 512 #print "newsegs",newsegs513 #print "ObjectsToVisuallyDelete",ObjectsToVisuallyDelete514 513 515 514 for drawOb in ObjectsToVisuallyDelete: … … 563 562 564 563 if dialog.ValuesOk: 565 print dialog.minAngle566 print dialog.maxArea564 log.critical(str(dialog.minAngle)) 565 log.critical(str(dialog.maxArea)) 567 566 568 567 self.clearSelections() … … 586 585 else: 587 586 pass 588 print "userMeshChanged = False"587 log.critical("userMeshChanged = False") 589 588 self.UserMeshChanged = False 590 589 self.visualiseMesh(self.mesh) 591 print "Mesh Generation finished"590 log.critical("Mesh Generation finished") 592 591 593 592 def MeshGenAreaAngle (self, minAngle, maxArea, mesh): … … 621 620 pass 622 621 meshArea = 0 623 #print "tempMesh.getTriangulation()", tempMesh.getTriangulation()624 622 meshArea = tempMesh.tri_mesh.calc_mesh_area() 625 623 maxArea = meshArea/numTriangles … … 639 637 #The screen canvas has y 'flipped'. -1* unflips it 640 638 self.lasty = self.starty = -1*self.canvas.canvasy(event.y) 641 print "----------------------"639 log.critical "----------------------") 642 640 self.mouseDownCurFunc( self.lastx, 643 641 self.lasty,event) #!!! remove the event? … … 651 649 if event.widget.find_withtag(CURRENT): # if there's a widget with a tag 652 650 [tag,string] = self.canvas.gettags(CURRENT) # get a list of them 653 print "tag",tag#tags ('M*1008', 'current')651 log.critical("tag %s" % str(tag)) #tags ('M*1008', 'current') 654 652 if tag[:2] == 'M*': #!!! this can be removed when there are 655 653 # only mesh objects on screen 656 654 #key, value = string.split(tag, '*') 657 655 objectID = tag 658 print "Found!! objectID:", objectID656 log.critical("Found!! objectID: %s" % str(objectID)) 659 657 660 658 meshObjects = self.getAllUserMeshObjects() … … 663 661 selMeshObject = meshObjects.getMeshObject(objectID) 664 662 found = True 665 print "Found! selMeshObject", selMeshObject 663 log.critical("Found! selMeshObject: %s" 664 % str(selMeshObject)) 666 665 #Only select one object at a time 667 666 if self.selMeshObject: … … 728 727 #x_scaled = self.SCALE*x 729 728 #y_scaled = -1*self.SCALE*y 730 #print "x y:", x,y731 729 vert = self.Vertices.draw(x-self.mesh.geo_reference.get_xllcorner, 732 730 y-self.mesh.geo_reference.get_yllcorner, … … 749 747 #x_scaled = self.SCALE*x 750 748 #y_scaled = -1*self.SCALE*y 751 #print "x y:", x,y752 749 vert = self.Vertices.draw(x,y,self.mesh,self.uniqueID,self.SCALE,self.canvas,event) 753 750 self.UserMeshChanged = True … … 784 781 if event.widget.find_withtag(CURRENT): # if there's a widget with a tag 785 782 [tag,string] = self.canvas.gettags(CURRENT) # get a list of them 786 print "tag",tag#tags ('M*1008', 'current')783 log.critical("tag %s" % str(tag)) #tags ('M*1008', 'current') 787 784 objectID = tag 788 #print "Found!! objectID:", objectID789 785 if self.Vertices.hasKey(objectID): #isinstance(self.meshObjects[objectID],mesh.Vertex): 790 786 vertex = self.Vertices.getMeshObject(objectID) 791 787 found = True 792 print "Found! vertex", vertex788 log.critical("Found! vertex: %s" % str(vertex)) 793 789 794 790 if found and self.selVertex == vertex: 795 print "The selected vertex has already been selected"791 log.critical("The selected vertex has already been selected") 796 792 #The selected vertex has already been selected 797 793 # therefore deselect it … … 808 804 self.selectVertex(vertex,objectID) 809 805 else: 810 print "vertex is the 1st vertex"806 log.critical("vertex is the 1st vertex") 811 807 #vertex is the 1st vertex 812 808 self.selectVertex(vertex,objectID) 813 809 else: 814 print " There are no widgets. This happen's too much"810 log.critical(" There are no widgets. This happen's too much") 815 811 816 812 … … 844 840 def printGeoReference(self): 845 841 try: 846 print "geo reference", self.mesh.geo_reference842 log.critical("geo reference %s" % str(self.mesh.geo_reference)) 847 843 except: 848 print "no geo reference"844 log.critical("no geo reference") 849 845 850 846 def visualiseMesh(self,mesh): … … 1007 1003 import mesh data from a variety of formats (currently 2!) 1008 1004 """ 1009 print "self.currentPath",self.currentPath1005 log.critical("self.currentPath %s" % str(self.currentPath)) 1010 1006 ofile = tkFileDialog.askopenfilename(initialdir=self.currentPath, 1011 1007 filetypes=[ ("text Mesh", … … 1021 1017 newmesh = mesh.importMeshFromFile(ofile) 1022 1018 self.currentPath, dummy = os.path.split(ofile) 1023 #print "be good self.currentPath",self.currentPath1024 1019 self.currentFilePathName = ofile 1025 1020 self.clearMesh() … … 1041 1036 # Could not get the file name to showup in the title 1042 1037 #appname = ofile + " - " + APPLICATION_NAME 1043 #print "appname",appname1044 1038 1045 1039 except load_mesh.loadASCII.TitleAmountError: … … 1086 1080 Save the current drawing 1087 1081 """ 1088 #print "dsg!!! self.currentFilePathName ",self.currentFilePathName1089 1082 if (self.currentFilePathName[-4:] != ".tsh" or 1090 1083 self.currentFilePathName[-4:] != ".msh"): … … 1120 1113 there is no generated mesh do not prompt. 1121 1114 """ 1122 #print "self.UserMeshChanged",self.UserMeshChanged1123 #print "self.mesh.isTriangulation()",self.mesh.isTriangulation()1124 1115 if (self.UserMeshChanged) and self.mesh.isTriangulation(): 1125 1116 … … 1220 1211 1221 1212 fd.close() 1222 print 'returning m'1213 log.critical('returning m') 1223 1214 return oadtestmesh(ofile) 1224 1215 -
anuga_core/source/anuga/pmesh/mesh.py
r7276 r7317 34 34 ensure_geospatial, ensure_absolute, ensure_numeric 35 35 from anuga.mesh_engine.mesh_engine import generate_mesh 36 import anuga.utilities.log as log 37 36 38 37 39 try: … … 145 147 x = scale*(self.x + xoffset) 146 148 y = -1*scale*(self.y + yoffset) # - since for a canvas - is up 147 #print "draw x:", x148 #print "draw y:", y149 149 cornerOffset= self.VERTEXSQUARESIDELENGTH/2 150 150 … … 187 187 x = scale*(self.x + xoffset) 188 188 y = -1*scale*(self.y + yoffset) # - since for a canvas - is up 189 #print "draw x:", x190 #print "draw y:", y191 189 cornerOffset= self.HOLECORNERLENGTH/2 192 190 return canvas.create_oval(x-cornerOffset, … … 612 610 # Depreciated 613 611 def addRegionEN(self, x,y): 614 print "depreciated, use add_region"612 log.critical("deprecated, use add_region") 615 613 return self.add_region(x,y) 616 614 … … 2266 2264 counter = newmesh.removeDuplicatedUserVertices() 2267 2265 if (counter >0): 2268 print "%i duplicate vertices removed from dataset" % (counter)2266 log.critical("%i duplicate vertices removed from dataset" % counter) 2269 2267 elif (ofile[-4:]== ".tsh" or ofile[-4:]== ".msh"): 2270 2268 dict = import_mesh_file(ofile) … … 2340 2338 region_list[i] = (region_list[i][0],region_list[i][1],i) 2341 2339 else: 2342 print "The region list has a bad size"2340 log.critical("The region list has a bad size") 2343 2341 # raise an error .. 2344 2342 raise Error -
anuga_core/source/anuga/pmesh/mesh_interface.py
r7276 r7317 5 5 import numpy as num 6 6 from anuga.utilities.polygon import inside_polygon 7 7 import anuga.utilities.log as log 8 8 9 9 … … 151 151 #raise Exception, msg 152 152 # Fixme: Use proper Python warning 153 if verbose: print 'WARNING: ', msg153 if verbose: log.critical('WARNING: %s' % msg) 154 154 155 155 … … 187 187 else: 188 188 msg += ' I will ignore it.' 189 print msg189 log.critical(msg) 190 190 191 191 else: … … 313 313 return m 314 314 else: 315 if verbose: print 'Generating mesh to file "%s"' %filename315 if verbose: log.critical("Generating mesh to file '%s'" % filename) 316 316 m.generate_mesh(minimum_triangle_angle=minimum_triangle_angle, 317 317 verbose=verbose) -
anuga_core/source/anuga/shallow_water/data_manager.py
r7308 r7317 92 92 93 93 from anuga.utilities.system_tools import get_vars_in_expression 94 import anuga.utilities.log as log 94 95 95 96 … … 181 182 pass # FIXME: What about access rights under Windows? 182 183 183 if verbose: print 'MESSAGE: Directory', path, 'created.'184 if verbose: log.critical('MESSAGE: Directory %s created.' % path) 184 185 except: 185 print 'WARNING: Directory', path, 'could not be created.'186 log.critical('WARNING: Directory %s could not be created.' % path) 186 187 if unix: 187 188 path = '/tmp/' … … 189 190 path = 'C:' + os.sep 190 191 191 print "Using directory '%s' instead" % path192 log.critical("Using directory '%s' instead" % path) 192 193 193 194 return path … … 211 212 os.remove(X) 212 213 except: 213 print "Could not remove file %s" % X214 log.critical("Could not remove file %s" % X) 214 215 215 216 os.rmdir(path) … … 227 228 try: 228 229 func(path) 229 if verbose: print 'Removed ', path230 if verbose: log.critical('Removed %s' % path) 230 231 except OSError, (errno, strerror): 231 print ERROR_STR % {'path' : path, 'error': strerror }232 log.critical(ERROR_STR % {'path' : path, 'error': strerror }) 232 233 233 234 … … 483 484 % self.filename 484 485 msg += ' - trying step %s again' % self.domain.time 485 print msg486 log.critical(msg) 486 487 retries += 1 487 488 sleep(1) … … 524 525 recursion=self.recursion+1) 525 526 if not self.recursion: 526 print ' file_size = %s' % file_size 527 print ' saving file to %s' % next_data_structure.filename 527 log.critical(' file_size = %s' % file_size) 528 log.critical(' saving file to %s' 529 % next_data_structure.filename) 528 530 529 531 #set up the new data_structure … … 723 725 msg = 'Warning (store_timestep): File %s could not be opened' \ 724 726 ' - trying again' % self.filename 725 print msg727 log.critical(msg) 726 728 retries += 1 727 729 sleep(1) … … 1298 1300 # Get NetCDF 1299 1301 FN = create_filename('.', basefilename, 'sww', size) 1300 print 'Reading from ', FN1302 log.critical('Reading from %s' % FN) 1301 1303 fid = NetCDFFile(FN, netcdf_mode_r) #Open existing file for read 1302 1304 … … 1327 1329 for k in range(len(time)): 1328 1330 t = time[k] 1329 print 'Processing timestep %f' %t1331 log.critical('Processing timestep %f' % t) 1330 1332 1331 1333 for i in range(M): … … 1375 1377 files = glob.glob(data_dir + os.sep + basefilename + '*.dat') 1376 1378 for filename in files: 1377 print 'Processing %s' % filename1379 log.critical('Processing %s' % filename) 1378 1380 1379 1381 lines = open(data_dir + os.sep + filename, 'r').readlines() … … 1454 1456 selection = range(first, last, step) 1455 1457 for i, j in enumerate(selection): 1456 print 'Copying timestep %d of %d (%f)' % (j, last-first, time[j]) 1458 log.critical('Copying timestep %d of %d (%f)' 1459 % (j, last-first, time[j])) 1457 1460 newtime[i] = time[j] 1458 1461 newstage[i,:] = stage[j,:] … … 1556 1559 infile = NetCDFFile(root + '.dem', netcdf_mode_r) 1557 1560 1558 if verbose: print 'Reading DEM from %s' %(root + '.dem')1561 if verbose: log.critical('Reading DEM from %s' % (root + '.dem')) 1559 1562 1560 1563 ncols = infile.ncols[0] … … 1581 1584 ptsname = basename_out + '.pts' 1582 1585 1583 if verbose: print 'Store to NetCDF file %s' %ptsname1586 if verbose: log.critical('Store to NetCDF file %s' % ptsname) 1584 1587 1585 1588 # NetCDF file definition … … 1657 1660 1658 1661 if verbose: 1659 print 'There are %d values in the elevation' %totalnopoints 1660 print 'There are %d values in the clipped elevation' %clippednopoints 1661 print 'There are %d NODATA_values in the clipped elevation' %nn 1662 log.critical('There are %d values in the elevation' % totalnopoints) 1663 log.critical('There are %d values in the clipped elevation' 1664 % clippednopoints) 1665 log.critical('There are %d NODATA_values in the clipped elevation' % nn) 1662 1666 1663 1667 outfile.createDimension('number_of_points', nopoints) … … 1680 1684 for i in range(i1_0, thisi+1, 1): 1681 1685 if verbose and i % ((nrows+10)/10) == 0: 1682 print 'Processing row %d of %d' % (i, nrows)1686 log.critical('Processing row %d of %d' % (i, nrows)) 1683 1687 1684 1688 lower_index = global_index … … 1820 1824 infile = open(root + '.sdf', 'r') 1821 1825 1822 if verbose: print 'Reading DEM from %s' %(root + '.sdf')1826 if verbose: log.critical('Reading DEM from %s' % (root + '.sdf')) 1823 1827 1824 1828 lines = infile.readlines() 1825 1829 infile.close() 1826 1830 1827 if verbose: print 'Converting to pts format'1831 if verbose: log.critical('Converting to pts format') 1828 1832 1829 1833 # Scan through the header, picking up stuff we need. … … 2026 2030 if is_parallel is True: 2027 2031 for i in range(nodes): 2028 print 'Sending node %d of %d' % (i, nodes)2032 log.critical('Sending node %d of %d' % (i, nodes)) 2029 2033 swwfiles = {} 2030 2034 if not reportname == None: … … 2037 2041 sww_extra = '_P%s_%s' % (i, nodes) 2038 2042 swwfile = file_loc + scenario_name + sww_extra + '.sww' 2039 print 'swwfile', swwfile2043 log.critical('swwfile %s' % swwfile) 2040 2044 swwfiles[swwfile] = label_id 2041 2045 … … 2055 2059 for label_id in production_dirs.keys(): 2056 2060 if label_id == 'boundaries': 2057 print 'boundaries'2061 log.critical('boundaries') 2058 2062 file_loc = project.boundaries_in_dir 2059 2063 swwfile = project.boundaries_dir_name3 + '.sww' … … 2196 2200 # Read sww file 2197 2201 if verbose: 2198 print 'Reading from %s' % swwfile2199 print 'Output directory is %s' % basename_out2202 log.critical('Reading from %s' % swwfile) 2203 log.critical('Output directory is %s' % basename_out) 2200 2204 2201 2205 from Scientific.IO.NetCDF import NetCDFFile … … 2234 2238 # Something like print swwstats(swwname) 2235 2239 if verbose: 2236 print '------------------------------------------------' 2237 print 'Statistics of SWW file:' 2238 print ' Name: %s' %swwfile 2239 print ' Reference:' 2240 print ' Lower left corner: [%f, %f]'\ 2241 %(xllcorner, yllcorner) 2240 log.critical('------------------------------------------------') 2241 log.critical('Statistics of SWW file:') 2242 log.critical(' Name: %s' % swwfile) 2243 log.critical(' Reference:') 2244 log.critical(' Lower left corner: [%f, %f]' % (xllcorner, yllcorner)) 2242 2245 if timestep is not None: 2243 print ' Time: %f' %(times)2246 log.critical(' Time: %f' % times) 2244 2247 else: 2245 print ' Start time: %f' %fid.starttime[0]2246 print ' Extent:'2247 print ' x [m] in [%f, %f], len(x) == %d'\2248 %(num.min(x), num.max(x), len(x.flat))2249 print ' y [m] in [%f, %f], len(y) == %d'\2250 %(num.min(y), num.max(y), len(y.flat))2248 log.critical(' Start time: %f' % fid.starttime[0]) 2249 log.critical(' Extent:') 2250 log.critical(' x [m] in [%f, %f], len(x) == %d' 2251 %(num.min(x), num.max(x), len(x.flat))) 2252 log.critical(' y [m] in [%f, %f], len(y) == %d' 2253 % (num.min(y), num.max(y), len(y.flat))) 2251 2254 if timestep is not None: 2252 print ' t [s] = %f, len(t) == %d' %(times, 1)2255 log.critical(' t [s] = %f, len(t) == %d' % (times, 1)) 2253 2256 else: 2254 print ' t [s] in [%f, %f], len(t) == %d'\2255 %(min(times), max(times), len(times))2256 print ' Quantities [SI units]:'2257 log.critical(' t [s] in [%f, %f], len(t) == %d' 2258 % (min(times), max(times), len(times))) 2259 log.critical(' Quantities [SI units]:') 2257 2260 # Comment out for reduced memory consumption 2258 2261 for name in ['stage', 'xmomentum', 'ymomentum']: … … 2260 2263 if timestep is not None: 2261 2264 q = q[timestep*len(x):(timestep+1)*len(x)] 2262 if verbose: print ' %s in [%f, %f]' %(name, min(q), max(q)) 2265 if verbose: log.critical(' %s in [%f, %f]' 2266 % (name, min(q), max(q))) 2263 2267 for name in ['elevation']: 2264 2268 q = fid.variables[name][:].flatten() 2265 if verbose: print ' %s in [%f, %f]' %(name, min(q), max(q)) 2269 if verbose: log.critical(' %s in [%f, %f]' 2270 % (name, min(q), max(q))) 2266 2271 2267 2272 # Get the variables in the supplied expression. … … 2313 2318 2314 2319 if verbose: 2315 print 'Processed values for %s are in [%f, %f]' % \2316 (quantity, min(result), max(result))2320 log.critical('Processed values for %s are in [%f, %f]' 2321 % (quantity, min(result), max(result))) 2317 2322 2318 2323 #Create grid and update xll/yll corner and x,y … … 2346 2351 assert ymax >= ymin, msg 2347 2352 2348 if verbose: print 'Creating grid'2353 if verbose: log.critical('Creating grid') 2349 2354 ncols = int((xmax-xmin)/cellsize) + 1 2350 2355 nrows = int((ymax-ymin)/cellsize) + 1 … … 2386 2391 2387 2392 #Interpolate using quantity values 2388 if verbose: print 'Interpolating'2393 if verbose: log.critical('Interpolating') 2389 2394 grid_values = interp.interpolate(result, grid_points).flatten() 2390 2395 2391 2396 if verbose: 2392 print 'Interpolated values are in [%f, %f]' %(num.min(grid_values),2393 num.max(grid_values))2397 log.critical('Interpolated values are in [%f, %f]' 2398 % (num.min(grid_values), num.max(grid_values))) 2394 2399 2395 2400 #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh) … … 2422 2427 2423 2428 #Write 2424 if verbose: print 'Writing %s' %demfile2429 if verbose: log.critical('Writing %s' % demfile) 2425 2430 2426 2431 import ermapper_grids … … 2434 2439 prjfile = basename_out + '.prj' 2435 2440 2436 if verbose: print 'Writing %s' %prjfile2441 if verbose: log.critical('Writing %s' % prjfile) 2437 2442 prjid = open(prjfile, 'w') 2438 2443 prjid.write('Projection %s\n' %'UTM') … … 2447 2452 prjid.close() 2448 2453 2449 if verbose: print 'Writing %s' %demfile2454 if verbose: log.critical('Writing %s' % demfile) 2450 2455 2451 2456 ascid = open(demfile, 'w') … … 2463 2468 for i in range(nrows): 2464 2469 if verbose and i % ((nrows+10)/10) == 0: 2465 print 'Doing row %d of %d' %(i, nrows)2470 log.critical('Doing row %d of %d' % (i, nrows)) 2466 2471 2467 2472 base_index = (nrows-i-1)*ncols … … 2501 2506 verbose = False, 2502 2507 origin = None): 2503 print 'sww2asc will soon be obsoleted - please use sww2dem'2508 log.critical('sww2asc will soon be obsoleted - please use sww2dem') 2504 2509 sww2dem(basename_in, 2505 2510 basename_out = basename_out, … … 2535 2540 origin=None, 2536 2541 datum='WGS84'): 2537 print 'sww2ers will soon be obsoleted - please use sww2dem'2542 log.critical('sww2ers will soon be obsoleted - please use sww2dem') 2538 2543 sww2dem(basename_in, 2539 2544 basename_out=basename_out, … … 2605 2610 2606 2611 # Read sww file 2607 if verbose: print 'Reading from %s' % swwfile2612 if verbose: log.critical('Reading from %s' % swwfile) 2608 2613 from Scientific.IO.NetCDF import NetCDFFile 2609 2614 fid = NetCDFFile(swwfile) … … 2638 2643 y = fid.variables['y'][:] 2639 2644 times = fid.variables['time'][:] 2640 print '------------------------------------------------'2641 print 'Statistics of SWW file:'2642 print ' Name: %s' % swwfile2643 print ' Reference:'2644 print ' Lower left corner: [%f, %f]' % (xllcorner, yllcorner)2645 print ' Start time: %f' % fid.starttime[0]2646 print ' Extent:'2647 print ' x [m] in [%f, %f], len(x) == %d' \2648 % (num.min(x), num.max(x), len(x.flat))2649 print ' y [m] in [%f, %f], len(y) == %d' \2650 % (num.min(y), num.max(y), len(y.flat))2651 print ' t [s] in [%f, %f], len(t) == %d' \2652 % (min(times), max(times), len(times))2653 print ' Quantities [SI units]:'2645 log.critical('------------------------------------------------') 2646 log.critical('Statistics of SWW file:') 2647 log.critical(' Name: %s' % swwfile) 2648 log.critical(' Reference:') 2649 log.critical(' Lower left corner: [%f, %f]' % (xllcorner, yllcorner)) 2650 log.critical(' Start time: %f' % fid.starttime[0]) 2651 log.critical(' Extent:') 2652 log.critical(' x [m] in [%f, %f], len(x) == %d' 2653 % (num.min(x), num.max(x), len(x.flat))) 2654 log.critical(' y [m] in [%f, %f], len(y) == %d' 2655 % (num.min(y), num.max(y), len(y.flat))) 2656 log.critical(' t [s] in [%f, %f], len(t) == %d' 2657 % (min(times), max(times), len(times))) 2658 log.critical(' Quantities [SI units]:') 2654 2659 for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']: 2655 2660 q = fid.variables[name][:].flat 2656 print ' %s in [%f, %f]' % (name, min(q), max(q))2661 log.critical(' %s in [%f, %f]' % (name, min(q), max(q))) 2657 2662 2658 2663 # Get quantity and reduce if applicable 2659 if verbose: print 'Processing quantity %s' % quantity2664 if verbose: log.critical('Processing quantity %s' % quantity) 2660 2665 2661 2666 # Turn NetCDF objects into numeric arrays … … 2670 2675 # q has a time component and needs to be reduced along 2671 2676 # the temporal dimension 2672 if verbose: print 'Reducing quantity %s' % quantity2677 if verbose: log.critical('Reducing quantity %s' % quantity) 2673 2678 2674 2679 q_reduced = num.zeros(number_of_points, num.float) … … 2682 2687 2683 2688 if verbose: 2684 print 'Processed values for %s are in [%f, %f]' \2685 % (quantity, min(q), max(q))2689 log.critical('Processed values for %s are in [%f, %f]' 2690 % (quantity, min(q), max(q))) 2686 2691 2687 2692 # Create grid and update xll/yll corner and x,y … … 2694 2699 2695 2700 # Interpolate using quantity values 2696 if verbose: print 'Interpolating'2701 if verbose: log.critical('Interpolating') 2697 2702 interpolated_values = interp.interpolate(q, data_points).flatten() 2698 2703 2699 2704 if verbose: 2700 print ('Interpolated values are in [%f, %f]' 2701 % (num.min(interpolated_values), num.max(interpolated_values))) 2705 log.critical('Interpolated values are in [%f, %f]' 2706 % (num.min(interpolated_values), 2707 num.max(interpolated_values))) 2702 2708 2703 2709 # Assign NODATA_value to all points outside bounding polygon … … 2793 2799 2794 2800 # Read Meta data 2795 if verbose: print 'Reading METADATA from %s' % root + '.prj'2801 if verbose: log.critical('Reading METADATA from %s' % (root + '.prj')) 2796 2802 2797 2803 metadatafile = open(root + '.prj') … … 2834 2840 datafile = open(basename_in + '.asc') 2835 2841 2836 if verbose: print 'Reading DEM from %s' % basename_in + '.asc'2842 if verbose: log.critical('Reading DEM from %s' % (basename_in + '.asc')) 2837 2843 2838 2844 lines = datafile.readlines() 2839 2845 datafile.close() 2840 2846 2841 if verbose: print 'Got', len(lines), ' lines'2847 if verbose: log.critical('Got %d lines' % len(lines)) 2842 2848 2843 2849 ncols = int(lines[0].split()[1].strip()) … … 2877 2883 netcdfname = basename_out + '.dem' 2878 2884 2879 if verbose: print 'Store to NetCDF file %s' % netcdfname2885 if verbose: log.critical('Store to NetCDF file %s' % netcdfname) 2880 2886 2881 2887 # NetCDF file definition … … 2917 2923 fields = line.split() 2918 2924 if verbose and i % ((n+10)/10) == 0: 2919 print 'Processing row %d of %d' % (i, nrows)2925 log.critical('Processing row %d of %d' % (i, nrows)) 2920 2926 2921 2927 if len(fields) != ncols: … … 3011 3017 3012 3018 # Get NetCDF data 3013 if verbose: print 'Reading files %s_*.nc' % basename_in3019 if verbose: log.critical('Reading files %s_*.nc' % basename_in) 3014 3020 3015 3021 file_h = NetCDFFile(basename_in + '_ha.nc', netcdf_mode_r) # Wave amplitude (cm) … … 3106 3112 longitudes = longitudes[lmin:lmax] 3107 3113 3108 if verbose: print 'cropping'3114 if verbose: log.critical('cropping') 3109 3115 3110 3116 zname = 'ELEVATION' … … 3184 3190 3185 3191 if verbose: 3186 print '------------------------------------------------' 3187 print 'Statistics:' 3188 print ' Extent (lat/lon):' 3189 print ' lat in [%f, %f], len(lat) == %d' \ 3190 % (num.min(latitudes), num.max(latitudes), len(latitudes.flat)) 3191 print ' lon in [%f, %f], len(lon) == %d' \ 3192 % (num.min(longitudes), num.max(longitudes), 3193 len(longitudes.flat)) 3194 print ' t in [%f, %f], len(t) == %d' \ 3195 % (num.min(times), num.max(times), len(times.flat)) 3192 log.critical('------------------------------------------------') 3193 log.critical('Statistics:') 3194 log.critical(' Extent (lat/lon):') 3195 log.critical(' lat in [%f, %f], len(lat) == %d' 3196 % (num.min(latitudes), num.max(latitudes), 3197 len(latitudes.flat))) 3198 log.critical(' lon in [%f, %f], len(lon) == %d' 3199 % (num.min(longitudes), num.max(longitudes), 3200 len(longitudes.flat))) 3201 log.critical(' t in [%f, %f], len(t) == %d' 3202 % (num.min(times), num.max(times), len(times.flat))) 3196 3203 3197 3204 # q = amplitudes.flatten() 3198 3205 name = 'Amplitudes (ha) [cm]' 3199 print ' %s in [%f, %f]' % (name, num.min(amplitudes), num.max(amplitudes)) 3206 log.critical(' %s in [%f, %f]' 3207 % (name, num.min(amplitudes), num.max(amplitudes))) 3200 3208 3201 3209 # q = uspeed.flatten() 3202 3210 name = 'Speeds (ua) [cm/s]' 3203 print ' %s in [%f, %f]' % (name, num.min(uspeed), num.max(uspeed)) 3211 log.critical(' %s in [%f, %f]' 3212 % (name, num.min(uspeed), num.max(uspeed))) 3204 3213 3205 3214 # q = vspeed.flatten() 3206 3215 name = 'Speeds (va) [cm/s]' 3207 print ' %s in [%f, %f]' % (name, num.min(vspeed), num.max(vspeed)) 3216 log.critical(' %s in [%f, %f]' 3217 % (name, num.min(vspeed), num.max(vspeed))) 3208 3218 3209 3219 # q = elevations.flatten() 3210 3220 name = 'Elevations (e) [m]' 3211 print ' %s in [%f, %f]' % (name, num.min(elevations), num.max(elevations)) 3221 log.critical(' %s in [%f, %f]' 3222 % (name, num.min(elevations), num.max(elevations))) 3212 3223 3213 3224 # print number_of_latitudes, number_of_longitudes … … 3242 3253 y = num.zeros(number_of_points, num.float) #Northing 3243 3254 3244 if verbose: print 'Making triangular grid'3255 if verbose: log.critical('Making triangular grid') 3245 3256 3246 3257 # Check zone boundaries … … 3302 3313 ymomentum = outfile.variables['ymomentum'] 3303 3314 3304 if verbose: print 'Converting quantities'3315 if verbose: log.critical('Converting quantities') 3305 3316 3306 3317 n = len(times) 3307 3318 for j in range(n): 3308 if verbose and j % ((n+10)/10) == 0: print ' Doing %d of %d' %(j, n) 3319 if verbose and j % ((n+10)/10) == 0: 3320 log.critical(' Doing %d of %d' % (j, n)) 3309 3321 3310 3322 i = 0 … … 3325 3337 x = outfile.variables['x'][:] 3326 3338 y = outfile.variables['y'][:] 3327 print '------------------------------------------------'3328 print 'Statistics of output file:'3329 print ' Name: %s' %swwname3330 print ' Reference:'3331 print ' Lower left corner: [%f, %f]' \3332 % (geo_ref.get_xllcorner(), geo_ref.get_yllcorner())3333 print ' Start time: %f' %starttime3334 print ' Min time: %f' %mint3335 print ' Max time: %f' %maxt3336 print ' Extent:'3337 print ' x [m] in [%f, %f], len(x) == %d' \3338 % (num.min(x), num.max(x), len(x.flat))3339 print ' y [m] in [%f, %f], len(y) == %d' \3340 % (num.min(y), num.max(y), len(y.flat))3341 print ' t [s] in [%f, %f], len(t) == %d' \3342 % (min(times), max(times), len(times))3343 print ' Quantities [SI units]:'3339 log.critical('------------------------------------------------') 3340 log.critical('Statistics of output file:') 3341 log.critical(' Name: %s' %swwname) 3342 log.critical(' Reference:') 3343 log.critical(' Lower left corner: [%f, %f]' 3344 % (geo_ref.get_xllcorner(), geo_ref.get_yllcorner())) 3345 log.critical(' Start time: %f' %starttime) 3346 log.critical(' Min time: %f' %mint) 3347 log.critical(' Max time: %f' %maxt) 3348 log.critical(' Extent:') 3349 log.critical(' x [m] in [%f, %f], len(x) == %d' 3350 % (num.min(x), num.max(x), len(x.flat))) 3351 log.critical(' y [m] in [%f, %f], len(y) == %d' 3352 % (num.min(y), num.max(y), len(y.flat))) 3353 log.critical(' t [s] in [%f, %f], len(t) == %d' 3354 % (min(times), max(times), len(times))) 3355 log.critical(' Quantities [SI units]:') 3344 3356 for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']: 3345 3357 q = outfile.variables[name][:] # .flatten() 3346 print ' %s in [%f, %f]' % (name, num.min(q), num.max(q))3358 log.critical(' %s in [%f, %f]' % (name, num.min(q), num.max(q))) 3347 3359 3348 3360 outfile.close() … … 3537 3549 NaN = 9.969209968386869e+036 3538 3550 3539 if verbose: print 'Reading from ', filename3551 if verbose: log.critical('Reading from %s' % filename) 3540 3552 3541 3553 fid = NetCDFFile(filename, netcdf_mode_r) # Open existing file for read … … 3570 3582 geo_reference = None 3571 3583 3572 if verbose: print ' getting quantities'3584 if verbose: log.critical(' getting quantities') 3573 3585 3574 3586 for quantity in fid.variables.keys(): … … 3595 3607 conserved_quantities.remove('time') 3596 3608 3597 if verbose: print ' building domain'3609 if verbose: log.critical(' building domain') 3598 3610 3599 3611 # From domain.Domain: … … 3637 3649 X = fid.variables[quantity][:] 3638 3650 if very_verbose: 3639 print ' ', quantity3640 print ' NaN =', NaN3641 print ' max(X)'3642 print ' ', max(X)3643 print ' max(X)==NaN'3644 print ' ', max(X)==NaN3645 print ''3651 log.critical(' %s' % str(quantity)) 3652 log.critical(' NaN = %s' % str(NaN)) 3653 log.critical(' max(X)') 3654 log.critical(' %s' % str(max(X))) 3655 log.critical(' max(X)==NaN') 3656 log.critical(' %s' % str(max(X)==NaN)) 3657 log.critical('') 3646 3658 if max(X) == NaN or min(X) == NaN: 3647 3659 if fail_if_NaN: … … 3662 3674 X = interpolated_quantities[quantity] 3663 3675 if very_verbose: 3664 print ' ',quantity3665 print ' NaN =', NaN3666 print ' max(X)'3667 print ' ', max(X)3668 print ' max(X)==NaN'3669 print ' ', max(X)==NaN3670 print ''3676 log.critical(' %s' % str(quantity)) 3677 log.critical(' NaN = %s' % str(NaN)) 3678 log.critical(' max(X)') 3679 log.critical(' %s' % str(max(X))) 3680 log.critical(' max(X)==NaN') 3681 log.critical(' %s' % str(max(X)==NaN)) 3682 log.critical('') 3671 3683 if max(X) == NaN or min(X) == NaN: 3672 3684 if fail_if_NaN: … … 3832 3844 infile = NetCDFFile(inname, netcdf_mode_r) 3833 3845 3834 if verbose: print 'Reading DEM from %s' % inname3846 if verbose: log.critical('Reading DEM from %s' % inname) 3835 3847 3836 3848 # Read metadata (convert from numpy.int32 to int where appropriate) … … 3856 3868 outname = basename_out + '.dem' 3857 3869 3858 if verbose: print 'Write decimated NetCDF file to %s' % outname3870 if verbose: log.critical('Write decimated NetCDF file to %s' % outname) 3859 3871 3860 3872 #Determine some dimensions for decimated grid … … 3908 3920 global_index = 0 3909 3921 for i in range(nrows_new): 3910 if verbose: print 'Processing row %d of %d' %(i, nrows_new)3922 if verbose: log.critical('Processing row %d of %d' % (i, nrows_new)) 3911 3923 3912 3924 lower_index = global_index … … 3951 3963 """ 3952 3964 3953 if verbose == True: print 'Creating domain from', filename3965 if verbose == True: log.critical('Creating domain from %s' % filename) 3954 3966 3955 3967 domain = pmesh_to_domain_instance(filename, Domain) 3956 3968 3957 if verbose == True: print "Number of triangles = ", len(domain)3969 if verbose == True: log.critical("Number of triangles = %s" % len(domain)) 3958 3970 3959 3971 domain.smooth = True … … 3964 3976 domain.reduction = mean 3965 3977 3966 if verbose == True: print "file_path",file_path3978 if verbose == True: log.critical("file_path = %s" % file_path) 3967 3979 3968 3980 if file_path == "": … … 3971 3983 3972 3984 if verbose == True: 3973 print "Output written to " + domain.get_datadir() + sep + \ 3974 domain.get_name() + "." + domain.format 3985 log.critical("Output written to %s%s%s.%s" 3986 % (domain.get_datadir(), sep, domain.get_name(), 3987 domain.format)) 3975 3988 3976 3989 sww = get_dataobject(domain) … … 4099 4112 4100 4113 if verbose: 4101 print '------------------------------------------------'4102 print 'Statistics:'4103 print ' Extent (lat/lon):'4104 print ' lat in [%f, %f], len(lat) == %d' \4105 % (min(latitudes), max(latitudes), len(latitudes))4106 print ' lon in [%f, %f], len(lon) == %d' \4107 % (min(longitudes), max(longitudes), len(longitudes))4108 print ' t in [%f, %f], len(t) == %d' \4109 % (min(times), max(times), len(times))4114 log.critical('------------------------------------------------') 4115 log.critical('Statistics:') 4116 log.critical(' Extent (lat/lon):') 4117 log.critical(' lat in [%f, %f], len(lat) == %d' 4118 % (min(latitudes), max(latitudes), len(latitudes))) 4119 log.critical(' lon in [%f, %f], len(lon) == %d' 4120 % (min(longitudes), max(longitudes), len(longitudes))) 4121 log.critical(' t in [%f, %f], len(t) == %d' 4122 % (min(times), max(times), len(times))) 4110 4123 4111 4124 ######### WRITE THE SWW FILE ############# … … 4160 4173 y = num.zeros(number_of_points, num.float) #Northing 4161 4174 4162 if verbose: print 'Making triangular grid'4175 if verbose: log.critical('Making triangular grid') 4163 4176 4164 4177 #Get zone of 1st point. … … 4203 4216 4204 4217 if verbose: 4205 print '------------------------------------------------'4206 print 'More Statistics:'4207 print ' Extent (/lon):'4208 print ' x in [%f, %f], len(lat) == %d' \4209 % (min(x), max(x), len(x))4210 print ' y in [%f, %f], len(lon) == %d' \4211 % (min(y), max(y), len(y))4212 print 'geo_ref: ', geo_ref4218 log.critical('------------------------------------------------') 4219 log.critical('More Statistics:') 4220 log.critical(' Extent (/lon):') 4221 log.critical(' x in [%f, %f], len(lat) == %d' 4222 % (min(x), max(x), len(x))) 4223 log.critical(' y in [%f, %f], len(lon) == %d' 4224 % (min(y), max(y), len(y))) 4225 log.critical('geo_ref: ', geo_ref) 4213 4226 4214 4227 z = num.resize(bath_grid,outfile.variables['z'][:].shape) … … 4227 4240 outfile.variables['time'][:] = times #Store time relative 4228 4241 4229 if verbose: print 'Converting quantities'4242 if verbose: log.critical('Converting quantities') 4230 4243 4231 4244 n = number_of_times … … 4254 4267 + missing*elevation_NaN_filler 4255 4268 4256 if verbose and j % ((n+10)/10) == 0: print ' Doing %d of %d' % (j, n) 4269 if verbose and j % ((n+10)/10) == 0: log.critical(' Doing %d of %d' 4270 % (j, n)) 4257 4271 4258 4272 i = 0 … … 4373 4387 datafile = open(filename) 4374 4388 4375 if verbose: print 'Reading DEM from %s' % filename4389 if verbose: log.critical('Reading DEM from %s' % filename) 4376 4390 4377 4391 lines = datafile.readlines() 4378 4392 datafile.close() 4379 4393 4380 if verbose: print 'Got', len(lines), ' lines'4394 if verbose: log.critical('Got %d lines' % len(lines)) 4381 4395 4382 4396 ncols = int(lines.pop(0).split()[1].strip()) … … 4630 4644 else: 4631 4645 files_in[i] += '.mux' 4632 print "file_name", file_name4646 log.critical("file_name %s" % file_name) 4633 4647 4634 4648 hashed_elevation = None … … 5315 5329 swwname = basename_out + '.sww' 5316 5330 5317 if verbose: print 'Output to ', swwname5331 if verbose: log.critical('Output to %s' % swwname) 5318 5332 5319 5333 outfile = NetCDFFile(swwname, netcdf_mode_w) … … 5331 5345 verbose=verbose) 5332 5346 5333 if verbose: print 'Converting quantities'5347 if verbose: log.critical('Converting quantities') 5334 5348 5335 5349 # Read in a time slice from each mux file and write it to the SWW file … … 5567 5581 5568 5582 if not isinstance(basename_in, ListType): 5569 if verbose: print 'Reading single source'5583 if verbose: log.critical('Reading single source') 5570 5584 basename_in = [basename_in] 5571 5585 … … 5593 5607 assert len(weights) == numSrc, msg 5594 5608 5595 if verbose: print 'Weights used in urs2sts:', weights5609 if verbose: log.critical('Weights used in urs2sts: %s' % str(weights)) 5596 5610 5597 5611 # Check output filename … … 5622 5636 # Establish permutation array 5623 5637 if ordering_filename is not None: 5624 if verbose is True: print 'Reading ordering file', ordering_filename 5638 if verbose is True: log.critical('Reading ordering file %s' 5639 % ordering_filename) 5625 5640 5626 5641 # Read ordering file … … 5651 5666 5652 5667 # Read MUX2 files 5653 if (verbose): print 'reading mux2 file'5668 if (verbose): log.critical('reading mux2 file') 5654 5669 5655 5670 mux={} … … 5770 5785 ymomentum = outfile.variables['ymomentum'] 5771 5786 5772 if verbose: print 'Converting quantities'5787 if verbose: log.critical('Converting quantities') 5773 5788 5774 5789 for j in range(len(times)): … … 5781 5796 msg = 'Setting nodata value %d to 0 at time = %f, ' \ 5782 5797 'point = %d' % (ha, times[j], i) 5783 print msg5798 log.critical(msg) 5784 5799 ha = 0.0 5785 5800 ua = 0.0 … … 5981 5996 5982 5997 if verbose: 5983 print '------------------------------------------------'5984 print 'Statistics:'5985 print ' t in [%f, %f], len(t) == %d' \5986 % (num.min(times), num.max(times), len(times.flat))5998 log.critical('------------------------------------------------') 5999 log.critical('Statistics:') 6000 log.critical(' t in [%f, %f], len(t) == %d' 6001 % (num.min(times), num.max(times), len(times.flat))) 5987 6002 5988 6003 ## … … 6063 6078 6064 6079 if verbose: 6065 print '------------------------------------------------'6066 print 'More Statistics:'6067 print ' Extent (/lon):'6068 print ' x in [%f, %f], len(lat) == %d' \6069 % (min(x), max(x), len(x))6070 print ' y in [%f, %f], len(lon) == %d' \6071 % (min(y), max(y), len(y))6072 print ' z in [%f, %f], len(z) == %d' \6073 % (min(elevation), max(elevation), len(elevation))6074 print 'geo_ref: ',geo_ref6075 print '------------------------------------------------'6080 log.critical('------------------------------------------------') 6081 log.critical('More Statistics:') 6082 log.critical(' Extent (/lon):') 6083 log.critical(' x in [%f, %f], len(lat) == %d' 6084 % (min(x), max(x), len(x))) 6085 log.critical(' y in [%f, %f], len(lon) == %d' 6086 % (min(y), max(y), len(y))) 6087 log.critical(' z in [%f, %f], len(z) == %d' 6088 % (min(elevation), max(elevation), len(elevation))) 6089 log.critical('geo_ref: %s' % str(geo_ref)) 6090 log.critical('------------------------------------------------') 6076 6091 6077 6092 #z = resize(bath_grid, outfile.variables['z'][:].shape) … … 6158 6173 # @param outfile UNUSED. 6159 6174 def verbose_quantities(self, outfile): 6160 print '------------------------------------------------'6161 print 'More Statistics:'6175 log.critical('------------------------------------------------') 6176 log.critical('More Statistics:') 6162 6177 for q in Write_sww.sww_quantities: 6163 print ' %s in [%f, %f]' % (q,6164 6165 outfile.variables[q+Write_sww.RANGE][1])6166 print '------------------------------------------------'6178 log.critical(' %s in [%f, %f]' 6179 % (q, outfile.variables[q+Write_sww.RANGE][0], 6180 outfile.variables[q+Write_sww.RANGE][1])) 6181 log.critical('------------------------------------------------') 6167 6182 6168 6183 … … 6188 6203 j = 0 6189 6204 for ha, ua, va in map(None, has, uas, vas): 6190 if verbose and j % ((n+10)/10) == 0: print ' Doing %d of %d' % (j, n) 6205 if verbose and j % ((n+10)/10) == 0: log.critical(' Doing %d of %d' 6206 % (j, n)) 6191 6207 w = zscale*ha + mean_stage 6192 6208 stage[j] = w … … 6371 6387 6372 6388 if verbose: 6373 print '------------------------------------------------'6374 print 'Statistics:'6375 print ' t in [%f, %f], len(t) == %d' \6376 % (num.min(times), num.max(times), len(times.flat))6389 log.critical('------------------------------------------------') 6390 log.critical('Statistics:') 6391 log.critical(' t in [%f, %f], len(t) == %d' 6392 % (num.min(times), num.max(times), len(times.flat))) 6377 6393 6378 6394 ## … … 6445 6461 6446 6462 if verbose: 6447 print '------------------------------------------------'6448 print 'More Statistics:'6449 print ' Extent (/lon):'6450 print ' x in [%f, %f], len(lat) == %d' \6451 % (min(x), max(x), len(x))6452 print ' y in [%f, %f], len(lon) == %d' \6453 % (min(y), max(y), len(y))6454 print ' z in [%f, %f], len(z) == %d' \6455 % (min(elevation), max(elevation), len(elevation))6456 print 'geo_ref: ',geo_ref6457 print '------------------------------------------------'6463 log.critical('------------------------------------------------') 6464 log.critical('More Statistics:') 6465 log.critical(' Extent (/lon):') 6466 log.critical(' x in [%f, %f], len(lat) == %d' 6467 % (min(x), max(x), len(x))) 6468 log.critical(' y in [%f, %f], len(lon) == %d' 6469 % (min(y), max(y), len(y))) 6470 log.critical(' z in [%f, %f], len(z) == %d' 6471 % (min(elevation), max(elevation), len(elevation))) 6472 log.critical('geo_ref: %s' % str(geo_ref)) 6473 log.critical('------------------------------------------------') 6458 6474 6459 6475 #z = resize(bath_grid,outfile.variables['z'][:].shape) … … 6644 6660 6645 6661 if access(dir_name, W_OK) == 0: 6646 if verbose: print 'Making directory %s' % dir_name6662 if verbose: log.critical('Making directory %s' % dir_name) 6647 6663 mkdir (dir_name,0777) 6648 6664 … … 6659 6675 (myid, numprocs, extra_info)) 6660 6676 6661 if verbose: print 'Starting ScreenCatcher, ' \6662 'all output will be stored in %s' % screen_output_name6677 if verbose: log.critical('Starting ScreenCatcher, all output will be ' 6678 'stored in %s' % screen_output_name) 6663 6679 6664 6680 # used to catch screen output to file … … 6680 6696 self.filename = filename 6681 6697 if exists(self.filename)is True: 6682 print 'Old existing file "%s" has been deleted' % self.filename 6698 log.critical('Old existing file "%s" has been deleted' 6699 % self.filename) 6683 6700 remove(self.filename) 6684 6701 … … 6716 6733 shutil.copy(f, dir_name) 6717 6734 if verbose: 6718 print 'File %s copied' % (f)6735 log.critical('File %s copied' % f) 6719 6736 else: 6720 6737 shutil.copy(file, dir_name) 6721 6738 if verbose: 6722 print 'File %s copied' % (file)6739 log.critical('File %s copied' % file) 6723 6740 6724 6741 # check we have a destination directory, create if necessary 6725 6742 if access(dir_name, F_OK) == 0: 6726 6743 if verbose: 6727 print 'Make directory %s' % dir_name6744 log.critical('Make directory %s' % dir_name) 6728 6745 mkdir(dir_name, 0777) 6729 6746 … … 6847 6864 file_header = fid.readline() 6848 6865 fid.close() 6849 if verbose: print 'read file header %s' % file_header6866 if verbose: log.critical('read file header %s' % file_header) 6850 6867 except: 6851 6868 msg = 'try to create new file: %s' % file 6852 if verbose: print msg6869 if verbose: log.critical(msg) 6853 6870 #tries to open file, maybe directory is bad 6854 6871 try: … … 6877 6894 6878 6895 if verbose: 6879 print 'file', file_header.strip('\n')6880 print 'head', header.strip('\n')6896 log.critical('file %s', file_header.strip('\n')) 6897 log.critical('head %s', header.strip('\n')) 6881 6898 if file_header.strip('\n') == str(header): 6882 print 'they equal'6899 log.critical('they equal') 6883 6900 6884 6901 msg = 'WARNING: File header does not match input info, ' \ 6885 6902 'the input variables have changed, suggest you change file name' 6886 print msg6903 log.critical(msg) 6887 6904 6888 6905 ################################################################################ … … 6924 6941 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 6925 6942 6926 if verbose: print 'Reading from ', filename6943 if verbose: log.critical('Reading from %s' % filename) 6927 6944 6928 6945 fid = NetCDFFile(filename, netcdf_mode_r) # Open existing file for read … … 6949 6966 geo_reference = None 6950 6967 6951 if verbose: print ' building mesh from sww file %s' %filename6968 if verbose: log.critical(' building mesh from sww file %s' % filename) 6952 6969 6953 6970 boundary = None … … 7025 7042 # Interpolate 7026 7043 if verbose: 7027 print 'Interpolating - total number of interpolation points = %d' \7028 % len(interpolation_points)7044 log.critical('Interpolating - total number of interpolation points = %d' 7045 % len(interpolation_points)) 7029 7046 7030 7047 I = Interpolation_function(time, … … 7084 7101 interpolation_points = interpolation_function.interpolation_points 7085 7102 7086 if verbose: print 'Computing hydrograph'7103 if verbose: log.critical('Computing hydrograph') 7087 7104 7088 7105 # Compute hydrograph … … 7164 7181 interpolation_points = interpolation_function.interpolation_points 7165 7182 7166 if verbose: print 'Computing %s energy' % kind7183 if verbose: log.critical('Computing %s energy' % kind) 7167 7184 7168 7185 # Compute total length of polyline for use with weighted averages … … 7330 7347 7331 7348 # Read sww file 7332 if verbose: print 'Reading from %s' % filename7349 if verbose: log.critical('Reading from %s' % filename) 7333 7350 # FIXME: Use general swwstats (when done) 7334 7351 … … 7340 7357 filename = join(dir, swwfile+'.sww') 7341 7358 7342 if verbose: print 'Reading from %s' % filename7359 if verbose: log.critical('Reading from %s' % filename) 7343 7360 # FIXME: Use general swwstats (when done) 7344 7361 … … 7503 7520 raise IOError, msg 7504 7521 7505 if verbose: print 'iterate over %s' % iterate_over7522 if verbose: log.critical('iterate over %s' % iterate_over) 7506 7523 7507 7524 return iterate_over … … 7551 7568 raise IOError, msg 7552 7569 7553 if verbose: print 'iterate over %s' %(iterate_over)7570 if verbose: log.critical('iterate over %s' % iterate_over) 7554 7571 7555 7572 return iterate_over … … 7584 7601 raise IOError, msg 7585 7602 7586 if verbose: print 'iterate over %s' % iterate_over7603 if verbose: log.critical('iterate over %s' % iterate_over) 7587 7604 7588 7605 return iterate_over -
anuga_core/source/anuga/shallow_water/most2nc.py
r6086 r7317 10 10 from Scientific.IO.NetCDF import NetCDFFile 11 11 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 12 import anuga.utilities.log as log 12 13 13 14 … … 33 34 in_file = open(input_file,'r') 34 35 35 if verbose: print 'reading header'36 if verbose: log.critical('reading header') 36 37 37 38 nx_ny_str = in_file.readline() … … 49 50 h2_list.reverse() 50 51 51 if verbose: print 'reading depths'52 if verbose: log.critical('reading depths') 52 53 53 54 in_depth_list = in_file.readlines() … … 56 57 out_depth_list = [[]] 57 58 58 if verbose: print 'processing depths'59 if verbose: log.critical('processing depths') 59 60 60 61 k=1 … … 74 75 75 76 # write the NetCDF file 76 if verbose: print 'writing results'77 if verbose: log.critical('writing results') 77 78 78 79 out_file = NetCDFFile(output_file, netcdf_mode_w) -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r7312 r7317 118 118 from anuga.utilities.polygon import inside_polygon, polygon_area, \ 119 119 is_inside_polygon 120 import anuga.utilities.log as log 120 121 121 122 from types import IntType, FloatType … … 453 454 454 455 # Compute flow 455 if verbose: print 'Computing flow through specified cross section' 456 if verbose: 457 log.critical('Computing flow through specified cross section') 456 458 457 459 # Get interpolated values … … 526 528 527 529 # Compute energy 528 if verbose: print 'Computing %s energy' %kind530 if verbose: log.critical('Computing %s energy' % kind) 529 531 530 532 # Get interpolated values … … 904 906 depth = stage-elevation 905 907 906 #print 'z', elevation907 #print 'w', stage908 #print 'h', depth909 908 return num.sum(depth*area) 910 909 … … 1328 1327 msg += 'transmissive_momentum_set_stage boundary object.\n' 1329 1328 msg += 'I will continue, reusing the object from t==0' 1330 print msg1329 log.critical(msg) 1331 1330 t -= self.function.time[-1] 1332 1331 … … 1838 1837 # check sanity of result 1839 1838 if (depth_dependent_friction < 0.010 or depth_dependent_friction > 9999.0) : 1840 print model_data.basename+' >>>> WARNING: computed depth_dependent friction out of range ddf,n1,n2 ', depth_dependent_friction, n1,n2 1839 log.critical('%s >>>> WARNING: computed depth_dependent friction ' 1840 'out of range, ddf%f, n1=%f, n2=%f' 1841 % (model_data.basename, 1842 depth_dependent_friction, n1, n2)) 1841 1843 1842 1844 # update depth dependent friction for that wet element … … 1850 1852 n_max=max(nvals) 1851 1853 1852 print " ++++ calculate_depth_dependent_friction - Updated friction - range %7.3f to %7.3f" %(n_min,n_max) 1854 log.critical(' ++++ calculate_depth_dependent_friction - ' 1855 'Updated friction - range %7.3f to %7.3f' 1856 % (n_min, n_max)) 1853 1857 1854 1858 return wet_friction … … 2287 2291 # Now rate is a number 2288 2292 if self.verbose is True: 2289 print 'Rate of %s at time = %.2f = %f' % (self.quantity_name, 2290 domain.get_time(), 2291 rate) 2293 log.critical('Rate of %s at time = %.2f = %f' 2294 % (self.quantity_name, domain.get_time(), rate)) 2292 2295 2293 2296 if self.exchange_indices is None: … … 2572 2575 msg = ('WARNING: psyco (speedup) could not be imported, ' 2573 2576 'you may want to consider installing it') 2574 print msg2577 log.critical(msg) 2575 2578 else: 2576 2579 psyco.bind(Domain.distribute_to_vertices_and_edges) -
anuga_core/source/anuga/shallow_water/smf.py
r7276 r7317