Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for AZFP multiple phase attributes parsing #1182

Merged
merged 5 commits into from
Oct 7, 2023

Conversation

praneethratna
Copy link
Contributor

Addresses #1171 and now XML parameters from multiple phases are stored in the Vendor_Specific group.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2023

Codecov Report

Merging #1182 (7cab189) into dev (ea01132) will decrease coverage by 5.28%.
Report is 3 commits behind head on dev.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1182      +/-   ##
==========================================
- Coverage   82.37%   77.09%   -5.28%     
==========================================
  Files          65       19      -46     
  Lines        5810     3061    -2749     
==========================================
- Hits         4786     2360    -2426     
+ Misses       1024      701     -323     
Flag Coverage Δ
unittests 77.09% <100.00%> (-5.28%) ⬇️

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

Files Coverage Δ
echopype/convert/parse_azfp.py 93.53% <100.00%> (+0.33%) ⬆️
echopype/convert/set_groups_azfp.py 97.95% <100.00%> (+0.25%) ⬆️

... and 56 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@leewujung leewujung removed their request for review September 24, 2023 20:17
Copy link
Collaborator

@emiliom emiliom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments and suggestions. The PR does what it's intended to do -- thank you!! It has no bugs. My suggestions are all just improvements or clarifications.

Copy link
Collaborator

@emiliom emiliom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! I have one or two questions and some suggestions, all easy to implement. The suggestion in the test is the only one that involves substantial changes, but they should be easy to implement, too.

@emiliom
Copy link
Collaborator

emiliom commented Oct 4, 2023

Hmm, now some tests are failing 😢 . @praneethratna can you look into the error messages to see what's going on?

@praneethratna
Copy link
Contributor Author

Hmm, now some tests are failing 😢 . @praneethratna can you look into the error messages to see what's going on?

Yeah sure, but they doesn't seem to be related to my changes, but anyway closing and reopening the PR so that tests will run again.

@emiliom
Copy link
Collaborator

emiliom commented Oct 4, 2023

Yeah sure, but they doesn't seem to be related to my changes, but anyway closing and reopening the PR so that tests will run again.

Ah. Thanks for rerunning the tests. They're still failing. I'll try to take a closer look tomorrow. Your changes impact how AZFP files are processed; so, depending on which tests are failing, and on what data files, it is possible that the changes are causing this. But it sounds like you've already looked closely and discarded that possibility?

@praneethratna
Copy link
Contributor Author

praneethratna commented Oct 4, 2023

Yeah sure, but they doesn't seem to be related to my changes, but anyway closing and reopening the PR so that tests will run again.

Ah. Thanks for rerunning the tests. They're still failing. I'll try to take a closer look tomorrow. Your changes impact how AZFP files are processed; so, depending on which tests are failing, and on what data files, it is possible that the changes are causing this. But it sounds like you've already looked closely and discarded that possibility?

Yes, I've did a tear-down of docker containers and re-deployed containers on my laptop and the tests are running fine. I'm not sure why they are failing here.

@emiliom
Copy link
Collaborator

emiliom commented Oct 4, 2023

Ah, thanks! I didn't know you were now set up to run the test suite locally. Fantastic!

@emiliom emiliom closed this Oct 5, 2023
@emiliom emiliom reopened this Oct 5, 2023
@praneethratna
Copy link
Contributor Author

praneethratna commented Oct 5, 2023

Ah, thanks! I didn't know you were now set up to run the test suite locally. Fantastic!

Ah, yes! I did set up the test suite locally during the first PR itself but I've had problems with conda on my laptop. So I can basically run all the tests in python 3.10 only.

@emiliom emiliom closed this Oct 5, 2023
@emiliom emiliom reopened this Oct 5, 2023
@emiliom
Copy link
Collaborator

emiliom commented Oct 5, 2023

FYI I ran the tests locally with Python 3.10. There were 3 errors. Yeah, they do look to be unrelated to this PR. All 3 errors involve echopype/tests/convert/test_parsed_to_zarr.py::TestParsed2Zarr::test__create_zarr_info.

I'll follow up with that elsewhere. We may end up merging this PR before we resolve those other problems, but for now I'd like to investigate further.

