Changeset 2905 for inundation/pyvolution/util.py
- Timestamp:
- May 18, 2006, 11:01:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/util.py
r2891 r2905 529 529 - structure which can be converted to a Numeric array, 530 530 such as a geospatial data object 531 531 532 532 label_id - used in generating latex output. It will be part of 533 533 the directory name of file_loc (typically the timestamp). … … 564 564 title_on - if True, export standard graphics with title 565 565 - if False, export standard graphics without title 566 567 566 568 567 569 Output: … … 641 643 if title_on is None: 642 644 title_on = True 643 645 644 646 assert type(label_id) == type(''),\ 645 647 'label_id to sww2timeseries must be a string' … … 677 679 678 680 if verbose: print 'Inputs OK - going to generate figures' 679 681 680 682 return generate_figures(plot_quantity, file_loc, report, 681 683 f, gauges, locations, … … 895 897 896 898 return texfile 899 900 def plot_polygons(bounding_polygon, 901 interior_polygon, 902 verbose = False): 903 904 """ Take bounding and interior polygons and plot. 905 906 Inputs: 907 908 bounding_polygon - polygon used in create_mesh_from_regions 909 910 interior_polygon - list of polygons used in create_mesh_from_regions 911 912 913 Output: 914 915 - plot named = polygon_plot.png 916 917 918 """ 919 920 921 k = _plot_polygons(bounding_polygon, 922 interior_polygon, 923 verbose) 924 925 return k 926 927 def _plot_polygons(bounding_polygon, 928 interior_polygon, 929 verbose = False): 930 931 from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close 932 933 assert type(bounding_polygon) == list,\ 934 'bounding_polygon must be a list' 935 936 assert type(interior_polygon) == list,\ 937 'interior_polygon must be a list' 938 939 ion() 940 hold(True) 941 942 x_bound, y_bound = poly_xy(bounding_polygon) 943 944 for i in range(len(interior_polygon)): 945 x_int, y_int = poly_xy(interior_polygon[i]) 946 plot(x_bound,y_bound,'r-',x_int,y_int,'g-') 947 xlabel('x') 948 ylabel('y') 949 950 savefig('polygon_plot') 951 952 close('all') 953 954 return 955 956 def poly_xy(poly): 957 x = [] 958 y = [] 959 n = len(poly) 960 for i in range(n+1): 961 if i == n: 962 thispt = poly[0] 963 else: 964 thispt = poly[i] 965 x.append(thispt[0]) 966 y.append(thispt[1]) 967 968 return x, y
Note: See TracChangeset
for help on using the changeset viewer.