-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add XArray DataArray support via XRImage #4
Conversation
See also this PR: pytroll/satpy#203 |
trollimage/xrimage.py
Outdated
self.data = data.expand_dims('bands') | ||
self.data['bands'] = ['L'] | ||
else: | ||
raise ValueError("No 'bands' dimension provided.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there is some dependence on the dimensions being named bands
, y
, x
. Would it be possible to infer these dimensions from the shape of the input array? Or is it just safer to force the user to ensure the dimensions before using this class? This may be something we need to force in satpy since I don't think all readers use y/x
as dimensions for swaths.
Either way, we should probably add an assertion that all three of the expected bands are in the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at least x
and y
have to be there
Color interpretation set is not supported. We will have to depend on the defaults.
Not sure if this applies to numpy arrays but it seems to work for dask.
because xarray needs a loaded array for that (says the error you get when you don't) |
So wouldn't it make sense to replace the Image's data attribute with the loaded data? Otherwise you compute it twice, right? Or is it possible to compute the data save and the quantile in the same operations. It would be similar to how I changed some of the stuff in pyresample. I'm ok leaving it this way for now too if it isn't used often. |
Ok, let me change it |
This PR implements support for xarray.DataArrays in trollimage (and indirectly dask arrays too).