# Multifrequency backscatter classification

This operator calculates the normal deviate (z-score) for walleye pollock (Theragra chalcogramma) as detailed in De Robertis et al. 2010 from three Sv inputs with the frequencies 38kHz, 120kHz, and 200kHz respectively.

## List of operands

Operand 1 - Single beam Sv (38 kHz)

Operand 2 - Single beam Sv (120 kHz)

Operand 3 - Single beam Sv (200 kHz)

## Code

```"""
Echoview Code Operator source file
========================================================================

Created by Echoview(R) 10.0.218 on Monday, 29 April 2019

See the Echoview help file for Code operator documentation and
examples.

NumPy User Guide: https://docs.scipy.org/doc/numpy/user/
NumPy Reference: https://docs.scipy.org/doc/numpy/Reference/
SciPy Reference Guide: https://docs.scipy.org/doc/scipy/Reference/

Echoview(R) is a registered trademark of Echoview Software Pty Ltd.
"""

# Authorship information
__author__ = "Echoview Software Pty Ltd. 2019."
__disclaimer__ = (
"This example code is provided AS IS, without warranty of any "
"kind, express or implied, including but not limited to the "
"warranties of merchantability, fitness for a particular purpose "
"and noninfringement. In no event shall Echoview Software Pty Ltd "
"be liable for any claim, damages or other liability, arising "
"from, out of or in connection with the use of this example code."
)
__version__ = "1.0"

# System Imports
from typing import List

# Libraries
from echoview import OperatorBase, MeasurementType, OperandInput, Error
import numpy as np

class Operator(OperatorBase):
"""
Normal derivative (z-score)
====================================================================

Calculates the normal derivative (z-score) for walleye pollock
(Theragra chalcogramma)

Operands
---------------------

* Operand 1 - Single beam Sv (38kHz)
* Operand 2 - Single beam Sv (120kHz)
* Operand 3 - Single beam Sv (200kHz)

Note that all operands must have the same ping timings and geometry.
This can be accomplished using *Match ping times* and
*Match geometry* virtual variables.

Notes
--------------------------

This operator calculates the normal deviate (z-score) for walleye
pollock (Theragra chalcogramma) as detailed in De Robertis et al.
2010 from three Sv inputs with the frequencies 38kHz, 120kHz, and
200kHz respectively.
"""

def result_type(self, input_types):
"""Returns single beam magnitude (linear) as the result type."""

return MeasurementType.SINGLE_BEAM_LINEAR

def eval(self, inputs):
"""
Calculates the normal deviate (z-score) for walleye pollock
for the specified input pings.
"""

input_0_data = inputs[0].measurement.data
input_1_data = inputs[1].measurement.data
input_2_data = inputs[2].measurement.data

return (np.abs((input_1_data-input_0_data-0.2)/2.6) +
np.abs((input_2_data-input_1_data-1.2)/1.8) +
np.abs((input_2_data-input_0_data-1.9)/2.5))/3.0
```