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

decouple mooring_array from cutout + bug + refactor + ... #399

Merged
merged 259 commits into from
Nov 7, 2023

Conversation

Mikejmnez
Copy link
Collaborator

@Mikejmnez Mikejmnez commented Nov 3, 2023

Closes #378 #379 #384

Checklist

  • The PR addresses an open issue.
  • All tests are passing locally with pytest.
  • The project passes linting with black and flake8.

Changes
This is essentially Part 2 of work I began back in March, when I started to work on mooring_array to allow compatibility with xoak. Here, a substantially more challenging and overwhelming effort which I began in July, decouples mooring_array from cutout, and addresses various open issues. In particular it closes: #378 , #379, #384 . See also #398.

To enumerate the features / fixes:

  1. Allows mooring_array to be calculated without going through cutout first, whenever the extra argument serial=True is passed.
  2. serial=False is the default behavior, and the new code implementation is separate from the previous way mooring_array works. This allows legacy code to remain intact.
  3. Unpins scipy, and as a result OceanSpy will fail to build a tree when there is nan-data in the coordinates. This can happen with cutout + llc-data at high lats, resulting in an Error.
  4. Because of 3, mooring_array + serial=True should be preferably used when face is a dimension.
  5. mooring_array and also returns the pair (diffX, diffY), which is necessary for mooring_volume_transport. These variables are otherwise computed in mooring_volume_transport in a way that is incompatible with datasets with face as a dimension.
  6. mooring_array + serial=True, computes the coordinates [XU,YU, XV, YV] from the coordinates of the mooring_array. Before, these were computed during cutout for the entire area encompassing the mooring_array, which was extremely inefficient. These 4 variables are required to be present in the dataset when computing mooring_volume_transport.
  7. Significantly improves coverage.

In addition, this PR also refactors quite a bit subsample, although I had to create a bunch of functions and added them to llc_rearrange.

To see some of the behavior, I uploaded a testing notebook to GH, that is rather clean. The link is here: https://github.com/Mikejmnez/Notebooks/blob/main/ospy_mooring_latest.ipynb

Also, see this notebook for a comparison between the behavior of mooring_array via cutout (serial=False) and the new implementation (serial=True) with ECCO, one single snapshot.
https://github.com/Mikejmnez/Notebooks/blob/main/Mooring_volume_transport.ipynb

@Mikejmnez
Copy link
Collaborator Author

hmm I though adding shapely into the ci/environment.yaml would be enough...

@Mikejmnez
Copy link
Collaborator Author

hmm. I had to add shapely as a dependency in pyproject.toml.

@Mikejmnez
Copy link
Collaborator Author

this is taking way to long... I am going to restart the build of 3.11

@Mikejmnez
Copy link
Collaborator Author

Good, finally. FYI test_opening_and_saving within oceanspy/tests/test_open_oceandataset.py often times will get stuck, that is what was happening here, and it often happens in my local computer.

oceanspy/utils.py Outdated Show resolved Hide resolved
oceanspy/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@MaceKuailv MaceKuailv left a comment

Choose a reason for hiding this comment

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

This is a lot of work and is really really cool!

@Mikejmnez
Copy link
Collaborator Author

Mikejmnez commented Nov 7, 2023

Feel free to merge this. I introduced some functions in llc_rearrage to be used with mooring_array/stations that I think can and should be used in the arctic transformation, i.e. they'd greatly improve the behavior of the transformation. And so both llc_rearrage and its testing needs refactoring just like @MaceKuailv says. But I don't think I have the capacity for this now...

@Mikejmnez Mikejmnez merged commit df6c6ac into hainegroup:main Nov 7, 2023
5 checks passed
@Mikejmnez Mikejmnez deleted the dev branch November 9, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mooring (xoak) sampling fails when nan data is present in the coordinates
3 participants