Skip to content

Commit

Permalink
Fixes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
faph committed Sep 4, 2015
2 parents 9dddea0 + 00c005f commit 54bfb5b
Show file tree
Hide file tree
Showing 26 changed files with 1,033 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_install:
- conda update -q conda
- conda info -a
- conda config --add channels http://conda.anaconda.org/openhydrology
- conda create -q -n pyenv python=$TRAVIS_PYTHON_VERSION nose appdirs=1.4 Jinja2=2.8 floodestimation=0.4.2
- conda create -q -n pyenv python=$TRAVIS_PYTHON_VERSION nose appdirs=1.4 Jinja2=2.8 floodestimation=0.5.1
- source activate pyenv

install:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
version 0.6.0 (2015-09-04)
--------------------------
- Application starts from Windows Start Menu instead of Windows Explorer context menu
- Support for xml catchment files

version 0.5.5 (2015-08-26)
--------------------------
- Upgrade to floodestimation library v0.4.2
Expand Down
29 changes: 22 additions & 7 deletions autostatistical/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,37 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import argparse
import tkinter as tk
import tkinter.messagebox as tkmb
import tkinter.filedialog as tkfd
import os.path
from . import Analysis


def main():
parser = argparse.ArgumentParser(description='Create OH Auto Statistical flood estimation report.')
parser.add_argument('cd3_file_path', help='Location of catchment CD3-file.')
parser = argparse.ArgumentParser(description='OH Auto Statistical')
parser.add_argument('file_path', nargs='?', default=None, help='Location of catchment .CD3 or.xml-file.')
args = parser.parse_args()

root = tk.Tk()
root.withdraw() # Hide main window to show dialogs only
root.iconbitmap(os.path.join(os.path.dirname(__file__), 'application.ico'))

# If no file provided, show file dialog
if not args.file_path:
args.file_path = tkfd.askopenfilename(filetypes=[("Catchment descriptor files", "*.cd3 *.xml")],
title="Select catchment file - " + parser.description)
if not args.file_path:
return # User cancelled

# Run analysis
try:
analysis = Analysis(args.cd3_file_path)
analysis = Analysis(args.file_path)
analysis.run()
analysis.create_report()

except Exception as e:
print(e)
input("Press Enter to close this window.")
tkmb.showerror(parser.description, 'The following error occurred:\n\n' + str(e))
else:
tkmb.showinfo(parser.description, 'OH Auto Statistical report successfully created.')


if __name__ == "__main__":
Expand Down
Binary file added autostatistical/application.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions autostatistical/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import math
import jinja2 as jj
import jinja2.exceptions
import jinja2.utils
from appdirs import AppDirs
import os

Expand Down Expand Up @@ -49,6 +50,7 @@ def __init__(self):
self.filters['signifcolumn'] = self.signifcolumn
self.filters['intcolumn'] = self.intcolumn
self.filters['strcolumn'] = self.strcolumn
self.filters['default'] = self.default

def user_template_folder(self):
template_folder = os.path.join(AppDirs(APP_NAME, APP_AUTHOR).user_data_dir, 'templates')
Expand Down Expand Up @@ -146,3 +148,10 @@ def strcolumn(value, width=25):
return "{value:<{width:d}s}".format(value=value, width=width)
except (ValueError, TypeError):
return ' ' * width

@staticmethod
def default(value, default=''):
if value is None or jinja2.utils.is_undefined(value):
return default
else:
return value
2 changes: 1 addition & 1 deletion autostatistical/templates/normal.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Date: {{ report_date|default(None)|dateformat }}

## Input data

