From 8df96d05a4e1d10a6f43ba538d2608537c5192bf Mon Sep 17 00:00:00 2001
From: Paul Garlick <pgarlick@tourbillion-technology.com>
Date: Thu, 18 Jun 2020 10:55:26 +0100
Subject: python: Enable writing rating curve data to file.

* python/makeBoundary: Add 'printing' definition.
demo/boundaryBottom.txt: Add 'printing' parameter.
demo/boundaryTop.txt: Add 'printing' parameter.
---
 demo/boundaryBottom.txt |  3 +++
 demo/boundaryTop.txt    |  3 +++
 python/makeBoundary     | 12 ++++++++++++
 3 files changed, 18 insertions(+)

diff --git a/demo/boundaryBottom.txt b/demo/boundaryBottom.txt
index c06623e..71389e7 100644
--- a/demo/boundaryBottom.txt
+++ b/demo/boundaryBottom.txt
@@ -8,6 +8,9 @@ type: 1
 # Enable plotting (True or False):
 plotting: False
 
+# Enable printing (True or False):
+printing: False
+
 # Local gradient:
 slope: -0.003646
 
diff --git a/demo/boundaryTop.txt b/demo/boundaryTop.txt
index ebcb5f7..789a6e3 100644
--- a/demo/boundaryTop.txt
+++ b/demo/boundaryTop.txt
@@ -8,6 +8,9 @@ type: 5
 # Enable plotting (True or False):
 plotting: True
 
+# Enable printing (True or False):
+printing: False
+
 # Local gradient:
 slope: -0.003646
 
diff --git a/python/makeBoundary b/python/makeBoundary
index 3684faf..f2f8840 100755
--- a/python/makeBoundary
+++ b/python/makeBoundary
@@ -146,6 +146,7 @@ btype       = definition_dict["type"]        # boundary type (1--5)
 slope       = abs(definition_dict["slope"])  # slope at top boundary
 target_flow = definition_dict["target_flow"] # imposed discharge
 plotting    = definition_dict["plotting"]    # enable or disable plotting
+printing    = definition_dict["printing"]    # enable or disable printing
 n_co        = definition_dict["n_co"]        # Manning's 'n' coefficients
 # TODO: use weighted mean 'n' values.  See
 # http://help.floodmodeller.com/isis/ISIS/River_Section.htm (Eq. 4)
@@ -275,6 +276,17 @@ for p in range(num_panels):
                 K_i[p], r'conveyance / $m^3/s$',
                 Q_i[p], r'discharge / $m^3/s$',
                 'Panel {}'.format(p))
+        if printing:
+            ratingCurveFileName = 'panel{}_{}.dat'.format(p,args.location)
+            with open(ratingCurveFileName, 'w') as f:
+                f.write('{:16} {:18} {:12} {:10}\n'.format(
+                    '#maximum depth', 'hydraulic radius',
+                    'conveyance', 'discharge'))
+                f.write('{:16} {:18} {:12} {:10}\n'.format(
+                    '#/ m', '/ m', '/ m^3/s', '/ m^3/s'))
+                for h in range(numH):
+                    f.write('{:7.6f} {:16.6f} {:19.6f} {:11.6f}\n'.format(
+                        h_i[p][h]-zmin[p],r_h[p][h],K_i[p][h],Q_i[p][h]))
     else:
         p_i[p], A_i[p], r_h[p], h_i[p], K_i[p], Q_i[p] = [
             [0] * numH for _ in range(6)]
-- 
cgit