aboutsummaryrefslogtreecommitdiff
path: root/makeBoundary.py
diff options
context:
space:
mode:
authorPaul Garlick <pgarlick@tourbillion-technology.com>2019-10-09 00:30:31 +0100
committerPaul Garlick <pgarlick@tourbillion-technology.com>2019-10-09 11:59:37 +0100
commitc6ed57637ccbd4c80e181b081cc605013cc9a6dd (patch)
treef4225edcce9b5d049de8ffbaea64ebf24384006b /makeBoundary.py
parent888736862a1f170e52d3c89360c01394576f82d5 (diff)
downloadfullSWOF-utils-c6ed57637ccbd4c80e181b081cc605013cc9a6dd.tar.gz
derive number of columns and rows of height data.
Diffstat (limited to 'makeBoundary.py')
-rwxr-xr-xmakeBoundary.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/makeBoundary.py b/makeBoundary.py
index 9b9e5e2..f71ef8c 100755
--- a/makeBoundary.py
+++ b/makeBoundary.py
@@ -4,6 +4,7 @@ import matplotlib.pyplot as plt
import numpy as np
import bisect
import ast
+import math
#TODO: use YAML/ruamel.yaml for configuration file.
def read_definition(filename):
@@ -37,7 +38,14 @@ height_data = definition_dict["height_data"] # topography
# print('gradient =', m, 'intercept =', c)
with open(height_data, "r") as topo:
- xin, yin, zin = np.loadtxt(topo, delimiter=' ', unpack=True)
+ xtp, ytp, ztp = np.loadtxt(topo, delimiter=' ', unpack=True)
+
+# number of cells in x direction
+ncols = int(math.sqrt(len(xtp)*(xtp[0]+xtp[-1])/(ytp[0]+ytp[-1])))
+# number of cells in y direction
+nrows = int(len(xtp)/ncols)
+
+print(ncols, nrows)
# array index and co-ordinates are related by:
# index = (co-ord - 0.25)*2