From a76ee2aba55c6c7fd8afe515d032f5b759b37d8f Mon Sep 17 00:00:00 2001 From: hcwinsemius Date: Thu, 16 Nov 2023 14:15:00 +0100 Subject: [PATCH] fixed bug in determination of x and y axis of velocimetry results #148 --- pyorc/api/frames.py | 4 +++- pyorc/helpers.py | 34 ++++++++++++---------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/pyorc/api/frames.py b/pyorc/api/frames.py index 7452178..dd43fcc 100644 --- a/pyorc/api/frames.py +++ b/pyorc/api/frames.py @@ -74,8 +74,10 @@ def get_piv(self, **kwargs): search_area_size=kwargs["search_area_size"], overlap=kwargs["overlap"] ) + cols_vector = cols[0].astype(np.int64) + rows_vector = rows[:, 0].astype(np.int64) # retrieve the x and y-axis belonging to the results - x, y = helpers.get_axes(cols, rows, self.camera_config.resolution) + x, y = helpers.get_axes(cols_vector, rows_vector, frames1.x.values, frames1.y.values) # convert in projected and latlon coordinates xs, ys = helpers.get_xs_ys( cols, diff --git a/pyorc/helpers.py b/pyorc/helpers.py index 245ceb4..134cd4a 100644 --- a/pyorc/helpers.py +++ b/pyorc/helpers.py @@ -100,7 +100,7 @@ def deserialize_attr(data_array, attr, dtype=np.array, args_parse=False): return dtype(eval(attr_obj)) -def get_axes(cols, rows, resolution): +def get_axes(cols, rows, x, y): """Retrieve a locally spaced axes for surface velocimetry results on the basis of resolution and row and col distances from the original frames @@ -110,32 +110,22 @@ def get_axes(cols, rows, resolution): ints, columns, sampled from the original projected frames rows: list ints, rows, sampled from the original projected frames - resolution: float - resolution of original frames + x: array-like + frames x-axis + y: array-like + frames y-axis Returns ------- - obj : np.ndarray - x-axis with origin at the left - obj2 : np.ndarray - y-axis with origin on the top + xax : np.ndarray + x-axis sampled from columns + yax : np.ndarray + y-axis sampled from columns """ - spacing_x = np.diff(cols[0])[0] - spacing_y = np.diff(rows[:, 0])[0] - x = np.linspace( - resolution / 2 * spacing_x, - (len(cols[0]) - 0.5) * resolution * spacing_x, - len(cols[0]), - ) - y = np.flipud( - np.linspace( - resolution / 2 * spacing_y, - (len(rows[:, 0]) - 0.5) * resolution * spacing_y, - len(rows[:, 0]), - ) - ) - return x, y + xax = x[cols] + yax = y[rows] + return xax, yax def get_geo_axes(tiles=None, extent=None, zoom_level=19, **kwargs):