From c6ed57637ccbd4c80e181b081cc605013cc9a6dd Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Wed, 9 Oct 2019 00:30:31 +0100 Subject: derive number of columns and rows of height data. --- makeBoundary.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 -- cgit