fixed graph_belts.py interpolate2d edge case bug on indices in table borders

This commit is contained in:
Félix Boisselier
2023-10-16 00:17:21 +02:00
parent c88f748839
commit bec3f478a2
8 changed files with 8 additions and 3 deletions

View File

@@ -192,8 +192,13 @@ def interpolate_2d(target_x, target_y, source_x, source_y, source_data):
# and ensure we don't exceed array bounds # and ensure we don't exceed array bounds
x_indices = np.searchsorted(source_x, x) - 1 x_indices = np.searchsorted(source_x, x) - 1
y_indices = np.searchsorted(source_y, y) - 1 y_indices = np.searchsorted(source_y, y) - 1
x_indices = max(0, min(len(source_x) - 2, x_indices)) x_indices = max(0, min(len(source_x) - 1, x_indices))
y_indices = max(0, min(len(source_y) - 2, y_indices)) y_indices = max(0, min(len(source_y) - 1, y_indices))
if x_indices == len(source_x) - 2:
x_indices -= 1
if y_indices == len(source_y) - 2:
y_indices -= 1
x1, x2 = source_x[x_indices], source_x[x_indices + 1] x1, x2 = source_x[x_indices], source_x[x_indices + 1]
y1, y2 = source_y[y_indices], source_y[y_indices + 1] y1, y2 = source_y[y_indices], source_y[y_indices + 1]

View File

@@ -21,7 +21,7 @@ If needed, refer to [my IS graphs documentation](./docs/input_shaper.md) for tip
| Belts graphs | X graphs | Y graphs | Vibrations measurement | | Belts graphs | X graphs | Y graphs | Vibrations measurement |
|:----------------:|:------------:|:------------:|:---------------------:| |:----------------:|:------------:|:------------:|:---------------------:|
| ![](./docs/images/resonances_belts_example.png) | ![](./docs/images/resonances_x_example.png) | ![](./docs/images/resonances_y_example.png) | ![](./docs/images/vibrations_example.png) | | ![](./docs/images/belts_example.png) | ![](./docs/images/X_example.png) | ![](./docs/images/Y_example.png) | ![](./docs/images/vibrations_example.png) |
## Installation ## Installation

BIN
docs/images/X_example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 KiB

BIN
docs/images/Y_example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB