[4580] | 1 | from os import getcwd, sep, altsep, mkdir, access, F_OK |
---|
| 2 | import project |
---|
| 3 | from anuga.abstract_2d_finite_volumes.util import sww2timeseries, get_gauges_from_file |
---|
| 4 | |
---|
| 5 | # Derive scenario name |
---|
| 6 | p = getcwd().split(sep) |
---|
| 7 | scenario = p[-1] # Last element of absolute CWD path |
---|
| 8 | scenario_name = scenario.split('_2006')[0] # Strip any text past `_2006` |
---|
| 9 | test = scenario_name.split('_') |
---|
| 10 | if len(test) <> 1: |
---|
| 11 | scenario_name = '%s %s' %(test[0], test[1]) |
---|
| 12 | |
---|
| 13 | # Create report directory |
---|
| 14 | reportdir = getcwd()+sep+'report'+sep |
---|
| 15 | if access(reportdir,F_OK) == 0: |
---|
| 16 | mkdir (reportdir) |
---|
| 17 | |
---|
| 18 | # |
---|
| 19 | production_dirs = {'20061008_234702': 'Mw 8-7', # 2500 res, 750000 other res |
---|
| 20 | #'20061016_065743': 'Mw 8-7 refined', #new interior res |
---|
| 21 | '20061017_004409': 'Mw 8-7 refined', #new interior res |
---|
| 22 | '20061017_022640': 'Mw 8-7 paleo sites', #new interior res |
---|
| 23 | 'MOST': 'MOST'} # MOST input for Mw 8-7 |
---|
| 24 | |
---|
| 25 | #production_dirs = {'20061006_062319': 'Mw 8-5', # 2500 res, 750000 other res |
---|
| 26 | # 'MOST': 'MOST'} # MOST input for Mw 8-5 |
---|
| 27 | |
---|
| 28 | gauge_map = 'boundary_gauges.jpg' |
---|
| 29 | |
---|
| 30 | # Create sections and graphs for each designated production directory |
---|
| 31 | latex_output = [] |
---|
| 32 | swwfiles = {} |
---|
| 33 | for label_id in production_dirs.keys(): |
---|
| 34 | |
---|
| 35 | file_loc = project.outputdir + label_id + sep |
---|
| 36 | swwfile = file_loc + project.basename + '.sww' |
---|
| 37 | if label_id == 'MOST': |
---|
| 38 | swwfile = project.boundarydir + project.boundary_basename + '.sww' |
---|
| 39 | swwfiles[swwfile] = label_id |
---|
| 40 | |
---|
| 41 | texname, elev_output = sww2timeseries(swwfiles, |
---|
| 42 | project.gauge_filename, |
---|
| 43 | production_dirs, |
---|
| 44 | report = True, |
---|
| 45 | reportname = 'latexoutput_boundary', |
---|
| 46 | #reportname = 'latexoutput_boundary_event2', |
---|
| 47 | plot_quantity = ['stage', 'speed'], |
---|
| 48 | generate_fig = True, |
---|
| 49 | surface = False, |
---|
| 50 | time_min = None, |
---|
| 51 | time_max = None, |
---|
| 52 | title_on = False, |
---|
| 53 | verbose = True) |
---|
| 54 | |
---|
| 55 | latex_output.append(texname) |
---|
| 56 | |
---|
| 57 | # Start report generation |
---|
| 58 | # Future: generate_report(reportdir, scenario, report_title, |
---|
| 59 | # project.gauge_filename, max_maps, damage_maps, production_dirs, latex_output) |
---|
| 60 | report_name = reportdir + 'boundary_report.tex' |
---|
| 61 | #report_name = reportdir + 'boundary_report_event2.tex' |
---|
| 62 | fid = open(report_name, 'w') |
---|
| 63 | |
---|
| 64 | s = """ |
---|
| 65 | % This is based on an automatically generated file (by make_report.py). |
---|
| 66 | % |
---|
| 67 | % Manual parts are: |
---|
| 68 | % * an abstract must be written in abstract.tex |
---|
| 69 | % * an introduction must be written in introduction.tex; a basic outline and |
---|
| 70 | % some of the core inputs are already in place |
---|
| 71 | % * outline of the modelling methodology provided in modelling_methodology.tex |
---|
| 72 | % * the tsunami-genic event should be discussed in tsunami_scenario.tex |
---|
| 73 | % * an computational_setup.tex file needs to be written for the particular scenario |
---|
| 74 | % * the interpretation of the results needs to be written to interpretation.tex |
---|
| 75 | % * maximum inundation maps need to be included in HAT_map.tex and LAT_map.tex etc. |
---|
| 76 | % * damage modelling maps need to be included in HAT_damage and LAT_damage etc. |
---|
| 77 | % * a summary must be written into summary.tex |
---|
| 78 | % * metadata for the scenario data to be included in metadata.tex |
---|
| 79 | |
---|
| 80 | \documentclass{article} |
---|
| 81 | |
---|
| 82 | \usepackage{ae} % or {zefonts} |
---|
| 83 | \usepackage[T1]{fontenc} |
---|
| 84 | \usepackage[ansinew]{inputenc} |
---|
| 85 | \usepackage{amsmath} |
---|
| 86 | \usepackage{amssymb} |
---|
| 87 | \usepackage{graphicx} |
---|
| 88 | \usepackage{color} |
---|
| 89 | \usepackage[colorlinks]{hyperref} |
---|
| 90 | \usepackage{lscape} %landcape pages support |
---|
| 91 | \usepackage{setspace} |
---|
| 92 | \usepackage{rotating} |
---|
| 93 | \include{appendix} |
---|
| 94 | \setstretch{1.25} |
---|
| 95 | \\topmargin 0pt |
---|
| 96 | \oddsidemargin 0pt |
---|
| 97 | \evensidemargin 0pt |
---|
| 98 | \marginparwidth 0.5pt |
---|
| 99 | \\textwidth \paperwidth |
---|
| 100 | \\advance\\textwidth -2in |
---|
| 101 | |
---|
| 102 | """ |
---|
| 103 | fid.write(s) |
---|
| 104 | |
---|
| 105 | s = """ |
---|
| 106 | \date{\\today} |
---|
| 107 | %\\author{Geoscience Australia} |
---|
| 108 | |
---|
| 109 | \\begin{document} |
---|
| 110 | \\title{Comparison between ANUGA and MOST} |
---|
| 111 | \maketitle |
---|
| 112 | """ |
---|
| 113 | fid.write(s) |
---|
| 114 | |
---|
| 115 | # Generate latex output for location points |
---|
| 116 | s = '\\begin{table} \\begin{center} \n' |
---|
| 117 | fid.write(s) |
---|
| 118 | s = '\caption{Defined point locations for %s study area.}' %scenario_name |
---|
| 119 | fid.write(s) |
---|
| 120 | s = """ |
---|
| 121 | \label{table:locations} |
---|
| 122 | \\begin{tabular}{|l|l|l|l|}\hline |
---|
| 123 | \\bf{Point Name} & \\bf{Easting} & \\bf{Northing} & \\bf{Elevation}\\\\ \hline |
---|
| 124 | """ |
---|
| 125 | fid.write(s) |
---|
| 126 | |
---|
| 127 | gauges, locations, elevation = get_gauges_from_file(project.gauge_filename) |
---|
| 128 | |
---|
| 129 | for name, gauges, elev in zip(locations, gauges, elevation): |
---|
| 130 | east = gauges[0] |
---|
| 131 | north = gauges[1] |
---|
| 132 | s = '%s & %.2f & %.2f & %.2f \\\\ \hline \n' %(name.replace('_',' '), east, north, elev) |
---|
| 133 | fid.write(s) |
---|
| 134 | |
---|
| 135 | s = '\\end{tabular} \n \end{center} \n \end{table} \n \n' |
---|
| 136 | fid.write(s) |
---|
| 137 | |
---|
| 138 | s = '\\begin{figure}[hbt] \n \centerline{ \includegraphics[width=\paperwidth]{../report_figures/%s}}' %gauge_map |
---|
| 139 | fid.write(s) |
---|
| 140 | |
---|
| 141 | s = """ |
---|
| 142 | \caption{Point locations used for boundary investigation.} |
---|
| 143 | \label{fig:points} |
---|
| 144 | \end{figure} |
---|
| 145 | """ |
---|
| 146 | fid.write(s) |
---|
| 147 | |
---|
| 148 | s = '\input{%s} \n \clearpage \n \n' %latex_output[0] |
---|
| 149 | fid.write(s) |
---|
| 150 | |
---|
| 151 | s=""" |
---|
| 152 | \end{document} |
---|
| 153 | """ |
---|
| 154 | fid.write(s) |
---|