Changeset 2908


Ignore:
Timestamp:
May 18, 2006, 11:57:18 AM (18 years ago)
Author:
sexton
Message:

changes to plotting polygons

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/util.py

    r2905 r2908  
    900900def plot_polygons(bounding_polygon,
    901901                  interior_polygon,
     902                  figname,
    902903                  verbose = False):
    903904   
     
    909910   
    910911    interior_polygon - list of polygons used in create_mesh_from_regions
    911                    
    912                      
    913     Output:
    914    
    915     - plot named = polygon_plot.png
    916 
    917                      
     912                       
     913    figname          - name to save figure to
     914                   
    918915    """
    919916
     
    921918    k = _plot_polygons(bounding_polygon,
    922919                       interior_polygon,
     920                       figname,
    923921                       verbose)
    924922
     
    927925def _plot_polygons(bounding_polygon,
    928926                   interior_polygon,
     927                   figname,
    929928                   verbose = False):   
    930929
     
    944943    for i in range(len(interior_polygon)):
    945944        x_int, y_int = poly_xy(interior_polygon[i])
    946         plot(x_bound,y_bound,'r-',x_int,y_int,'g-')
     945        plot(x_bound,y_bound,'r-',x_int,y_int,'r-')
    947946        xlabel('x')
    948947        ylabel('y')
    949948
    950     savefig('polygon_plot')
     949    savefig(figname)
    951950
    952951    close('all')
  • production/onslow_2006/plot_data_extent.py

    r2860 r2908  
    66from utilities.polygon import inside_polygon
    77import project
    8 
     8from pyvolution.util import plot_polygons
    99
    1010datadir = project.datadir
    1111ion()
    12 hold(False)
     12
     13plot_data = True
     14plot_with_poly = False
     15
     16if plot_data == True:
     17    file1 = datadir+'onslow_onshore_30m_dted.pts'
     18    file2 = datadir+'onslow_offshore_points.xya'
     19
     20    G1 = Geospatial_data(file_name = file1)
     21    G2 = Geospatial_data(file_name = file2)
     22
     23    pts1 = G1.get_data_points(absolute = True)
     24    pts2 = G2.get_data_points(absolute = True)
     25
     26    if plot_with_poly == True:
     27        figname = 'onslow_data_poly'
     28        figure(1)
     29        plot(pts1[:,0],pts1[:,1],'g.',
     30             pts2[:,0],pts2[:,1],'b.')
     31        plot_polygons(project.polyAll,
     32                      [project.poly_onslow, project.poly_coast, project.poly_region],
     33                      figname,
     34                      verbose = True)
     35        axis([])
     36        savefig(figname)
     37    else:
     38        figure(2)
     39        plot(pts1[:,0],pts1[:,1],'g.',
     40             pts2[:,0],pts2[:,1],'b.')
     41        xlabel('x')
     42        ylabel('y')
     43        savefig('onslow_data_extent')
     44else:
    1345   
    14 file1 = datadir+'onslow_onshore_30m_dted.pts'
    15 file2 = datadir+'onslow_offshore_points.xya'
     46    figure(3)
     47    figname = 'onslow_polys'
     48    plot_polygons(project.polyAll,
     49                 [project.poly_onslow, project.poly_coast, project.poly_region],
     50                  figname,
     51                  verbose = True)
    1652
    17 G1 = Geospatial_data(file_name = file1)
    18 G2 = Geospatial_data(file_name = file2)
    19 
    20 pts1 = G1.get_data_points(absolute = True)
    21 pts2 = G2.get_data_points(absolute = True)
    22 z1 = G1.get_attributes()
    23 z2 = G2.get_attributes()
    24 
    25 minz1 = min(z1)
    26 maxz1 = max(z1)
    27 minz2 = min(z2)
    28 maxz2 = max(z2)
    29 
    30 print ''
    31 print 'Offshore elevation in range [%.2f %.2f]   ' %(minz1, maxz1)
    32 print 'Onshore elevation in range [%.2f %.2f]   ' %(minz2, maxz2)
    33 print ''
    34 
    35 minelev = min(minz1,minz2)
    36 maxelev = max(maxz1,maxz2)
    37 
    38 # bounding polygon for Onslow scenario
    39 polygon_bound = project.polyAll
    40 
    41 x_bound = []
    42 y_bound = []
    43 n = len(polygon_bound)
    44 for i in range(n+1):
    45     if i == n:
    46         thispt = polygon_bound[0]
    47     else:
    48         thispt = polygon_bound[i]
    49     x_bound.append(thispt[0])
    50     y_bound.append(thispt[1])
    51 
    52 # interior regions
    53 figure(1)
    54 plot(pts1[:,0],pts1[:,1],'g.',
    55      pts2[:,0],pts2[:,1],'b.',
    56      x_bound,y_bound,'r-')
    57 #title('Offhore (g) and onshore (b) data: Onslow scenario. \n Elevation in range [%.2f %.2f]' %(minelev, maxelev))
    58 xlabel('x')
    59 ylabel('y')
    60 savefig('onslow_data_extent')
    61 
    62 
     53close('all')
  • production/pt_hedland_2006/run_pt_hedland.py

    r2904 r2908  
    139139        count += 1
    140140
     141figname = 'pt_hedland_polys'
    141142plot_polygons(project.polyAll,
    142143              [project.poly_pt_hedland, project.poly_region],
     144              figname,
    143145              verbose = True)
    144146
     
    147149else:
    148150    print 'check out your interior polygons'
    149     print 'check polygon_plot.png in production directory'
     151    print 'check %s in production directory' %figname
    150152    import sys; sys.exit()
    151153   
Note: See TracChangeset for help on using the changeset viewer.