Changeset 4845


Ignore:
Timestamp:
Nov 22, 2007, 1:54:53 PM (16 years ago)
Author:
sexton
Message:

generate plot to show interpolation points (which could be the model domain) with polygon of boundary file

Location:
anuga_core/source/anuga
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r4839 r4845  
    565565            # Plot boundary and interpolation points
    566566            # FIXME (Jane): Here's a beginning towards plotting
    567             #if verbose is True:
    568             #    from anuga.utilities.polygon import plot_polygons
    569             #    from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close               
    570             #    plot_polygons([mesh_boundary_polygon],
    571             #                  verbose=verbose)
    572 
    573                 # Add cloud of interpolation points to polygon plot
    574             #    x = interpolation_points[:,0]
    575             #    y = interpolation_points[:,1]               
    576             #    plot(x, y, 'b.')
    577             #    title('Interpolation function: Polygon and interpolation points')
    578            
     567            if verbose is True:
     568                from anuga.utilities.polygon import plot_polygons_points
     569                title = 'Interpolation function: Polygon and interpolation points'
     570                plot_polygons_points([mesh_boundary_polygon,interpolation_points],
     571                                     ['line','point'],label=title,verbose=verbose)
    579572
    580573            m = len(self.interpolation_points)
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r4833 r4845  
    49294929        #                              domain2)
    49304930        Bf = Field_boundary(domain1.get_name() + '.' + domain1.format,
    4931                             domain2, mean_stage=mean_stage)
     4931                            domain2, mean_stage=mean_stage, verbose=False)
    49324932       
    49334933        domain2.set_boundary({'right':Br, 'bottom':Br, 'diagonal':Bf})
     
    51035103        #                              domain2)
    51045104        Bf = Field_boundary(domain1.get_name() + '.' + domain1.format,
    5105                             domain2, mean_stage=1)
     5105                            domain2, mean_stage=1, verbose=True)
    51065106       
    51075107        domain2.set_boundary({'right':Br, 'bottom':Br, 'diagonal':Bf})
  • anuga_core/source/anuga/utilities/polygon.py

    r4769 r4845  
    341341    return abs(poly_area/2)
    342342
    343 def plot_polygons(polygons, figname=None, verbose=False):
     343def plot_polygons_points(polygons_points, style=None, figname=None, label=None, verbose=False):
    344344   
    345345    """ Take list of polygons and plot.
     
    348348
    349349    polygons         - list of polygons
     350
     351    style            - style list corresponding to each polygon
    350352                       
    351353    figname          - name to save figure to
     354
     355    label            - title for plot
    352356
    353357    Outputs:
     
    357361    """
    358362
    359     from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close
    360 
    361     assert type(polygons) == list,\
    362                'input must be a list of polygons'
     363    from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close, title
     364
     365    assert type(polygons_points) == list,\
     366               'input must be a list of polygons and/or points'
    363367               
    364368    ion()
     
    369373    miny = 1e10
    370374    maxy = 0.0
    371    
    372     for polygon in polygons:
    373         x, y = poly_xy(polygon) 
     375
     376    if label is None: label = ''
     377   
     378    n = len(polygons_points)
     379    if style is None:
     380        style_type = 'line'
     381        style = []
     382        for i in range(n):
     383            style.append(style_type)
     384       
     385    for i, item in enumerate(polygons_points):
     386        x, y = poly_xy(item) 
    374387        if min(x) < minx: minx = min(x)
    375388        if max(x) > maxx: maxx = max(x)
    376389        if min(y) < miny: miny = min(y)
    377390        if max(y) > maxy: maxy = max(y)
    378         plot(x,y,'r-')
     391        if style[i] is 'line':
     392            plot(x,y,'b-')
     393        else:
     394            plot(x,y,'r.')
    379395        xlabel('x')
    380396        ylabel('y')
    381 
    382     if figname is not None:   
     397        title(label)
     398
     399    if figname is not None:
    383400        savefig(figname)
    384401    else:
    385         raw_input('Press a key to continue')
     402        savefig('test_image')
    386403
    387404    close('all')
Note: See TracChangeset for help on using the changeset viewer.