-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix regression in time-like check when decoding masked data #8277
Conversation
This fix works for timedelta There might be other unit-strings possible, like |
Thanks for tracking this down @kmuehlbauer -- looks good. Could you maybe just add a simple test?
Right, yeah, I think this is something we have been living with for a while within our datetime decoding logic: Line 826 in 2cd8f96
In that case (regardless of what happens during masking) an error will eventually be raised related to the fact that what comes after |
Thanks @spencerkclark, I'll add a test along the lines of the example in #8269 and check that variables with non time-like units are not treated as time-like. |
Sounds good, thanks!
Hmm as I think about this more, I guess we might need to worry about the case when one uses |
Yes, that makes sense. I've avoided so far importing from |
Maybe we actually take things a step further and not apply this special time-masking behavior at all in the case that What are your thoughts on that? I guess I'm wondering whether this special masking behavior (replacing integer missing values with the minimum integer) should apply if we are not ultimately decoding values as times. |
I've wrapped my head around that many times without coming to a robust and nice solution. Sometimes we can't clearly separate the different coding steps. Consider the following example. If we do not keep/treat time-like with int64 resolution in ds = xr.open_dataset(filename, decode_times=False)
ds = ds.pipe(fix_time_units)
ds = xr.decode_cf(decode_times=True) without losing nanosecond resolution (because conversion into floating point). Yes, we could advertise to complete drop cf decoding in those cases instead of just dropping time decoding. |
Good point, I guess it really is a coupled problem...one way or the other you will need to completely drop CF decoding to fix something (either remove the time-like units to prevent special decoding of time-like missing values, or fix the time units without losing nanosecond precision). On balance as a user I might be more surprised to see time-like units playing a role in how fields were masked in the case that |
Maybe we can punt on the question of whether to apply the special time masking or not when
Ah gotcha, for this, one alternative is to import |
Thanks Spencer! I'm currently traveling and can pick up work next week. Feel free to push this forward. |
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.
Thanks @kmuehlbauer!
whats-new.rst