OSOceanAcoustics / echopype

Enabling interoperability and scalability in ocean sonar data analysis
https://echopype.readthedocs.io/
Apache License 2.0
91 stars 71 forks source link

Enable use of data from EchoData object in `consolidate.add_depth` #1205

Closed emiliom closed 1 month ago

emiliom commented 8 months ago

Overhaul consolidate.add_depth to enable using data from EchoData object. Addresses #790. See the echopype documentation for reference on several of the variables.

Rotations are performed using scipy.spatial.transform.Rotation.

Notes and caveats:

codecov-commenter commented 8 months ago

Codecov Report

Merging #1205 (43e44cd) into dev (9dfe5ba) will increase coverage by 15.77%. Report is 3 commits behind head on dev. The diff coverage is 97.61%.

@@             Coverage Diff             @@
##              dev    #1205       +/-   ##
===========================================
+ Coverage   77.08%   92.85%   +15.77%     
===========================================
  Files          67        3       -64     
  Lines        5921      196     -5725     
===========================================
- Hits         4564      182     -4382     
+ Misses       1357       14     -1343     
Flag Coverage Δ
unittests 92.85% <97.61%> (+15.77%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
echopype/consolidate/api.py 94.95% <97.61%> (+1.13%) :arrow_up:

... and 64 files with indirect coverage changes

:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

emiliom commented 8 months ago

Notes to self for creating mock EchoData data for testing the new functionality. Here's the minimal code needed to create a bare EchoData object that has just the elements needed by consolidate.add_depth: a sonar_model attribute and the "Platform" and "Sonar/Beam_group1" groups.

from datatree import DataTree
import xarray as xr
from echopype.echodata.echodata import EchoData

ed = EchoData(sonar_model="EK80")

ds1 = xr.Dataset(dict(bar=("x", [1, 2])))
ds2 = xr.Dataset(dict(bar=("x", [10, 20])))
tree = DataTree.from_dict({'Platform': ds1, 'Sonar/Beam_group1': ds2}, name='root')
ed._set_tree(tree)
emiliom commented 8 months ago

Added a test function to generate mock EchoData object with only the variables (and one attribute) required by consolidate.add_depth. This function partially populates only the Platform, Sonar and Sonar/Beam_group1 groups, plus root by default. Also added a test (test_add_depth_from_echodata_mock) that uses this mock data, together with a mock Sv Dataset.

leewujung commented 3 months ago

@ctuguinay : This is also related to #1152. Let's talk through this.

leewujung commented 1 month ago

We'll close this now because it'll be superseded by #1319 .