diff --git a/meson.build b/meson.build index 466ef1b..ac46180 100644 --- a/meson.build +++ b/meson.build @@ -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 ) diff --git a/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echodata.py b/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echodata.py index ebecbab..aec3032 100644 --- a/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echodata.py +++ b/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echodata.py @@ -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, ): @@ -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) @@ -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) @@ -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) diff --git a/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echoproxy.py b/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echoproxy.py index 79074e9..79a9e23 100644 --- a/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echoproxy.py +++ b/python/themachinethatgoesping/pingprocessing/watercolumn/echograms/echoproxy.py @@ -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, ): @@ -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) @@ -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) diff --git a/python/themachinethatgoesping/pingprocessing/widgets/echogramviewer.py b/python/themachinethatgoesping/pingprocessing/widgets/echogramviewer.py index 3d4e06c..e8c8889 100644 --- a/python/themachinethatgoesping/pingprocessing/widgets/echogramviewer.py +++ b/python/themachinethatgoesping/pingprocessing/widgets/echogramviewer.py @@ -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