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

apply nomalization to rgb data along the time dim #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zxdawn
Copy link

@zxdawn zxdawn commented Dec 13, 2024

See this discussion: #76

Copy link
Owner

@aazuspan aazuspan left a comment

Choose a reason for hiding this comment

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

Thanks @zxdawn! The failed check is unrelated to your change, but I ran tests locally and test_normalize is failing. That test (below) uses a DataArray without a variable dimension, which should be supported.

wxee/test/test_xarray.py

Lines 60 to 68 in 1c41593

def test_normalize():
"""Test that a normalized DataArray is in the correct range"""
ds = xr.load_dataset(os.path.join("test", "test_data", "COPERNICUS_S2_SR_test.nc"))
da = ds.B4
da_norm = da.wx.normalize(stretch=0.9)
assert da_norm.max().values == 1.0
assert da_norm.min().values == 0.0

Instead of specifying which dims to use, it will probably be safer to just use everything but time. Something like this should work:

reduce_dims = set(da.dims) - {"time"}
min_val = da.quantile(1 - stretch, dim=reduce_dims)

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.

2 participants