Skip to content

Introducing modes of operation#34

Merged
forman merged 57 commits into
mainfrom
forman-6-introduce_modes
Apr 15, 2025
Merged

Introducing modes of operation#34
forman merged 57 commits into
mainfrom
forman-6-introduce_modes

Conversation

@forman
Copy link
Copy Markdown
Collaborator

@forman forman commented Mar 19, 2025

Closes #6

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 99.57356% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xarray_eopf/backend.py 97.72% 1 Missing ⚠️
xarray_eopf/spatial.py 98.90% 1 Missing ⚠️
Files with missing lines Coverage Δ
xarray_eopf/amode.py 100.00% <100.00%> (ø)
xarray_eopf/amodes/__init__.py 100.00% <100.00%> (ø)
xarray_eopf/amodes/sentinel1.py 100.00% <100.00%> (ø)
xarray_eopf/amodes/sentinel2.py 100.00% <100.00%> (ø)
xarray_eopf/amodes/sentinel3.py 100.00% <100.00%> (ø)
xarray_eopf/constants.py 100.00% <100.00%> (ø)
xarray_eopf/filter.py 100.00% <100.00%> (ø)
xarray_eopf/flatten.py 100.00% <100.00%> (ø)
xarray_eopf/prefix.py 100.00% <100.00%> (ø)
xarray_eopf/store.py 100.00% <100.00%> (ø)
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@forman forman changed the title Introducing modes Introducing modes of operation Apr 2, 2025
@forman
Copy link
Copy Markdown
Collaborator Author

forman commented Apr 11, 2025

  • allow also Zarr groups like r10m to be opened, thus open_dataset method needs to understand if this is a Zarr group

That might be ok, but may also be achieved by dropping/excluding variables. Anyway it is out of scope of this PR. Let's create an issue and PR for this after this PR.

  • I am not convinced by the flat structure when using open_dataset in native mode; it looks very complicated, ...

I am, because:

  1. The main intend is to have a view of the complicated data tree as a dataset - no matter how things are named. The naming follows a logical and traceable pattern, that allows for easier access of data variables given well-known keys.
  2. Regarding it looks very complicated: Jupyter notebooks users are not the only ones. For example, you could also use the xarray backend in server context where xarray.Dataset objects are required, not xarray.DataTree and where no user actually looks at the names, hence it doesn't matter whether they "look complicated" or not.

We should add this to the user docs!

  • We should try to get rid of product_type_name, and extract the product type from the file name; it is possible for a FSMap from fsspec via root; it is possible for zarr.DirectoryStore; I think this should cover most cases.

Yes, we discussed this already once. There is also a TODO in the code and we should create another PR dedicated to this later.

@forman forman marked this pull request as ready for review April 11, 2025 07:09
@forman forman requested a review from konstntokas April 11, 2025 07:09
Copy link
Copy Markdown
Collaborator

@konstntokas konstntokas left a comment

Choose a reason for hiding this comment

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

A few general points here and see my comments below. We are almost done!

  • remove examples/ceph_tests.ipynb
  • delete cell 22 in examples/open-sen1-native.ipynb and rerun again, the cells after cell 22 are not executed due to the error
  • [Optional] improve colorbars in examples/open-sen2-analysis.ipynb; set vmin and vmax fo reflectance data; use mask
  • run isort .`

Comment thread docs/guide.md Outdated
Comment thread docs/guide.md Outdated
@@ -0,0 +1,108 @@
The xarray backend for EOPF data products `"eopf-zarr"` has two modes of operation,
namely _analysis mode_ and _native mode_, which are described in the following.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should write here that the analysis mode is the default.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread docs/guide.md Outdated
Comment on lines +42 to +46
Works basically as `open_datatree()` but using flattened Zarr groups, e.g., groups
`r10m`, `r20m`, `r60m` in Sentinel 2 MSI products.
Flattening includes renaming variables and dimensions by prefixing them using the
concatenated names of nested groups.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is no renaming happening of the variables and coordinates in the analysis mode. I think these 4 lines need some adjustment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread xarray_eopf/constants.py Outdated
Comment on lines +26 to +28
OPEN_DT_URL = "https://docs.xarray.dev/en/stable/generated/xarray.open_datatree.html"
OPEN_DS_URL = "https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html"
FSSPEC_USAGE_URL = "https://filesystem-spec.readthedocs.io/en/latest/usage.html"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These constants are not used.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, they are leftovers from my try to use them in f-string docstrings. But unfortunately that didn't work with mkdocs-python.

Removed.

Comment thread xarray_eopf/filter.py
Comment on lines +22 to +23
# TODO: also drop now unused coordinates + dimensions as
# they remain even if no longer referenced by any data variables
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I created an issue #38

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good!

Comment thread xarray_eopf/flatten.py Outdated
Comment thread xarray_eopf/spatial.py Outdated
data=rescaled_data,
dims=var.dims[:-2] + ref_var.dims[-2:],
name=var.name,
attrs=var.attrs,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should add information here, if a band was rescaled and what was the original resolution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good idea. Will add a history entry.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

forman and others added 7 commits April 14, 2025 18:17
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
@forman
Copy link
Copy Markdown
Collaborator Author

forman commented Apr 14, 2025

A few general points here and see my comments below. We are almost done!

  • remove examples/ceph_tests.ipynb

Done.

  • delete cell 22 in examples/open-sen1-native.ipynb and rerun again, the cells after cell 22 are not executed due to the error

Done.

  • [Optional] improve colorbars in examples/open-sen2-analysis.ipynb; set vmin and vmax fo reflectance data; use mask

Adjust as you like.

  • run isort .`

Done.

@forman forman requested a review from konstntokas April 14, 2025 18:11
Copy link
Copy Markdown
Collaborator

@konstntokas konstntokas left a comment

Choose a reason for hiding this comment

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

Thank you, looks all good. We can merge now!

I created issue #38, #39, #40, #41 as follow up tasks.

@forman forman merged commit 4cdff22 into main Apr 15, 2025
1 of 2 checks passed
@forman forman deleted the forman-6-introduce_modes branch April 16, 2025 07:56
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.

Implement convenience mode

2 participants