-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Simrad echosounders have a hierachical relationship between individual sonar model strings and the broader processing "class" (used loosely!). Specifically:
| "Class" | Sonar models |
|---|---|
| EK60 | EK60, ES70 |
| EK80 | EK80, ES80, EA640 |
Converting from the sonar model strings to the "class" is a recurring need across the code base that is implemented independently in many different places. Here are two examples:
echopype/echopype/convert/set_groups_base.py
Line 349 in f8082ca
| if self.sonar_model in ["EK60", "ES70"]: |
echopype/echopype/calibrate/range.py
Lines 150 to 153 in f8082ca
| if echodata.sonar_model in ("EK60", "ES70"): | |
| ek_str = "EK60" | |
| elif echodata.sonar_model in ("EK80", "ES80", "EA640"): | |
| ek_str = "EK80" |
This need to reimplement carries the potential of forgetting to do it; I've run into those oversights a couple of times.
The relationship is already expressed implicitly in core.SONAR_MODELS, eg:
Lines 80 to 91 in f8082ca
| "ES80": { | |
| "validate_ext": validate_ext(".raw"), | |
| "xml": False, | |
| "parser": ParseEK80, | |
| "parsed2zarr": Parsed2ZarrEK80, | |
| "set_groups": SetGroupsEK80, | |
| "dgram_zarr_vars": { | |
| "power": ["timestamp", "channel_id"], | |
| "complex": ["timestamp", "channel_id"], | |
| "angle": ["timestamp", "channel_id"], | |
| }, | |
| }, |
We should think about options for handling this more systematically. For example, one option could involve encoding the sonar model "class" (I'm sure there's a better label for this!) in core.SONAR_MODELS, then using that consistently. And/or encoding it as a property of the echodata object, so it's always available. Doing something like that would eliminate a lot of hard-wired listings of individual sonar models in if-then statements.