@emiliom emiliom changed the title added support for multiple phase attributes parsing added support for AZFP multiple phase attributes parsing Oct 7, 2023
@emiliom
Copy link
Collaborator

emiliom commented Oct 7, 2023

I am persuaded that this PR is fine and can be merged, and the CI errors are cause by an unrelated problem. So, I'll go ahead and merge it now. Thanks @praneethratna !!

I'll open a new issue to address the CI problem.

@emiliom emiliom merged commit 7d413ec into OSOceanAcoustics:dev Oct 7, 2023
2 of 8 checks passed
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Oct 24, 2023
* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Feat/add nasc fix (#96)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: ruxandra valcu <ruxandra.valcu@gmail.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* docs(README): Update README on contributing section (OSOceanAcoustics#1160)

* docs(README): Update README on contributing section

Added contributors images directly from contributor graph.
Update text to move Brandon to previous dev.
Also bump the copyright date.

* docs: More updates to contrib sections

* docs: Remove thumbnails and revert text

* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
mihaiboldeanu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Readded charset-normalizer<3.2 in requirements

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 7, 2023
* added the feature described in issue 1

* Moved code for the signal attenuation mask to new file

* Resolved merge conflicts by accepting remote versions of files

* Update mask_attenuated_signal.py

* renamed utils

* Added unit test

* Test can now automatically download its data

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/utils/mask_transformation.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Cleaned up mask_transformation

* moved files and rerouted importing paths accordingly (#36)

Co-authored-by: alejandro-ariza <alejandro.ariza@ird.fr>

* Feature/add transient noise mask (#35)

* Completed feature #3 transient noise mask
---------

Co-authored-by: Mihai Boldeanu <35964395+mihaiboldeanu@users.noreply.github.com>
Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>
Co-authored-by: ruxandra valcu <ruxandra.valcu@gmail.com>

* Added extra tests for the utils/mask_transformation module to increase coverage

* Reverted test_mask.py reformating

* Moved impulse and transient noise functions to echopype/clean

* Fixed import order

* Fixed missing import in clean/conftest.py

* Moved content of tests/clean/conftest.py to tests/conftest.py

* Refactoring

* Running some linters on the code

* Fix unused imports in conftest

* Update echopype/mask/mask_attenuated_signal.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

Update mask_transformation.py

Cleaned up mask_transformation

Delinted

Removing pytest req

Refactoring

Refactoring and cleaning imports

Fixed twod test

Fixing some future merge conflicts

Fix unused import

Added attenuation mask to init

* Added channel selection to signal attenuation mask

* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* ci: Bump docker/setup-qemu-action from 2 to 3 (OSOceanAcoustics#1172)

Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](docker/setup-qemu-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci: Bump docker/login-action from 2 to 3 (OSOceanAcoustics#1175)

Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci: Bump docker/build-push-action from 4 to 5 (OSOceanAcoustics#1173)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci: Bump docker/setup-buildx-action from 2 to 3 (OSOceanAcoustics#1174)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Delinting

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* Impulse noise: modified ryan_iterable to use ryan directly

* Impulse noise: renamed medianf

* Consolidating functions

* Impulse noise refactoring: using a parameter dictionary and a function map

* Frequency filtering

* Frequency filtering (temp add to transient noise and signal attenuation, will refactor)

* Signal attenuation refactor

* Transmission noise refactor

* Impulse noise default params

* Multichannel noise masks

* Made the noise masks able to handle taking a file path as an input

* Initial mods

* Lin, log, downsample - upsample not yet functional

* Temporarily readded skimage to requirements.txt (will remove it later once I've cleaned the dependencies)

* Added xarray upsample

* Added xarray ryan/ryan_iterable

* Removed wang method for impulse noise removal. The reason for this is that we had had to adapt it quite a bit to make it generate a mask rather than modify the Sv directly (which made it quite aggressive) and trying to rebuild it to work directly on binary image operations rather than grayscale ones (dask image only has binary erode/dilate implemented currently) would have worsened it even further. Will likely make a separate PR for it once grayscale image operators are introduced in dask image.

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1 (OSOceanAcoustics#1187)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.0 to 4.7.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.7.0...v4.7.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix build bug

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1188)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](codespell-project/codespell@v2.2.5...v2.2.6)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bug/transient attenuation mask type (#93)

* Refactor _fielding function for consistent return type

* Refactor signal attenuation functions for consistent return type

* Mask transformation updates

* xarray transient method (#104)

* xarray signal attenuation method (#105)

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1197)

updates:
- [github.com/psf/black: 23.9.1 → 23.10.1](psf/black@23.9.1...23.10.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Removed scikit

* Added a test for get_dataset

* Documentation modifications

* Removed a file unused in the current PR

* Fixed an issue with multichannel denoise masks

* Merge/dev (#111)

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added dask chunking for transient data (#116)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Andrei Rusu <andrei.rusu@beatfactor.net>
Co-authored-by: ruxandra valcu <ruxandra.valcu@gmail.com>
Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>
Co-authored-by: Andrei Rusu <beatfactor@users.noreply.github.com>
Co-authored-by: alejandro-ariza <alejandro.ariza@ird.fr>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Nov 13, 2023
* docs(README): Update README on contributing section (OSOceanAcoustics#1160)

* docs(README): Update README on contributing section

Added contributors images directly from contributor graph.
Update text to move Brandon to previous dev.
Also bump the copyright date.

* docs: More updates to contrib sections

* docs: Remove thumbnails and revert text

* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
@emiliom emiliom added this to the 0.8.2 milestone Nov 15, 2023
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Dec 5, 2023
* Initial implementation of the seabed masking.

* Code for seabed masking

* Changed dilation source package from cv2 to skimage.

* some refactoring and add unit test

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/tests/mask/test_mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Re-added mask_transformation, with only the necessary functions kept

* Changed the tests to be able to autodownload its files - must check that I have the correct one though since the test isn't passing

* Cleaned up mask_transformation

* Copyright notices

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update incorrect file name

* Mask transformation consistency

* Mask transformation consistency

* Removing pytest req

* Refactoring

* Fix twod test

* Refactoring

* Test fixes

* Fixing merge compatibility

* Added dataset generation for datasets enriched with beam angle and location data

* Added dataset generation for datasets enriched with beam angle and location data

* Added channel selection.

* Modified Blackwell methods to use the physical beam angle rather than the raw EK60 beam angle - doing this using a correction on the angle itself (rather than modifying the constants) since the changes are nonlinear so if I want a linear transformation, I need to apply it on the angle data itself - angle * 22 * 128 / 180, which gets it close to how a decently calibrated EK60 instrument as used by Blackwell et al stores its raw angle data.

* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Import fix

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Refactored seabed generation masks to use parameter dicts and function maps

* Added multichannel mask support to seabed generation

* Fix build bug

* Refactor seabed detection functions for consistent return type (#92)

* Update outdated comments (#102)

Update outdated information in comments about empty masks

* Merge/dev (#113)

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Ariza conversion and initial version of ariza_interactive

* Added xarray mask transformations

* Added experimental secondary thressholding support

* Added shoal demasking option for ariza (they show up as "spikes" in the mask)

* Fix tests

* Fix tests

* Fix tests

* Fix tests - new values

* Fix tests - new values

* Reverted to original tests

* Fix/test data download (#132)

* Changed the git actions to get the files from gdrive

* Fixed typo

* Also removed charset from requirements

* Fix windows test action

* Fixed unzip on windows test

* Fixed unzip on windows test

* Fixed unzip on windows test

* Changed windows to wget

* Changed windows to wget

* Changed windows to wget

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Mihai Boldeanu <mishu_boldy@yahoo.com>
Co-authored-by: Andrei Rusu <andrei.rusu@beatfactor.net>
Co-authored-by: Andrei Rusu <beatfactor@users.noreply.github.com>
Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: Mihai Boldeanu <35964395+mihaiboldeanu@users.noreply.github.com>
ruxandra-valcu added a commit to OceanStreamIO/echopype that referenced this pull request Dec 5, 2023
* Initial implementation of the seabed masking.

* Code for seabed masking

* Changed dilation source package from cv2 to skimage.

* some refactoring and add unit test

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/tests/mask/test_mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Re-added mask_transformation, with only the necessary functions kept

* Changed the tests to be able to autodownload its files - must check that I have the correct one though since the test isn't passing

* Cleaned up mask_transformation

* Copyright notices

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update echopype/mask/mask_seabed.py

Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>

* Update incorrect file name

* Mask transformation consistency

* Mask transformation consistency

* Removing pytest req

* Refactoring

* Fix twod test

* Refactoring

* Test fixes

* Fixing merge compatibility

* Added dataset generation for datasets enriched with beam angle and location data

* Added dataset generation for datasets enriched with beam angle and location data

* Added channel selection.

* Modified Blackwell methods to use the physical beam angle rather than the raw EK60 beam angle - doing this using a correction on the angle itself (rather than modifying the constants) since the changes are nonlinear so if I want a linear transformation, I need to apply it on the angle data itself - angle * 22 * 128 / 180, which gets it close to how a decently calibrated EK60 instrument as used by Blackwell et al stores its raw angle data.

* Changed parser in `parse_azfp.py` to maintain consistency over other parsers. (OSOceanAcoustics#1135)

* replaced usage of xml.dom.minidom with xml.etree.ElementTree

* modified azfp parser and parsed all parameters

* refactored the parse_azfp code and added new tests

* small tweak in test, rename conversion function to _camel_to_snake

* updated parameter names

* Replace camel-to-snake conversion funcitonality (#1)

* Create utils camel-to-snake-case function in new misc.py, and use it in ek_raw_parsers

* Replace AZFP camel-to-snake function with new utils/misc.py function

* fixed minor error in code

* minor change in test_convert_azfp.py

* fixed failing tests

* fixed failing tests related to attribute name

* fixed minor bug

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Import fix

* ci: added support for running individual test files (OSOceanAcoustics#1166)

Added a support for testing individual test files also instead of having support for testing only subpackages.

* refactor(convert): refactor and cleanup parsed2zarr (OSOceanAcoustics#1070)

* Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (OSOceanAcoustics#999)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.8.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.6.4...v1.8.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/cache from 3.2.5 to 3.3.1 (OSOceanAcoustics#982)

Bumps [actions/cache](https://github.com/actions/cache) from 3.2.5 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3.2.5...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (OSOceanAcoustics#1022)

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.5 (OSOceanAcoustics#1021)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.1...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.5.0 to 4.6.0 (OSOceanAcoustics#1036)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.5.0...v4.6.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 (OSOceanAcoustics#1041)

Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.8.5...v1.8.6)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mamba-org/provision-with-micromamba from 15 to 16 (OSOceanAcoustics#1048)

Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16.
- [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases)
- [Commits](mamba-org/provision-with-micromamba@v15...v16)

---
updated-dependencies:
- dependency-name: mamba-org/provision-with-micromamba
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.6.0 to 4.6.1 (OSOceanAcoustics#1052)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Extract out whether_write_to_zarr and remove use_swap arg

* Initial add of destination_path

* Start using destination path and storage options, modify cleanup

* Update docstrings, and add some checks

* Add sonar model attribute to parser object

* Pass sonar_model to parser and fix bug

* Move dataarrays creation to parsed2zarr

* Remove atexit registration

* Add default DEFAULT_ZARR_TEMP_DIR global var

* Initial test for parsed2zarr components

* Add explicit no swap for conversion test

* fix: add parsed2zarr_obj to self to fix bug

* fix: uncomment zarr store close to close the store

* fix: remove unneeded typing

* fix: no need to close fsmap zarr store anymore, removing code

* feat: write tx datagram to zarr in  during p2z

* feat: add  property for ek80 p2z

* feat: set  from swap array

* fix: missing transmit data when no swap

* fix: only delete col when it exists in p2z_ek80

* test(echodata): add simple P2Z object to utils mock

* fix: Import 'List' typehint

Added import for 'List' that is currently
in use but missing.

* fix: Remove elif for column removal

Changed the if elif to a for if so
it removes both 'power' and 'angle' columns
for RAW4 'tx_datagram_df' data.

* fix: Removed dependency to 'more-itertools'

Removed dependency to 'more-itertools' by using similar
method that uses 'numpy.array_split' instead to
evenly split data into desired chunks

* test: Set 'no_swap' for 'test_combine_echodata_combined_append'

Assign 'no_swap' to 'destination_path' during 'open_raw'
to ensure that everything is in memory since the new
parsed to zarr functionality is 'auto' by default.

* feat: Add 'auto' keyword to enable auto 'use_swap'

Changed the way that 'auto' determination of 'use_swap'
by specifying an 'auto' keyword, rather than by default.
Now defaulting back to 'no_swap' for empty 'destination_path'.

* revert: Removed 'no_swap' in 'test_combine_echodata_combined_append'

On OSOceanAcoustics@b6b79fa
'no_swap' was set, however because now the default is 'no_swap'
this shouldn't be needed!

* fix: Use convention yaml for 'backscatter_x'

Sets 'long_name' attributes for 'backscatter_r' and
'backscatter_i' from the convention yaml for p2z
outputs. Additionally, units changed from 'V' to 'dB' to
sync up with the "no_swap" counterpart.

Old tests for 'test_direct_to_zarr_integration' has been activated
again to ensure equivalency b/w the two methods.

* test: Added P2Z Arrays tests

Added testing for underlying methods that
gets called during a 'datagram_to_zarr'
call to ensure that zarr arrays actually gets
created.

Ref: OSOceanAcoustics#777

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid):  improve 'compute_MVBS' using flox [all tests ci] (OSOceanAcoustics#1124)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* chore: Update suggested changes

Update some texts from suggested review as discussed.

Ref: OSOceanAcoustics#1124 (review)

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Refactored seabed generation masks to use parameter dicts and function maps

* Added multichannel mask support to seabed generation

* Fix build bug

* Refactor seabed detection functions for consistent return type (#92)

* Update outdated comments (#102)

Update outdated information in comments about empty masks

* Merge/dev (#113)

* ci: Fix run-test.py for module runs (OSOceanAcoustics#1180)

Fixes the 'run-test.py' script so it can run module
based testing rather than only specific test files.

Ref: OSOceanAcoustics#1166

* added support for AZFP multiple phase attributes parsing (OSOceanAcoustics#1182)

* added support for multiple phase attributes parsing

* minor changes to code

* Update echopype/convert/set_groups_azfp.py

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Update set_groups_azfp.py

* Update test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* ci: Update CI to barebone python [all tests ci] (OSOceanAcoustics#1192)

* ci: Add installed packages listing

* ci: Add pip listing

* ci: Remove conda from PR action

* ci: Update worklows and add P2Z skip

* ci: More cleanup to workflow

* ci: Bump actions/setup-python from 4.7.0 to 4.7.1

* fix: Fix encoding in 'to_zarr' to remove 'preferred_chunks' before saving (OSOceanAcoustics#1128)

* Encoding and Chunk matching only if DaskArray

* Removing preffered chunks from encoding dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* `parse_azfp` now parses AZFP pressure data according to given matlab code (OSOceanAcoustics#1189)

* added support for parsing azfp pressure data

* fixed failing ci tests

* Revert "fixed failing ci tests"

This reverts commit c378dc0.

* minor changes to tests

* Update test_convert_azfp.py

* Update echopype/tests/convert/test_convert_azfp.py

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* Enhanced `update_platform` to Auto-assign first `ping_time` as `Platform` timestamp for fixed-location update case without timestamp. [all tests ci] (OSOceanAcoustics#1196)

* first  is auto assigned as  timestamp for lon and lat update without timestamp

* fix small typo

---------

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Added `depth_from_pressure` method required for the calculation of `vertical_offset` value (OSOceanAcoustics#1207)

* added depth_from_pressure method

* Function arguments can be scalars or sequences; and add more tests (#2)

* Reverse order of equation terms to match UNESCO 1983 source

* For depth_from_pressure, accept scalars, lists and arrays for all 3 arguments. Include consistency checks.

* Add a greater variety of depth_from_pressure tests.

* Update echopype/utils/misc.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(commongrid): fix bugs and improve `compute_NASC` using flox (OSOceanAcoustics#1167)

* chore(deps): add flox dependency >=0.7.2

* fix(commongrid): fixes 'compute_MVBS' so it can work better and scale

Under the hood, binning along ping time and echo range now uses flox.
This allows for scalability and more community-maintained.

* docs: add small code comment

* refactor: change how ping_time index is retrieved

* refactor: remove for loop for channel

* test(mvbs): add mock Sv datasets and tests for dims (#2)

Note that @leewujung also changed mean to nanmean for skipping NaNs in each bin.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: change dask to numpy

Changed the use of dask for log10 to numpy instead since numpy can also handle dask array inputs properly.

* feat: Add method argument

Added 'method' argument to 'get_MVBS_along_channels'
and also expose additional keyword arguments control for
flox.

* fix(commongrid): Fixed to include lat lon

Fixed 'compute_MVBS' function to now
include latitude and longitude if the variables
exists in the Sv dataset.

Additionally, the flox method and keyword arguments
are now exposed within the 'compute_MVBS' function.

Ref: Issue OSOceanAcoustics#1002

* refactor: Set defaults to recommended

After some investigation, @lsetiawan
concluded that at this time the
method 'map-reduce', engine 'numpy',
and reindex True works the best,
so this is now set as default.

Also, getting echo range maximum is
through direct data slicing rather than
computation.

* feat(commongrid): Add 'range_var' argument to 'compute_MVBS'

Added a new argument 'range_var' so that user can set
the range variable to perform binning with.
There are 2 options of 'echo_range' and 'depth':

- 'echo_range': When this is set, variable 'water_level'
                is now included in the resulting MVBS dataset
- 'depth': A check is in place to ensure that this variable exists
           before moving forward and use this to perform range binning.

Ref: Issue OSOceanAcoustics#1002

* fix: Add missing attributes for lat lon

* test: Update test to use random generator

* fix: Add case for no 'water_level'

Added a case for dataset that doesn't have water level variable.

* test(nasc): Remove 'compute_NASC' import to avoid failure

* fix: Removed assumption on echo range max

Reverted back the echo range max computation
to computing on the fly since there may be some
NaN values.

* test: Extract api test and add markings

Extracted fixtures to conftest.py for commongrid.
Additionally, clean up unused functions and mark
tests b/w unit and integration. Added a new test module
called 'test_api.py' for 'commongrid.api'.

* test: Add latlon test for 'compute_MVBS'

Added a test for Sv dataset that contains latitude
and longitude going through 'compute_MVBS'
to ensure that those variables gets propagated through.

Ref: OSOceanAcoustics#1002

* test: Add small get_MVBS_along_channels test

Added test for 'get_MVBS_along_channels' with either 'depth'
as the 'range_var' or checking for 'has_positions' is True
or False.

* refactor: Integrate suggested changes

Integrated suggested changes from review such as
additional comments in code, fixing some variable names,
and extracting out the lin2log and log2lin functions.

Additionally, now echopype imports pint library
to start having unit checks in the input for compute_MVBS.

* test: Added check for position values

* test: Update range_meter_bin to strings

* test: Added 'compute_MVBS' values test

* Update echopype/tests/utils/test_processinglevels_integration.py

compute_MVBS now should preserve the processing level attributes. So, test for presence rather than absence

* test: Add 'nan' sprinkles

Sprinkled 'nan' values all over 'echo_range' to ensure that
computed values from 'compute_MVBS' doesn't take into account
the 'nan'. Added check for the expected distribution of 'nan'
in the resulting array.

Ref: OSOceanAcoustics#1124 (comment)

* revert: Revert the use of 'pint'

Removed dependency to 'pint' and use simple regex
to ensure that 'range_bin' input is unit 'm'.
Renamed 'range_meter_bin' argument to 'range_bin'.

Ref: OSOceanAcoustics#1124 (comment)

* feat: Allow 'range_bin' to have space

* fix: Apply suggestions from code review

Applied fix for regex not capturing decimal values by @emiliom

Ref: https://github.com/OSOceanAcoustics/echopype/pull/1124/files#r1320422121

Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix test text for wrong unit

* test: Remove the 'e.g.' part on pytest

Removed the part with '(e.g., '10m')' since
it's messing up pytests regex matching.

* revive the function to make changes easier to see

* add TODOs

* add computation steps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused _lin2log

* test: Remove remnant for test_ek.py

* refactor: Extract range_bin parsing and add close arg

Extracts out the 'range_bin' string to float into a private function.
Additionally now there's a fine tune argument for bin close edges
so user can specify either close is 'left' or 'right'.
Bins are converted to pandas interval index before passing
into 'get_MVBS_along_channels'.

* refactor: Update arg types to include interval index

Added argument type options for 'range_interval' and 'ping_interval' to
also be interval index.

* test: Update tests to have brute force creation

Changed mock mvbs to be created by doing brute force
rather than hard coding.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: Fix brute force mvbs gen

Fixes the generation of expected mvbs with brute force
as well as tweaks to mvbs_along_channel test.

* chore: Clean up old code for doing compute MVBS

Removes old code that perfoms compute_MVBS since
now we've switched over to flox

* chore(pytest): Added custom markers 'unit' and 'integration'

* docs: Update docstring for `compute_MVBS`

Added options for literal arguments

* refactor: Change 'parse_range_bin' to 'parse_x_bin'

Make bin parsing to be more general by making it
to 'parse_x_bin'.

* refactor: Initial unification of MVBS and NASC

Added setup and validate function for shared checks
between compute MVBS and NASC so only unique
checks are in its individual function.

* fix typo when porting from notebook

* correct attribute units from m to nmi

* refactor: Add typehints and use method

* feat: Add get_x_along_channels

Added 'get_x_along_channels' function that generalizes
the reduction routines from 'get_MVBS_along_channels'.
This now removes the old function in mvbs.py module.

Additionally, uses of 'get_MVBS_along_channels' has
been removed from the test and code for 'compute_MVBS'.

* feat: Implement new 'compute_NASC'

Use 'get_x_along_channels' for 'compute_NASC'
and turn on old 'test_nasc.py' for initial nasc testing

* test: Renamed and moved get_x_along_channels test

* fix: Use 'ffill' and 'bfill'

Fixes the 'FutureWarning' coming from pandas
since as of pandas version 2.1.0 the 'method'
argument for 'fillna' is deprecated.

Ref: OSOceanAcoustics#1167 (comment)

* feat: Allow import 'compute_NASC' from 'commongrid' module

* fix: Fix bug on setup and validate and test

Fixes bug on 'setup_and_validate' during variable checks.

Also added simple testing for values from flox vs echoview.

* test: Update simple NASC integration test

* test: Add brute force values test for NASC

* chore: Apply suggestions from code review

Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* refactor: Extract position reduction

* refactor: Separate sv mean and raw computations

* test: Remove empty test_nasc.py

* docs: Update docs for functions

* refactor: Move helper funcs to utils.py

* add L4 processing level to compute_NASC

---------

Co-authored-by: Landung 'Don' Setiawan <landungs@uw.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>

---------

Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>

* Ariza conversion and initial version of ariza_interactive

* Added xarray mask transformations

* Added experimental secondary thressholding support

* Added shoal demasking option for ariza (they show up as "spikes" in the mask)

* Stash

* Functional blackwell

* Functional blackwell

* For merge reasons

* Blackwell can now take custom percentile values

* Implemented modified Blackwell

* Fixed requirements.txt

* Removed an unused import

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Mihai Boldeanu <mishu_boldy@yahoo.com>
Co-authored-by: Andrei Rusu <andrei.rusu@beatfactor.net>
Co-authored-by: Andrei Rusu <beatfactor@users.noreply.github.com>
Co-authored-by: Raluca Simedroni <92971445+simedroniraluca@users.noreply.github.com>
Co-authored-by: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com>
Co-authored-by: Wu-Jung Lee <leewujung@gmail.com>
Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com>
Co-authored-by: Don Setiawan <landungs@uw.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Soham Butala <38330817+Sohambutala@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data conversion enhancement This makes echopype better
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants