[2815] | 1 | """ |
---|
| 2 | Generate report for production run |
---|
| 3 | |
---|
| 4 | Inputs: |
---|
| 5 | |
---|
[2839] | 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. |
---|
[2815] | 10 | |
---|
| 11 | |
---|
| 12 | Outputs: |
---|
| 13 | |
---|
| 14 | * Report generated to scenario_report.tex where the scenario relates |
---|
| 15 | the name of the production directory this script is being run from. |
---|
[2837] | 16 | * figures used for report stored in the report_figure directory |
---|
[2815] | 17 | NOTE, this directory will need to be committed, as well as |
---|
| 18 | the latex files. |
---|
| 19 | |
---|
| 20 | The report structure is |
---|
| 21 | |
---|
| 22 | * Introduction |
---|
| 23 | * Data sources |
---|
| 24 | * Tsunami scenario |
---|
| 25 | * Inundation modelling results |
---|
[2870] | 26 | * Damage modelling |
---|
[2815] | 27 | * Summary |
---|
| 28 | * References |
---|
| 29 | * Appendix: Metadata |
---|
| 30 | |
---|
[2839] | 31 | Other files included in document which require manual intervention: |
---|
[2815] | 32 | |
---|
| 33 | * an abstract must be written in abstract.tex |
---|
| 34 | * an introduction must be written in introduction.tex; a basic outline and |
---|
| 35 | some of the core inputs are already in place |
---|
[2898] | 36 | * an results.tex file needs to be written for the particular scenario |
---|
[2815] | 37 | * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
| 38 | * a summary must be written into summary.tex |
---|
| 39 | * metadata for the scenario data to be included in metadata.tex |
---|
| 40 | |
---|
| 41 | May 2006 |
---|
| 42 | """ |
---|
| 43 | |
---|
| 44 | from os import getcwd, sep |
---|
| 45 | import project |
---|
| 46 | from pyvolution.util import sww2timeseries |
---|
| 47 | |
---|
[2837] | 48 | # Derive scenario name |
---|
[2815] | 49 | p = getcwd().split(sep) |
---|
[2837] | 50 | scenario = p[-1] # Last element of absolute CWD path |
---|
[2839] | 51 | scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` |
---|
| 52 | test = scenario_name.split('_') |
---|
| 53 | if len(test) <> 1: |
---|
| 54 | scenario_name = '%s %s' %(test[0], test[1]) |
---|
[2815] | 55 | |
---|
[2837] | 56 | # User defined inputs |
---|
[2820] | 57 | report_title = 'Tsunami impact modelling for the North West shelf: %s' %scenario_name.title() |
---|
[2815] | 58 | |
---|
[2898] | 59 | production_dirs = {'20060426_004129': 'Highest Astronomical Tide', |
---|
| 60 | '20060426_004237': 'Lowest Astronomical Tide'} |
---|
| 61 | |
---|
[2837] | 62 | # Create sections and graphs for each designated production directory |
---|
[2815] | 63 | latex_output = [] |
---|
[2839] | 64 | for label_id in production_dirs.keys(): |
---|
[2815] | 65 | |
---|
[2837] | 66 | file_loc = project.outputdir + label_id + sep |
---|
[2815] | 67 | swwfile = file_loc + project.basename + '.sww' |
---|
| 68 | |
---|
| 69 | texname = sww2timeseries(swwfile, |
---|
[2837] | 70 | project.gauge_filename, |
---|
[2815] | 71 | label_id, |
---|
[2839] | 72 | report = True, |
---|
[2815] | 73 | plot_quantity = ['stage', 'velocity', 'bearing'], |
---|
| 74 | time_min = None, |
---|
| 75 | time_max = None, |
---|
[2898] | 76 | title_on = False, |
---|
[2815] | 77 | verbose = True) |
---|
| 78 | |
---|
| 79 | latex_output.append(texname) |
---|
| 80 | |
---|
[2837] | 81 | |
---|
| 82 | # Start report generation |
---|
[2815] | 83 | report_name = scenario + '_report.tex' |
---|
| 84 | fid = open(report_name, 'w') |
---|
| 85 | |
---|
[2837] | 86 | s = """ |
---|
| 87 | % This is based on an automatically generated file (by make_report.py). |
---|
| 88 | % |
---|
| 89 | % Manual parts are: |
---|
| 90 | % * an abstract must be written in abstract.tex |
---|
| 91 | % * an introduction must be written in introduction.tex; a basic outline and |
---|
| 92 | % some of the core inputs are already in place |
---|
[2898] | 93 | % * an results.tex file needs to be written for the particular scenario |
---|
[2837] | 94 | % * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
| 95 | % * a summary must be written into summary.tex |
---|
| 96 | % * metadata for the scenario data to be included in metadata.tex |
---|
| 97 | |
---|
| 98 | \documentclass{article} |
---|
| 99 | |
---|
| 100 | \usepackage{ae} % or {zefonts} |
---|
| 101 | \usepackage[T1]{fontenc} |
---|
| 102 | \usepackage[ansinew]{inputenc} |
---|
| 103 | \usepackage{amsmath} |
---|
| 104 | \usepackage{amssymb} |
---|
| 105 | \usepackage{graphicx} |
---|
| 106 | \usepackage{color} |
---|
| 107 | \usepackage[colorlinks]{hyperref} |
---|
| 108 | \usepackage{lscape} %landcape pages support |
---|
[2857] | 109 | \usepackage{setspace} |
---|
| 110 | \setstretch{1.25} |
---|
[2837] | 111 | \\topmargin 0pt |
---|
| 112 | \oddsidemargin 0pt |
---|
| 113 | \evensidemargin 0pt |
---|
| 114 | \marginparwidth 0.5pt |
---|
| 115 | \\textwidth \paperwidth |
---|
| 116 | \\advance\\textwidth -2in |
---|
[2839] | 117 | |
---|
[2837] | 118 | """ |
---|
[2815] | 119 | fid.write(s) |
---|
| 120 | |
---|
[2837] | 121 | s = '\\title{%s} \n' %report_title |
---|
[2815] | 122 | fid.write(s) |
---|
| 123 | |
---|
[2839] | 124 | s = """ |
---|
| 125 | \date{\\today} |
---|
[2857] | 126 | \\author{Geoscience Australia} |
---|
[2837] | 127 | \\begin{document} |
---|
| 128 | \maketitle |
---|
| 129 | |
---|
| 130 | \\begin{abstract} |
---|
| 131 | \input{abstract} |
---|
| 132 | \end{abstract} |
---|
| 133 | |
---|
| 134 | \\tableofcontents |
---|
| 135 | |
---|
| 136 | \section{Introduction} |
---|
| 137 | \label{sec:intro} |
---|
| 138 | \input{introduction} |
---|
| 139 | |
---|
| 140 | \section{Data sources} |
---|
| 141 | \label{sec:data} |
---|
| 142 | \input{data} |
---|
| 143 | |
---|
| 144 | \section{Tsunami scenarios} |
---|
| 145 | \label{sec:tsunami_scenarios} |
---|
| 146 | \input{tsunami_scenario} |
---|
| 147 | |
---|
| 148 | \section{Inundation modelling results} |
---|
| 149 | \label{sec:results} |
---|
| 150 | \input{results} |
---|
[2839] | 151 | |
---|
[2837] | 152 | """ |
---|
[2815] | 153 | fid.write(s) |
---|
| 154 | |
---|
[2837] | 155 | # Assign titles to each production section |
---|
| 156 | # Must specify one name per section |
---|
[2839] | 157 | for i, name in enumerate(production_dirs.keys()): |
---|
| 158 | |
---|
| 159 | s = '\subsection{%s} \n \n' %production_dirs[name] |
---|
[2821] | 160 | fid.write(s) |
---|
[2837] | 161 | |
---|
[2839] | 162 | s = '\input{%s} \n \clearpage \n \n' %latex_output[i] |
---|
[2815] | 163 | fid.write(s) |
---|
| 164 | |
---|
[2837] | 165 | |
---|
[2870] | 166 | # Closing |
---|
| 167 | |
---|
| 168 | s = """ |
---|
| 169 | \section{Damage modelling} |
---|
| 170 | \input{damage} |
---|
| 171 | |
---|
| 172 | \section{Summary} |
---|
[2837] | 173 | \input{summary} |
---|
| 174 | |
---|
| 175 | \section{References} |
---|
[2839] | 176 | |
---|
[2837] | 177 | \section{Metadata} |
---|
| 178 | \label{sec:metadata} |
---|
| 179 | \input{metadata} |
---|
[2839] | 180 | |
---|
[2837] | 181 | \end{document} |
---|
| 182 | """ |
---|
[2815] | 183 | fid.write(s) |
---|