Skip to content

Commit

Permalink
fixed bug in determination of x and y axis of velocimetry results #148
Browse files Browse the repository at this point in the history
  • Loading branch information
hcwinsemius committed Nov 16, 2023
1 parent 5971fcd commit a76ee2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
4 changes: 3 additions & 1 deletion pyorc/api/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 12 additions & 22 deletions pyorc/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit a76ee2a

Please sign in to comment.