Changeset 2836
- Timestamp:
- May 8, 2006, 4:55:59 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/util.py
r2808 r2836 574 574 - if title_on = False then output latex file will be generated 575 575 in same directory as where script is run (usually production 576 scenario direcotry. Name = latex _output_label_id.tex576 scenario direcotry. Name = latexoutpulabel_id.tex 577 577 578 578 Other important information: … … 606 606 time_max = None, 607 607 title_on = None, 608 verbose = False): 609 610 from pylab import * #FIXME (Ole): List actual functions used rather than * 611 608 verbose = False): 612 609 613 610 assert type(swwfile) == type(''),\ … … 677 674 678 675 if verbose: print 'Inputs OK - going to generate figures' 676 677 # could try different approach for file_loc: 678 # index = swwfile.find(basename.sww) 679 # file_loc = swwfile[:index-1] 679 680 680 681 return generate_figures(plot_quantity, file_loc, f, gauges, locations, … … 739 740 740 741 from math import sqrt, atan, degrees 741 from os import sep, altsep 742 from Numeric import ones 743 from os import sep, altsep, getcwd, mkdir, access, F_OK, environ 744 from os.path import expanduser 745 from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close 742 746 743 747 filename = file_loc.split(sep) … … 746 750 #ext = '.eps' 747 751 ext = '' 748 texfilename = 'latex_output_%s.tex' %(label_id.replace(sep,'_')) 752 label_id1 = label_id.replace(sep,'') 753 label_id2 = label_id1.replace('_','') 754 texfile = 'latexoutput%s' %(label_id2) 755 texfilename = texfile + '.tex' 749 756 if verbose: print '\n Latex output printed to %s \n' %texfilename 750 757 fid = open(texfilename, 'w') … … 820 827 figure(i+1, frameon = False) 821 828 if which_quantity == 'depth': 822 plot(model_time, depths, ' g-')829 plot(model_time, depths, '-') 823 830 units = 'm' 824 831 if which_quantity == 'stage': 825 plot(model_time, stages, ' g-')832 plot(model_time, stages, '-') 826 833 units = 'm' 827 834 if which_quantity == 'momentum': 828 plot(model_time, momenta, ' g-')835 plot(model_time, momenta, '-') 829 836 units = 'm^2 / sec' 830 837 if which_quantity == 'xmomentum': 831 plot(model_time, xmom, ' g-')838 plot(model_time, xmom, '-') 832 839 units = 'm^2 / sec' 833 840 if which_quantity == 'ymomentum': 834 plot(model_time, ymom, ' g-')841 plot(model_time, ymom, '-') 835 842 units = 'm^2 / sec' 836 843 if which_quantity == 'velocity': 837 plot(model_time, velocity, ' g-')844 plot(model_time, velocity, '-') 838 845 units = 'm / sec' 839 846 if which_quantity == 'bearing': 840 847 due_east = 90.0*ones([len(model_time)]) 841 848 due_west = 270.0*ones([len(model_time)]) 842 plot(model_time, bearings, ' r-', model_time, due_west, '-.g',843 model_time, due_east, '-. b')849 plot(model_time, bearings, '-', model_time, due_west, '-.', 850 model_time, due_east, '-.') 844 851 units = 'degrees from North' 845 852 ax = axis([time_min, time_max, 0, 360]) … … 849 856 ylabel('%s (%s)' %(which_quantity, units)) 850 857 851 gaugeloc1 = gaugeloc.replace(' ','_') 852 graphname = '%sgauge_%s_%s%s' %(file_loc, gaugeloc1, which_quantity, ext) 853 latex_file_loc = file_loc.replace(sep,altsep) 854 graphname_latex = '%sgauge_%s_%s_report%s' %(latex_file_loc, gaugeloc1, which_quantity, ext) 855 858 gaugeloc1 = gaugeloc.replace(' ','') 859 graphname = '%sgauge%s_%s%s' %(file_loc, gaugeloc1, which_quantity, ext) 860 figdir = getcwd()+sep+'report_figures'+sep 861 if access(figdir,F_OK) == 0 : 862 mkdir (figdir) 863 latex_file_loc = figdir.replace(sep,altsep) 864 865 graphname_latex = '%sgauge%s%s%s%s' %(latex_file_loc, gaugeloc1, which_quantity, label_id2, ext) 866 867 p = getcwd().split(sep) 868 scenario = p[len(p)-1] 869 home = expanduser('~') 870 report_fig_loc = '~'+altsep+'anuga'+altsep+'production'+altsep+scenario+altsep+'report_figures'+altsep 871 graphname_report = '%sgauge%s%s%s%s' %('report_figures'+altsep, gaugeloc1, which_quantity, label_id2, ext) 872 856 873 if title_on == True: 857 874 title('%s scenario: %s at %s gauge' … … 859 876 savefig(graphname) 860 877 else: 861 label = '%s _%s_gauge_%s' %(label_id.replace(sep,'_'), which_quantity, gaugeloc1)862 caption = 'Time series for %s ' %(which_quantity)863 s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width= 75mm, height=75mm]{%s}} \n' %(graphname_latex)878 label = '%s%sgauge%s' %(label_id2, which_quantity, gaugeloc1) 879 caption = 'Time series for %s at %s gauge location' %(which_quantity, gaugeloc) 880 s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width=100mm, height=75mm]{%s%s}} \n' %(graphname_report, '.png') 864 881 fid.write(s) 865 882 s = '\\caption{%s} \n \label{fig:%s} \n \end{figure} \n \n' %(caption, label) … … 879 896 close('all') 880 897 881 return texfile name898 return texfile
Note: See TracChangeset
for help on using the changeset viewer.