Changeset 3190 for inundation/pyvolution/util.py
- Timestamp:
- Jun 21, 2006, 9:31:57 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/util.py
r3176 r3190 548 548 reportname = None, 549 549 plot_quantity = None, 550 surface = None, 550 551 time_min = None, 551 552 time_max = None, … … 596 597 - default will be ['stage', 'speed', 'bearing'] 597 598 599 surface - if True, then generate solution surface with 3d plot 600 and save to current working directory 601 598 602 time_min - beginning of user defined time range for plotting purposes 599 603 - default will be first available time found in swwfile … … 631 635 reportname, 632 636 plot_quantity, 637 surface, 633 638 time_min, 634 639 time_max, … … 644 649 reportname = None, 645 650 plot_quantity = None, 651 surface = None, 646 652 time_min = None, 647 653 time_max = None, … … 670 676 check_list(plot_quantity) 671 677 678 if surface is None: 679 surface = False 680 672 681 if title_on is None: 673 682 title_on = True … … 727 736 if verbose: print 'Inputs OK - going to generate figures' 728 737 729 return generate_figures(plot_quantity, file_loc, report, reportname, leg_label,730 f_list, gauges, locations, elev, production_dirs,738 return generate_figures(plot_quantity, file_loc, report, reportname, surface, 739 leg_label, f_list, gauges, locations, elev, production_dirs, 731 740 time_min, time_max, title_on, label_id, verbose) 732 741 … … 789 798 return bearing 790 799 791 def generate_figures(plot_quantity, file_loc, report, reportname, leg_label, f_list, gauges, 792 locations, elev, production_dirs, time_min, time_max, 800 def generate_figures(plot_quantity, file_loc, report, reportname, surface, 801 leg_label, f_list, 802 gauges, locations, elev, production_dirs, time_min, time_max, 793 803 title_on, label_id, verbose): 794 804 795 805 from math import sqrt, atan, degrees 796 from Numeric import ones, allclose, zeros, Float 806 from Numeric import ones, allclose, zeros, Float, ravel 797 807 from os import sep, altsep, getcwd, mkdir, access, F_OK, environ 798 808 from pylab import ion, hold, plot, axis, figure, legend, savefig, \ 799 809 xlabel, ylabel, title, close, subplot 810 811 import pylab as p1 812 import mpl3d.mplot3d as p3 800 813 801 814 if report == True: … … 837 850 bearings = zeros((n0,m,p), Float) 838 851 depths = zeros((n0,m,p), Float) 852 eastings = zeros((n0,m,p), Float) 839 853 min_stages = [] 840 854 max_stages = [] … … 842 856 max_speeds = [] 843 857 c = 0 858 model_time_plot3d = zeros((n0,m), Float) 859 stages_plot3d = zeros((n0,m), Float) 860 eastings_plot3d = zeros((n0,m),Float) 844 861 ##### loop over each swwfile ##### 845 862 for j, f in enumerate(f_list): … … 858 875 fid_out.write(s) 859 876 #### generate quantities ####### 860 861 877 for i, t in enumerate(f.get_time()): 862 878 if time_min <= t <= time_max: … … 872 888 vel = m / (depth + 1.e-30) 873 889 bearing = calc_bearing(uh, vh) 874 model_time[i,k,j] = t/60.0 875 stages[i,k,j] = w 890 model_time[i,k,j] = t/60.0 891 stages[i,k,j] = w 876 892 elevations[i,k,j] = z 877 893 xmom[i,k,j] = uh … … 880 896 speed[i,k,j] = vel 881 897 bearings[i,k,j] = bearing 882 depths[i,k,j] = depth 898 depths[i,k,j] = depth 899 thisgauge = gauges[k] 900 eastings[i,k,j] = thisgauge[0] 883 901 s = '%.2f, %.2f, %.2f, %.2f\n' %(t, w, m, vel) 884 902 fid_out.write(s) … … 886 904 if w < min_stage: min_stage = w 887 905 if m > max_momentum: max_momentum = m 888 if vel > max_speed: max_speed = vel 889 906 if vel > max_speed: max_speed = vel 907 890 908 max_stages.append(max_stage) 891 909 min_stages.append(min_stage) 892 910 max_momentums.append(max_momentum) 893 911 max_speeds.append(max_speed) 912 #### finished generating quantities for each swwfile ##### 913 914 model_time_plot3d[:,:] = model_time[:,:,j] 915 stages_plot3d[:,:] = stages[:,:,j] 916 eastings_plot3d[:,] = eastings[:,:,j] 894 917 895 #### finished generating quantities for each swwfile ##### 896 918 if surface == True: 919 print 'Printing surface figure' 920 for i in range(2): 921 fig = p1.figure(10) 922 ax = p3.Axes3D(fig) 923 if len(gauges) > 80: 924 ax.plot_surface(eastings,model_time_plot3d,stages_plot3d) 925 #ax.plot_surface(eastings[:,:,j],model_time[:,:,j],stages[:,:,j]) 926 else: 927 #ax.plot_wireframe(eastings[:,:,j],model_time[:,:,j],stages[:,:,j]) 928 ax.plot_wireframe(eastings,model_time_plot3d,stages_plot3d) 929 #ax.plot3D(ravel(eastings[:,:,j]),ravel(model_time[:,:,j]),ravel(stages[:,:,j])) 930 ax.set_xlabel('x') 931 ax.set_ylabel('time') 932 ax.set_zlabel('stage') 933 fig.add_axes(ax) 934 p1.show() 935 surfacefig = 'solution_surface%s' %leg_label[j] 936 p1.savefig(surfacefig) 937 p1.close() 938 897 939 #### finished generating quantities for all swwfiles ##### 898 940 899 941 stage_axis = axis([time_min/60.0, time_max/60.0, min(min_stages), max(max_stages)*1.1]) 900 942 vel_axis = axis([time_min/60.0, time_max/60.0, min(max_speeds), max(max_speeds)*1.1]) … … 975 1017 mkdir (figdir) 976 1018 latex_file_loc = figdir.replace(sep,altsep) 977 # storing files in production directory 978 graphname_latex = '%sgauge%s%s' %(latex_file_loc, gaugeloc2, which_quantity) 979 # giving location in latex output file 980 graphname_report_input = '%sgauge%s%s' %('..'+altsep+'report_figures'+altsep, gaugeloc2, which_quantity) 1019 graphname_latex = '%sgauge%s%s' %(latex_file_loc, gaugeloc2, which_quantity) # storing files in production directory 1020 graphname_report_input = '%sgauge%s%s' %('..'+altsep+'report_figures'+altsep, gaugeloc2, which_quantity) # giving location in latex output file 981 1021 graphname_report.append(graphname_report_input) 982 1022 … … 991 1031 992 1032 if len(label_id) == 1: 993 # storing files in production directory 994 graphname_latex = '%sgauge%s%s%s' %(latex_file_loc, gaugeloc2, which_quantity, label_id2) 995 # giving location in latex output file 996 graphname_report = '%sgauge%s%s%s' %('..'+altsep+'report_figures'+altsep, gaugeloc2, which_quantity, label_id2) 1033 graphname_latex = '%sgauge%s%s%s' %(latex_file_loc, gaugeloc2, which_quantity, label_id2) # storing files in production directory 1034 graphname_report = '%sgauge%s%s%s' %('..'+altsep+'report_figures'+altsep, gaugeloc2, which_quantity, label_id2) # giving location in latex output file 997 1035 s = '\includegraphics[width=0.49\linewidth, height=50mm]{%s%s}' %(graphname_report, '.png') 998 1036 fid.write(s)
Note: See TracChangeset
for help on using the changeset viewer.