Skip to content

Commit 60bfd45

Browse files
committed
added add_station_times function to echogramviewer
1 parent 24dbe54 commit 60bfd45

File tree

4 files changed

+356
-5
lines changed

4 files changed

+356
-5
lines changed

python/themachinethatgoesping/pingprocessing/split_pings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .by_time import by_time_difference
33
from .by_distance import by_distance_difference
44
from .by_channel_id import by_channel_id
5-
from .by_file import by_file_nr, by_file_path
5+
from .by_file import by_file_nr, by_file_path, by_folder_path
66
from .by_function_return import by_function_return
77
from .by_time_blocks import by_time_blocks
88
from .into_time_blocks import into_time_blocks

python/themachinethatgoesping/pingprocessing/split_pings/by_file.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import defaultdict
33
import numpy as np
44
import math
5+
import os
56
from typing import Dict, List
67
from themachinethatgoesping.pingprocessing.core.progress import get_progress_iterator
78
import themachinethatgoesping.navigation as nav
@@ -49,3 +50,25 @@ def by_file_path(pings: List[I_Ping], progress: bool = True) -> Dict[str, List[I
4950

5051
return split_pings
5152

53+
54+
def by_folder_path(pings: List[I_Ping], progress: bool = True) -> Dict[str, List[I_Ping]]:
55+
"""
56+
Splits a list of pings by the folder path where the primary file is located.
57+
58+
Args:
59+
pings (List[I_Ping]): A list of pings to be split.
60+
progress (bool, optional): Whether to show a progress bar. Defaults to True.
61+
62+
Returns:
63+
Dict[str, List[I_Ping]]: A dictionary where the keys are folder paths and the values are lists of pings.
64+
"""
65+
it = get_progress_iterator(pings, progress, desc="Split pings by folder path")
66+
67+
split_pings = defaultdict(list)
68+
69+
for ping in it:
70+
folder_path = os.path.dirname(ping.file_data.get_primary_file_path())
71+
split_pings[folder_path].append(ping)
72+
73+
return split_pings
74+

python/themachinethatgoesping/pingprocessing/watercolumn/image/make_wci.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,28 @@ def from_pings_and_limits(
206206
vmax = _vmax + (_vmax - vmin) * 0.01
207207

208208
# build array with backtraced positions (beam angle, range from transducer)
209-
y_coordinates = np.linspace(hmin, hmax, horizontal_pixels)
210-
res = y_coordinates[1] - y_coordinates[0]
211-
z_coordinates = np.arange(vmin, vmax + res, res)
209+
# Apply horizontal_pixels to the longer axis to maintain aspect ratio
210+
# and prevent grid explosion when one dimension is much smaller than the other
211+
h_range = hmax - hmin
212+
v_range = vmax - vmin
213+
214+
if h_range >= v_range:
215+
# Horizontal is longer: apply max pixels to horizontal
216+
y_pixels = horizontal_pixels
217+
z_pixels = max(1, int(np.ceil(horizontal_pixels * v_range / h_range)))
218+
else:
219+
# Vertical is longer: apply max pixels to vertical
220+
z_pixels = horizontal_pixels
221+
y_pixels = max(1, int(np.ceil(horizontal_pixels * h_range / v_range)))
222+
223+
y_coordinates = np.linspace(hmin, hmax, y_pixels)
224+
z_coordinates = np.linspace(vmin, vmax, z_pixels)
225+
226+
y_res = y_coordinates[1] - y_coordinates[0] if len(y_coordinates) > 1 else h_range
227+
z_res = z_coordinates[1] - z_coordinates[0] if len(z_coordinates) > 1 else v_range
212228

213229
# compute the extent
214-
extent = [hmin - res * 0.5, hmax + res * 0.5, vmax + res * 0.5, vmin - res * 0.5]
230+
extent = [hmin - y_res * 0.5, hmax + y_res * 0.5, vmax + z_res * 0.5, vmin - z_res * 0.5]
215231

216232
# single ping case
217233
if not is_iterable(pings):

0 commit comments

Comments
 (0)