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

rename_labels doesn't work with duplicate add_dimension #198

Open
soxofaan opened this issue Aug 12, 2022 · 0 comments
Open

rename_labels doesn't work with duplicate add_dimension #198

soxofaan opened this issue Aug 12, 2022 · 0 comments

Comments

@soxofaan
Copy link
Member

soxofaan commented Aug 12, 2022

From https://discuss.eodc.eu/t/renaming-existing-bands-bugged/442

It took a while to trim the issue down to the following minimal use case.
The original case had resample_spatial and merge_cubes in it, which seemed like more probable sources of the bug,
but it just turned out that the user accidentally had two time same add_dimension in process graph, and that caused rename_labels to not work anymore.

Anyway, this is minimal use case:

connection = openeo.connect("openeo.vito.be").authenticate_oidc()

bbox = {"west": 4, "south": 51, "east":4.1, "north": 51.1}
dates = ["2022-07-01", "2022-08-01"]
cube = (
    connection.load_collection(
        "SENTINEL2_L2A", spatial_extent=bbox, temporal_extent=dates,
        bands=["B02"]
    )
    .drop_dimension("bands")
    .add_dimension("bands", label="B02", type="bands")
    .add_dimension("bands", label="B02", type="bands")
    .rename_labels("bands", source=["B02"], target=["Blue"])
)
cube.download(outdir / "minimal.nc")
print(list(xarray.load_dataset(outdir / "minimal.nc").data_vars.keys()))
# Results in: ['crs', 'B02']

When removing the duplicate add_dimension, the result is correct:

['crs', 'Blue']
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

No branches or pull requests

1 participant