Tutorial 4: Extract WCD#

themachinethatgoesping tutorial series#

themachinethatgoesping concepts covered:

  • Get WCD

  • WCD data subselection

[1]:
%matplotlib widget

import numpy as np
import themachinethatgoesping as theping
from matplotlib import pyplot as plt
from tqdm.auto import tqdm

# data folder
folder = '../unittest_data'

# list raw data files
files = theping.echosounders.index_functions.find_files(folder,['.all','.wcd'])
files.sort()

# create the file handler
cache_files = theping.echosounders.index_functions.get_index_paths(files)
fileHandler = theping.echosounders.kongsbergall.KongsbergAllFileHandler(files,cache_files,init=True)

# get the list of all pings that contain WCD
pings = theping.pingprocessing.filter_pings.by_features(fileHandler.get_pings(),['watercolumn.amplitudes'])

# check data with the WCI Viewer
viewer = theping.widgets.WCIViewer(pings)
Found 18 files
indexing files ⢀ 99% [00m:00s<00m:00s] [Found: 1484 datagrams in 18 files (26MB)]
Initializing ping interface ⢀ 90% [00m:00s<00m:00s] [Done]
WARNING: get_depth_sensor_offsets: Only DSH (Depth (pressure) sensor heave) == NI is supported yet, but DSH is IN
WARNING: get_depth_sensor_offsets: Only DSH (Depth (pressure) sensor heave) == NI is supported yet, but DSH is IN

Get WCD#

[2]:
# Get the WCD from the first ping
image = pings[0].watercolumn.get_av()
# output is a beam x samples numpy array
print(f"num beams: {np.shape(image)[0]}, num samples: {np.shape(image)[1]}")

# display
fig1,ax1 = theping.pingprocessing.core.create_figure('wci') # we transpose the image for display purposes
ax1.imshow(image.transpose(),aspect='auto')
ax1.set_xlabel('Beam #')
ax1.set_ylabel('Sample #')
ax1.set_title('first ping full WCD, flat view')
num beams: 128, num samples: 880
[2]:
Text(0.5, 1.0, 'first ping full WCD, flat view')

WCD data subselection#

[3]:
# We can specify the data we want, using a pingsampleselector
pss = theping.echosounders.pingtools.PingSampleSelector()
pss.select_beam_range_by_angles(-45,0,5) # min angle, max angle, stepsize in degrees. Other selection options are available

# apply the ping selector for beam x sample data
bs = pss.apply_selection(pings[0].watercolumn)
image = pings[0].watercolumn.get_av(bs)

# display
fig2,ax2 = theping.pingprocessing.core.create_figure('wci') # we transpose the image for display purposes
ax2.imshow(image.transpose(),aspect='auto')
ax2.set_xlabel('Beam #')
ax2.set_ylabel('Sample #')
ax2.set_title('first ping WCD, flat view, selected beams')
[3]:
Text(0.5, 1.0, 'first ping WCD, flat view, selected beams')
[ ]: