From 4540b53add0fe7af62422faa3cbc43c44c4e9ddc Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 2 Mar 2022 14:45:13 +0100 Subject: [PATCH] Reorganised processing/read_swash --- swash/processing/read_swash.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/swash/processing/read_swash.py b/swash/processing/read_swash.py index 1d1da2c..f101d4a 100644 --- a/swash/processing/read_swash.py +++ b/swash/processing/read_swash.py @@ -6,25 +6,23 @@ def read_nohead(path): return file.read() -def read_nohead_scalar(path, n): +def read_reshape(path, shape): return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape( - (-1, n) + shape ) +def read_nohead_scalar(path, n): + return read_reshape(path, (-1, n)) + + def read_nohead_k(path, n, k): - return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape( - (-1, n, k) - ) + return read_reshape(path, (-1, n, k)) def read_nohead_vect(path, n): - return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape( - (-1, n, 2) - ) + return read_reshape(path, (-1, n, 2)) def read_nohead_vect_k(path, n): - return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape( - (-1, n, 2, k) - ) + return read_reshape(path, (-1, n, 2, k))