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

Return single band object instead of a list of band objects when converting a single string to band #138

Closed
jsetty opened this issue Apr 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jsetty
Copy link
Contributor

jsetty commented Apr 18, 2024

I would like to rename the DataArray key in the xr.Dataset object returned by S2Product.load() because I am unable to serialize xr.Dataset to a netCDF file. The xr.Dataset.to_netcdf() raises TypeError: DataArray.name or Dataset key must be either a string or None for serialization to netCDF files. Therefore, I rename the keys from SpectralBandNames objects to strings. When I load from the netcdf file, I would like to rename the string keys to band keys to exactly reconstuct the xr.Dataset object. For this, I call to_band for each str but the to_band returns a list.

Solution:
return a single band instead of a list of bands when to_band is called with a single string

Could not find an alternative to this

@jsetty jsetty added the enhancement New feature or request label Apr 18, 2024
@remi-braun
Copy link
Member

Hi!

Thanks for this feature.

A workaround could be to take the list of all the string keys, convert them all at once in SpectralBandNames and loop on the converted keys.
Wouldn't it be possible?

@jsetty jsetty mentioned this issue Apr 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants