Changeset 9191


Ignore:
Timestamp:
Jun 18, 2014, 6:42:46 PM (10 years ago)
Author:
steve
Message:

Now get_output can deal with a scalar timeSlices

Location:
trunk/anuga_core/source/anuga/utilities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/plot_utils.py

    r9190 r9191  
    236236        inds='max' #
    237237    else:
    238         inds=list(timeSlices)
     238        try:
     239            inds=list(timeSlices)
     240        except:
     241            inds=[timeSlices]
    239242   
    240243    if(inds is not 'max'):
     
    421424        inds='max' #
    422425    else:
    423         inds=list(timeSlices)
     426        try:
     427            inds=list(timeSlices)
     428        except:
     429            inds=[timeSlices]
    424430   
    425431    if(inds is not 'max'):
     
    873879    if(swwFile is not None):
    874880        # Read in ANUGA outputs
     881       
     882        # Ensure myTimeStep is a list
     883        if type(myTimeStep)!=list:
     884            myTimeStep=[myTimeStep]
     885           
    875886        if(verbose):
    876887            print 'Reading sww File ...'
     
    890901            myTimeStep=range(len(p2.time))
    891902
    892         # Ensure myTimeStep is a list
    893         if type(myTimeStep)!=list:
    894             myTimeStep=[myTimeStep]
    895903
    896904        if(verbose):
  • trunk/anuga_core/source/anuga/utilities/test_plot_utils.py

    r9160 r9191  
    164164        self.everything_equal(pc_12, 0, p2, 0)
    165165        self.everything_equal(pc_12, 1, p2, 3)
     166       
     167
     168        # Try getting some time-slices, and checking all is as intended
     169        p_12a=util.get_output('test_plot_utils.sww', timeSlices=3)
     170        pc_12a=util.get_centroids(p_12a,velocity_extrapolation=ve)
     171
     172        #print p_12a.timeSlices
     173        #print pc_12a.timeSlices
     174        assert(p_12a.timeSlices==[3])
     175        assert(pc_12a.timeSlices==[3])
     176
     177        self.everything_equal(p_12a, 0, p, 3)
     178        self.everything_equal(pc_12a, 0, p2, 3)
     179       
     180
     181        # Try getting some time-slices, and checking all is as intended
     182        p_12b=util.get_output('test_plot_utils.sww')
     183        pc_12b=util.get_centroids(p_12b,velocity_extrapolation=ve, timeSlices=3)
     184
     185        #print p_12b.timeSlices
     186        #print pc_12b.timeSlices
     187        assert(p_12b.timeSlices==[0, 1, 2, 3, 4, 5])
     188        assert(pc_12b.timeSlices==[3])
     189
     190        self.everything_equal(p_12b, 0, p, 0)
     191        self.everything_equal(p_12b, 5, p, 5)
     192        self.everything_equal(pc_12b, 0, p2, 3)
     193       
    166194
    167195        # Check we can get the 'last' time, and it is correct
Note: See TracChangeset for help on using the changeset viewer.