1 | """ |
---|
2 | Generate latex output comparing time series of given sww files |
---|
3 | |
---|
4 | Inputs: |
---|
5 | |
---|
6 | production dirs: dictionary of output directories with a |
---|
7 | association to simulation, eg 50m boundary, 100m boundary |
---|
8 | |
---|
9 | gauge_map: graphical output from make_gauges.py |
---|
10 | |
---|
11 | Outputs: |
---|
12 | |
---|
13 | * latex output to generate figures for report |
---|
14 | * figures used for report stored in the report_figure directory |
---|
15 | NOTE, this directory will need to be committed, as well as |
---|
16 | the latex files. |
---|
17 | |
---|
18 | June 2006 |
---|
19 | """ |
---|
20 | |
---|
21 | from os import sep, getcwd, F_OK, access, mkdir |
---|
22 | import project |
---|
23 | from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file |
---|
24 | |
---|
25 | # Derive scenario name |
---|
26 | p = getcwd().split(sep) |
---|
27 | scenario = p[-1] # Last element of absolute CWD path |
---|
28 | scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` |
---|
29 | test = scenario_name.split('_') |
---|
30 | if len(test) <> 1: |
---|
31 | scenario_name = '%s %s' %(test[0], test[1]) |
---|
32 | |
---|
33 | # Create report directory |
---|
34 | reportdir = getcwd()+sep+'report'+sep |
---|
35 | if access(reportdir,F_OK) == 0: |
---|
36 | mkdir (reportdir) |
---|
37 | |
---|
38 | # User defined inputs |
---|
39 | report_title = 'Parameter change comparison for ANUGA: %s' %scenario_name.title() |
---|
40 | |
---|
41 | # User defined inputs |
---|
42 | production_dirs = {'20060704_063005': 'June 2006', # HAT |
---|
43 | '20061106_223150': 'Nov 2006'} # HAT |
---|
44 | #'MOST': 'MOST'} |
---|
45 | |
---|
46 | gauge_map = 'onslow_dli_gauge.jpg' |
---|
47 | |
---|
48 | # Create sections and graphs for each designated production directory |
---|
49 | latex_output = [] |
---|
50 | swwfiles = {} |
---|
51 | for label_id in production_dirs.keys(): |
---|
52 | |
---|
53 | file_loc = project.outputdir + label_id + sep |
---|
54 | swwfile = file_loc + project.basename + '.sww' |
---|
55 | if label_id == 'MOST': |
---|
56 | swwfile = project.boundarydir + project.boundary_basename + '.sww' |
---|
57 | swwfiles[swwfile] = label_id |
---|
58 | |
---|
59 | print 'swwfiles', swwfiles |
---|
60 | |
---|
61 | texname, vec = sww2timeseries(swwfiles, |
---|
62 | project.gauge_comparison, |
---|
63 | production_dirs, |
---|
64 | report = True, |
---|
65 | reportname = 'latexoutputparameterchange', |
---|
66 | plot_quantity = ['stage', 'speed'], |
---|
67 | generate_fig = True, |
---|
68 | surface = False, |
---|
69 | time_min = None, |
---|
70 | time_max = None, |
---|
71 | title_on = False, |
---|
72 | verbose = True) |
---|
73 | |
---|
74 | latex_output.append(texname) |
---|
75 | |
---|
76 | # Start report generation |
---|
77 | report_name = reportdir + scenario + '_parameter_comparison_onslow.tex' |
---|
78 | fid = open(report_name, 'w') |
---|
79 | |
---|
80 | s = """ |
---|
81 | % This is based on an automatically generated file (by make_report.py). |
---|
82 | % |
---|
83 | % Manual parts are: |
---|
84 | % * an abstract must be written in abstract.tex |
---|
85 | % * an introduction must be written in introduction.tex; a basic outline and |
---|
86 | % some of the core inputs are already in place |
---|
87 | % * outline of the modelling methodology provided in modelling_methodology.tex |
---|
88 | % * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
89 | % * an computational_setup.tex file needs to be written for the particular scenario |
---|
90 | % * the interpretation of the results needs to be written to interpretation.tex |
---|
91 | % * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc. |
---|
92 | % * damage modelling maps need to be included in HAT_damage and LAT_damage etc. |
---|
93 | % * a summary must be written into summary.tex |
---|
94 | % * metadata for the scenario data to be included in metadata.tex |
---|
95 | |
---|
96 | \documentclass{article} |
---|
97 | |
---|
98 | \usepackage{ae} % or {zefonts} |
---|
99 | \usepackage[T1]{fontenc} |
---|
100 | \usepackage[ansinew]{inputenc} |
---|
101 | \usepackage{amsmath} |
---|
102 | \usepackage{amssymb} |
---|
103 | \usepackage{graphicx} |
---|
104 | \usepackage{color} |
---|
105 | \usepackage[colorlinks]{hyperref} |
---|
106 | \usepackage{lscape} %landcape pages support |
---|
107 | \usepackage{setspace} |
---|
108 | \usepackage{rotating} |
---|
109 | \include{appendix} |
---|
110 | \setstretch{1.25} |
---|
111 | \\topmargin 0pt |
---|
112 | \oddsidemargin 0pt |
---|
113 | \evensidemargin 0pt |
---|
114 | \marginparwidth 0.5pt |
---|
115 | \\textwidth \paperwidth |
---|
116 | \\advance\\textwidth -2in |
---|
117 | |
---|
118 | """ |
---|
119 | fid.write(s) |
---|
120 | |
---|
121 | #s = '\\title{%s} \n' %report_title |
---|
122 | #fid.write(s) |
---|
123 | |
---|
124 | s = """ |
---|
125 | \date{\\today} |
---|
126 | %\\author{Geoscience Australia} |
---|
127 | |
---|
128 | \\begin{document} |
---|
129 | \\title{ |
---|
130 | \\begin{figure}[hbt] |
---|
131 | \centerline{ \includegraphics[scale=0.4]{../report_figures/GAlogo.jpg}} |
---|
132 | \end{figure} |
---|
133 | """ |
---|
134 | fid.write(s) |
---|
135 | |
---|
136 | fid.write(s) |
---|
137 | s = '%s} '%report_title |
---|
138 | fid.write(s) |
---|
139 | |
---|
140 | s = '\maketitle' |
---|
141 | fid.write(s) |
---|
142 | |
---|
143 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=150mm, height=100mm]{../report_figures/%s}}' %gauge_map |
---|
144 | fid.write(s) |
---|
145 | |
---|
146 | s = """ |
---|
147 | \caption{Point locations used to compare ANUGA output for Onslow region.} |
---|
148 | \label{fig:comparisonpoints} |
---|
149 | \end{figure} |
---|
150 | """ |
---|
151 | fid.write(s) |
---|
152 | |
---|
153 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
154 | fid.write(s) |
---|
155 | |
---|
156 | s = '\end{document}' |
---|
157 | fid.write(s) |
---|
158 | |
---|