Changeset 2839
- Timestamp:
- May 9, 2006, 11:52:30 AM (18 years ago)
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/util.py
r2836 r2839 507 507 def sww2timeseries(swwfile, 508 508 gauge_filename, 509 file_loc,510 509 label_id, 510 report = None, 511 511 plot_quantity = None, 512 512 time_min = None, … … 530 530 such as a geospatial data object 531 531 532 file_loc - file location of sww file 533 - gauge graphs and data written to this directory 532 label_id - used in generating latex output. It will be part of 533 the directory name of file_loc (typically the timestamp). 534 Helps to differentiate latex files for different simulations 535 for a particular scenario. 536 537 report - if True, then write figures to report_figures directory in 538 relevant production directory 539 - if False, figures are already stored with sww file 540 - default to False 534 541 535 542 plot_quantity - list containing quantities to plot, they must … … 555 562 - default will be last available time found in swwfile 556 563 557 title_on - if True, export standard graphics 558 - if False, export graphics as eps and generate 559 latex output (how about png which is much smaller 560 and can still latex using pdflatex?) 561 - latex output to be written to same directory as 562 where this function is being used from and named 563 according to scenario name 564 565 label_id - used in generating latex output. It will generally 566 be part of the directory name of file_loc (the 567 time stamp, if using that). Helps to differentiate 568 between runs within a particular scenario. 564 title_on - if True, export standard graphics with title 565 - if False, export standard graphics without title 569 566 570 567 Output: … … 572 569 - time series data stored in .csv for later use if required. 573 570 Name = gauges_timeseries followed by gauge name 574 - if title_on = False then output latex file will be generated575 in same directory as where script is run (usually production576 scenario direcotry. Name = latexoutpulabel_id.tex571 - latex file will be generated in same directory as where script is 572 run (usually production scenario direcotry. 573 Name = latexoutputlabel_id.tex 577 574 578 575 Other important information: … … 588 585 k = _sww2timeseries(swwfile, 589 586 gauge_filename, 590 file_loc,591 587 label_id, 588 report, 592 589 plot_quantity, 593 590 time_min, … … 600 597 def _sww2timeseries(swwfile, 601 598 gauge_filename, 602 file_loc,603 599 label_id, 600 report = None, 604 601 plot_quantity = None, 605 602 time_min = None, … … 618 615 raise msg 619 616 617 index = swwfile.rfind(sep) 618 file_loc = swwfile[:index+1] 619 620 620 assert type(gauge_filename) == type(''),\ 621 621 'Gauge filename must be a string' … … 627 627 %(gauge_filename, e) 628 628 raise msg 629 630 if report is None: 631 report = False 629 632 630 633 assert type(plot_quantity) == list,\ … … 644 647 if verbose: print '\n Gauges obtained from: %s \n' %gauge_filename 645 648 gauges, locations = get_gauges_from_file(gauge_filename) 646 647 #from pyvolution.util import file_function648 649 649 650 sww_quantity = ['stage', 'elevation', 'xmomentum', 'ymomentum'] … … 674 675 675 676 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] 680 681 return generate_figures(plot_quantity, file_loc, f, gauges, locations, 677 678 return generate_figures(plot_quantity, file_loc, report, 679 f, gauges, locations, 682 680 time_min, time_max, title_on, label_id, verbose) 683 681 … … 736 734 return bearing 737 735 738 def generate_figures(plot_quantity, file_loc, f, gauges,736 def generate_figures(plot_quantity, file_loc, report, f, gauges, 739 737 locations, time_min, time_max, title_on, label_id, verbose): 740 738 … … 742 740 from Numeric import ones 743 741 from os import sep, altsep, getcwd, mkdir, access, F_OK, environ 744 from os.path import expanduser745 742 from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close 746 743 747 744 filename = file_loc.split(sep) 748 745 749 if title_on == False: 750 #ext = '.eps' 751 ext = '' 746 if report == True: 752 747 label_id1 = label_id.replace(sep,'') 753 748 label_id2 = label_id1.replace('_','') … … 755 750 texfilename = texfile + '.tex' 756 751 if verbose: print '\n Latex output printed to %s \n' %texfilename 752 757 753 fid = open(texfilename, 'w') 758 754 s = '\\begin{center} \n \\begin{tabular}{|l|l|l|}\hline \n \\bf{Gauge Name} & \\bf{Easting} & \\bf{Northing} \\\\ \hline \n' … … 768 764 fid.write(s) 769 765 else: 770 texfilename = '' 771 ext = '' 766 texfile = '' 772 767 773 768 ##### loop over each gauge ##### … … 857 852 858 853 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 873 if title_on == True: 874 title('%s scenario: %s at %s gauge' 875 %(label_id, which_quantity, gaugeloc)) 876 savefig(graphname) 877 else: 854 graphname = '%sgauge%s_%s' %(file_loc, gaugeloc1, which_quantity) 855 856 if report == True: 857 858 figdir = getcwd()+sep+'report_figures'+sep 859 if access(figdir,F_OK) == 0 : 860 mkdir (figdir) 861 latex_file_loc = figdir.replace(sep,altsep) 862 863 # storing files in production directory 864 graphname_latex = '%sgauge%s%s%s' %(latex_file_loc, gaugeloc1, which_quantity, label_id2) 865 # giving location in latex output file 866 graphname_report = '%sgauge%s%s%s' %('report_figures'+altsep, gaugeloc1, which_quantity, label_id2) 867 878 868 label = '%s%sgauge%s' %(label_id2, which_quantity, gaugeloc1) 879 869 caption = 'Time series for %s at %s gauge location' %(which_quantity, gaugeloc) … … 882 872 s = '\\caption{%s} \n \label{fig:%s} \n \end{figure} \n \n' %(caption, label) 883 873 fid.write(s) 884 savefig(graphname_latex) 874 savefig(graphname_latex) # save figures in production directory for report generation 885 875 876 if title_on == True: 877 title('%s scenario: %s at %s gauge' %(label_id, which_quantity, gaugeloc)) 878 879 savefig(graphname) # save figures with sww file 880 881 886 882 thisfile = file_loc+sep+'gauges_time_series'+'_'+gaugeloc+'.csv' 887 883 fid_out = open(thisfile, 'w') -
production/onslow_2006/make_report.py
r2837 r2839 4 4 Inputs: 5 5 6 Report title:title to be included in tex file7 latex_output: list of latex_outputs which are 8 generated for the desired output, eg high tide,9 low tide and MSL.6 report_title: title to be included in tex file 7 production dirs: dictionary of production directories with a 8 association to that simulation run, eg high tide, 9 low tide and MSL. 10 10 11 11 … … 28 28 * Appendix: Metadata 29 29 30 Other files included in document :30 Other files included in document which require manual intervention: 31 31 32 32 * an abstract must be written in abstract.tex … … 50 50 p = getcwd().split(sep) 51 51 scenario = p[-1] # Last element of absolute CWD path 52 scenario_name = scenario.split('_')[0] # Strip any text past `_` 52 scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` 53 test = scenario_name.split('_') 54 if len(test) <> 1: 55 scenario_name = '%s %s' %(test[0], test[1]) 53 56 54 57 # User defined inputs 55 58 report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title() 56 59 57 production_dirs = ['20060424_020426_duplictate_time_steps', 58 '20060426_004129'] 59 60 production_dirs = {'20060424_020426_duplictate_time_steps': 'Highest Astronomical Tide', 61 '20060426_004129': 'Lowest Astronomical Tide'} 60 62 61 63 # Create sections and graphs for each designated production directory 62 64 latex_output = [] 63 for label_id in production_dirs :65 for label_id in production_dirs.keys(): 64 66 65 67 file_loc = project.outputdir + label_id + sep … … 68 70 texname = sww2timeseries(swwfile, 69 71 project.gauge_filename, 70 file_loc,71 72 label_id, 73 report = True, 72 74 plot_quantity = ['stage', 'velocity', 'bearing'], 73 75 time_min = None, … … 115 117 \\textwidth \paperwidth 116 118 \\advance\\textwidth -2in 119 117 120 """ 118 121 fid.write(s) … … 121 124 fid.write(s) 122 125 123 s = 124 """ 125 \date{\today} 126 s = """ 127 \date{\\today} 126 128 \\begin{document} 127 129 \maketitle … … 149 151 \input{results} 150 152 \input{interpretation} 153 151 154 """ 152 155 fid.write(s) 153 156 154 155 156 157 # Assign titles to each production section 157 158 # Must specify one name per section 158 for i, s in enumerate(['\subsection{Highest Astronomical Tide} \n', 159 '\subsection{Lowest Astronomical Tide} \n', 160 '\subsection{} \n']): 161 159 for i, name in enumerate(production_dirs.keys()): 160 161 s = '\subsection{%s} \n \n' %production_dirs[name] 162 162 fid.write(s) 163 163 164 s = '\input{%s} \n \clearpage \n ' %latex_output[i]164 s = '\input{%s} \n \clearpage \n \n' %latex_output[i] 165 165 fid.write(s) 166 166 167 167 168 168 # Closing 169 s = 170 """\section{Summary} 169 s = """\section{Summary} 171 170 \input{summary} 172 171 173 172 \section{References} 173 174 174 \section{Metadata} 175 175 \label{sec:metadata} 176 176 \input{metadata} 177 177 178 \end{document} 178 179 """ -
production/onslow_2006/onslow_2006_report.tex
r2831 r2839 1 \documentclass{article} 2 \usepackage{ae} % or {zefonts} 3 \usepackage[T1]{fontenc} 4 \usepackage[ansinew]{inputenc} 5 \usepackage{amsmath} 6 \usepackage{amssymb} 7 \usepackage{graphicx} 8 \usepackage{color} 9 \usepackage[colorlinks]{hyperref} 10 \usepackage{lscape} %landcape pages support 11 \topmargin 0pt 12 \oddsidemargin 0pt 13 \evensidemargin 0pt 14 \marginparwidth 0.5pt 15 \textwidth \paperwidth 16 \advance\textwidth -2in 1 2 % This is based on an automatically generated file (by make_report.py). 3 % 4 % Manual parts are: 5 % * an abstract must be written in abstract.tex 6 % * an introduction must be written in introduction.tex; a basic outline and 7 % some of the core inputs are already in place 8 % * an interpretation.tex file needs to be written for the particular scenario 9 % * any data issues must be included in data_issues.tex (data.tex should 10 % be revised for future reports) 11 % * the tsunami-genic event should be discussed in tsunami_scenario.tex 12 % * a summary must be written into summary.tex 13 % * metadata for the scenario data to be included in metadata.tex 14 15 \documentclass{article} 16 17 \usepackage{ae} % or {zefonts} 18 \usepackage[T1]{fontenc} 19 \usepackage[ansinew]{inputenc} 20 \usepackage{amsmath} 21 \usepackage{amssymb} 22 \usepackage{graphicx} 23 \usepackage{color} 24 \usepackage[colorlinks]{hyperref} 25 \usepackage{lscape} %landcape pages support 26 27 \topmargin 0pt 28 \oddsidemargin 0pt 29 \evensidemargin 0pt 30 \marginparwidth 0.5pt 31 \textwidth \paperwidth 32 \advance\textwidth -2in 33 17 34 \title{Tsunami impact modelling for the North West shelf: Onslow} 18 \date{} 19 \begin{document} 20 \maketitle 21 \begin{abstract} 22 \input{abstract} 23 \end{abstract} 24 \tableofcontents 25 \section{Introduction} 26 \label{sec:intro} 27 \input{introduction} 28 \section{Data sources} 29 \label{sec:data} 30 \input{data} 31 \section{Tsunami scenarios} 32 \label{sec:tsunami_scenarios} 33 \input{tsunami_scenario} 34 \section{Inundation modelling results} 35 \label{sec:results} 36 \input{results} 37 \input{interpretation} 38 \subsection{Highest Astronomical Tide} 35 36 \date{\today} 37 \begin{document} 38 \maketitle 39 40 \begin{abstract} 41 \input{abstract} 42 \end{abstract} 43 44 \tableofcontents 45 46 \section{Introduction} 47 \label{sec:intro} 48 \input{introduction} 49 50 \section{Data sources} 51 \label{sec:data} 52 \input{data} 53 54 \section{Tsunami scenarios} 55 \label{sec:tsunami_scenarios} 56 \input{tsunami_scenario} 57 58 \section{Inundation modelling results} 59 \label{sec:results} 60 \input{results} 61 \input{interpretation} 62 63 \subsection{Highest Astronomical Tide} 64 39 65 \input{latexoutput20060424020426duplictatetimesteps} 40 66 \clearpage 67 41 68 \subsection{Lowest Astronomical Tide} 69 42 70 \input{latexoutput20060426004129} 43 71 \clearpage 44 \section{Summary} 45 \input{summary} 46 \section{References} 47 \section{Metadata} 48 \label{sec:metadata} 49 \input{metadata} 50 \end{document} 72 73 \section{Summary} 74 \input{summary} 75 76 \section{References} 77 78 \section{Metadata} 79 \label{sec:metadata} 80 \input{metadata} 81 82 \end{document} -
production/onslow_2006/run_timeseries.py
r2815 r2839 4 4 import project 5 5 from os import sep 6 from shutil import copy7 6 8 7 # define directory location of sww and gauge data … … 10 9 file_loc = project.outputdir + timestampdir + sep #project.outputtimedir 11 10 swwfile = file_loc + project.basename + '.sww' 12 gauge_filename = project.gauge_filename13 11 label_id = timestampdir 14 15 # False to generate latex output, True otherwise16 title_on = True17 12 18 13 # generate figures - see sww2timeseries for documentation 19 14 texname = sww2timeseries(swwfile, 20 gauge_filename, 21 file_loc, 15 project.gauge_filename, 22 16 label_id, 17 report = False, 23 18 plot_quantity = ['stage', 'velocity', 'bearing'], 24 19 time_min = None, 25 20 time_max = None, 26 title_on = title_on,21 title_on = True, 27 22 verbose = True) 28 23
Note: See TracChangeset
for help on using the changeset viewer.