Changeset 1824


Ignore:
Timestamp:
Sep 13, 2005, 10:52:08 AM (19 years ago)
Author:
ole
Message:

Rewrote boundary_stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/domain.py

    r1753 r1824  
    336336                    self.number_of_first_order_steps)
    337337
    338     def boundary_stats(self, quantities = None, tag = None):
    339         """Output statistics about boundary forcing
    340 
    341 
    342         """
    343 
     338    def boundary_stats(self, quantities = None, tags = None):
     339        """Output statistics about boundary forcing at each timestep
     340
     341        Example
     342        Tag 'wall':
     343            stage in [2, 5.5]
     344            xmomentum in []
     345            ymomentum in []
     346        Tag 'ocean'
     347
     348        quantities and tags can be either None, a string or a list of strings
     349
     350        If quantitites are specified only report on those. Otherwise take all conserved quantities.
     351        If tags are specified only report on those, otherwise take all tags.
     352
     353        #FIXME: Should return text string
     354        """
     355
     356        #Input checks
     357        import types
     358       
    344359        if quantities is None:
    345360            quantities = self.conserved_quantities
    346 
     361        elif type(quantities) == types.StringType:
     362            quantities = [quantities] #Turn it into a list
     363
     364        msg = 'Keyword argument quantities must be either None, '
     365        msg += 'string or list. I got %s' %str(quantitites)   
     366        assert type(quantities) == types.ListType, msg
     367           
     368
     369        if tag is None:
     370            tags = self.get_boundary_tags()
     371        elif type(tags) == types.StringType:
     372            tags = [tags] #Turn it into a list
     373
     374        msg = 'Keyword argument tags must be either None, '
     375        msg += 'string or list. I got %s' %str(quantitites)   
     376        assert type(tags) == types.ListType, msg           
     377
     378
     379        #Output stats   
    347380
    348381        print 'Boundary values at time %.4f:' %self.time
    349         for name in quantities:
    350             q = self.quantities[name]
    351 
    352             if tag is None:
    353                 #Take entire boundary
    354                 print '    Quantity %s: min = %12.8f, max = %12.8f'\
    355                       %(name, min(q.boundary_values), max(q.boundary_values))
    356             else:
    357                 #Take only boundary associated with tag
     382
     383        for tag in tags:
     384            print '    Tag: %s' %tag
     385
     386            for name in quantities:
     387                q = self.quantities[name]
     388
     389                #Find range of boundary values for tag and q
    358390                maxval = minval = None
    359391                for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects):
     
    364396
    365397                if minval is None or maxval is None:
    366                     print 'Sorry no information about tag %s' %tag
     398                    print 'Sorry no information about tag %s and quantity %s' %(tag, name)
    367399                else:
    368                     print '    Quantity %s, tag %s: min = %12.8f, max = %12.8f'\
    369                           %(name, tag, minval, maxval)
     400                    print '        %s\t in [%12.8f, %12.8f]'\
     401                          %(name, minval, maxval)
     402
     403
     404           
     405       
     406        #for name in quantities:
     407        #    q = self.quantities[name]
     408        #
     409        #    if tag is None:
     410        #        #Take entire boundary
     411        #        print '    Quantity %s: min = %12.8f, max = %12.8f'\
     412        #              %(name, min(q.boundary_values), max(q.boundary_values))
     413        #    else:
     414        #        #Take only boundary associated with tag
     415        #        maxval = minval = None
     416        #        for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects):
     417        #            if self.boundary[(vol_id, edge_id)] == tag:
     418        #                v = q.boundary_values[i]
     419        #                if minval is None or v < minval: minval = v
     420        #                if maxval is None or v > maxval: maxval = v
     421        #
     422        #        if minval is None or maxval is None:
     423        #            print 'Sorry no information about tag %s' %tag
     424        #        else:
     425        #            print '    Quantity %s, tag %s: min = %12.8f, max = %12.8f'\
     426        #                  %(name, tag, minval, maxval)
    370427
    371428
Note: See TracChangeset for help on using the changeset viewer.