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