Right now we have 2 places that checks the combination of input argument for compute_Sv/Sp in terms of encode_mode and waveform_mode.
Here:
|
# TODO: consolidate the below block with simrad.py::check_input_args_combination() |
|
# Check on waveform_mode, encode_mode inputs, and assumption on single filter time |
|
if echodata.sonar_model == "EK80": |
|
if waveform_mode is None or encode_mode is None: |
|
raise ValueError("waveform_mode and encode_mode must be specified for EK80 calibration") |
|
check_input_args_combination(waveform_mode=waveform_mode, encode_mode=encode_mode) |
|
elif echodata.sonar_model in ("EK60", "AZFP", "AZFP6"): |
|
if waveform_mode is not None and waveform_mode != "CW": |
|
logger.warning( |
|
"This sonar model transmits only narrowband signals (waveform_mode='CW'). " |
|
"Calibration will be in CW mode", |
|
) |
|
if encode_mode is not None and encode_mode != "power": |
|
logger.warning( |
|
"This sonar model only record data as power or power/angle samples " |
|
"(encode_mode='power'). Calibration will be done on the power samples.", |
|
) |
and in the function check_input_args_combination here:
|
def check_input_args_combination( |
|
waveform_mode: str, encode_mode: str, pulse_compression: bool = None |
|
) -> None: |
|
""" |
|
Checks that the ``waveform_mode`` and ``encode_mode`` have |
|
the correct values and that the combination of input arguments are valid, without |
|
considering the actual data. |
|
|
|
Parameters |
|
---------- |
|
waveform_mode: str |
|
Type of transmit waveform |
|
encode_mode: str |
|
Type of encoded return echo data |
|
pulse_compression: bool |
|
States whether pulse compression should be used |
|
""" |
|
|
|
if waveform_mode not in ["CW", "BB"]: |
|
raise ValueError("The input waveform_mode must be either 'CW' or 'BB'!") |
|
|
|
if encode_mode not in ["complex", "power"]: |
|
raise ValueError("The input encode_mode must be either 'complex' or 'power'!") |
|
|
|
# BB has complex data only, but CW can have complex or power data |
|
if (waveform_mode == "BB") and (encode_mode == "power"): |
|
raise ValueError( |
|
"Data from broadband ('BB') transmission must be recorded as complex samples" |
|
) |
|
|
|
# make sure that we have BB and complex inputs, if pulse compression is selected |
|
if pulse_compression is not None: |
|
if pulse_compression and ((waveform_mode != "BB") or (encode_mode != "complex")): |
|
raise RuntimeError( |
|
"Pulse compression can only be used with " |
|
"waveform_mode='BB' and encode_mode='complex'" |
|
) |
The checks these code blocks perform are different, since one also deals with different sonar_models, but I think it would be cleaner to just have 1 function in the calibration subpackage to do this (check_input_args_combination shouldn't be in echodata/simrad.py).
Right now we have 2 places that checks the combination of input argument for
compute_Sv/Spin terms ofencode_modeandwaveform_mode.Here:
echopype/echopype/calibrate/api.py
Lines 39 to 55 in 2720812
and in the function
check_input_args_combinationhere:echopype/echopype/echodata/simrad.py
Lines 13 to 49 in 2720812
The checks these code blocks perform are different, since one also deals with different
sonar_models, but I think it would be cleaner to just have 1 function in thecalibrationsubpackage to do this (check_input_args_combinationshouldn't be inechodata/simrad.py).