-
Notifications
You must be signed in to change notification settings - Fork 16
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
Initial xarray support #35
base: master
Are you sure you want to change the base?
Conversation
data = self.fh.getDataSliceSB(vname, slicebuilder) | ||
datav = data.values() | ||
data_shaped = np.reshape(datav, dimsizes) | ||
if self.scale_offset: |
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.
consider using getScaledDataSliceSB and let fimex do the scale/offset handling
Thanks. I think that the scale and offset handling should be replaced with I wonder why you commented out the Did you try putting this into |
var = np.array([np.datetime64(int(v), "s") for v in var]) | ||
|
||
coords["time"] = var | ||
|
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.
I don't really know what this should do in xarray, but the time-variable in netcdf is every variable with a time unit, i.e. 'days since 2005-09-03 +15:00'. One cannot rely on the dimension-name, and that there is only one "time"-axis per file.
Fimex supports conversion of the time-units, i.e. by getScaledDataSizeInUnit(...) so you can get a unified handling (needs doubles or quads, I would say). Not really sure what you do her (expect time to be epoch-seconds?).
add_offset = cdm.getAttribute(cname, "add_offset").getData().values() | ||
except RuntimeError: | ||
add_offset = 0 | ||
values = values*scale_factor + add_offset |
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.
use getScaledData
It is fairly easy to implement support for using
xarray
withfimex
as a reader. I am opening this PR in the hope this will be useful for others who usexarray
There is still a lot to do to support more features of
xarray
, but this should cover the basic API