Skip to content

Commit

Permalink
- no_navigation mode for echodata and echoproxy from_pings functions
Browse files Browse the repository at this point in the history
 - invert_y_axis for echogramviewer
  • Loading branch information
peter-urban committed Nov 26, 2024
1 parent 6e39fbe commit e8d699e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(
'themachinethatgoesping_pingprocessing',
'cpp',
license: 'MPL-2.0',
version: '0.9.1',
version: '0.9.2',
default_options: ['warning_level=2', 'buildtype=release', 'cpp_std=c++20'],
meson_version: '>=1.3.2' #first version with clang-cl openmp support
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def from_pings(
pss=echosounders.pingtools.PingSampleSelector(),
wci_value: str = "sv/av/pv/rv",
linear_mean=True,
no_navigation=False,
apply_pss_to_bottom=False,
verbose=True,
):
Expand Down Expand Up @@ -214,18 +215,22 @@ def from_pings(
continue

c = ping.watercolumn.get_sound_speed_at_transducer()
z = ping.get_geolocation().z
range_res = ping.watercolumn.get_sample_interval() * c * 0.5
angle_factor = np.cos(
np.radians(np.mean(ping.watercolumn.get_beam_crosstrack_angles()[sel.get_beam_numbers()]))
)
min_r[nr] = sel.get_first_sample_number_ensemble() * range_res
max_r[nr] = sel.get_last_sample_number_ensemble() * range_res
min_d[nr] = z + min_r[nr] * angle_factor
max_d[nr] = z + max_r[nr] * angle_factor

echosounder_d_times.append(times[nr])
echosounder_d.append(z)
max_r[nr] = sel.get_last_sample_number_ensemble() * range_res
echosounder_d_times.append(times[nr])

if not no_navigation:
if not ping.has_geolocation():
raise RuntimeError(f"ERROR: ping {nr} has no geolocation. Either filter pings based on geolocation feature or set no_navigation to True")

z = ping.get_geolocation().z
min_d[nr] = z + min_r[nr] * angle_factor
max_d[nr] = z + max_r[nr] * angle_factor
echosounder_d.append(z)

if max_d[nr] > 6000:
print(f"ERROR [{nr}], r1{min_r[nr]}, r1{max_r[nr]}, d1{min_d[nr]}, d1{max_d[nr]}", z, angle_factor)
Expand All @@ -236,14 +241,14 @@ def from_pings(
# bd = np.nanmin(p.bottom.get_xyz(sel_bottom).z) + p.get_geolocation().z
# this is incorrect
br = np.nanquantile(ping.bottom.get_xyz(sel).z, 0.05)
bd = br + z
mr = np.nanquantile(ping.watercolumn.get_bottom_range_samples(), 0.05) * range_res * angle_factor
md = mr + z
# bd = minslant_d

bottom_d_times.append(times[nr])
bottom_d.append(bd)
minslant_d.append(md)

if not no_navigation:
bd = br + z
md = mr + z
bottom_d.append(bd)
minslant_d.append(md)

# select which ping.watercolumn.get_ function to call based on wci_value
wci = pingprocessing.watercolumn.helper.select_get_wci_image(ping, sel, wci_value)
Expand All @@ -263,7 +268,9 @@ def from_pings(

data = cls(wc_data, times)
data.set_range_extent(min_r, max_r)
data.set_depth_extent(min_d, max_d)
if not no_navigation:
data.set_depth_extent(min_d, max_d)

if len(bottom_d) > 0:
data.add_ping_param("bottom", "Ping time", "Depth (m)", bottom_d_times, bottom_d)
data.add_ping_param("minslant", "Ping time", "Depth (m)", bottom_d_times, minslant_d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def from_pings(
pss=echosounders.pingtools.PingSampleSelector(),
wci_value: str = "sv/av/pv/rv",
linear_mean=True,
no_navigation=False,
apply_pss_to_bottom=False,
verbose=True,
):
Expand Down Expand Up @@ -230,18 +231,22 @@ def from_pings(
continue

c = ping.watercolumn.get_sound_speed_at_transducer()
z = ping.get_geolocation().z
range_res = ping.watercolumn.get_sample_interval() * c * 0.5
angle_factor = np.cos(
np.radians(np.mean(ping.watercolumn.get_beam_crosstrack_angles()[sel.get_beam_numbers()]))
)
min_r[nr] = sel.get_first_sample_number_ensemble() * range_res
max_r[nr] = sel.get_last_sample_number_ensemble() * range_res
min_d[nr] = z + min_r[nr] * angle_factor
max_d[nr] = z + max_r[nr] * angle_factor

echosounder_d_times.append(times[nr])
echosounder_d.append(z)
max_r[nr] = sel.get_last_sample_number_ensemble() * range_res
echosounder_d_times.append(times[nr])

if not no_navigation:
if not ping.has_geolocation():
raise RuntimeError(f"ERROR: ping {nr} has no geolocation. Either filter pings based on geolocation feature or set no_navigation to True")

z = ping.get_geolocation().z
min_d[nr] = z + min_r[nr] * angle_factor
max_d[nr] = z + max_r[nr] * angle_factor
echosounder_d.append(z)

if max_d[nr] > 6000:
print(f"ERROR [{nr}], r1{min_r[nr]}, r1{max_r[nr]}, d1{min_d[nr]}, d1{max_d[nr]}", z, angle_factor)
Expand All @@ -252,18 +257,20 @@ def from_pings(
# bd = np.nanmin(p.bottom.get_xyz(sel_bottom).z) + p.get_geolocation().z
# this is incorrect
br = np.nanquantile(ping.bottom.get_xyz(sel).z, 0.05)
bd = br + z
mr = np.nanquantile(ping.watercolumn.get_bottom_range_samples(), 0.05) * range_res * angle_factor
md = mr + z
# bd = minslant_d

bottom_d_times.append(times[nr])
bottom_d.append(bd)
minslant_d.append(md)

if not no_navigation:
bd = br + z
md = mr + z
bottom_d.append(bd)
minslant_d.append(md)

data = cls(pings, times, beam_sample_selections, wci_value, linear_mean=linear_mean)
data.set_range_extent(min_r, max_r)
data.set_depth_extent(min_d, max_d)
if not no_navigation:
data.set_depth_extent(min_d, max_d)

if len(bottom_d) > 0:
data.add_ping_param("bottom", "Ping time", "Depth (m)", bottom_d_times, bottom_d)
data.add_ping_param("minslant", "Ping time", "Depth (m)", bottom_d_times, minslant_d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ def show_background_zoom(self, event = 0):

self.progress.description = 'Idle'

def invert_y_axis(self):
with self.output:
for ax in self.axes:
ax.invert_yaxis()
self.fig.canvas.draw()

def update_view(self, w=None, reset=False):
with self.output:
# detect changes in view settings
Expand Down

0 comments on commit e8d699e

Please sign in to comment.