Changeset 7317


Ignore:
Timestamp:
Jul 22, 2009, 9:22:11 AM (14 years ago)
Author:
rwilson
Message:

Replaced 'print' statements with log.critical() calls.

Location:
anuga_core/source/anuga
Files:
47 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r7276 r7317  
    3232from anuga.abstract_2d_finite_volumes.util import get_textual_float
    3333from quantity import Quantity
     34import anuga.utilities.log as log
    3435
    3536import numpy as num
     
    144145        self.geo_reference = self.mesh.geo_reference
    145146
    146         if verbose: print 'Initialising Domain'
     147        if verbose: log.critical('Initialising Domain')
    147148
    148149        # List of quantity names entering the conservation equations
     
    186187
    187188        # 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)')
    189191        self.nsys = len(self.conserved_quantities)
    190192        for key in self.full_send_dict:
     
    212214        if not num.allclose(self.tri_full_flag[:self.number_of_full_nodes], 1):
    213215            if self.numproc>1:
    214                 print ('WARNING: '
    215                        'Not all full triangles are store before ghost triangles')
     216                log.critical('WARNING: Not all full triangles are store before '
     217                             'ghost triangles')
    216218
    217219        # Defaults
     
    275277            # If the mesh file passed any quantity values,
    276278            # initialise with these values.
    277             if verbose: print 'Domain: Initialising quantity values'
     279            if verbose: log.critical('Domain: Initialising quantity values')
    278280            self.set_quantity_vertices_dict(vertex_quantity_dict)
    279281
    280         if verbose: print 'Domain: Done'
     282        if verbose: log.critical('Domain: Done')
    281283
    282284    ######
     
    831833    # @param track_speeds If True, print smallest track speed.
    832834    def write_time(self, track_speeds=False):
    833         print self.timestepping_statistics(track_speeds)
     835        log.critical(self.timestepping_statistics(track_speeds))
    834836
    835837    ##
     
    981983    # @param tags A name or list of names of tags to report.
    982984    def write_boundary_statistics(self, quantities=None, tags=None):
    983         print self.boundary_statistics(quantities, tags)
     985        log.critical(self.boundary_statistics(quantities, tags))
    984986
    985987    # @brief Get a string containing boundary forcing stats at each timestep.
     
    16131615        for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects):
    16141616            if B is None:
    1615                 print 'WARNING: Ignored boundary segment (None)'
     1617                log.critical('WARNING: Ignored boundary segment (None)')
    16161618            else:
    16171619                q = B.evaluate(vol_id, edge_id)
     
    16521654                hist[4] == hist[5] == hist[6] == hist[7] == hist[8] == 0:
    16531655                    # Danger of isolated degenerate triangles
    1654                     # print self.timestepping_statistics(track_speeds=True)
    16551656
    16561657                    # Find triangles in last bin
     
    16651666                                         self.max_speed[i])
    16661667
    1667                             # print 'Found offending triangle', i,
    1668                             # self.max_speed[i]
    16691668                            self.get_quantity('xmomentum').\
    16701669                                            set_values(0.0, indices=[i])
     
    16951694                    msg += 'even after %d steps of 1 order scheme' \
    16961695                               % self.max_smallsteps
    1697                     print msg
     1696                    log.critical(msg)
    16981697                    timestep = min_timestep  # Try enforcing min_step
    16991698
    1700                     print self.timestepping_statistics(track_speeds=True)
     1699                    log.critical(self.timestepping_statistics(track_speeds=True))
    17011700
    17021701                    raise Exception, msg
     
    18301829            # Psyco isn't supported on 64 bit systems, but it doesn't matter
    18311830        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')
    18351833    else:
    18361834        psyco.bind(Domain.update_boundary)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/ermapper_grids.py

    r7276 r7317  
    11#!/usr/bin/env python
    22
    3 # from os import open, write, read
    43import numpy as num
    54
     
    134133    # Write the registration coordinate information
    135134    fid.write('\t\tRegistrationCoord Begin\n')
    136     ###print X_Class
    137135    fid.write('\t\t\t' + X_Class + '\t\t\t = ' + header[X_Class.lower()] + '\n')
    138136    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  
    33
    44from anuga.coordinate_transforms.geo_reference import Geo_reference
     5import anuga.utilities.log as log
    56
    67class General_mesh:
     
    8990        """
    9091
    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')
    9294
    9395        self.triangles = num.array(triangles, num.int)
     
    147149        # Initialise each triangle
    148150        if verbose:
    149             print 'General_mesh: Computing areas, normals and edgelengths'
     151            log.critical('General_mesh: Computing areas, normals '
     152                         'and edgelengths')
    150153
    151154        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))
    153156
    154157            x0, y0 = V[3*i, :]
     
    195198
    196199        # 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')
    198201        self.build_inverted_triangle_structure()
    199202
  • anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r7276 r7317  
    77from anuga.fit_interpolate.interpolate import Modeltime_too_late
    88from anuga.fit_interpolate.interpolate import Modeltime_too_early
     9import anuga.utilities.log as log
    910
    1011import numpy as num
     
    176177                            %str(self.default_boundary)
    177178                        msg += 'Note: Further warnings will be supressed'
    178                         print msg
     179                        log.critical(msg)
    179180               
    180181                    # FIXME (Ole): Replace this crude flag with
     
    240241        # any tagged boundary later on.
    241242
    242         if verbose: print 'Find midpoint coordinates of entire boundary'
     243        if verbose: log.critical('Find midpoint coordinates of entire boundary')
    243244        self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float)
    244245        boundary_keys = domain.boundary.keys()
     
    275276            self.boundary_indices[(vol_id, edge_id)] = i
    276277
    277         if verbose: print 'Initialise file_function'
     278        if verbose: log.critical('Initialise file_function')
    278279        self.F = file_function(filename,
    279280                               domain,
     
    315316            msg += 'outside aren\'t used on the actual boundary segment.'
    316317            if verbose is True:           
    317                 print msg
     318                log.critical(msg)
    318319            #raise Exception(msg)
    319320
     
    365366                                %str(self.default_boundary)
    366367                            msg += 'Note: Further warnings will be supressed'
    367                             print msg
     368                            log.critical(msg)
    368369                   
    369370                        # FIXME (Ole): Replace this crude flag with
     
    441442        # any tagged boundary later on.
    442443
    443         if verbose: print 'Find midpoint coordinates of entire boundary'
     444        if verbose: log.critical('Find midpoint coordinates of entire boundary')
    444445        self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float)
    445446        boundary_keys = domain.boundary.keys()
     
    475476
    476477
    477         if verbose: print 'Initialise file_function'
     478        if verbose: log.critical('Initialise file_function')
    478479        self.F = file_function(filename, domain,
    479480                                   interpolation_points=self.midpoint_coordinates,
     
    501502            msg += 'outside aren\'t used on the actual boundary segment.'
    502503            if verbose is True:           
    503                 print msg
     504                log.critical(msg)
    504505            #raise Exception(msg)
    505506
  • anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory.py

    r7276 r7317  
    33"""
    44
     5import anuga.utilities.log as log
    56import numpy as num
    67
     
    585586            offending +=1
    586587
    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)))
    588590    return points, triangles, values
    589591
  • anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r7276 r7317  
    1010from general_mesh import General_mesh
    1111from anuga.caching import cache
     12import anuga.utilities.log as log
     13
    1214from math import pi, sqrt
    1315
     
    9193                              verbose=verbose)
    9294
    93         if verbose: print 'Initialising mesh'
     95        if verbose: log.critical('Initialising mesh')
    9496
    9597        N = len(self) #Number_of_triangles
     
    111113
    112114        #Initialise each triangle
    113         if verbose: print 'Mesh: Computing centroids and radii'
     115        if verbose: log.critical('Mesh: Computing centroids and radii')
    114116        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))
    116118
    117119            x0, y0 = V[3*i, :]
     
    166168
    167169        #Build neighbour structure
    168         if verbose: print 'Mesh: Building neigbour structure'
     170        if verbose: log.critical('Mesh: Building neigbour structure')
    169171        self.build_neighbour_structure()
    170172
    171173        #Build surrogate neighbour structure
    172         if verbose: print 'Mesh: Building surrogate neigbour structure'
     174        if verbose: log.critical('Mesh: Building surrogate neigbour structure')
    173175        self.build_surrogate_neighbour_structure()
    174176
    175177        #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')
    177179        self.build_boundary_dictionary(boundary)
    178180
    179181        #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')
    181183        self.build_tagged_elements_dictionary(tagged_elements)
    182184
     
    194196
    195197        #FIXME check integrity?
    196         if verbose: print 'Mesh: Done'
     198        if verbose: log.critical('Mesh: Done')
    197199
    198200    def __repr__(self):
     
    365367
    366368                            #FIXME: Print only as per verbosity
    367                             #print msg
    368369
    369370                            #FIXME: Make this situation an error in the future
     
    398399                msg = 'Not all elements exist. '
    399400                assert max(tagged_elements[tag]) < len(self), msg
    400         #print "tagged_elements", tagged_elements
    401401        self.tagged_elements = tagged_elements
    402402
     
    438438            #FIXME: One would detect internal boundaries as follows
    439439            #if self.neighbours[id, edge] > -1:
    440             #    print 'Internal boundary'
     440            #    log.critical('Internal boundary')
    441441
    442442            self.neighbours[id, edge] = index
     
    536536
    537537                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))
    540540
    541541                # Check that previous are not in candidate list
     
    566566                        # Give preference to angles on the right hand side
    567567                        # of v_prev
    568                         # print 'pc = %s, changing angle from %f to %f'\
    569                         # %(pc, ac*180/pi, (ac-2*pi)*180/pi)
    570568                        ac = ac-2*pi
    571569
     
    577575
    578576                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))
    581579            else:
    582580                p1 = candidate_list[0]
     
    587585                    # If it is the initial point, the polygon is complete.
    588586                    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))
    591590
    592591                    # We have completed the boundary polygon - yeehaa
     
    870869
    871870        polygon = self.get_boundary_polygon()
    872         #print polygon, point
    873871
    874872        if is_outside_polygon(point, polygon):
     
    882880        for i, triangle in enumerate(self.triangles):
    883881            poly = V[3*i:3*i+3]
    884             #print i, poly
    885882
    886883            if is_inside_polygon(point, poly, closed=True):
     
    10681065
    10691066            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)))
    10711070
    10721071            if status == 1:
     
    11901189        point1 = polyline[i+1]
    11911190        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]))
    11951194
    11961195        line = [point0, point1]
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r7276 r7317  
    2424from anuga.config import epsilon
    2525from anuga.caching import cache
     26import anuga.utilities.log as log
    2627
    2728import anuga.utilities.numerical_tools as aunt
     
    234235
    235236        if beta < 0.0:
    236             print 'WARNING: setting beta < 0.0'
     237            log.critical('WARNING: setting beta < 0.0')
    237238        if beta > 2.0:
    238             print 'WARNING: setting beta > 2.0'
     239            log.critical('WARNING: setting beta > 2.0')
    239240
    240241        self.beta = beta
     
    737738            y = V[:,1]
    738739            if use_cache is True:
    739                 #print 'Caching function'
    740740                values = cache(f, (x, y), verbose=verbose)               
    741741            else:
    742742                if verbose is True:
    743                     print 'Evaluating function in set_values'
     743                    log.critical('Evaluating function in set_values')
    744744                values = f(x, y)
    745745
     
    914914        # Call underlying method using array values
    915915        if verbose:
    916             print 'Applying fitted data to domain'
     916            log.critical('Applying fitted data to domain')
    917917        self.set_values_from_array(vertex_attributes, location,
    918918                                   indices, use_cache=use_cache,
     
    11671167
    11681168        if verbose is True:
    1169             print 'Getting values from %s' % location
     1169            log.critical('Getting values from %s' % location)
    11701170
    11711171        if interpolation_points is not None:
  • anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py

    r6145 r7317  
    1616     Transmissive_boundary, Time_boundary
    1717from anuga.shallow_water.shallow_water_domain import Weir_simple as Weir
     18import anuga.utilities.log as log
    1819
    1920from mesh_factory import rectangular
     
    2627N = 12
    2728
    28 print 'Creating domain'
     29log.critical('Creating domain')
    2930#Create basic mesh
    3031points, vertices, boundary = rectangular(N, N/2, len1=1.2,len2=0.6,
    3132                                         origin=(-0.07, 0))
    3233
    33 print 'Number of elements', len(vertices)
     34log.critical('Number of elements=%d' % len(vertices))
    3435#Create shallow water domain
    3536domain = Domain(points, vertices, boundary)
     
    4546Z = Weir(inflow_stage)
    4647
    47 print 'Field values'
     48log.critical('Field values')
    4849domain.set_quantity('elevation', Z)
    4950domain.set_quantity('friction', manning)
     
    5354# Boundary conditions
    5455#
    55 print 'Boundaries'
     56log.critical('Boundaries')
    5657Br = Reflective_boundary(domain)
    5758Bt = Transmissive_boundary(domain)
     
    7475#Initial condition
    7576#
    76 print 'Initial condition'
     77log.critical('Initial condition')
    7778domain.set_quantity('stage', Z)
    7879
     
    8283    domain.write_boundary_statistics(['stage'],'left')
    8384
    84 print 'Done'   
     85log.critical('Done')
    8586   
    8687
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py

    r7276 r7317  
    1717def set_bottom_friction(tag, elements, domain):
    1818    if tag == "bottom":
    19         #print 'bottom - indices',elements
    2019        domain.set_quantity('friction', 0.09, indices = elements)
    2120
    2221def set_top_friction(tag, elements, domain):
    2322    if tag == "top":
    24         #print 'top - indices',elements
    2523        domain.set_quantity('friction', 1., indices = elements)
    2624
     
    347345        A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], num.float)
    348346        B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], num.float)
    349        
    350         #print A
    351         #print B
    352         #print A+B
    353347       
    354348        # Shorthands
     
    721715
    722716        domain.set_region([set_bottom_friction, set_top_friction])
    723         #print domain.quantities['friction'].get_values()
    724717        assert num.allclose(domain.quantities['friction'].get_values(),\
    725718                            [[ 0.09,  0.09,  0.09],
     
    731724
    732725        domain.set_region([set_all_friction])
    733         #print domain.quantities['friction'].get_values()
    734726        assert num.allclose(domain.quantities['friction'].get_values(),
    735727                            [[ 10.09, 10.09, 10.09],
     
    765757        domain.set_region('bottom', 'friction', 0.09)
    766758       
    767         #print domain.quantities['friction'].get_values()
    768759        msg = ("domain.quantities['friction'].get_values()=\n%s\n"
    769760               'should equal\n'
     
    784775       
    785776        domain.set_region([set_bottom_friction, set_top_friction])
    786         #print domain.quantities['friction'].get_values()
    787777        assert num.allclose(domain.quantities['friction'].get_values(),
    788778                            [[ 0.09,  0.09,  0.09],
     
    794784
    795785        domain.set_region([set_all_friction])
    796         #print domain.quantities['friction'].get_values()
    797786        assert num.allclose(domain.quantities['friction'].get_values(),
    798787                            [[ 10.09, 10.09, 10.09],
     
    815804        assert num.allclose(full_send_dict[0][0] , [ 4,  5,  6,  7, 20, 21, 22, 23])
    816805
    817         #print 'HERE'
    818        
    819806        conserved_quantities = ['quant1', 'quant2']
    820807        domain = Domain(points, vertices, boundary, conserved_quantities,
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r7282 r7317  
    2626
    2727from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     28import anuga.utilities.log as log
    2829
    2930import numpy as num
     
    114115            msg = 'Quantities specified in file_function are None,'
    115116            msg += ' so I will use stage, xmomentum, and ymomentum in that order'
    116             print msg
     117            log.critical(msg)
    117118        quantities = ['stage', 'xmomentum', 'ymomentum']
    118119
     
    171172            msg += ' Modifying domain starttime accordingly.'
    172173           
    173             if verbose: print msg
     174            if verbose: log.critical(msg)
    174175
    175176            domain.set_starttime(starttime) #Modifying model time
    176177
    177             if verbose: print 'Domain starttime is now set to %f'\
    178                %domain.starttime
     178            if verbose: log.critical('Domain starttime is now set to %f'
     179                                     % domain.starttime)
    179180    return f
    180181
     
    277278
    278279    # Open NetCDF file
    279     if verbose: print 'Reading', filename
     280    if verbose: log.critical('Reading %s' % filename)
    280281
    281282    fid = NetCDFFile(filename, netcdf_mode_r)
     
    338339
    339340    # Get variables
    340     # if verbose: print 'Get variables'   
     341    # if verbose: log.critical('Get variables'    )
    341342    time = fid.variables['time'][:]   
    342343    # FIXME(Ole): Is time monotoneous?
     
    348349   
    349350    if time_limit is not None:
    350         #if verbose is True:
    351         #    print '****** Time limit', time_limit
    352         #    print '****** Start time', starttime
    353         #    print '****** Time in ', time[0], time[-1]
    354        
    355351        # Adjust given time limit to given start time
    356352        time_limit = time_limit - starttime
     
    367363
    368364        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))
    371367
    372368    time = time[:upper_time_index]
     
    438434            gauge_neighbour_id=None
    439435
    440         #print gauge_neighbour_id
    441        
    442436        if interpolation_points is not None:
    443437            # Adjust for georef
     
    460454       
    461455    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:')
    465458        if spatial:
    466             print '    Lower left corner: [%f, %f]'\
    467                   %(xllcorner, yllcorner)
    468         print '    Start time:   %f' %starttime               
     459            log.critical('    Lower left corner: [%f, %f]'
     460                         % (xllcorner, yllcorner))
     461        log.critical('    Start time:   %f' % starttime)
    469462       
    470463   
     
    490483
    491484    if verbose:
    492         print 'Calling interpolation function'
     485        log.critical('Calling interpolation function')
    493486       
    494487    # Return Interpolation_function instance as well as
     
    674667    """Temporary Interface to new location"""
    675668
    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"')
    678672
    679673    return utilities.polygon.inside_polygon(*args, **kwargs)   
     
    684678    """Temporary Interface to new location"""
    685679
    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"')
    688683
    689684    return utilities.polygon.outside_polygon(*args, **kwargs)   
     
    694689    """Temporary Interface to new location"""
    695690
    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"')
    699694
    700695    return utilities.polygon.separate_points_by_polygon(*args, **kwargs)   
     
    705700    """Temporary Interface to new location"""
    706701
    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"')
    709705
    710706    return utilities.polygon.read_polygon(*args, **kwargs)   
     
    715711    """Temporary Interface to new location"""
    716712
    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"')
    719716
    720717    return utilities.polygon.populate_polygon(*args, **kwargs)   
     
    732729         as dm_start_screen_catcher
    733730
    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"')
    737734   
    738735    return dm_start_screen_catcher(dir_name, myid='', numprocs='',
     
    872869    msg += ' PLUS another new function to create graphs from csv files called '
    873870    msg += 'csv2timeseries_graphs in anuga.abstract_2d_finite_volumes.util'
    874     print msg
     871    log.critical(msg)
    875872   
    876873    k = _sww2timeseries(swwfiles,
     
    952949        title_on = True
    953950   
    954     if verbose: print '\n Gauges obtained from: %s \n' %gauge_filename
     951    if verbose: log.critical('Gauges obtained from: %s' % gauge_filename)
    955952
    956953    gauges, locations, elev = get_gauges_from_file(gauge_filename)
     
    973970
    974971        if verbose:
    975             print 'swwfile', swwfile
     972            log.critical('swwfile = %s' % swwfile)
    976973
    977974        # Extract parent dir name and use as label
     
    979976        _, label = os.path.split(path)       
    980977       
    981         #print 'label', label
    982978        leg_label.append(label)
    983979
     
    995991            if f(0.0, point_id = k)[2] > 1.0e6:
    996992                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])
    999995            else:
    1000996                gauge_index.append(k)
    1001997
    1002998        if len(gauge_index) > 0:
    1003             print 'Gauges contained here: \n',
     999            log.critical('Gauges contained here:')
    10041000        else:
    1005             print 'No gauges contained here. \n'
     1001            log.critical('No gauges contained here.')
    10061002        for i in range(len(gauge_index)):
    1007              print locations[gauge_index[i]]
     1003             log.critical(locations[gauge_index[i]])
    10081004             
    10091005        index = swwfile.rfind(sep)
     
    10321028
    10331029    if verbose and len(gauge_index) > 0:
    1034          print 'Inputs OK - going to generate figures'
     1030         log.critical('Inputs OK - going to generate figures')
    10351031
    10361032    if len(gauge_index) <> 0:
     
    12361232            fid = open(texfilename, 'w')
    12371233
    1238             if verbose: print '\n Latex output printed to %s \n' %texfilename
     1234            if verbose: log.critical('Latex output printed to %s' % texfilename)
    12391235        else:
    12401236            texfile = texdir+reportname
     
    12431239            fid = open(texfilename, 'w')
    12441240
    1245             if verbose: print '\n Latex output printed to %s \n' %texfilename
     1241            if verbose: log.critical('Latex output printed to %s' % texfilename)
    12461242    else:
    12471243        texfile = ''
     
    12871283    ##### loop over each swwfile #####
    12881284    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)))
    12901286
    12911287        starttime = f.starttime
     
    12971293        ##### loop over each gauge #####
    12981294        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)))
    13001296
    13011297            g = gauges[k]
     
    13811377           
    13821378        if surface is True:
    1383             print 'Printing surface figure'
     1379            log.critical('Printing surface figure')
    13841380            for i in range(2):
    13851381                fig = p1.figure(10)
     
    16961692    from anuga.shallow_water.data_manager import \
    16971693                    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"')
    17011697   
    17021698    return dm_copy_code_files(dir_name, filename1, filename2)
     
    17361732    from anuga.shallow_water.data_manager import \
    17371733                        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"')
    17411737   
    17421738    return dm_get_data_from_file(filename,separator_value = ',')
     
    17541750    from anuga.shallow_water.data_manager \
    17551751                    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"')
    17591755   
    17601756    return dm_store_parameters(verbose=False,**kwargs)
     
    18131809
    18141810        # Modify the triangles
    1815         #print "loners", loners
    1816         #print "triangles before", triangles
    18171811        triangles = num.choose(triangles,loners)
    1818         #print "triangles after", triangles
    18191812    return verts, triangles
    18201813
     
    20642057    list_filenames=[]
    20652058    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.')
    20672060   
    20682061    for i,directory in enumerate(directories_dic.keys()):
     
    20832076    min_start_time = 100000
    20842077   
    2085     if verbose: print 'Determining uniform axes'
     2078    if verbose: log.critical('Determining uniform axes')
    20862079
    20872080    #this entire loop is to determine the min and max range for the
     
    21122105            directory_add_tide = directories_dic[directory][2]
    21132106
    2114             if verbose: print 'reading: %s.csv' %dir_filename
     2107            if verbose: log.critical('reading: %s.csv' % dir_filename)
    21152108
    21162109            #add time to get values
     
    21892182
    21902183        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]))
    21992192
    22002193    cstr = ['b', 'r', 'g', 'c', 'm', 'y', 'k']
    22012194
    2202     if verbose: print 'Now start to plot \n'
     2195    if verbose: log.critical('Now start to plot')
    22032196   
    22042197    i_max = len(directories_dic.keys())
     
    22062199    legend_list = []
    22072200    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))
    22092203
    22102204        # FIXME THIS SORT IS VERY IMPORTANT
     
    22132207        list_filenames[i].sort()
    22142208        for j, filename in enumerate(list_filenames[i]):
    2215             if verbose: print 'Starting %s' % filename 
     2209            if verbose: log.critical('Starting %s' % filename)
    22162210
    22172211            directory_name = directories_dic[directory][0]
     
    22362230           
    22372231            if min_ele != max_ele:
    2238                 print "Note! Elevation changes in %s" %dir_filename
     2232                log.critical("Note! Elevation changes in %s" % dir_filename)
    22392233
    22402234            # creates a dictionary with keys that is the filename and attributes
     
    22872281                                     extra_plot_name)
    22882282
    2289                     if verbose: print 'saving figure here %s' %figname
     2283                    if verbose: log.critical('saving figure here %s' % figname)
    22902284
    22912285                    pylab.savefig(figname)
    22922286           
    2293     if verbose: print 'Closing all plots'
     2287    if verbose: log.critical('Closing all plots')
    22942288
    22952289    pylab.close('all')
    22962290    del pylab
    22972291
    2298     if verbose: print 'Finished closing plots'
     2292    if verbose: log.critical('Finished closing plots')
    22992293
    23002294##
     
    23072301    """
    23082302
    2309     if list == None: print 'List must be provided'
     2303    if list == None: log.critical('List must be provided')
    23102304       
    23112305    return min(list), max(list)
     
    23442338    easting = [float(x) for x in attribute_dic["x"]]
    23452339
    2346     print 'Reading %s' %sww_filename
     2340    log.critical('Reading %s' % sww_filename)
    23472341
    23482342    runup_locations=[]
     
    23622356       
    23632357        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))
    23652360       
    23662361        #writes to file
     
    24452440        raise msg
    24462441
    2447     if verbose: print '\n Gauges obtained from: %s \n' %gauge_file
     2442    if verbose: log.critical('Gauges obtained from: %s' % gauge_file)
    24482443   
    24492444    point_reader = reader(file(gauge_file))
     
    24772472       
    24782473    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)
    24802475    else:
    24812476        msg = 'File "%s" could not be opened: no read permission' % sww_file
     
    24852480                                 base_name=base,
    24862481                                 verbose=verbose)
    2487     #print 'sww files just after get_all_swwfiles()', sww_files
     2482
    24882483    # fudge to get SWW files in 'correct' order, oldest on the left
    24892484    sww_files.sort()
    24902485
    24912486    if verbose:
    2492         print 'sww files', sww_files
     2487        log.critical('sww files=%s' % sww_files)
    24932488   
    24942489    #to make all the quantities lower case for file_function
     
    25132508        points_writer[point_i].writerow(heading)
    25142509   
    2515     if verbose: print 'Writing csv files'
     2510    if verbose: log.critical('Writing csv files')
    25162511
    25172512    quake_offset_time = None
     
    25302525        for time in callable_sww.get_time():
    25312526            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)
    25342527                #add domain starttime to relative time.
    25352528                quake_time = time + quake_offset_time
    25362529                points_list = [quake_time, quake_time/3600.]# fudge around SWW time bug
    2537                 #print 'point list = ', str(points_list)
    25382530                point_quantities = callable_sww(time,point_i)
    2539                 #print 'point quantities = ', str(point_quantities)
    25402531               
    25412532                for quantity in quantities:
    25422533                    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)
    25442536                    else:
    25452537                        if quantity == 'stage':
  • anuga_core/source/anuga/advection/advection.py

    r7276 r7317  
    3232
    3333from anuga.abstract_2d_finite_volumes.domain import *
     34import anuga.utilities.log as log
    3435
    3536import numpy as num
     
    165166
    166167        """
    167         print "======================================"
    168         print "BEFORE compute_fluxes"
    169         print "stage_update",Stage.explicit_update
    170         print "stage_edge",Stage.edge_values
    171         print "stage_bdry",Stage.boundary_values
    172         print "neighbours",self.neighbours
    173         print "neighbour_edges",self.neighbour_edges
    174         print "normals",self.normals
    175         print "areas",self.areas
    176         print "radii",self.radii
    177         print "edgelengths",self.edgelengths
    178         print "tri_full_flag",self.tri_full_flag
    179         print "huge_timestep",huge_timestep
    180         print "max_timestep",max_timestep
    181         print "velocity",self.velocity
     168        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))
    182183        """
    183184
  • anuga_core/source/anuga/advection/test_all.py

    r4978 r7317  
    2929        if os.path.isdir(file):
    3030            sys.path.append(file)
    31             #print 'Recursing into', file
    3231            test_files += get_test_files(path + os.sep + file)
    3332        elif file[:5] == 'test_' and file[-2:] == 'py':
    34             #print 'Appending', file
    3533            test_files.append(file)
    3634        else:
  • anuga_core/source/anuga/alpha_shape/alpha_shape.py

    r7276 r7317  
    7474          points: List of coordinate pairs [[x1, y1],[x2, y2]..]
    7575        """
    76         # print "setting points"
    7776        if len (points) <= 2:
    7877            raise PointError, "Too few points to find an alpha shape"
     
    9695        Write the boundary to a file
    9796        """
    98         #print " this info will be in the file"
    9997        export_boundary_file(file_name, self.get_boundary(),
    10098                             OUTPUT_FILE_TITLE, delimiter = ',')
     
    178176        """
    179177
    180         #print "starting alpha shape algorithm"
    181 
    182178        self.alpha = alpha
    183179
     
    194190        pointattlist = [ [] for i in range(len(points)) ]
    195191        mode = "Qzcn"
    196         #print "computing delaunay triangulation ... \n"
    197192        tridata = generate_mesh(points,seglist,holelist,regionlist,
    198193                                 pointattlist,segattlist,mode)
    199         #print tridata
    200         #print "point attlist: ", tridata['generatedpointattributelist'],"\n"
    201         #print "hull segments: ", tridata['generatedsegmentlist'], "\n"
    202194        self.deltri = tridata['generatedtrianglelist']
    203195        self.deltrinbr = tridata['generatedtriangleneighborlist']
    204196        self.hulledges = tridata['generatedsegmentlist']
    205 
    206         #print "Number of delaunay triangles: ", len(self.deltri), "\n"
    207         #print "deltrinbrs: ", self.deltrinbr, "\n"
    208197
    209198        ## Build Alpha table
     
    211200        ## triangles, edges, and vertices of the delaunay triangulation
    212201        self._tri_circumradius()
    213         # print "Largest circumradius ", max(self.triradius)
    214202        self._edge_intervals()
    215203        self._vertex_intervals()
     
    221209            self.optimum_alpha = max([iv[0] for iv in self.vertexinterval \
    222210                                      if iv!=[] ])
    223             # print "optimum alpha ", self.optimum_alpha
    224211            alpha = self.optimum_alpha
    225212        self.alpha = alpha
    226213        reg_edge = self.get_regular_edges(self.alpha)
    227214        self.boundary = [self.edge[k] for k in reg_edge]
    228         #print "alpha boundary edges ", self.boundary
    229215        self._init_boundary_triangles()
    230216       
     
    258244
    259245        denom = x21*y31 - x31*y21
    260         #print "denom = ", denom
    261246
    262247        # dx/2, dy/2 give circumcenter relative to x1,y1.
     
    271256        while zeroind!=[]:
    272257            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.")
    274259            for d in zeroind:
    275260                x1[d] = x1[d]+delta*(random.random()-0.5)
     
    296281
    297282        self.triradius = 0.5*num.sqrt(dx*dx + dy*dy)
    298         #print "triangle radii", self.triradius
    299283
    300284    def _edge_intervals(self):
     
    325309                                    dy[(i+1)%3]*dy[(i+2)%3]) for i in [0,1,2]])
    326310           
    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                          
    332311            for i in [0,1,2]:
    333312                j = (i+1)%3
     
    351330        self.edgenbr = edgenbrs
    352331        self.edgeinterval = edgeinterval
    353         #print "edges: ",edges, "\n"
    354         #print "edge nbrs:", edgenbrs ,"\n"
    355         #print "edge intervals: ",edgeinterval , "\n"
    356332
    357333    def _vertex_intervals(self):
     
    381357        self.vertexnbr = vertexnbrs
    382358        self.vertexinterval = vertexinterval
    383         #print "vertex nbrs ", vertexnbrs, "\n"
    384         #print "vertex intervals ",vertexinterval, "\n"
    385359       
    386360    def get_alpha_triangles(self,alpha):
     
    450424        self.boundarytriangle = btri
    451425 
    452         #print "exterior triangles: ", extrind
    453 
    454426       
    455427    def _remove_holes(self,small):
     
    458430        The routine does this by implementing a union-find algorithm.
    459431        """
    460 
    461         #print "running _remove_holes \n"
    462432
    463433        bdry = self.boundary
     
    475445        # get a list of unique vertex labels:
    476446        verts = self._vertices_from_edges(bdry)
    477         #print "verts ", verts, "\n"
    478447
    479448        # vptr represents the union-find tree.
     
    486455        EMPTY = -max(verts)-len(verts)
    487456        vptr = [EMPTY for k in range(len(verts))]
    488         #print "vptr init: ", vptr, "\n"
    489457
    490458        #add edges and maintain union tree
    491459        for i in range(len(bdry)):
    492             #print "edge ",i,"\t",bdry[i]
    493460            vl = verts.index(bdry[i][0])
    494461            vr = verts.index(bdry[i][1])
    495462            rvl = findroot(vl)
    496463            rvr = findroot(vr)
    497             #print "roots:  ",rvl, rvr
    498464            if not(rvl==rvr):
    499465                if (vptr[vl]==EMPTY):
     
    517483                            vptr[rvr] = rvl
    518484                            vptr[vr] = rvl
    519                 #print "vptr: ", vptr, "\n"
    520485        # end edge loop
    521486
     
    523488            raise FlagError, "We didn't hit all the vertices in the boundary"
    524489       
    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"
    527490        # discard the edges in the little components
    528491        # (i.e. those components with less than 'small' fraction of bdry points)
    529492        cutoff = round(small*len(verts))
    530         # print "cutoff component size is ", cutoff, "\n"
    531493        largest_component = -min(vptr)
    532494        if cutoff > largest_component:
     
    568530        """
    569531       
    570         #print "running _smooth_indents \n"
    571 
    572532        bdry = self.boundary
    573533        bdrytri = self.boundarytriangle
     
    608568                acutetri.append(tind[0])
    609569
    610         #print "acute boundary triangles ", acutetri
    611 
    612570        # adjust the bdry edges and triangles by adding
    613571        #in the acutetri triangles
     
    624582                newbdry.append(ed)
    625583       
    626         #print "new boundary ", newbdry
    627584        return newbdry
    628585
     
    632589        Expand by adding back in associated triangles.
    633590        """
    634         #print "running _expand_pinch \n"
    635591
    636592        bdry = self.boundary
     
    643599        probv = [v[k] for k in range(len(v)) \
    644600                 if (v[k]!=v[k-1] and v.count(v[k])>2) ]
    645         #print "problem vertices: ", probv 
    646601
    647602        # find boundary triangles that have at least one vertex in probv
     
    654609                probtri.append(ind)
    655610
    656         #print "problem boundary triangle indices ", probtri
    657611
    658612        # "add in" the problem triangles
     
    669623                newbdry.append(ed)
    670624       
    671         #print "new boundary ", newbdry
    672625        return newbdry
    673626
  • anuga_core/source/anuga/caching/caching.py

    r7309 r7317  
    5151  unix = True
    5252
     53import anuga.utilities.log as log
     54
    5355import numpy as num
    5456
     
    332334            os.system('del '+fn)
    333335          if verbose is True:
    334             print 'MESSAGE (caching): File %s deleted' %fn
     336            log.critical('MESSAGE (caching): File %s deleted' % fn)
    335337        ##else:
    336         ##  print '%s was not accessed' %fn
     338        ##  log.critical('%s was not accessed' % fn)
    337339    return None
    338340
     
    468470    import zlib
    469471  except:
    470     print
    471     print '*** Could not find zlib, default to no-compression      ***'
    472     print '*** Installing zlib will improve performance of caching ***'
    473     print
     472    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()
    474476    compression = 0       
    475477    set_option('compression', compression)   
    476478 
    477   print 
    478   print_header_box('Testing caching module - please stand by')
    479   print   
     479  log.critical('\nTesting caching module - please stand by\n')
    480480
    481481  # Define a test function to be cached
     
    709709      test_OK('Performance test: relative time saved = %s pct' \
    710710              %str(round((t1-t2)*100/t1,2)))
    711     #else:
    712     #  print 'WARNING: Performance a bit low - this could be specific to current platform'
    713711  else:       
    714712    test_error('Basic caching failed for new problem')
     
    742740      cachestat()
    743741    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')
    746744     
    747   print
    748745  test_OK('Caching self test completed')   
    749746     
     
    841838  #
    842839  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]))
    845842  (datafile,compressed0) = myopen(CD+FN+'_'+file_types[0],"rb",compression)
    846843  (argsfile,compressed1) = myopen(CD+FN+'_'+file_types[1],"rb",compression)
     
    848845
    849846  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())
    851848
    852849  if not (argsfile and datafile and admfile) or \
     
    890887  if dependencies and not compare(depsref, deps):
    891888    if verbose:
    892       print 'MESSAGE (caching.py): Dependencies', dependencies, \
    893             'have changed - recomputing'
     889      log.critical('Dependencies %s have changed - recomputing' % dependencies)
     890
    894891    # Don't use cached file - recompute
    895892    reason = 2
     
    899896  #
    900897  bytecode = get_bytecode(my_F)
    901 
    902   #print compare(argsref,args),   
    903   #print compare(kwargsref,kwargs),
    904   #print compare(bytecode,coderef)
    905898
    906899  # Check if arguments or bytecode have changed
     
    921914
    922915      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)
    926919  else:
    927920
     
    934927                    verbose, compression, dependencies)
    935928
    936     # DEBUGGING
    937     # if not Retrieved:
    938     #   print 'Arguments did not match'
    939     # else:
    940     #   print 'Match found !'
    941    
    942929    # The real reason is that args or bytecodes have changed.
    943930    # Not that the recursive seach has found an unused filename
     
    983970    funcname = get_funcname(my_F)
    984971    if verbose:
    985       print 'MESSAGE (caching.py): Clearing', CD+funcname+'*'
     972      log.critical('Clearing %s' % CD+funcname+'*')
    986973
    987974    file_names = os.listdir(CD)
     
    999986    if len(file_names) > 0:
    1000987      if verbose:
    1001         print 'MESSAGE (caching.py): Remove the following files:'
     988        log.critical('Remove the following files:')
    1002989        for file_name in file_names:
    1003             print file_name
     990            log.critical('     ' + file_name)
    1004991
    1005992        A = raw_input('Delete (Y/N)[N] ?')
     
    10411028    delfiles = numfiles-maxfiles+block
    10421029    if verbose:
    1043       print 'Deleting '+`delfiles`+' expired files:'
     1030      log.critical('Deleting %d expired files:' % delfiles)
    10441031      os.system('ls -lur '+CD+'* | head -' + `delfiles`)            # List them
    10451032    os.system('ls -ur '+CD+'* | head -' + `delfiles` + ' | xargs /bin/rm')
     
    10971084  if not datafile:
    10981085    if verbose:
    1099       print 'ERROR (caching): Could not open %s' %datafile.name
     1086        log.critical('ERROR: Could not open %s' % datafile.name)
    11001087    raise IOError
    11011088
    11021089  if not admfile:
    11031090    if verbose:
    1104       print 'ERROR (caching): Could not open %s' %admfile.name
     1091        log.critical('ERROR: Could not open %s' % admfile.name)
    11051092    raise IOError
    11061093
     
    12461233        #  Rs  = zlib.decompress(RsC)
    12471234        #  zlib.error: Error -5 while decompressing data
    1248         #print 'ERROR (caching): Could not decompress ', file.name
    12491235        #raise Exception
    12501236        reason = 6  # Unreadable file
     
    12661252    import sys
    12671253    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)
    12701256
    12711257    # Raise the error again for now
     
    12911277      import zlib
    12921278    except:
    1293       print
    1294       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) ***")
    12971283      raise Exception
    12981284     
     
    14401426    if (iA, iB) in ids:
    14411427        # A and B have been compared already
    1442         #print 'Found', (iA, iB), A, B
    14431428        return ids[(iA, iB)]
    14441429    else:
     
    16181603  import types
    16191604
    1620   #print 'Caching DEBUG: Dependencies are', dependencies
    16211605  d = {}
    16221606  if dependencies:
     
    16791663    # Hack to get the results anyway (works only on Unix at the moment)
    16801664    #
    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')
    16821666
    16831667    if unix:
     
    17751759      else:
    17761760        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)
    17781762    except:
    17791763      if warn is True:
    1780         print 'WARNING: Directory', CD, 'could not be created.'
     1764        log.critical('WARNING: Directory %s could not be created.' % CD)
    17811765      if unix:
    17821766        CD = '/tmp/'
     
    17841768        CD = 'C:' 
    17851769      if warn is True:
    1786         print 'Using directory %s instead' %CD
     1770        log.critical('Using directory %s instead' % CD)
    17871771
    17881772  return(CD)
     
    18231807    #    pass
    18241808  except:
    1825     print 'Warning: Stat file could not be opened'
     1809    log.critical('Warning: Stat file could not be opened')
    18261810
    18271811  try:
     
    18661850    statfile.close()
    18671851  except:
    1868     print 'Warning: Writing of stat file failed'
     1852    log.critical('Warning: Writing of stat file failed')
    18691853
    18701854# -----------------------------------------------------------------------------
     
    19331917  for FN in SF:
    19341918    input = open(SD+FN,'r')
    1935     print 'Reading file ', SD+FN
     1919    log.critical('Reading file %s' % SD+FN)
    19361920
    19371921    while True:
     
    19411925      for record in A:
    19421926        record = tuple(split(rstrip(record),','))
    1943         #print record, len(record)
    19441927
    19451928        if len(record) == 9:
     
    19731956            compression = 0
    19741957          else:
    1975             print 'Unknown value of compression', record[4]
    1976             print record
     1958            log.critical('Unknown value of compression %s' % str(record[4]))
     1959            log.critical(str(record))
    19771960            total_discarded = total_discarded + 1           
    19781961            continue
     
    20021985             
    20031986        else:
    2004           #print 'Record discarded'
    2005           #print record
    20061987          total_discarded = total_discarded + 1
    20071988
     
    20131994  if total_read == 0:
    20141995    printline(Widths,'=')
    2015     print 'CACHING STATISTICS: No valid records read'
     1996    log.critical('CACHING STATISTICS: No valid records read')
    20161997    printline(Widths,'=')
    20171998    return
    20181999
    2019   print
     2000  log.critical()
    20202001  printline(Widths,'=')
    2021   print 'CACHING STATISTICS: '+ctime(firstday)+' to '+ctime(lastday)
     2002  log.critical('CACHING STATISTICS: '+ctime(firstday)+' to '+ctime(lastday))
    20222003  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])
    20342012
    20352013  if showuser:
     
    20532031    # Write Header
    20542032    #
    2055     print
    2056     #print Dictnames[i], 'statistics:'; i=i+1
     2033    log.critical()
    20572034    printline(Widths,'-')
    20582035    n = 0
     
    20602037      if s == Fields[0]:  # Left justify
    20612038        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
    20632042      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()
    20662047    printline(Widths,'-')
    20672048
     
    20722053      n = 0
    20732054      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
    20752058      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()
    20792064
    20802065#==============================================================================
     
    21212106
    21222107    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
    21262110
    21272111    val = rec[sortidx]
     
    21492133      s = s+char
    21502134
    2151   print s
     2135  log.critical(s)
    21522136
    21532137#==============================================================================
     
    21632147
    21642148  import string
    2165   #print 'MESSAGE (caching.py): Evaluating function', funcname,
    21662149
    21672150  print_header_box('Evaluating function %s' %funcname)
     
    21722155  print_footer()
    21732156 
    2174   #
    2175   # Old message
    2176   #
    2177   #args_present = 0
    2178   #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 = 1     
    2184   #   
    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 = 1           
    2196   #else:
    2197   #  print    # Newline when no keyword args present
    2198   #       
    2199   #if not args_present:   
    2200   #  print '',  # Default if no args or kwargs present
    2201    
    2202    
    2203 
    22042157# -----------------------------------------------------------------------------
    22052158
     
    22242177  msg8(reason)
    22252178
    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')
    22272181
    22282182# -----------------------------------------------------------------------------
     
    22362190
    22372191  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)')
    22402194  msg5(CD,FN,deps,compression)
    22412195
     
    22542208 
    22552209  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')
    22602216  msg5(CD,FN,deps,compression)
    22612217
     
    22742230  import os, time, string
    22752231
    2276   print '|'
    2277   print string.ljust('| Caching dir: ', textwidth1) + CD
     2232  log.critical('|')
     2233  log.critical(string.ljust('| Caching dir: ', textwidth1) + CD)
    22782234
    22792235  if compression:
     
    22862242  for file_type in file_types:
    22872243    file_name = FN + '_' + file_type + suffix
    2288     print string.ljust('| ' + file_type + ' file: ', textwidth1) + file_name,
    22892244    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('|')
    22932249  if len(deps) > 0:
    2294     print '| Dependencies:  '
     2250    log.critical('| Dependencies:  ')
    22952251    dependencies  = deps.keys()
    22962252    dlist = []; maxd = 0
     
    23172273      s = string.rjust(slist[n], maxs)
    23182274
    2319       print '| ', d, t, ' ', s, 'bytes'
     2275      log.critical('| %s %s %s bytes' % (d, t, s))
    23202276  else:
    2321     print '| No dependencies'
     2277    log.critical('| No dependencies')
    23222278  print_footer()
    23232279
     
    23322288
    23332289  import string
    2334   print string.ljust('| Function:', textwidth1) + funcname
     2290  log.critical(string.ljust('| Function:', textwidth1) + funcname)
    23352291
    23362292  msg7(args, kwargs)
     
    23502306  if args:
    23512307    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))
    23542310    else:
    2355       print string.ljust('| Arguments:', textwidth1) + \
    2356             mkargstr(args, textwidth2)
     2311      log.critical(string.ljust('| Arguments:', textwidth1) +
     2312                   mkargstr(args, textwidth2))
    23572313    args_present = 1
    23582314           
    23592315  if kwargs:
    23602316    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))
    23632319    else:
    2364       print string.ljust('| Keyword Args:', textwidth1) + \
    2365             mkargstr(kwargs, textwidth2)
     2320      log.critical(string.ljust('| Keyword Args:', textwidth1) +
     2321                   mkargstr(kwargs, textwidth2))
    23662322    args_present = 1
    23672323
    23682324  if not args_present:               
    2369     print '| No arguments' # Default if no args or kwargs present
     2325    log.critical('| No arguments')    # Default if no args or kwargs present
    23702326
    23712327# -----------------------------------------------------------------------------
     
    23852341    R = 'Unknown' 
    23862342 
    2387   print string.ljust('| Reason:', textwidth1) + R
     2343  log.critical(string.ljust('| Reason:', textwidth1) + R)
    23882344   
    23892345# -----------------------------------------------------------------------------
     
    24062362  s = '+' + '-'*N + CR
    24072363
    2408   print s + '| ' + line + CR + s,
     2364  log.critical(s + '| ' + line + CR + s)
    24092365
    24102366  textwidth3 = N
     
    24192375  s = '+' + '-'*N + CR   
    24202376     
    2421   print s     
     2377  log.critical(s)
    24222378     
    24232379# -----------------------------------------------------------------------------
     
    25082464  import string
    25092465   
    2510   print string.ljust(msg, textwidth4) + ' - OK'
     2466  log.critical(string.ljust(msg, textwidth4) + ' - OK' )
    25112467 
    25122468  #raise StandardError
     
    25212477  """
    25222478 
    2523   print 'ERROR (caching.test): %s' %msg
    2524   print 'Please send this code example and output to '
    2525   print 'Ole.Nielsen@anu.edu.au'
    2526   print
    2527   print
     2479  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()
    25282484 
    25292485  raise StandardError
  • anuga_core/source/anuga/caching/test_caching.py

    r7309 r7317  
    5050
    5151def retrieve_cache(Dummy, verbose=False):
    52   if verbose: print 'Check that cache is there'
     52  if verbose: print('Check that cache is there')
    5353 
    5454  X = cache(Dummy, args=(9,10), test=1,
     
    386386        f2 = call(5, 7)
    387387
    388         #print myhash(f1)
    389         #print myhash(f2)     
    390 
    391388        # Check that hash value of callable objects don't change
    392389        # FIXME (Ole): The hash values do appear to change when OS
     
    411408        bc2 = get_bytecode(f2)
    412409       
    413         #print 'bc1', bc1
    414         #print 'bc2', bc2
    415        
    416410        msg = 'Byte code should be different'
    417411        assert bc1 != bc2, msg
     
    631625       
    632626        T4 = cache(f, (a,b,c,N), {'x':x, 'y':y}, test=1)
    633         #print 'T4', T4
    634627        assert T4 is None, "Option 'test' when cache absent failed"
    635628
  • anuga_core/source/anuga/coordinate_transforms/geo_reference.py

    r7276 r7317  
    1414                                             ParsingError, ShapeError
    1515from anuga.config import netcdf_float, netcdf_int, netcdf_float32
     16import anuga.utilities.log as log
    1617
    1718import numpy as num
     
    153154
    154155        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.")
    158161
    159162        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.")
    164169
    165170        if self.datum.upper() != DEFAULT_DATUM.upper():
    166             print "WARNING: Datum of %s specified." % self.datum
    167             print "Default Datum is %s." % DEFAULT_DATUM
    168             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.")
    169174
    170175        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.")
    174181
    175182        if self.units.upper() != DEFAULT_UNITS.upper():
    176             print "WARNING: Units of %s specified." % self.units
    177             print "Default units is %s." % DEFAULT_UNITS
    178             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.")
    179186
    180187################################################################################
  • anuga_core/source/anuga/coordinate_transforms/lat_long_UTM_conversion.py

    r4450 r7317  
    127127    #UTMZone was originally returned here.  I don't know what the
    128128    #letter at the end was for.
    129     #print "UTMZone", UTMZone
    130129    return (ZoneNumber, UTMEasting, UTMNorthing)
    131130
  • anuga_core/source/anuga/coordinate_transforms/redfearn.py

    r6424 r7317  
    6767    else:
    6868        K0 = scale_factor
    69     #print 'scale', K0
    7069    zone_width = 6                      #Degrees
    7170
  • anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r7276 r7317  
    121121        lofl = [[3.0,311.0], [677.0,6.0]]
    122122        new_lofl = g.change_points_geo_ref(lofl)
    123         #print "lofl",lofl
    124         #print "new_lofl",new_lofl
    125123
    126124        self.failUnless(type(new_lofl) == types.ListType, ' failed')
     
    137135        lofl = [[3.0,388.0]]
    138136        new_lofl = g.change_points_geo_ref(lofl)
    139         #print "lofl",lofl
    140         #print "new_lofl",new_lofl
    141137
    142138        self.failUnless(type(new_lofl) == types.ListType, ' failed')
     
    152148        lofl = [3.0,345.0]
    153149        new_lofl = g.change_points_geo_ref(lofl)
    154         #print "lofl",lofl
    155         #print "new_lofl",new_lofl
    156150
    157151        self.failUnless(type(new_lofl) == types.ListType, ' failed')
     
    168162        lofl = num.array([[3.0,323.0], [6.0,645.0]])
    169163        new_lofl = g.change_points_geo_ref(lofl)
    170         #print "4 lofl",lofl
    171         #print "4 new_lofl",new_lofl
    172164
    173165        self.failUnless(isinstance(new_lofl, num.ndarray), ' failed')
     
    183175        lofl = num.array([[3.0,323.0]])
    184176
    185        
    186         #print "5 lofl before",lofl         
    187177        new_lofl = g.change_points_geo_ref(lofl.copy())
    188         #print "5 lofl",lofl
    189         #print "5 new_lofl",new_lofl
    190178
    191179        self.failUnless(isinstance(new_lofl, num.ndarray), ' failed')
     
    203191        lofl = num.array([355.0,3.0])
    204192        new_lofl = g.change_points_geo_ref(lofl.copy())       
    205         #print "lofl",lofl
    206         #print "new_lofl",new_lofl
    207193
    208194        self.failUnless(isinstance(new_lofl, num.ndarray), ' failed')
     
    221207        lofl = [[3.0,30.0], [67.0,6.0]]
    222208        new_lofl = g.change_points_geo_ref(lofl,points_geo_ref=points_geo_ref)
    223         #print "lofl",lofl
    224         #print "new_lofl",new_lofl
    225209
    226210        self.failUnless(type(new_lofl) == types.ListType, ' failed')
  • anuga_core/source/anuga/coordinate_transforms/test_lat_long_UTM_conversion.py

    r7276 r7317  
    5757        lat = degminsec2decimal_degrees(-37,57,03.7203)
    5858        lon = degminsec2decimal_degrees(144,25,29.5244)
    59         #print lat, lon
    6059
    6160        zone, easting, northing = LLtoUTM(lat,lon)
     
    7776
    7877        zone, easting, northing = LLtoUTM(lat,lon)
    79         #print zone, easting, northing
    8078
    8179        assert zone == 52
     
    112110        zone, easting, northing = LLtoUTM(lat,lon)
    113111
    114         #print zone, easting, northing
    115112
    116113        assert zone == 56
  • anuga_core/source/anuga/coordinate_transforms/test_redfearn.py

    r7276 r7317  
    7171        lat = degminsec2decimal_degrees(-37,57,03.7203)
    7272        lon = degminsec2decimal_degrees(144,25,29.5244)
    73         #print lat, lon
    7473
    7574        zone, easting, northing = redfearn(lat,lon)
     
    8685
    8786        zone, easting, northing = redfearn(lat,lon)
    88         #print zone, easting, northing
    8987
    9088        assert zone == 52
     
    116114       
    117115        zone, easting, northing = redfearn(lat,lon)
    118 
    119         #print zone, easting, northing
    120116
    121117        assert zone == 56
     
    452448        points = [[lat_gong, lon_gong], [lat_2, lon_2]]
    453449        points, zone = convert_from_latlon_to_utm(points=points)
    454         #print "points",points
    455450        assert num.allclose(points[0][0], 308728.009)
    456451        assert num.allclose(points[0][1], 6180432.601)
  • anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py

    r7276 r7317  
    1111
    1212"""
     13
    1314print 'Starting.... Importing Modules...'
     15
    1416#------------------------------------------------------------------------------
    1517# Import necessary modules
  • anuga_core/source/anuga/culvert_flows/culvert_class.py

    r7276 r7317  
    1313from anuga.config import g, epsilon
    1414from anuga.config import minimum_allowed_height, velocity_protection       
     15import anuga.utilities.log as log
    1516
    1617import numpy as num
     
    287288                msg += ' does not match distance between specified'
    288289                msg += ' end points (%.2f m)' %self.length
    289                 print msg
     290                log.critical(msg)
    290291       
    291292        self.verbose = verbose
     
    441442            msg += 'Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced)
    442443            if self.verbose is True:
    443                 print msg
     444                log.critical(msg)
    444445               
    445446            if self.log_filename is not None:               
     
    506507        delta_total_energy = openings[0].total_energy - openings[1].total_energy
    507508        if delta_total_energy > 0:
    508             #print 'Flow U/S ---> D/S'
    509509            inlet = openings[0]
    510510            outlet = openings[1]
    511511        else:
    512             #print 'Flow D/S ---> U/S'
    513512            inlet = openings[1]
    514513            outlet = openings[0]
     
    530529            # Flow will be purely controlled by uphill outlet face
    531530            if self.verbose is True:
    532                 print '%.2fs - WARNING: Flow is running uphill.' % time
     531                log.critical('%.2fs - WARNING: Flow is running uphill.' % time)
    533532           
    534533        if self.log_filename is not None:
     
    789788            msg += ' does not match distance between specified'
    790789            msg += ' end points (%.2f m)' %self.length
    791             print msg
     790            log.critical(msg)
    792791       
    793792        self.verbose = verbose
     
    906905                V += d * domain.areas[i]
    907906           
    908             #Vsimple = mean(depth)*self.inlet.exchange_area # Current volume in exchange area 
    909             #print 'Q', Q, 'dt', delta_t, 'Q*dt', Q*delta_t, 'V', V, 'Vsimple', Vsimple
    910 
    911907            dt = delta_t           
    912908            if Q*dt > V:
     
    918914                msg += ' Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced)
    919915               
    920                 #print msg
    921                
    922916                if self.verbose is True:
    923                     print msg
     917                    log.critical(msg)
    924918                if hasattr(self, 'log_filename'):                   
    925919                    log_to_file(self.log_filename, msg)                                       
     
    13131307                   
    13141308                opening.total_energy = 0.5*(u*u + v*v)/g + stage
    1315                 #print 'Et = %.3f m' %opening.total_energy
    13161309
    13171310                # Store current average stage and depth with each opening object
     
    13301323
    13311324            if delta_Et > 0:
    1332                 #print 'Flow U/S ---> D/S'
    13331325                inlet = openings[0]
    13341326                outlet = openings[1]
     
    13381330
    13391331            else:
    1340                 #print 'Flow D/S ---> U/S'
    13411332                inlet = openings[1]
    13421333                outlet = openings[0]
     
    13611352                # Flow will be purely controlled by uphill outlet face
    13621353                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)))
    13641357
    13651358
  • anuga_core/source/anuga/culvert_flows/culvert_routines.py

    r7276 r7317  
    8686    if inlet_depth > 0.1: #this value was 0.01:
    8787        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))
    9092        # Water has risen above inlet
    9193       
     
    138140                flow_width= diameter
    139141                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')
    142145            else:
    143146                #alpha = acos(1 - outlet_culvert_depth/diameter)    # Where did this Come From ????/
     
    149152                case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    150153                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)))
    153159            if delta_total_energy < inlet_specific_energy:  #  OUTLET CONTROL !!!!
    154160                # Calculate flows for outlet control
     
    162168                    case = 'Outlet submerged'
    163169                    if local_debug =='true':
    164                         print 'Outlet submerged'
     170                        log.critical('Outlet submerged')
    165171                else:   # Culvert running PART FULL for PART OF ITS LENGTH   Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
    166172                    # IF  outlet_depth < diameter
     
    178184                        case = 'Outlet unsubmerged PIPE FULL'
    179185                        if local_debug =='true':
    180                             print  'Outlet unsubmerged PIPE FULL'
     186                            log.critical('Outlet unsubmerged PIPE FULL')
    181187                    else:
    182188                        alpha = acos(1-2*outlet_culvert_depth/diameter)*2
     
    185191                        perimeter = alpha*diameter/2.0
    186192                        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))
    194203            hyd_rad = flow_area/perimeter
    195204
     
    200209            # Outlet control velocity using tail water
    201210            if local_debug =='true':
    202                 print 'GOT IT ALL CALCULATING Velocity'
    203                 print 'HydRad = ',hyd_rad     
     211                log.critical('GOT IT ALL CALCULATING Velocity')
     212                log.critical('HydRad = %s' % str(hyd_rad))
    204213            culvert_velocity = sqrt(delta_total_energy/((sum_loss/2/g)+(manning**2*culvert_length)/hyd_rad**1.33333))
    205214            Q_outlet_tailwater = flow_area * culvert_velocity
    206215            if local_debug =='true':
    207                 print 'VELOCITY = ',culvert_velocity
    208                 print 'Outlet Ctrl Q = ',Q_outlet_tailwater
     216                log.critical('VELOCITY = %s' % str(culvert_velocity))
     217                log.critical('Outlet Ctrl Q = %s' % str(Q_outlet_tailwater))
    209218            if log_filename is not None:               
    210219                s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
     
    212221            Q = min(Q, Q_outlet_tailwater)
    213222            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))
    216228
    217229        else:
     
    221233
    222234        #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')
    226238            # Box culvert (rectangle or square)   ========================================================================================================================
    227239
     
    318330        culv_froude=sqrt(Q**2*flow_width/(g*flow_area**3))
    319331        if local_debug =='true':
    320             print 'FLOW AREA = ',flow_area
    321             print 'PERIMETER = ',perimeter
    322             print 'Q final = ',Q
    323             print 'FROUDE = ',culv_froude
     332            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))
    324336        if log_filename is not None:                           
    325337            s = 'Froude in Culvert = %f' % culv_froude
  • anuga_core/source/anuga/culvert_flows/test_culvert_class.py

    r7276 r7317  
    135135            if delta_w < min_delta_w: min_delta_w = delta_w           
    136136           
    137             #print domain.timestepping_statistics()
    138137            pass
    139138
     
    236235        ref_volume = domain.get_quantity('stage').get_integral()
    237236        for t in domain.evolve(yieldstep = 1, finaltime = 25):
    238             #print domain.timestepping_statistics()
    239237            new_volume = domain.get_quantity('stage').get_integral()
    240238           
     
    339337        ref_volume = domain.get_quantity('stage').get_integral()
    340338        for t in domain.evolve(yieldstep = 0.1, finaltime = 25):
    341             #print domain.timestepping_statistics()
    342339            new_volume = domain.get_quantity('stage').get_integral()
    343340           
    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))
    348343            assert num.allclose(new_volume, ref_volume), msg       
    349344       
     
    360355            ref_volume = domain.get_quantity('stage').get_integral()
    361356            for t in domain.evolve(yieldstep = 0.1, finaltime = 25):
    362                 #print domain.timestepping_statistics()
    363357                new_volume = domain.get_quantity('stage').get_integral()
    364358           
    365                 #print new_volume, ref_volume, new_volume-ref_volume
    366359                msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\
    367360                    % (new_volume, ref_volume)
     
    471464        for t in domain.evolve(yieldstep = 1, finaltime = 25):
    472465           
    473             #print domain.timestepping_statistics()
    474466            new_volume = domain.get_quantity('stage').get_integral()
    475467
     
    558550        culvert(domain)
    559551   
    560         #print 'Inlet flow', culvert.inlet.rate
    561         #print 'Outlet flow', culvert.outlet.rate       
    562        
    563    
    564552               
    565553#-------------------------------------------------------------
     554
    566555if __name__ == "__main__":
    567556    suite = unittest.makeSuite(Test_Culvert, 'test')
  • anuga_core/source/anuga/damage_modelling/inundation_damage.py

    r7276 r7317  
    3535from anuga.geospatial_data.geospatial_data import ensure_absolute
    3636from anuga.utilities.numerical_tools import NAN
     37import anuga.utilities.log as log
    3738from config import epsilon
    3839depth_epsilon = epsilon
     
    102103                                '.' + split_name[-1]
    103104        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)
    105107   
    106108def add_depth_and_momentum2csv(sww_base_name, exposure_file_in,
     
    141143    """
    142144    quantities =  ['stage', 'elevation', 'xmomentum', 'ymomentum']
    143     #print "points",points
    144145    points = ensure_absolute(points)
    145146    point_count = len(points)
     
    151152    # How many sww files are there?
    152153    dir, base = os.path.split(sww_base_name)
    153     #print "basename_in",basename_in
    154154    if base[-4:] == '.sww':
    155155        base = base[:-4]
    156     #print "base",base
    157156    if dir == "": dir = "." # Unix compatibility
    158157    dir_ls = os.listdir(dir)
     
    162161              %(sww_base_name)
    163162        raise IOError, msg
    164     #print "interate_over", interate_over
    165163    from os import sep
    166164    for this_sww_file in interate_over:
     
    323321                                                   self.shore_distances,
    324322                                                   self.walls):
    325             #print "i",i
    326             #print "max_depth",max_depth
    327             #print "shore_distance",shore_distance
    328             #print "wall",wall
    329323            ## WARNING SKIP IF DEPTH < 0.0
    330324            if 0.0 > max_depth:
     
    376370                                                   self.shore_distances,
    377371                                                   self.walls):
    378             #print "i",i
    379             #print "max_depth",max_depth
    380             #print "shore_distance",shore_distance
    381             #print "wall",wall
    382372            # WARNING ASSUMING THE FIRST BIN OF DEPTHS GIVE A ZERO PROBABILITY
    383373            depth_upper_limits = self.depth_upper_limits
     
    431421            # Warning, the collapse_probability list now lists
    432422            # houses that did not collapse, (though not all of them)
    433             #print "",self.collapse_csv_info
    434423           
    435424#############################################################################
  • anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py

    r7276 r7317  
    143143        num_of_points
    144144        '''
    145         #print "num_of_points",num_of_points
    146         #print "maxArea",maxArea
    147         #print "max_points_per_cell", max_points_per_cell
    148145        if geo_ref is True:
    149146            geo = Geo_reference(xllcorner = 2.0, yllcorner = 2.0)
     
    158155                                              verbose=verbose)
    159156
    160         #print "len(mesh_dict['triangles'])",len(mesh_dict['triangles'])
    161157        if is_fit is True:
    162158            op = "Fit_"
     
    187183        if is_fit is True:
    188184
    189             # print "Fit in Fit"
    190185            if use_file_type == None:
    191186                points = geospatial
     
    224219        else:
    225220            # run an interploate problem.
    226             #print "Interpolate!"
    227221           
    228222            if run_profile:
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r7276 r7317  
    4040from anuga.utilities.numerical_tools import ensure_numeric, gradient
    4141from anuga.config import default_smoothing_parameter as DEFAULT_ALPHA
     42import anuga.utilities.log as log
    4243
    4344import exceptions
     
    112113        self.point_count = 0
    113114        if self.alpha <> 0:
    114             if verbose: print 'Building smoothing matrix'
     115            if verbose: log.critical('Building smoothing matrix')
    115116            self._build_smoothing_matrix_D()
    116117           
     
    129130
    130131        if self.alpha <> 0:
    131             #if verbose: print 'Building smoothing matrix'
     132            #if verbose: log.critical('Building smoothing matrix')
    132133            #self._build_smoothing_matrix_D()
    133134            self.B = self.AtA + self.alpha*self.D
     
    275276        for d, i in enumerate(inside_indices):
    276277            # 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))
    278280            x = point_coordinates[i]
    279281           
     
    291293                for j in js:
    292294                    self.Atz[j] +=  sigmas[j]*z[i]
    293                     #print "self.Atz building", self.Atz
    294                     #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]
    298295                   
    299296                    for k in js:
     
    356353                    # is dependant on the # of Triangles
    357354                       
    358                     print 'Processing Block %d' %i
     355                    log.critical('Processing Block %d' % i)
    359356                    # FIXME (Ole): It would be good to say how many blocks
    360357                    # there are here. But this is no longer necessary
     
    379376                assert self.AtA is not None, msg
    380377               
    381                 #print 'Matrix was built OK'
    382 
    383                
    384378            point_coordinates = None
    385379        else:
     
    387381           
    388382        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')
    390384            msg = 'No interpolation matrix.'
    391385            assert self.AtA is not None, msg
     
    422416            msg += 'The following vertices are not part of a triangle;\n'
    423417            msg += str(loners)
    424             print msg
     418            log.critical(msg)
    425419            #raise VertsWithNoTrianglesError(msg)
    426420       
     
    591585                                             geo_reference = mesh_origin)
    592586
    593         if verbose: print 'FitInterpolate: Building mesh'       
     587        if verbose: log.critical('FitInterpolate: Building mesh')
    594588        mesh = Mesh(vertex_coordinates, triangles)
    595589        mesh.check_integrity()
     
    650644    except IOError,e:
    651645        if display_errors:
    652             print "Could not load bad file. ", e
     646            log.critical("Could not load bad file: %s" % str(e))
    653647        raise IOError  #Could not load bad mesh file.
    654648   
     
    665659        old_title_list = mesh_dict['vertex_attribute_titles']
    666660
    667     if verbose: print 'tsh file %s loaded' %mesh_file
     661    if verbose: log.critical('tsh file %s loaded' % mesh_file)
    668662
    669663    # load in the points file
     
    672666    except IOError,e:
    673667        if display_errors:
    674             print "Could not load bad file. ", e
     668            log.critical("Could not load bad file: %s" % str(e))
    675669        raise IOError  #Re-raise exception 
    676670
     
    685679        mesh_origin = None
    686680
    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")
    689683    f = fit_to_mesh(point_coordinates,
    690684                    vertex_coordinates,
     
    696690                    data_origin = None,
    697691                    mesh_origin = mesh_origin)
    698     if verbose: print "finished fitting to mesh"
     692    if verbose: log.critical("finished fitting to mesh")
    699693
    700694    # convert array to list of lists
     
    713707        mesh_dict['vertex_attribute_titles'] = title_list
    714708
    715     if verbose: print "exporting to file ", mesh_output_file
     709    if verbose: log.critical("exporting to file %s" % mesh_output_file)
    716710
    717711    try:
     
    719713    except IOError,e:
    720714        if display_errors:
    721             print "Could not write file. ", e
     715            log.critical("Could not write file %s", str(e))
    722716        raise IOError
  • anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py

    r7276 r7317  
    3434     ensure_absolute
    3535from anuga.fit_interpolate.search_functions import set_last_triangle
     36import anuga.utilities.log as log
    3637
    3738import numpy as num
     
    101102                                                 geo_reference = mesh_origin)
    102103
    103                 if verbose: print 'FitInterpolate: Building mesh'       
     104                if verbose: log.critical('FitInterpolate: Building mesh')
    104105                self.mesh = Mesh(vertex_coordinates, triangles)
    105106                #self.mesh.check_integrity() # Time consuming
     
    110111
    111112        if self.mesh is not None:
    112             if verbose: print 'FitInterpolate: Building quad tree'
     113            if verbose: log.critical('FitInterpolate: Building quad tree')
    113114            #This stores indices of vertices
    114115            t0 = time.time()
    115             #print "self.mesh.get_extent(absolute=True)", \
    116             #self.mesh.get_extent(absolute=True)
    117116            self.root = build_quadtree(self.mesh,
    118117                                       max_points_per_cell = max_vertices_per_cell)
    119             #print "self.root",self.root.show()
    120118       
    121119            build_quadtree_time =  time.time()-t0
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r7276 r7317  
    3939from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    4040from utilities.polygon import interpolate_polyline
    41 
     41import anuga.utilities.log as log
    4242
    4343import numpy as num
     
    262262        # This has now been addressed through an attempt in interpolate_block
    263263
    264         if verbose: print 'Build intepolation object'
     264        if verbose: log.critical('Build intepolation object')
    265265        if isinstance(point_coordinates, Geospatial_data):
    266266            point_coordinates = point_coordinates.get_data_points(absolute=True)
     
    274274                #     if verbose, give warning
    275275                if verbose:
    276                     print 'WARNING: Recalculating A matrix, due to blocking.'
     276                    log.critical('WARNING: Recalculating A matrix, '
     277                                 'due to blocking.')
    277278                point_coordinates = self._point_coordinates
    278279            else:
     
    445446        """
    446447
    447         if verbose: print 'Building interpolation matrix'
     448        if verbose: log.critical('Building interpolation matrix')
    448449
    449450        # Convert point_coordinates to numeric arrays, in case it was a list.
    450451        point_coordinates = ensure_numeric(point_coordinates, num.float)
    451452
    452         if verbose: print 'Getting indices inside mesh boundary'
     453        if verbose: log.critical('Getting indices inside mesh boundary')
    453454
    454455        inside_poly_indices, outside_poly_indices = \
     
    459460        # Build n x m interpolation matrix
    460461        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.')
    462463
    463464        # Since you can block, throw a warning, not an error.
    464465        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!')
    466467
    467468        m = self.mesh.number_of_nodes  # Nbr of basis functions (1/vertex)
    468469        n = point_coordinates.shape[0] # Nbr of data points
    469470
    470         if verbose: print 'Number of datapoints: %d' %n
    471         if verbose: print 'Number of basis functions: %d' %m
     471        if verbose: log.critical('Number of datapoints: %d' % n)
     472        if verbose: log.critical('Number of basis functions: %d' % m)
    472473
    473474        A = Sparse(n,m)
     
    476477
    477478        # 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)
    479481
    480482        for d, i in enumerate(inside_poly_indices):
    481483            # 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))
    483486
    484487            x = point_coordinates[i]
     
    760763
    761764        if verbose is True:
    762             print 'Interpolation_function: input checks'
     765            log.critical('Interpolation_function: input checks')
    763766
    764767        # Check temporal info
     
    794797
    795798        if verbose is True:
    796             print 'Interpolation_function: thinning by %d' % time_thinning
     799            log.critical('Interpolation_function: thinning by %d'
     800                         % time_thinning)
    797801
    798802
     
    805809
    806810        if verbose is True:
    807             print 'Interpolation_function: precomputing'
     811            log.critical('Interpolation_function: precomputing')
    808812
    809813        # Save for use with statistics
     
    886890                    # be ignored leaving good points for continued processing.
    887891                    if verbose:
    888                         print msg
     892                        log.critical(msg)
    889893                    #raise Exception(msg)
    890894
     
    919923
    920924            if verbose is True:
    921                 print 'Build interpolator'
     925                log.critical('Build interpolator')
    922926
    923927
     
    929933                           % (vertex_coordinates.shape[0],
    930934                              triangles.shape[0])
    931                     print msg
     935                    log.critical(msg)
    932936
    933937                # This one is no longer needed for STS files
     
    938942            elif triangles is None and vertex_coordinates is not None:
    939943                if verbose:
    940                     msg = 'Interpolation from STS file'
    941                     print msg
     944                    log.critical('Interpolation from STS file')
    942945
    943946
    944947
    945948            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]))
    948951
    949952                if time_thinning > 1:
    950                     print 'Timesteps were thinned by a factor of %d' \
    951                           % time_thinning
     953                    log.critical('Timesteps were thinned by a factor of %d'
     954                                 % time_thinning)
    952955                else:
    953                     print
     956                    log.critical()
    954957
    955958            for i, t in enumerate(self.time):
    956959                # Interpolate quantities at this timestep
    957960                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))
    959962
    960963                for name in quantity_names:
     
    965968
    966969                    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)))
    968971
    969972                    # Interpolate
     
    985988            # Report
    986989            if verbose:
    987                 print self.statistics()
     990                log.critical(self.statistics())
    988991        else:
    989992            # Store quantitites as is
     
    11861189    #open sww file
    11871190    x, y, volumes, time, quantities = read_sww(sww_file)
    1188     print "x",x
    1189     print "y",y
    1190 
    1191     print "time", time
    1192     print "quantities", quantities
     1191    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))
    11931196
    11941197    #Add the x and y together
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r7276 r7317  
    2626from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    2727from anuga.config import netcdf_float
     28import anuga.utilities.log as log
    2829
    2930
     
    170171            if verbose is True:
    171172                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)
    173175
    174176            self.import_points_file(file_name, verbose=verbose)
     
    181183        if verbose is True:
    182184            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)
    184187                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')
    186189
    187190                    if file_name.endswith('csv') or file_name.endswith('txt'):
     
    437440
    438441        if self.verbose is True:
    439             print 'Using attribute %s' %attribute_name
    440             print 'Available attributes: %s' %(self.attributes.keys())
     442            log.critical('Using attribute %s' % attribute_name)
     443            log.critical('Available attributes: %s' % (self.attributes.keys()))
    441444
    442445        msg = 'Attribute name %s does not exist in data set' % attribute_name
     
    696699
    697700        # 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")
    699703
    700704        total = num.array(range(self_size), num.int)    #array default#
    701705        total_list = total.tolist()
    702706
    703         if verbose: print "total list len", len(total_list)
     707        if verbose: log.critical("total list len=%d" % len(total_list))
    704708
    705709        # There will be repeated random numbers however will not be a
     
    708712        # still basically random
    709713        ## 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))
    711716
    712717        # Set seed if provided, mainly important for unit test!
     
    717722            seed()
    718723
    719         #if verbose: print "seed:", get_seed()
    720 
    721724        random_num = randint(0, self_size-1, (int(new_size),))
    722725        random_num = random_num.tolist()
     
    726729        random_num.reverse()
    727730
    728         if verbose: print "make random number list and get indices"
     731        if verbose: log.critical("make random number list and get indices")
    729732
    730733        j = 0
     
    740743            # prints progress
    741744            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))
    743746                k += 1
    744747
     
    755758
    756759        # 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")
    758761        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")
    760764        G2 = self.get_sample(remainder_list)
    761765
     
    800804
    801805            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)
    807811        else:
    808812            # Assume the file is a csv file
     
    837841                if (self.show_verbose >= self.start_row
    838842                    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))
    842846
    843847                    self.show_verbose += max(self.max_read_lines,
     
    976980    """
    977981
    978     if verbose: print 'Reading ', file_name
     982    if verbose: log.critical('Reading %s' % file_name)
    979983
    980984    # See if the file is there.  Throw a QUIET IO error if it isn't
     
    988992    keys = fid.variables.keys()
    989993
    990     if verbose: print 'Got %d variables: %s' % (len(keys), keys)
     994    if verbose: log.critical('Got %d variables: %s' % (len(keys), keys))
    991995
    992996    try:
     
    9991003    attributes = {}
    10001004    for key in keys:
    1001         if verbose: print "reading attribute '%s'" % key
     1005        if verbose: log.critical("reading attribute '%s'" % key)
    10021006
    10031007        attributes[key] = num.array(fid.variables[key])
     
    11731177        raise IOError, msg
    11741178
    1175     if verbose: print 'Got %d variables: %s' % (len(keys), keys)
     1179    if verbose: log.critical('Got %d variables: %s' % (len(keys), keys))
    11761180
    11771181    try:
     
    15621566
    15631567    if mesh_file is None:
    1564         if verbose: print "building mesh"
     1568        if verbose: log.critical("building mesh")
    15651569        mesh_file = 'temp.msh'
    15661570
     
    15971601
    15981602    # split topo data
    1599     if verbose: print 'Reading elevation file: %s' % data_file
     1603    if verbose: log.critical('Reading elevation file: %s' % data_file)
    16001604    G = Geospatial_data(file_name = data_file)
    1601     if verbose: print 'Start split'
     1605    if verbose: log.critical('Start split')
    16021606    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')
    16041608    points = G_small.get_data_points()
    16051609
    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))
    16071612
    16081613    if alpha_list == None:
     
    16281633    normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=num.float)
    16291634
    1630     if verbose: print 'Setup computational domains with different alphas'
     1635    if verbose: log.critical('Setup computational domains with '
     1636                             'different alphas')
    16311637
    16321638    for i, alpha in enumerate(alphas):
    16331639        # add G_other data to domains with different alphas
    16341640        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))
    16361643        domain = Domain(mesh_file, use_cache=cache, verbose=verbose)
    1637         if verbose: print domain.statistics()
     1644        if verbose: log.critical(domain.statistics())
    16381645        domain.set_quantity(attribute_smoothed,
    16391646                            geospatial_data=G_other,
     
    16471654        # returns the predicted elevation of the points that were "split" out
    16481655        # 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')
    16501658        elevation_predicted = \
    16511659                domain.quantities[attribute_smoothed].\
     
    16601668
    16611669        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('--------------------------------------------')
    16651673
    16661674    normal_cov0 = normal_cov[:,0]
     
    16781686
    16791687    if verbose:
    1680         print 'Final results:'
     1688        log.critical('Final results:')
    16811689        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])
    16861694
    16871695    # covariance and optimal alpha
     
    18021810    # split topo data
    18031811    G = Geospatial_data(file_name=data_file)
    1804     if verbose: print 'start split'
     1812    if verbose: log.critical('start split')
    18051813    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')
    18071815    points = G_small.get_data_points()
    18081816
    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))
    18101819
    18111820    if alpha_list == None:
     
    18181827    domains = {}
    18191828
    1820     if verbose: print 'Setup computational domains with different alphas'
     1829    if verbose: log.critical('Setup computational domains with '
     1830                             'different alphas')
    18211831
    18221832    for alpha in alphas:
    18231833        # add G_other data to domains with different alphas
    18241834        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))
    18261837        domain = Domain(mesh_file, use_cache=cache, verbose=verbose)
    1827         if verbose: print domain.statistics()
     1838        if verbose: log.critical(domain.statistics())
    18281839        domain.set_quantity(attribute_smoothed,
    18291840                            geospatial_data=G_other,
     
    18491860
    18501861    if verbose:
    1851         print 'Determine difference between predicted results and actual data'
     1862        log.critical('Determine difference between predicted results '
     1863                     'and actual data')
    18521864
    18531865    for i, alpha in enumerate(domains):
     
    18671879        ele_cov = cov(elevation_sample - elevation_predicted)
    18681880        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]))
    18711884
    18721885    normal_cov0 = normal_cov[:,0]
  • anuga_core/source/anuga/load_mesh/loadASCII.py

    r7276 r7317  
    6767from anuga.config import netcdf_float, netcdf_char, netcdf_int
    6868from anuga.utilities.system_tools import *
     69import anuga.utilities.log as log
    6970
    7071from Scientific.IO.NetCDF import NetCDFFile
     
    10121013
    10131014    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]")
    10151016        point_atts = half_pts(point_atts)
    10161017
     
    10301031    outfiles = []
    10311032
    1032     if verbose: print "# of points", point_atts['pointlist'].shape[0]
     1033    if verbose: log.critical("# of points", point_atts['pointlist'].shape[0])
    10331034
    10341035    while point_atts['pointlist'].shape[0] > max_points:
    10351036        point_atts = half_pts(point_atts)
    10361037
    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]))
    10381040
    10391041        outfile = root + delimiter + str(point_atts['pointlist'].shape[0]) + ext
  • anuga_core/source/anuga/mesh_engine/mesh_engine.py

    r7276 r7317  
    5454        raise ANUGAError, msg
    5555
    56     #print "pointatts",pointatts
    5756    # This is after points is numeric
    5857    if pointatts is None or pointatts == []:
     
    112111        raise ANUGAError, msg
    113112   
    114     #print "mode", mode
    115113    if mode.find('n'):
    116114        #pass
     
    122120        # EG handles lone verts!
    123121           
    124     #print "points",points
    125     #print "segments", segments
    126     #print "segments.shape", segments.shape
    127     #print "holes", holes
    128     #print "regions", regions
    129     #print "pointatts", pointatts
    130     #print "segatts", segatts
    131     #print "mode", mode
    132     #print "yeah"
    133     # .copy()
    134122    trianglelist, pointlist, pointmarkerlist, pointattributelist, triangleattributelist, segmentlist, segmentmarkerlist, neighborlist = triang.genMesh(points,segments,holes,regions,
    135123                          pointatts,segatts, mode)
     
    138126    mesh_dict['generatedtrianglelist'] = trianglelist
    139127    mesh_dict['generatedpointlist'] = pointlist
    140     #print "mesh engine mesh_dict['generatedpointlist']", mesh_dict['generatedpointlist']
    141128    # WARNING - generatedpointmarkerlist IS UNTESTED
    142129    mesh_dict['generatedpointmarkerlist'] = pointmarkerlist
     
    148135
    149136    #mesh_dict['triangleattributelist'] = triangleattributelist
    150     #print "mesh eng generatedtrianglelist", trianglelist
    151     #print "mesh eng mesh_dict['triangleattributelist'] ",mesh_dict['triangleattributelist']
    152     #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist']   
    153137    if True:
    154138        mesh_dict['generatedtriangleattributelist'] = triangleattributelist
     
    167151            # this is used by urs_ungridded2sww
    168152            raise NoTrianglesError
    169     #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 
    170153    a = mesh_dict['generatedtriangleattributelist']
    171     #print 'mesh_dict', mesh_dict
    172154    # the structure of generatedtriangleattributelist is an list of
    173155    # list of integers.  It is transformed into a list of list of
  • anuga_core/source/anuga/pmesh/graphical_mesh_generator.py

    r5188 r7317  
    1717import load_mesh.loadASCII
    1818from anuga.alpha_shape.alpha_shape import AlphaError
     19import anuga.utilities.log as log
    1920
    2021# CONSTANTS
     
    413414        dialog = AddVertexDialog(self.canvas)
    414415        if dialog.xyValuesOk:
    415             print dialog.x
    416             print dialog.y
     416            log.critical(str(dialog.x))
     417            log.critical(str(dialog.y))
    417418            self.drawVertex(dialog.x*self.SCALE,dialog.y*self.SCALE,None)
    418419            #Since the new vertex may be off screen
    419420            self.ResizeToFit()
    420421        else:
    421             print "bad values"
     422            log.critical("bad values")
    422423   
    423424    def windowDefault (self, parent):
     
    510511                             smooth_indents=dialog.smooth_indents.get(),
    511512                             expand_pinch=dialog.expand_pinch.get())
    512         #print "newsegs",newsegs
    513         #print "ObjectsToVisuallyDelete",ObjectsToVisuallyDelete
    514513           
    515514        for drawOb in ObjectsToVisuallyDelete:
     
    563562       
    564563        if dialog.ValuesOk:
    565             print dialog.minAngle
    566             print dialog.maxArea
     564            log.critical(str(dialog.minAngle))
     565            log.critical(str(dialog.maxArea))
    567566           
    568567            self.clearSelections()
     
    586585            else:
    587586                pass
    588             print "userMeshChanged = False"
     587            log.critical("userMeshChanged = False")
    589588            self.UserMeshChanged = False
    590589            self.visualiseMesh(self.mesh)
    591             print "Mesh Generation finished"
     590            log.critical("Mesh Generation finished")
    592591           
    593592    def MeshGenAreaAngle (self, minAngle, maxArea, mesh):
     
    621620            pass
    622621        meshArea = 0
    623         #print "tempMesh.getTriangulation()", tempMesh.getTriangulation()
    624622        meshArea = tempMesh.tri_mesh.calc_mesh_area()
    625623        maxArea = meshArea/numTriangles
     
    639637        #The screen canvas has y 'flipped'.  -1* unflips it
    640638        self.lasty = self.starty = -1*self.canvas.canvasy(event.y)
    641         print "----------------------"
     639        log.critical "----------------------")
    642640        self.mouseDownCurFunc( self.lastx,
    643641                               self.lasty,event) #!!! remove the event?
     
    651649        if event.widget.find_withtag(CURRENT): # if there's a widget with a tag
    652650            [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')
    654652            if tag[:2] == 'M*':   #!!! this can be removed when there are
    655653                #    only mesh objects on screen
    656654                #key, value = string.split(tag, '*')
    657655                objectID = tag
    658                 print "Found!! objectID:", objectID
     656                log.critical("Found!! objectID: %s" % str(objectID))
    659657               
    660658                meshObjects = self.getAllUserMeshObjects()
     
    663661                    selMeshObject = meshObjects.getMeshObject(objectID)
    664662                    found = True
    665                     print "Found! selMeshObject", selMeshObject
     663                    log.critical("Found! selMeshObject: %s"
     664                                 % str(selMeshObject))
    666665                    #Only select one object at a time
    667666                    if self.selMeshObject:
     
    728727        #x_scaled =  self.SCALE*x
    729728        #y_scaled = -1*self.SCALE*y
    730         #print "x y:", x,y
    731729        vert = self.Vertices.draw(x-self.mesh.geo_reference.get_xllcorner,
    732730                                  y-self.mesh.geo_reference.get_yllcorner,
     
    749747        #x_scaled =  self.SCALE*x
    750748        #y_scaled = -1*self.SCALE*y
    751         #print "x y:", x,y
    752749        vert = self.Vertices.draw(x,y,self.mesh,self.uniqueID,self.SCALE,self.canvas,event)
    753750        self.UserMeshChanged = True
     
    784781        if event.widget.find_withtag(CURRENT): # if there's a widget with a tag
    785782            [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')
    787784            objectID = tag
    788             #print "Found!! objectID:", objectID
    789785            if self.Vertices.hasKey(objectID): #isinstance(self.meshObjects[objectID],mesh.Vertex):
    790786                vertex = self.Vertices.getMeshObject(objectID)
    791787                found = True
    792                 print "Found! vertex", vertex
     788                log.critical("Found! vertex: %s" % str(vertex))
    793789           
    794790        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")
    796792            #The selected vertex has already been selected
    797793            # therefore deselect it
     
    808804                    self.selectVertex(vertex,objectID)
    809805            else:
    810                 print "vertex is the 1st vertex"
     806                log.critical("vertex is the 1st vertex")
    811807                #vertex is the 1st vertex
    812808                self.selectVertex(vertex,objectID)
    813809        else:
    814             print " There are no widgets.  This happen's too much"
     810            log.critical(" There are no widgets.  This happen's too much")
    815811                   
    816812
     
    844840    def printGeoReference(self):
    845841        try:
    846             print "geo reference", self.mesh.geo_reference
     842            log.critical("geo reference %s" % str(self.mesh.geo_reference))
    847843        except:
    848             print "no geo reference"
     844            log.critical("no geo reference")
    849845       
    850846    def visualiseMesh(self,mesh):
     
    10071003        import mesh data from a variety of formats (currently 2!)
    10081004        """
    1009         print "self.currentPath",self.currentPath
     1005        log.critical("self.currentPath %s" % str(self.currentPath))
    10101006        ofile = tkFileDialog.askopenfilename(initialdir=self.currentPath,
    10111007                                             filetypes=[ ("text Mesh",
     
    10211017            newmesh = mesh.importMeshFromFile(ofile)
    10221018            self.currentPath, dummy = os.path.split(ofile)
    1023             #print "be good self.currentPath",self.currentPath
    10241019            self.currentFilePathName = ofile
    10251020            self.clearMesh()
     
    10411036        # Could not get the file name to showup in the title
    10421037        #appname =  ofile + " - " + APPLICATION_NAME
    1043         #print "appname",appname
    10441038       
    10451039        except load_mesh.loadASCII.TitleAmountError:
     
    10861080        Save the current drawing
    10871081        """
    1088         #print "dsg!!! self.currentFilePathName ",self.currentFilePathName
    10891082        if (self.currentFilePathName[-4:] != ".tsh" or
    10901083            self.currentFilePathName[-4:] != ".msh"):
     
    11201113        there is no generated mesh do not prompt.
    11211114        """
    1122         #print "self.UserMeshChanged",self.UserMeshChanged
    1123         #print "self.mesh.isTriangulation()",self.mesh.isTriangulation()
    11241115        if (self.UserMeshChanged) and self.mesh.isTriangulation():
    11251116           
     
    12201211       
    12211212        fd.close()
    1222         print 'returning m'
     1213        log.critical('returning m')
    12231214        return oadtestmesh(ofile)
    12241215         
  • anuga_core/source/anuga/pmesh/mesh.py

    r7276 r7317  
    3434     ensure_geospatial, ensure_absolute, ensure_numeric
    3535from anuga.mesh_engine.mesh_engine import generate_mesh
     36import anuga.utilities.log as log
     37
    3638
    3739try: 
     
    145147        x =  scale*(self.x + xoffset)
    146148        y = -1*scale*(self.y + yoffset)  # - since for a canvas - is up
    147         #print "draw x:", x
    148         #print "draw y:", y
    149149        cornerOffset= self.VERTEXSQUARESIDELENGTH/2
    150150
     
    187187        x =  scale*(self.x + xoffset)
    188188        y = -1*scale*(self.y + yoffset)  # - since for a canvas - is up
    189         #print "draw x:", x
    190         #print "draw y:", y
    191189        cornerOffset= self.HOLECORNERLENGTH/2
    192190        return canvas.create_oval(x-cornerOffset,
     
    612610    # Depreciated
    613611    def addRegionEN(self, x,y):
    614         print "depreciated, use add_region"
     612        log.critical("deprecated, use add_region")
    615613        return self.add_region(x,y)
    616614
     
    22662264        counter = newmesh.removeDuplicatedUserVertices()
    22672265        if (counter >0):
    2268             print "%i duplicate vertices removed from dataset" % (counter)
     2266            log.critical("%i duplicate vertices removed from dataset" % counter)
    22692267    elif (ofile[-4:]== ".tsh" or ofile[-4:]== ".msh"):
    22702268        dict = import_mesh_file(ofile)
     
    23402338            region_list[i] = (region_list[i][0],region_list[i][1],i)
    23412339        else:
    2342             print "The region list has a bad size"
     2340            log.critical("The region list has a bad size")
    23432341            # raise an error ..
    23442342            raise Error
  • anuga_core/source/anuga/pmesh/mesh_interface.py

    r7276 r7317  
    55import numpy as num
    66from anuga.utilities.polygon import inside_polygon
    7 
     7import anuga.utilities.log as log
    88
    99
     
    151151                #raise Exception, msg
    152152                # Fixme: Use proper Python warning
    153                 if verbose: print 'WARNING: ', msg
     153                if verbose: log.critical('WARNING: %s' % msg)
    154154               
    155155
     
    187187                else:
    188188                    msg += ' I will ignore it.'
    189                     print msg
     189                    log.critical(msg)
    190190
    191191            else:
     
    313313        return m
    314314    else:
    315         if verbose: print 'Generating mesh to file "%s"' %filename
     315        if verbose: log.critical("Generating mesh to file '%s'" % filename)
    316316        m.generate_mesh(minimum_triangle_angle=minimum_triangle_angle,
    317317                        verbose=verbose)
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r7308 r7317  
    9292
    9393from anuga.utilities.system_tools import get_vars_in_expression
     94import anuga.utilities.log as log
    9495
    9596
     
    181182                pass  # FIXME: What about access rights under Windows?
    182183
    183             if verbose: print 'MESSAGE: Directory', path, 'created.'
     184            if verbose: log.critical('MESSAGE: Directory %s created.' % path)
    184185        except:
    185             print 'WARNING: Directory', path, 'could not be created.'
     186            log.critical('WARNING: Directory %s could not be created.' % path)
    186187            if unix:
    187188                path = '/tmp/'
     
    189190                path = 'C:' + os.sep
    190191
    191             print "Using directory '%s' instead" % path
     192            log.critical("Using directory '%s' instead" % path)
    192193
    193194    return path
     
    211212                    os.remove(X)
    212213                except:
    213                     print "Could not remove file %s" % X
     214                    log.critical("Could not remove file %s" % X)
    214215
    215216        os.rmdir(path)
     
    227228    try:
    228229        func(path)
    229         if verbose: print 'Removed ', path
     230        if verbose: log.critical('Removed %s' % path)
    230231    except OSError, (errno, strerror):
    231         print ERROR_STR % {'path' : path, 'error': strerror }
     232        log.critical(ERROR_STR % {'path' : path, 'error': strerror })
    232233
    233234
     
    483484                      % self.filename
    484485                msg += ' - trying step %s again' % self.domain.time
    485                 print msg
     486                log.critical(msg)
    486487                retries += 1
    487488                sleep(1)
     
    524525                                                  recursion=self.recursion+1)
    525526            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)
    528530
    529531            #set up the new data_structure
     
    723725                msg = 'Warning (store_timestep): File %s could not be opened' \
    724726                      ' - trying again' % self.filename
    725                 print msg
     727                log.critical(msg)
    726728                retries += 1
    727729                sleep(1)
     
    12981300    # Get NetCDF
    12991301    FN = create_filename('.', basefilename, 'sww', size)
    1300     print 'Reading from ', FN
     1302    log.critical('Reading from %s' % FN)
    13011303    fid = NetCDFFile(FN, netcdf_mode_r)  #Open existing file for read
    13021304
     
    13271329    for k in range(len(time)):
    13281330        t = time[k]
    1329         print 'Processing timestep %f' %t
     1331        log.critical('Processing timestep %f' % t)
    13301332
    13311333        for i in range(M):
     
    13751377    files = glob.glob(data_dir + os.sep + basefilename + '*.dat')
    13761378    for filename in files:
    1377         print 'Processing %s' % filename
     1379        log.critical('Processing %s' % filename)
    13781380
    13791381        lines = open(data_dir + os.sep + filename, 'r').readlines()
     
    14541456    selection = range(first, last, step)
    14551457    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]))
    14571460        newtime[i] = time[j]
    14581461        newstage[i,:] = stage[j,:]
     
    15561559    infile = NetCDFFile(root + '.dem', netcdf_mode_r)
    15571560
    1558     if verbose: print 'Reading DEM from %s' %(root + '.dem')
     1561    if verbose: log.critical('Reading DEM from %s' % (root + '.dem'))
    15591562
    15601563    ncols = infile.ncols[0]
     
    15811584        ptsname = basename_out + '.pts'
    15821585
    1583     if verbose: print 'Store to NetCDF file %s' %ptsname
     1586    if verbose: log.critical('Store to NetCDF file %s' % ptsname)
    15841587
    15851588    # NetCDF file definition
     
    16571660
    16581661    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)
    16621666
    16631667    outfile.createDimension('number_of_points', nopoints)
     
    16801684    for i in range(i1_0, thisi+1, 1):
    16811685        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))
    16831687
    16841688        lower_index = global_index
     
    18201824    infile = open(root + '.sdf', 'r')
    18211825
    1822     if verbose: print 'Reading DEM from %s' %(root + '.sdf')
     1826    if verbose: log.critical('Reading DEM from %s' % (root + '.sdf'))
    18231827
    18241828    lines = infile.readlines()
    18251829    infile.close()
    18261830
    1827     if verbose: print 'Converting to pts format'
     1831    if verbose: log.critical('Converting to pts format')
    18281832
    18291833    # Scan through the header, picking up stuff we need.
     
    20262030    if is_parallel is True:
    20272031        for i in range(nodes):
    2028             print 'Sending node %d of %d' % (i, nodes)
     2032            log.critical('Sending node %d of %d' % (i, nodes))
    20292033            swwfiles = {}
    20302034            if not reportname == None:
     
    20372041                    sww_extra = '_P%s_%s' % (i, nodes)
    20382042                    swwfile = file_loc + scenario_name + sww_extra + '.sww'
    2039                     print 'swwfile', swwfile
     2043                    log.critical('swwfile %s' % swwfile)
    20402044                    swwfiles[swwfile] = label_id
    20412045
     
    20552059        for label_id in production_dirs.keys():
    20562060            if label_id == 'boundaries':
    2057                 print 'boundaries'
     2061                log.critical('boundaries')
    20582062                file_loc = project.boundaries_in_dir
    20592063                swwfile = project.boundaries_dir_name3 + '.sww'
     
    21962200    # Read sww file
    21972201    if verbose:
    2198         print 'Reading from %s' % swwfile
    2199         print 'Output directory is %s' % basename_out
     2202        log.critical('Reading from %s' % swwfile)
     2203        log.critical('Output directory is %s' % basename_out)
    22002204
    22012205    from Scientific.IO.NetCDF import NetCDFFile
     
    22342238    # Something like print swwstats(swwname)
    22352239    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))
    22422245        if timestep is not None:
    2243             print '    Time: %f' %(times)
     2246            log.critical('    Time: %f' % times)
    22442247        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)))
    22512254        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))
    22532256        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]:')
    22572260        # Comment out for reduced memory consumption
    22582261        for name in ['stage', 'xmomentum', 'ymomentum']:
     
    22602263            if timestep is not None:
    22612264                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)))
    22632267        for name in ['elevation']:
    22642268            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)))
    22662271
    22672272    # Get the variables in the supplied expression.
     
    23132318
    23142319    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)))
    23172322
    23182323    #Create grid and update xll/yll corner and x,y
     
    23462351    assert ymax >= ymin, msg
    23472352
    2348     if verbose: print 'Creating grid'
     2353    if verbose: log.critical('Creating grid')
    23492354    ncols = int((xmax-xmin)/cellsize) + 1
    23502355    nrows = int((ymax-ymin)/cellsize) + 1
     
    23862391
    23872392    #Interpolate using quantity values
    2388     if verbose: print 'Interpolating'
     2393    if verbose: log.critical('Interpolating')
    23892394    grid_values = interp.interpolate(result, grid_points).flatten()
    23902395
    23912396    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)))
    23942399
    23952400    #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh)
     
    24222427
    24232428        #Write
    2424         if verbose: print 'Writing %s' %demfile
     2429        if verbose: log.critical('Writing %s' % demfile)
    24252430
    24262431        import ermapper_grids
     
    24342439        prjfile = basename_out + '.prj'
    24352440
    2436         if verbose: print 'Writing %s' %prjfile
     2441        if verbose: log.critical('Writing %s' % prjfile)
    24372442        prjid = open(prjfile, 'w')
    24382443        prjid.write('Projection    %s\n' %'UTM')
     
    24472452        prjid.close()
    24482453
    2449         if verbose: print 'Writing %s' %demfile
     2454        if verbose: log.critical('Writing %s' % demfile)
    24502455
    24512456        ascid = open(demfile, 'w')
     
    24632468        for i in range(nrows):
    24642469            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))
    24662471
    24672472            base_index = (nrows-i-1)*ncols
     
    25012506            verbose = False,
    25022507            origin = None):
    2503     print 'sww2asc will soon be obsoleted - please use sww2dem'
     2508    log.critical('sww2asc will soon be obsoleted - please use sww2dem')
    25042509    sww2dem(basename_in,
    25052510            basename_out = basename_out,
     
    25352540            origin=None,
    25362541            datum='WGS84'):
    2537     print 'sww2ers will soon be obsoleted - please use sww2dem'
     2542    log.critical('sww2ers will soon be obsoleted - please use sww2dem')
    25382543    sww2dem(basename_in,
    25392544            basename_out=basename_out,
     
    26052610
    26062611    # Read sww file
    2607     if verbose: print 'Reading from %s' % swwfile
     2612    if verbose: log.critical('Reading from %s' % swwfile)
    26082613    from Scientific.IO.NetCDF import NetCDFFile
    26092614    fid = NetCDFFile(swwfile)
     
    26382643        y = fid.variables['y'][:]
    26392644        times = fid.variables['time'][:]
    2640         print '------------------------------------------------'
    2641         print 'Statistics of SWW file:'
    2642         print '  Name: %s' % swwfile
    2643         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]:')
    26542659        for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']:
    26552660            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)))
    26572662
    26582663    # Get quantity and reduce if applicable
    2659     if verbose: print 'Processing quantity %s' % quantity
     2664    if verbose: log.critical('Processing quantity %s' % quantity)
    26602665
    26612666    # Turn NetCDF objects into numeric arrays
     
    26702675        # q has a time component and needs to be reduced along
    26712676        # the temporal dimension
    2672         if verbose: print 'Reducing quantity %s' % quantity
     2677        if verbose: log.critical('Reducing quantity %s' % quantity)
    26732678
    26742679        q_reduced = num.zeros(number_of_points, num.float)
     
    26822687
    26832688    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)))
    26862691
    26872692    # Create grid and update xll/yll corner and x,y
     
    26942699
    26952700    # Interpolate using quantity values
    2696     if verbose: print 'Interpolating'
     2701    if verbose: log.critical('Interpolating')
    26972702    interpolated_values = interp.interpolate(q, data_points).flatten()
    26982703
    26992704    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)))
    27022708
    27032709    # Assign NODATA_value to all points outside bounding polygon
     
    27932799
    27942800    # Read Meta data
    2795     if verbose: print 'Reading METADATA from %s' % root + '.prj'
     2801    if verbose: log.critical('Reading METADATA from %s' % (root + '.prj'))
    27962802
    27972803    metadatafile = open(root + '.prj')
     
    28342840    datafile = open(basename_in + '.asc')
    28352841
    2836     if verbose: print 'Reading DEM from %s' % basename_in + '.asc'
     2842    if verbose: log.critical('Reading DEM from %s' % (basename_in + '.asc'))
    28372843
    28382844    lines = datafile.readlines()
    28392845    datafile.close()
    28402846
    2841     if verbose: print 'Got', len(lines), ' lines'
     2847    if verbose: log.critical('Got %d lines' % len(lines))
    28422848
    28432849    ncols = int(lines[0].split()[1].strip())
     
    28772883        netcdfname = basename_out + '.dem'
    28782884
    2879     if verbose: print 'Store to NetCDF file %s' % netcdfname
     2885    if verbose: log.critical('Store to NetCDF file %s' % netcdfname)
    28802886
    28812887    # NetCDF file definition
     
    29172923        fields = line.split()
    29182924        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))
    29202926           
    29212927        if len(fields) != ncols:
     
    30113017
    30123018    # Get NetCDF data
    3013     if verbose: print 'Reading files %s_*.nc' % basename_in
     3019    if verbose: log.critical('Reading files %s_*.nc' % basename_in)
    30143020
    30153021    file_h = NetCDFFile(basename_in + '_ha.nc', netcdf_mode_r) # Wave amplitude (cm)
     
    31063112    longitudes = longitudes[lmin:lmax]
    31073113
    3108     if verbose: print 'cropping'
     3114    if verbose: log.critical('cropping')
    31093115
    31103116    zname = 'ELEVATION'
     
    31843190
    31853191    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)))
    31963203
    31973204#        q = amplitudes.flatten()
    31983205        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)))
    32003208
    32013209#        q = uspeed.flatten()
    32023210        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)))
    32043213
    32053214#        q = vspeed.flatten()
    32063215        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)))
    32083218
    32093219#        q = elevations.flatten()
    32103220        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)))
    32123223
    32133224    # print number_of_latitudes, number_of_longitudes
     
    32423253    y = num.zeros(number_of_points, num.float)  #Northing
    32433254
    3244     if verbose: print 'Making triangular grid'
     3255    if verbose: log.critical('Making triangular grid')
    32453256
    32463257    # Check zone boundaries
     
    33023313    ymomentum = outfile.variables['ymomentum']
    33033314
    3304     if verbose: print 'Converting quantities'
     3315    if verbose: log.critical('Converting quantities')
    33053316
    33063317    n = len(times)
    33073318    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))
    33093321
    33103322        i = 0
     
    33253337        x = outfile.variables['x'][:]
    33263338        y = outfile.variables['y'][:]
    3327         print '------------------------------------------------'
    3328         print 'Statistics of output file:'
    3329         print '  Name: %s' %swwname
    3330         print '  Reference:'
    3331         print '    Lower left corner: [%f, %f]' \
    3332               % (geo_ref.get_xllcorner(), geo_ref.get_yllcorner())
    3333         print ' Start time: %f' %starttime
    3334         print '    Min time: %f' %mint
    3335         print '    Max time: %f' %maxt
    3336         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]:')
    33443356        for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']:
    33453357            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)))
    33473359
    33483360    outfile.close()
     
    35373549    NaN = 9.969209968386869e+036
    35383550
    3539     if verbose: print 'Reading from ', filename
     3551    if verbose: log.critical('Reading from %s' % filename)
    35403552
    35413553    fid = NetCDFFile(filename, netcdf_mode_r)    # Open existing file for read
     
    35703582        geo_reference = None
    35713583
    3572     if verbose: print '    getting quantities'
     3584    if verbose: log.critical('    getting quantities')
    35733585
    35743586    for quantity in fid.variables.keys():
     
    35953607    conserved_quantities.remove('time')
    35963608
    3597     if verbose: print '    building domain'
     3609    if verbose: log.critical('    building domain')
    35983610
    35993611    #    From domain.Domain:
     
    36373649        X = fid.variables[quantity][:]
    36383650        if very_verbose:
    3639             print '       ', quantity
    3640             print '        NaN =', NaN
    3641             print '        max(X)'
    3642             print '       ', max(X)
    3643             print '        max(X)==NaN'
    3644             print '       ', max(X)==NaN
    3645             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('')
    36463658        if max(X) == NaN or min(X) == NaN:
    36473659            if fail_if_NaN:
     
    36623674        X = interpolated_quantities[quantity]
    36633675        if very_verbose:
    3664             print '       ',quantity
    3665             print '        NaN =', NaN
    3666             print '        max(X)'
    3667             print '       ', max(X)
    3668             print '        max(X)==NaN'
    3669             print '       ', max(X)==NaN
    3670             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('')
    36713683        if max(X) == NaN or min(X) == NaN:
    36723684            if fail_if_NaN:
     
    38323844    infile = NetCDFFile(inname, netcdf_mode_r)
    38333845
    3834     if verbose: print 'Reading DEM from %s' % inname
     3846    if verbose: log.critical('Reading DEM from %s' % inname)
    38353847
    38363848    # Read metadata (convert from numpy.int32 to int where appropriate)
     
    38563868        outname = basename_out + '.dem'
    38573869
    3858     if verbose: print 'Write decimated NetCDF file to %s' % outname
     3870    if verbose: log.critical('Write decimated NetCDF file to %s' % outname)
    38593871
    38603872    #Determine some dimensions for decimated grid
     
    39083920    global_index = 0
    39093921    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))
    39113923
    39123924        lower_index = global_index
     
    39513963    """
    39523964
    3953     if verbose == True:print 'Creating domain from', filename
     3965    if verbose == True: log.critical('Creating domain from %s' % filename)
    39543966
    39553967    domain = pmesh_to_domain_instance(filename, Domain)
    39563968
    3957     if verbose == True:print "Number of triangles = ", len(domain)
     3969    if verbose == True: log.critical("Number of triangles = %s" % len(domain))
    39583970
    39593971    domain.smooth = True
     
    39643976    domain.reduction = mean
    39653977
    3966     if verbose == True:print "file_path",file_path
     3978    if verbose == True: log.critical("file_path = %s" % file_path)
    39673979
    39683980    if file_path == "":
     
    39713983
    39723984    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))
    39753988
    39763989    sww = get_dataobject(domain)
     
    40994112
    41004113    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)))
    41104123
    41114124    ######### WRITE THE SWW FILE #############
     
    41604173    y = num.zeros(number_of_points, num.float)  #Northing
    41614174
    4162     if verbose: print 'Making triangular grid'
     4175    if verbose: log.critical('Making triangular grid')
    41634176
    41644177    #Get zone of 1st point.
     
    42034216
    42044217    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_ref
     4218        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)
    42134226
    42144227    z = num.resize(bath_grid,outfile.variables['z'][:].shape)
     
    42274240    outfile.variables['time'][:] = times   #Store time relative
    42284241
    4229     if verbose: print 'Converting quantities'
     4242    if verbose: log.critical('Converting quantities')
    42304243
    42314244    n = number_of_times
     
    42544267                                 + missing*elevation_NaN_filler
    42554268
    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))
    42574271
    42584272        i = 0
     
    43734387    datafile = open(filename)
    43744388
    4375     if verbose: print 'Reading DEM from %s' % filename
     4389    if verbose: log.critical('Reading DEM from %s' % filename)
    43764390
    43774391    lines = datafile.readlines()
    43784392    datafile.close()
    43794393
    4380     if verbose: print 'Got', len(lines), ' lines'
     4394    if verbose: log.critical('Got %d lines' % len(lines))
    43814395
    43824396    ncols = int(lines.pop(0).split()[1].strip())
     
    46304644            else:
    46314645               files_in[i] += '.mux'
    4632                print "file_name", file_name
     4646               log.critical("file_name %s" % file_name)
    46334647
    46344648    hashed_elevation = None
     
    53155329        swwname = basename_out + '.sww'
    53165330
    5317     if verbose: print 'Output to ', swwname
     5331    if verbose: log.critical('Output to %s' % swwname)
    53185332
    53195333    outfile = NetCDFFile(swwname, netcdf_mode_w)
     
    53315345                            verbose=verbose)
    53325346
    5333     if verbose: print 'Converting quantities'
     5347    if verbose: log.critical('Converting quantities')
    53345348
    53355349    # Read in a time slice from each mux file and write it to the SWW file
     
    55675581
    55685582    if not isinstance(basename_in, ListType):
    5569         if verbose: print 'Reading single source'
     5583        if verbose: log.critical('Reading single source')
    55705584        basename_in = [basename_in]
    55715585
     
    55935607        assert len(weights) == numSrc, msg
    55945608
    5595     if verbose: print 'Weights used in urs2sts:', weights
     5609    if verbose: log.critical('Weights used in urs2sts: %s' % str(weights))
    55965610
    55975611    # Check output filename
     
    56225636    # Establish permutation array
    56235637    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)
    56255640
    56265641        # Read ordering file
     
    56515666
    56525667    # Read MUX2 files
    5653     if (verbose): print 'reading mux2 file'
     5668    if (verbose): log.critical('reading mux2 file')
    56545669
    56555670    mux={}
     
    57705785    ymomentum = outfile.variables['ymomentum']
    57715786
    5772     if verbose: print 'Converting quantities'
     5787    if verbose: log.critical('Converting quantities')
    57735788
    57745789    for j in range(len(times)):
     
    57815796                    msg = 'Setting nodata value %d to 0 at time = %f, ' \
    57825797                          'point = %d' % (ha, times[j], i)
    5783                     print msg
     5798                    log.critical(msg)
    57845799                ha = 0.0
    57855800                ua = 0.0
     
    59815996
    59825997        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)))
    59876002
    59886003    ##
     
    60636078
    60646079        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_ref
    6075             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('------------------------------------------------')
    60766091
    60776092        #z = resize(bath_grid, outfile.variables['z'][:].shape)
     
    61586173    # @param outfile UNUSED.
    61596174    def verbose_quantities(self, outfile):
    6160         print '------------------------------------------------'
    6161         print 'More Statistics:'
     6175        log.critical('------------------------------------------------')
     6176        log.critical('More Statistics:')
    61626177        for q in Write_sww.sww_quantities:
    6163             print '  %s in [%f, %f]' % (q,
    6164                                        outfile.variables[q+Write_sww.RANGE][0],
    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('------------------------------------------------')
    61676182
    61686183
     
    61886203    j = 0
    61896204    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))
    61916207        w = zscale*ha + mean_stage
    61926208        stage[j] = w
     
    63716387
    63726388        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)))
    63776393
    63786394    ##
     
    64456461
    64466462        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_ref
    6457             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('------------------------------------------------')
    64586474
    64596475        #z = resize(bath_grid,outfile.variables['z'][:].shape)
     
    66446660
    66456661    if access(dir_name, W_OK) == 0:
    6646         if verbose: print 'Making directory %s' % dir_name
     6662        if verbose: log.critical('Making directory %s' % dir_name)
    66476663        mkdir (dir_name,0777)
    66486664
     
    66596675                                       (myid, numprocs, extra_info))
    66606676
    6661     if verbose: print 'Starting ScreenCatcher, ' \
    6662                       'all output will be stored in %s' % screen_output_name
     6677    if verbose: log.critical('Starting ScreenCatcher, all output will be '
     6678                             'stored in %s' % screen_output_name)
    66636679
    66646680    # used to catch screen output to file
     
    66806696        self.filename = filename
    66816697        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)
    66836700            remove(self.filename)
    66846701
     
    67166733                shutil.copy(f, dir_name)
    67176734                if verbose:
    6718                     print 'File %s copied' % (f)
     6735                    log.critical('File %s copied' % f)
    67196736        else:
    67206737            shutil.copy(file, dir_name)
    67216738            if verbose:
    6722                 print 'File %s copied' % (file)
     6739                log.critical('File %s copied' % file)
    67236740
    67246741    # check we have a destination directory, create if necessary
    67256742    if access(dir_name, F_OK) == 0:
    67266743        if verbose:
    6727             print 'Make directory %s' % dir_name
     6744            log.critical('Make directory %s' % dir_name)
    67286745        mkdir(dir_name, 0777)
    67296746
     
    68476864        file_header = fid.readline()
    68486865        fid.close()
    6849         if verbose: print 'read file header %s' % file_header
     6866        if verbose: log.critical('read file header %s' % file_header)
    68506867    except:
    68516868        msg = 'try to create new file: %s' % file
    6852         if verbose: print msg
     6869        if verbose: log.critical(msg)
    68536870        #tries to open file, maybe directory is bad
    68546871        try:
     
    68776894
    68786895        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'))
    68816898        if file_header.strip('\n') == str(header):
    6882             print 'they equal'
     6899            log.critical('they equal')
    68836900
    68846901        msg = 'WARNING: File header does not match input info, ' \
    68856902              'the input variables have changed, suggest you change file name'
    6886         print msg
     6903        log.critical(msg)
    68876904
    68886905################################################################################
     
    69246941    from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    69256942
    6926     if verbose: print 'Reading from ', filename
     6943    if verbose: log.critical('Reading from %s' % filename)
    69276944
    69286945    fid = NetCDFFile(filename, netcdf_mode_r)    # Open existing file for read
     
    69496966        geo_reference = None
    69506967
    6951     if verbose: print '    building mesh from sww file %s' %filename
     6968    if verbose: log.critical('    building mesh from sww file %s' % filename)
    69526969
    69536970    boundary = None
     
    70257042    # Interpolate
    70267043    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))
    70297046
    70307047    I = Interpolation_function(time,
     
    70847101    interpolation_points = interpolation_function.interpolation_points
    70857102
    7086     if verbose: print 'Computing hydrograph'
     7103    if verbose: log.critical('Computing hydrograph')
    70877104
    70887105    # Compute hydrograph
     
    71647181    interpolation_points = interpolation_function.interpolation_points
    71657182
    7166     if verbose: print 'Computing %s energy' % kind
     7183    if verbose: log.critical('Computing %s energy' % kind)
    71677184
    71687185    # Compute total length of polyline for use with weighted averages
     
    73307347
    73317348    # Read sww file
    7332     if verbose: print 'Reading from %s' % filename
     7349    if verbose: log.critical('Reading from %s' % filename)
    73337350    # FIXME: Use general swwstats (when done)
    73347351
     
    73407357        filename = join(dir, swwfile+'.sww')
    73417358
    7342         if verbose: print 'Reading from %s' % filename
     7359        if verbose: log.critical('Reading from %s' % filename)
    73437360        # FIXME: Use general swwstats (when done)
    73447361
     
    75037520        raise IOError, msg
    75047521
    7505     if verbose: print 'iterate over %s' % iterate_over
     7522    if verbose: log.critical('iterate over %s' % iterate_over)
    75067523
    75077524    return iterate_over
     
    75517568        raise IOError, msg
    75527569
    7553     if verbose: print 'iterate over %s' %(iterate_over)
     7570    if verbose: log.critical('iterate over %s' % iterate_over)
    75547571
    75557572    return iterate_over
     
    75847601        raise IOError, msg
    75857602
    7586     if verbose: print 'iterate over %s' % iterate_over
     7603    if verbose: log.critical('iterate over %s' % iterate_over)
    75877604
    75887605    return iterate_over
  • anuga_core/source/anuga/shallow_water/most2nc.py

    r6086 r7317  
    1010from Scientific.IO.NetCDF import NetCDFFile
    1111from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
     12import anuga.utilities.log as log
    1213
    1314
     
    3334    in_file = open(input_file,'r')
    3435
    35     if verbose: print 'reading header'
     36    if verbose: log.critical('reading header')
    3637
    3738    nx_ny_str = in_file.readline()
     
    4950    h2_list.reverse()
    5051
    51     if verbose: print 'reading depths'
     52    if verbose: log.critical('reading depths')
    5253
    5354    in_depth_list = in_file.readlines()
     
    5657    out_depth_list = [[]]
    5758
    58     if verbose: print 'processing depths'
     59    if verbose: log.critical('processing depths')
    5960
    6061    k=1
     
    7475
    7576    # write the NetCDF file
    76     if verbose: print 'writing results'
     77    if verbose: log.critical('writing results')
    7778
    7879    out_file = NetCDFFile(output_file, netcdf_mode_w)
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r7312 r7317  
    118118from anuga.utilities.polygon import inside_polygon, polygon_area, \
    119119                                    is_inside_polygon
     120import anuga.utilities.log as log
    120121
    121122from types import IntType, FloatType
     
    453454
    454455        # Compute flow
    455         if verbose: print 'Computing flow through specified cross section'
     456        if verbose:
     457            log.critical('Computing flow through specified cross section')
    456458
    457459        # Get interpolated values
     
    526528
    527529        # Compute energy
    528         if verbose: print 'Computing %s energy' %kind
     530        if verbose: log.critical('Computing %s energy' % kind)
    529531
    530532        # Get interpolated values
     
    904906        depth = stage-elevation
    905907       
    906         #print 'z', elevation
    907         #print 'w', stage
    908         #print 'h', depth
    909908        return num.sum(depth*area)
    910909       
     
    13281327                msg += 'transmissive_momentum_set_stage boundary object.\n'
    13291328                msg += 'I will continue, reusing the object from t==0'
    1330                 print msg
     1329                log.critical(msg)
    13311330                t -= self.function.time[-1]
    13321331
     
    18381837        # check sanity of result
    18391838        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))
    18411843       
    18421844        # update depth dependent friction  for that wet element
     
    18501852        n_max=max(nvals)
    18511853       
    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))
    18531857   
    18541858    return wet_friction
     
    22872291        # Now rate is a number
    22882292        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))
    22922295
    22932296        if self.exchange_indices is None:
     
    25722575            msg = ('WARNING: psyco (speedup) could not be imported, '
    25732576                   'you may want to consider installing it')
    2574             print msg
     2577            log.critical(msg)
    25752578    else:
    25762579        psyco.bind(Domain.distribute_to_vertices_and_edges)
  • anuga_core/source/anuga/shallow_water/smf.py

    r7276 r7317