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