Skip to content

Commit

Permalink
correctly process variations of sv/av/rv/... in echograms and make_image
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Oct 20, 2024
1 parent 1fdf1fd commit 563377a
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 196 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(
'cpp',
license: 'MPL-2.0',

version: '0.8.4',
version: '0.8.5',
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
1 change: 1 addition & 0 deletions python/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sources = [
'themachinethatgoesping/pingprocessing/watercolumn/image/make_wci.py',
'themachinethatgoesping/pingprocessing/watercolumn/helper/__init__.py',
'themachinethatgoesping/pingprocessing/watercolumn/helper/make_image_helper.py',
'themachinethatgoesping/pingprocessing/watercolumn/helper/select_get_wci_image.py',
'themachinethatgoesping/pingprocessing/core/__init__.py',
'themachinethatgoesping/pingprocessing/core/asserts.py',
'themachinethatgoesping/pingprocessing/core/helper.py',
Expand Down
4 changes: 2 additions & 2 deletions python/tests/widgets/test_wciviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def test_viewing_pings_in_wci_viewer_should_not_crash(self):
for folder, files in subfolders.items():
LOGGER.info(f"Testing {ending} files in {folder}")
pings = self.get_pings(files)
# viewer = Ping.pingprocessing.widgets.WCIViewer(pings)
#viewer = Ping.pingprocessing.widgets.WCIViewer(pings)

# viewer = Ping.pingprocessing.widgets.WCIViewer(self.get_pings(self.files_all+self.files_wcd))
#viewer = Ping.pingprocessing.widgets.WCIViewer(self.get_pings(self.files_all+self.files_wcd))
Original file line number Diff line number Diff line change
Expand Up @@ -244,54 +244,8 @@ def from_pings(
bottom_d.append(bd)
minslant_d.append(md)

match wci_value:
case "sv/av/pv/rv":
if ping.watercolumn.has_sv():
wci = ping.watercolumn.get_sv(sel)
elif ping.watercolumn.has_av():
wci = ping.watercolumn.get_av(sel)
elif ping.watercolumn.has_pv():
wci = ping.watercolumn.get_pv(sel)
else:
wci = ping.watercolumn.get_rv(sel)
case "sp/ap/pp/rp":
if ping.watercolumn.has_sp():
wci = ping.watercolumn.get_sp(sel)
elif ping.watercolumn.has_ap():
wci = ping.watercolumn.get_ap(sel)
elif ping.watercolumn.has_pp():
wci = ping.watercolumn.get_pp(sel)
else:
wci = ping.watercolumn.get_rp(sel)
case "power/amp":
if ping.watercolumn.has_power():
wci = ping.watercolumn.get_power(sel)
else:
wci = ping.watercolumn.get_amplitudes(sel)
case "amp":
wci = ping.watercolumn.get_amplitudes(sel)
case "av":
wci = ping.watercolumn.get_av(sel)
case "ap":
wci = ping.watercolumn.get_ap(sel)
case "power":
wci = ping.watercolumn.get_power(sel)
case "sp":
wci = ping.watercolumn.get_sp(sel)
case "sv":
wci = ping.watercolumn.get_sv(sel)
case "pv":
wci = ping.watercolumn.get_pv(sel)
case "rv":
wci = ping.watercolumn.get_rv(sel)
case "rp":
wci = ping.watercolumn.get_rp(sel)
case "pp":
wci = ping.watercolumn.get_pp(sel)
case _:
raise ValueError(
f"Invalid value for wci_value: {wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)
# select which ping.watercolumn.get_ function to call based on wci_value
wci = pingprocessing.watercolumn.helper.select_get_wci_image(ping, sel, wci_value)

if wci.shape[0] == 1:
wci = wci[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,54 +275,10 @@ def from_pings(
def get_wci(self, nr):
sel = self.beam_sample_selections[nr]
ping = self.pings[nr]
match self.wci_value:
case "sv/av/pv/rv":
if ping.watercolumn.has_sv():
wci = ping.watercolumn.get_sv(sel)
elif ping.watercolumn.has_av():
wci = ping.watercolumn.get_av(sel)
elif ping.watercolumn.has_pv():
wci = ping.watercolumn.get_pv(sel)
else:
wci = ping.watercolumn.get_rv(sel)
case "sp/ap/pp/rp":
if ping.watercolumn.has_sp():
wci = ping.watercolumn.get_sp(sel)
elif ping.watercolumn.has_ap():
wci = ping.watercolumn.get_ap(sel)
elif ping.watercolumn.has_pp():
wci = ping.watercolumn.get_pp(sel)
else:
wci = ping.watercolumn.get_rp(sel)
case "power/amp":
if ping.watercolumn.has_power():
wci = ping.watercolumn.get_power(sel)
else:
wci = ping.watercolumn.get_amplitudes(sel)
case "amp":
wci = ping.watercolumn.get_amplitudes(sel)
case "av":
wci = ping.watercolumn.get_av(sel)
case "ap":
wci = ping.watercolumn.get_ap(sel)
case "power":
wci = ping.watercolumn.get_power(sel)
case "sp":
wci = ping.watercolumn.get_sp(sel)
case "sv":
wci = ping.watercolumn.get_sv(sel)
case "pv":
wci = ping.watercolumn.get_pv(sel)
case "rv":
wci = ping.watercolumn.get_rv(sel)
case "rp":
wci = ping.watercolumn.get_rp(sel)
case "pp":
wci = ping.watercolumn.get_pp(sel)
case _:
raise ValueError(
f"Invalid value for wci_value: {self.wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)

# select which ping.watercolumn.get_ function to call based on wci_value
wci = pingprocessing.watercolumn.helper.select_get_wci_image(ping, sel, self.wci_value)


if wci.shape[0] == 1:
return wci[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

# modules
from . import make_image_helper
from .select_get_wci_image import select_get_wci_image
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
def select_get_wci_image(ping, selection, wci_value):

wci_values = wci_value.split("/")

# if there is a "/" select the first value that is available
# if none is available, still the last specified is selected
for wci_value in wci_values:
match wci_value:
case "amp":
if ping.watercolumn.has_amplitudes():
break
case "av":
if ping.watercolumn.has_av():
break
case "ap":
if ping.watercolumn.has_ap():
break
case "power":
if ping.watercolumn.has_power():
break
case "sp":
if ping.watercolumn.has_sp():
break
case "sv":
if ping.watercolumn.has_sv():
break
case "pv":
if ping.watercolumn.has_pv():
break
case "rv":
if ping.watercolumn.has_rv():
break
case "rp":
if ping.watercolumn.has_rp():
break
case "pp":
if ping.watercolumn.has_pp():
break
case _:
raise ValueError(
f"Invalid value for wci_value: {wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)

match wci_value:
case "amp":
wci = ping.watercolumn.get_amplitudes(selection)
case "av":
wci = ping.watercolumn.get_av(selection)
case "ap":
wci = ping.watercolumn.get_ap(selection)
case "power":
wci = ping.watercolumn.get_power(selection)
case "sp":
wci = ping.watercolumn.get_sp(selection)
case "sv":
wci = ping.watercolumn.get_sv(selection)
case "pv":
wci = ping.watercolumn.get_pv(selection)
case "rv":
wci = ping.watercolumn.get_rv(selection)
case "rp":
wci = ping.watercolumn.get_rp(selection)
case "pp":
wci = ping.watercolumn.get_pp(selection)
case _:
raise ValueError(
f"Invalid value for wci_value: {wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)

return wci
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import themachinethatgoesping.echosounders as es
import themachinethatgoesping.algorithms.geoprocessing as gp

from themachinethatgoesping import pingprocessing
import themachinethatgoesping.pingprocessing.watercolumn.helper.make_image_helper as mi_hlp
from themachinethatgoesping.pingprocessing.core.progress import get_progress_iterator
import themachinethatgoesping as Ping
Expand Down Expand Up @@ -238,54 +239,8 @@ def make_beam_sample_image(

sel = ping_sample_selector.apply_selection(ping.watercolumn)

match wci_value:
case "sv/av/pv/rv":
if ping.watercolumn.has_sv():
wci = ping.watercolumn.get_sv(sel)
elif ping.watercolumn.has_av():
wci = ping.watercolumn.get_av(sel)
elif ping.watercolumn.has_pv():
wci = ping.watercolumn.get_pv(sel)
else:
wci = ping.watercolumn.get_rv(sel)
case "sp/ap/pp/rp":
if ping.watercolumn.has_sp():
wci = ping.watercolumn.get_sp(sel)
elif ping.watercolumn.has_ap():
wci = ping.watercolumn.get_ap(sel)
elif ping.watercolumn.has_pp():
wci = ping.watercolumn.get_pp(sel)
else:
wci = ping.watercolumn.get_rp(sel)
case "power/amp":
if ping.watercolumn.has_power():
wci = ping.watercolumn.get_power(sel)
else:
wci = ping.watercolumn.get_amplitudes(sel)
case "amp":
wci = ping.watercolumn.get_amplitudes(sel)
case "av":
wci = ping.watercolumn.get_av(sel)
case "ap":
wci = ping.watercolumn.get_ap(sel)
case "power":
wci = ping.watercolumn.get_power(sel)
case "sp":
wci = ping.watercolumn.get_sp(sel)
case "sv":
wci = ping.watercolumn.get_sv(sel)
case "pv":
wci = ping.watercolumn.get_pv(sel)
case "rv":
wci = ping.watercolumn.get_rv(sel)
case "rp":
wci = ping.watercolumn.get_rp(sel)
case "pp":
wci = ping.watercolumn.get_pp(sel)
case _:
raise ValueError(
f"Invalid value for wci_value: {wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)
# select which ping.watercolumn.get_ function to call based on wci_value
wci = pingprocessing.watercolumn.helper.select_get_wci_image(ping, sel, wci_value)

return wci, [-0.5, wci.shape[0]+0.5, wci.shape[1]+0.5, -0.5]

Expand Down Expand Up @@ -344,55 +299,10 @@ def make_wci(
sel = ping_sample_selector.apply_selection(ping.watercolumn)

# t.append(time()) # 6
# get amplitudes for each pixel
match wci_value:
case "sv/av/pv/rv":
if ping.watercolumn.has_sv():
wci = ping.watercolumn.get_sv(sel)
elif ping.watercolumn.has_av():
wci = ping.watercolumn.get_av(sel)
elif ping.watercolumn.has_pv():
wci = ping.watercolumn.get_pv(sel)
else:
wci = ping.watercolumn.get_rv(sel)
case "sp/ap/pp/rp":
if ping.watercolumn.has_sp():
wci = ping.watercolumn.get_sp(sel)
elif ping.watercolumn.has_ap():
wci = ping.watercolumn.get_ap(sel)
elif ping.watercolumn.has_pp():
wci = ping.watercolumn.get_pp(sel)
else:
wci = ping.watercolumn.get_rp(sel)
case "power/amp":
if ping.watercolumn.has_power():
wci = ping.watercolumn.get_power(sel)
else:
wci = ping.watercolumn.get_amplitudes(sel)
case "amp":
wci = ping.watercolumn.get_amplitudes(sel)
case "av":
wci = ping.watercolumn.get_av(sel)
case "ap":
wci = ping.watercolumn.get_ap(sel)
case "power":
wci = ping.watercolumn.get_power(sel)
case "sp":
wci = ping.watercolumn.get_sp(sel)
case "sv":
wci = ping.watercolumn.get_sv(sel)
case "pv":
wci = ping.watercolumn.get_pv(sel)
case "rv":
wci = ping.watercolumn.get_rv(sel)
case "rp":
wci = ping.watercolumn.get_rp(sel)
case "pp":
wci = ping.watercolumn.get_pp(sel)
case _:
raise ValueError(
f"Invalid value for wci_value: {wci_value}. Choose any of ['amp','power', 'rp', 'rv', 'pp', 'pv', 'ap', 'av', 'sp', 'sv', 'power/amp', 'sp/ap/pp/rp', 'sv/av/pv/rv']."
)

# select which ping.watercolumn.get_ function to call based on wci_value
wci = pingprocessing.watercolumn.helper.select_get_wci_image(ping, sel, wci_value)

# t.append(time()) # 7
# lookup beam/sample numbers for each pixel
wci = bt.lookup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ def __init__(self, pings, horizontal_pixels=1024, name="WCI", figure=None, progr
description="wci value",
options=[
"sv/av/pv/rv",
"sv/av/pv",
"sv/av",
"sp/ap/pp/rp",
"sp/ap/pp",
"sp/ap",
"power/amp",
"av",
"ap",
Expand Down

0 comments on commit 563377a

Please sign in to comment.