Echoview 10’s Code operator: using Python® scripts to subsample data (and other Code operator examples)
17 July 2019
The recent article “Don’t work too hard: Subsampling leads to efficient analysis of large acoustic datasets” (Levine and De Robertis, 2019) demonstrates the potential value of subsampling to improve data processing efficiency. The authors of this article used MATLAB® to write new data files that contained only subsampled pings, but the new Code operator now makes this technique fast and easy to implement entirely within Echoview.
To try this technique: open the Dataflow window in Echoview, right-click and select New and then Variable, find the Code operator in the operator list, and click OK. On the Code page of the Variable Properties dialog box click the New button, give the Python source file a name, and click Save. In the file that opens replace the default code with the code below, then save and close the Python file.
from echoview import OperatorBase, MeasurementType, OperandInput from typing import List import numpy as np from datetime import datetime, date, time, timedelta class Operator(OperatorBase): """ Returns the first 50 pings out of every 500; all others are returned as nodata. Operands --------------------- * Operand 0 - Any acoustic variable """ def eval(self, inputs: List[OperandInput]): ping = inputs.measurement if (ping.index % 500 < 50): return ping.data else: return np.full(ping.data.shape, np.nan)
Click OK to create the variable and then double-click the newly-created object in the Dataflow window to view the resulting echogram.
Once you have created a Code operator variable you can then use the Reduce Pings operator (Method 1 or Method 2) to remove the no data (blank) pings.
The Echoview help file contains even more examples for the Code operator, including:
- Dusk and dawn bitmap: identify pings that are within a given window of time around dusk and dawn
- Biomass density estimator: distinguishes whether biomass density is low enough to obtain reliable in situ TS values, by calculating the number of fish in the acoustic sampling volume (Nv, Sawada et al., 1993; see also Gauthier and Rose, 2001) and ratio of multiple echoes when measuring a single target (M) and then testing the resulting values against their respective threshold values
- Z-score multifrequency backscatter classification: Calculates the normal derivative (Z-score) for walleye pollock (Theragra chalcogramma) as detailed in De Robertis et al. 2010
- Multibeam cross filter: Generates a bitmap representing the fish detected by applying a crossfilter on DIDSON data as detailed in Balk et al. 2009
See the help file for further details and example code.