Changeset 6472


Ignore:
Timestamp:
Mar 5, 2009, 2:48:11 PM (16 years ago)
Author:
rwilson
Message:

Took Ole's changes to the test_get_maximum_inundation code and made it numpy.

Location:
branches/numpy/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/shallow_water/test_data_manager.py

    r6428 r6472  
    1059010590        ymomentum = fid.variables['ymomentum'][:]       
    1059110591
    10592         h = stage-z
    10593         for i in range(len(stage)):
    10594             if num.alltrue(h[i] == 0.0):
    10595                 assert num.alltrue(xmomentum[i] == 0.0)
    10596                 assert num.alltrue(ymomentum[i] == 0.0)
    10597             else:
    10598                 msg = ('h[i]=\n%s\ndomain.minimum_storable_height=%s'
    10599                        % (str(h[i]), str(domain.minimum_storable_height)))
    10600                 assert num.alltrue(h[i] >= domain.minimum_storable_height), msg
     10592        for i in range(stage.shape[0]):
     10593            h = stage[i]-z # depth vector at time step i
     10594           
     10595            # Check every node location
     10596            for j in range(stage.shape[1]):
     10597                # Depth being either exactly zero implies
     10598                # momentum being zero.
     10599                # Or else depth must be greater than or equal to
     10600                # the minimal storable height
     10601                if h[j] == 0.0:
     10602                    assert xmomentum[i,j] == 0.0
     10603                    assert ymomentum[i,j] == 0.0               
     10604                else:
     10605                    assert h[j] >= domain.minimum_storable_height
    1060110606       
    1060210607        fid.close()
     
    1063510640
    1063610641        # Check runup restricted to a polygon
    10637         p = num.array([[50,1], [99,1], [99,49], [50,49]]) + num.array([E, N])
     10642        p = num.array([[50,1], [99,1], [99,49], [50,49]], num.int) + \
     10643                num.array([E, N], num.int)      #array default#
    1063810644
    1063910645        runup = get_maximum_inundation_elevation(swwfile, polygon=p)
  • branches/numpy/anuga/shallow_water/tsunami_okada.py

    r6410 r6472  
    215215            yrec=x
    216216            for i in range(0,len(zrec[0])):
    217                 if (num.alltrue(zrec[0][i]==yrec) and
    218                     num.alltrue(zrec[1][i]==xrec)):
     217                if (num.any(zrec[0][i]==yrec) and num.any(zrec[1][i]==xrec)):
    219218                    Z=zrec[2][i]
    220219                    Z=0.001*Z
Note: See TracChangeset for help on using the changeset viewer.