OSOceanAcoustics / echopype

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

Use Simple Indexing for Noise and Attenuation Function Aggregations/Comparisons #1321

Closed ctuguinay closed 2 months ago

ctuguinay commented 4 months ago

This issue addresses the performance issue encountered in the #1314 noise and attenuation masking functions, which comes from the aggregations in the masking functions being those where the selection of depth is assumed to be non-uniform across channel and ping time. This forces us to basically do a 'where depth meets this criteria' check to create our aggregations instead of doing something fast and index-based like .coarsen.

From @leewujung in #1314 discussion:

All of the criteria are built on the concept of comparing with neighbors, and the binning from accurate bin edges (from the coordinate labels) vs inaccurate bin edges (from just the indices) would likely result in pretty small differences. If the noise needs to be masked, it would get masked either way; if the noise is borderline, the masking is likely be at least equally sensitive to other independent parameter changes (such as changing the averaging bin size along depth or across pings).

I envision implementing a fast indexed version of these functions by allowing the user to pass in use_index_binning=True/False into each of the existing functions and right before an aggregation occurs in the masking function, we choose between a .coarsen like function and the slow aggregations that we currently have from #1314 (based on use_index_binning).