River: {{ catchment.watercourse|default("Unnamed") }}
River: {{ catchment.watercourse|default("Unknown") }}
Location: {{ catchment.location|default("Unknown") }}
NGR outlet: {{ catchment.point.x }}, {{ catchment.point.y }}
NGR centroid: {{ catchment.descriptors.centroid_ngr.x }}, {{ catchment.descriptors.centroid_ngr.y }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flood Estimation Report

Date: 26/08/2015
Date: 28/08/2015

## Input data

Expand Down Expand Up @@ -29,7 +29,7 @@ FARL | 0.824  | SAAR4170 | 951      | |
Source: http://nrfaapps.ceh.ac.uk/peak_flow/WINFAP-FEH_v3.3.4.zip
Version: 3.3.4
Published: August 2014
Retrieved: 26/08/2015
Retrieved: 28/08/2015

## Median annual flood (QMED)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flood Estimation Report

Date: 26/08/2015
Date: 28/08/2015

## Input data

Expand Down Expand Up @@ -68,7 +68,7 @@ FARL | 0.994  | SAAR4170 | 604      | |
Source: http://nrfaapps.ceh.ac.uk/peak_flow/WINFAP-FEH_v3.3.4.zip
Version: 3.3.4
Published: August 2014
Retrieved: 26/08/2015
Retrieved: 28/08/2015

## Median annual flood (QMED)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Flood Estimation Report

Date: 28/08/2015

## Input data

River: Unknown
Location: Unknown
NGR outlet: 204000, 748400
NGR centroid: 207378, 751487

### Catchment descriptors

Source: CEH (2009)

Descriptor | Value | Descriptor | Value | Descriptor | Value
:------------|-----------:|:------------|-----------:|:------------|----------:
AREA | 30.09   | FPEXT | 0.0369 | SPRHOST | 53.35  
ALTBAR | 367      | LDP | 11.50   | URBCONC1990 |      
ASPBAR | 247      | PROPWET | 0.79   | URBEXT1990 | 0.0000
ASPVAR | 0.17   | RMED-1H | 13.9    | URBLOC1990 |      
BFIHOST | 0.394  | RMED-1D | 72.0    | URBCONC2000 |      
DPLBAR | 6.56   | RMED-2D | 112.4    | URBEXT2000 | 0.0000
DPSBAR | 356.3    | SAAR | 2810      | URBLOC2000 |      
FARL | 0.986  | SAAR4170 | 2969      | |      

### National River Flow Archive (NRFA) data

Source: http://nrfaapps.ceh.ac.uk/peak_flow/WINFAP-FEH_v3.3.4.zip
Version: 3.3.4
Published: August 2014
Retrieved: 28/08/2015

## Median annual flood (QMED)

Methology: Kjeldsen, Jones & Bayliss (2008, eqs. 8.1 & 8.2), Kjeldsen (2010, eq. 8), Kjeldsen, Jones & Morris
(2014), Open Hydrology Contributors (2015)
Analysis type: Catchment descriptors regression model with nearby catchments adjustment

QMED, rural: 45.6 m³/s
URBEXT, 2015: 0.0000
Adj. factor: 1.000
QMED, urban: 45.6 m³/s

### QMED donor catchments

Donor river | Donor location | Distance (km)| Observed/Model | Power
:-------------------|:-------------------------------|-------------:|---------------:|-----:
Nevis | Claggan | 20 | 1.377 | 0.163
Strae | Glen Strae | 21 | 0.996 | 0.160
Allt Leachdach | Intake | 31 | 0.539 | 0.088
Falloch | Glen Falloch | 39 | 1.673 | 0.059
Tay | Kenmore | 50 | 1.032 | 0.029
Tay | Pitnacree | 53 | 0.939 | 0.025

Adj. factor: 1.027
QMED: 47 m³/s

## Growth curve

Methology: Kjeldsen, Jones & Bayliss (2008, eqs. 8.3‒8.12 & 8.16), Kjeldsen (2010, eqs. 10 & 11), Open Hydrology
Contributors (2015)
Analysis type: Pooled catchments analysis (ungauged)

### Growth curve donor catchments (pooling group)

Donor river | Donor location | Sim. dist. | Rec. length | L-var. | Weight | L-skew | Weight
:-------------------|:-------------------------------|-----------:|------------:|-------:|-------:|-------:|------:
Strae | Glen Strae | 0.33 | 29 | 0.093 | 0.094 | -0.108 | 0.078
East Dart | Bellever | 0.71 | 48 | 0.162 | 0.080 | 0.082 | 0.078
Sprint | Sprint Mill | 0.73 | 43 | 0.197 | 0.078 | 0.191 | 0.076
Rhondda Fawr | Tynewydd | 0.91 | 11 | 0.120 | 0.055 | -0.087 | 0.040
West Dart | Dunnabridge | 0.93 | 31 | 0.171 | 0.069 | 0.122 | 0.068
Ettrick Water | Brockhoperig | 1.02 | 41 | 0.203 | 0.069 | 0.276 | 0.073
Fowey | Trekeivesteps | 1.12 | 43 | 0.220 | 0.067 | 0.290 | 0.074
Walkham | Horrabridge | 1.15 | 39 | 0.212 | 0.066 | 0.240 | 0.072
Harwood Beck | Harwood | 1.16 | 43 | 0.189 | 0.066 | 0.251 | 0.073
Nevis | Claggan | 1.17 | 24 | 0.136 | 0.061 | 0.180 | 0.061
De Lank | De Lank | 1.18 | 46 | 0.232 | 0.066 | 0.241 | 0.075
St Neot | Craigshill Wood | 1.25 | 12 | 0.245 | 0.051 | 0.373 | 0.042
Mellte | Pontneddfechan | 1.28 | 41 | 0.171 | 0.063 | 0.122 | 0.072
Warleggan | Trengoffe | 1.30 | 43 | 0.268 | 0.063 | 0.287 | 0.073
Megget Water | Henderland | 1.36 | 13 | 0.216 | 0.051 | 0.074 | 0.045
Total/weighted avg. | | | 507 | 0.186 | 1.000 | 0.172 | 1.000

L-var., urban: 0.186
L-skew, urban: 0.172

### Flood frequency curve

Distribution: GLO
Parameters: 1.000, 0.177, -0.172

AEP (%) | Growth factor | Flow (m³/s)
-------:|--------------:|-----------:
50.0 | 1.00 | 47  
20.0 | 1.28 | 60  
10.0 | 1.47 | 69  
5.0 | 1.68 | 79  
3.3 | 1.81 | 85  
2.0 | 1.98 | 93  
1.3 | 2.13 | 100  
1.0 | 2.24 | 100  
0.5 | 2.53 | 120  
0.2 | 2.97 | 140  
0.1 | 3.34 | 160  

## References

CEH (2009). FEH CD-ROM 3 (Software). Wallingford: Centre for Ecology & Hydrology.

Kjeldsen, T. R., Jones, D. A. & Bayliss, A. C. (2008). *Improving the FEH statistical procedures for flood frequency
estimation* (No. SC050050). Bristol: Environment Agency.

Kjeldsen, T. R. (2010). *Modelling the impact of urbanization on flood frequency relationships in the UK*. Hydrology
Research, 41 (5). pp. 391‒405

Kjeldsen, T. R., Jones, D. A. & Morris, D. G. (2014). *Using multiple donor sites for enhanced flood estimation in
ungauged catchments*. Water Resour. Res., 50, pp. 6646‒6657

Open Hydrology Contributors (2015). OH Auto Statistical. http://docs.open-hydrology.org/projects/oh-auto-statistical
48 changes: 48 additions & 0 deletions autostatistical/tests/data/NN 04000 48400.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Created by FEH CD-ROM 3 at 13:05:09 GMT on Wed 10-Jun-2015 -->
<FEHCDROMExportedDescriptors version="2.0.000" appVersion="3.0.000">
<CatchmentDescriptors grid="GB" x="204000" y="748400" mgr="NN 04000 48400">
<CatchmentCentroid grid="GB" x="207378" y="751487" mgr="NN 07378 51487" />
<area>30.09</area>
<altbar>367</altbar>
<aspbar>247</aspbar>
<aspvar>0.17</aspvar>
<bfihost>0.394</bfihost>
<dplbar>6.56</dplbar>
<dpsbar>356.3</dpsbar>
<farl>0.986</farl>
<fpext>0.0369</fpext>
<fpdbar>0.825</fpdbar>
<fploc>0.676</fploc>
<ldp>11.5</ldp>
<propwet>0.79</propwet>
<rmed_1h>13.9</rmed_1h>
<rmed_1d>72.0</rmed_1d>
<rmed_2d>112.4</rmed_2d>
<saar>2810</saar>
<saar4170>2969</saar4170>
<sprhost>53.35</sprhost>
<urbconc1990>NaN</urbconc1990>
<urbext1990>0.0</urbext1990>
<urbloc1990>NaN</urbloc1990>
<urbconc2000>NaN</urbconc2000>
<urbext2000>0.0</urbext2000>
<urbloc2000>NaN</urbloc2000>
</CatchmentDescriptors>
<CatchmentAverageDDFValues grid="GB" x="204000" y="748400" mgr="NN 04000 48400">
<c>-0.01884</c>
<d1>0.53527</d1>
<d2>0.5086</d2>
<d3>0.49952</d3>
<e>0.25011</e>
<f>2.69933</f>
</CatchmentAverageDDFValues>
<PointDDFValues grid="GB" x="204000" yx="748000" mgr="NN 04000 48000">
<c_1_km>-0.019</c_1_km>
<d1_1_km>0.566</d1_1_km>
<d2_1_km>0.54</d2_1_km>
<d3_1_km>0.602</d3_1_km>
<e_1_km>0.251</e_1_km>
<f_1_km>2.608</f_1_km>
</PointDDFValues>
</FEHCDROMExportedDescriptors>
5 changes: 5 additions & 0 deletions autostatistical/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ def test_gauged_report(self):
analysis = astat.Analysis('./autostatistical/tests/data/37017.CD3')
analysis.run()
analysis.create_report()

def test_xml_catchment(self):
analysis = astat.Analysis('./autostatistical/tests/data/NN 04000 48400.xml')
analysis.run()
analysis.create_report()
11 changes: 6 additions & 5 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,29 @@ requirements:
- setuptools
- appdirs 1.4*
- jinja2 2.8*
- floodestimation 0.4.2
- floodestimation 0.5.1

run:
- python
- appdirs 1.4*
- jinja2 2.8*
- floodestimation 0.4.2
- floodestimation 0.5.1

test:
# Python imports
imports:
- autostatistical

app:
entry: autostatistical
type: desk
icon:
entry: autostatistical # [not win]
# Run without console for Windows
entry: ${PREFIX}/pythonw.exe -m autostatistical # [win]
own_environment: true
summary: Fully automated flood estimation for UK catchments

about:
home: https://github.com/OpenHydrology/OH-Auto-Statistical
license: GPLv3
license_file: LICENSE
summary: Fully automated flood estimation for UK catchments
readme: README.md
Binary file removed docs/source/_static/context-menu.png
Binary file not shown.
Binary file added docs/source/_static/start-menu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/comparison.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The table below provides an overview and comparison of features included in OH A
============================= =========================== =================
Aspect OH Auto Statistical WINFAP-FEH
============================= =========================== =================
Input file type .cd3 and .xml .cd3
Selection of best method automatic manual
Single site analyses no (no longer a recommended yes
method)
Expand Down
11 changes: 0 additions & 11 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ interfere with any existing Python installation.
`National River Flow Archive (NRFA) <http://www.ceh.ac.uk/data/nrfa/>`_ for pooled analyses. This may take some time!
NRFA data are subject to `terms and conditions <http://www.ceh.ac.uk/data/nrfa/data/data_terms.html>`_.

.. attention::

No Windows Start Menu items are created, except for a link to the online documentation. This is intentionally. OH
Auto Statistical is run by **right-clicking on a .CD3-file**.


Mac OS and Linux
----------------
Expand All @@ -45,9 +40,3 @@ Or alternatively directly from the source code:

.. image:: https://img.shields.io/github/release/openhydrology/oh-auto-statistical.svg?style=flat-square
:target: https://github.com/OpenHydrology/OH-Auto-Statistical/releases/latest

OH Auto Statistical is run as follows:

.. code-block:: shell
python -m autostatistical "path/to/catchment.cd3"

0 comments on commit 54bfb5b

Please sign in to comment.