-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conditions to match ref.time
& hist.time
, and also ref.time.size
& sim.time.size
#1995
Conversation
it keeps saying that some checks were not successful, but I don't see any red x, showing the failures. |
Weird, the previous CI shows some runs "cancelled". I don't see why they were cancelled... |
It's a configuration issue. I'll see what I can do. |
So all this discussion about conflict values of time with I guess that's why "ref": ref.rename(time="time_hist"),
"hist": hist.rename(time="time_hist"),
"sim": sim, I'll try and see if the class For MBCn, I didn't see this with the groupies-like implementation since it doesn't use |
Ready for xclim next version |
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.
Looks good to me. I think the replace_sim
logic needs a bit more doc, the current docstring does not list "same size same calendar" as a requirement for sim
.
Hmm, should I just leave this a case-by-case for each specific method? I don't think there is much documentation on I guess e.g. if not cls._allow_diff_calendars and len(calendars) > 1:
raise ValueError(
"Inputs are defined on different calendars,"
f" this is not supported for {cls.__name__} adjustment."
) vs. # This below implies that ref.time and sim.time have the same size
# Since `ref,hist, sim` are in the same `map_groups` call, they must have
# the same time
if cls._replace_sim_time:
sim_time = sim.time
sim["time"] = ref["time"] maybe I should simply have : EDIT: This would already be better, we can anticipate a wrong input, and raise an error if need-be |
Héhé I guess you're right about the other having almost no doc. The difference though is that |
Yes good point, that's what I was slowly converging to when thinking about your comment. Is |
FYI, the issues with conda are fixed here: 9aa4e4a |
I can just add You know, there is an implicit assumption in other function that
|
Just to say: |
…xclim into check_matching_times
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…xclim into fix_nan_handling_dOTC
<!--Please ensure the PR fulfills the following requirements! --> <!-- If this is your first PR, make sure to add your details to the AUTHORS.rst! --> ### Pull Request Checklist: - [ ] This PR addresses an already opened issue (for bug fixes / features) - This PR fixes #xyz - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] (If applicable) Documentation has been added / updated (for bug fixes / features) - [ ] CHANGELOG.rst has been updated (with summary of main changes) - [ ] Link to issue (:issue:`number`) and pull request (:pull:`number`) has been added ### What kind of change does this PR introduce? *nans are now removed and put back in place at a lower level. This simplifies the handling of times. ### Does this PR introduce a breaking change? I'm not sure, I should check if the previous method was handling nans correctly. I have a suspicion that it was not. But this way is simpler, more in-line with other xclim methods, and technically what we want ### Other information: The motivation behind this is that we want to be able to use different time but same size for `ref` and `sim` so they can be passed to a `map_groups` function. Apparently, the handling of nans was messing with the relative sizes of `ref` ,`sim`. Before the computation, they were the same (by construction) and at some intermediary step, they ended up with different dimensions. Maybe the dimensions were ultimately restored, but I was nervous about this, and I think this new implementation is more simple.
ref
& hist
times in bias adjustment methods must matchref.time
& hist.time
, and also ref.time.size
& sim.time.size
@aulemahal I accidentally merged the changes from a child PR in this one 🤡 Thoses changes were prompted because I wanted to make the |
Ah! I now understand the reaction haha. Were you going to ask me a review on that other PR, is it ready ? |
I had tagged Sarah for this one. I was planning to take a bit more time on this one, but really, it's not all that complicated. There were some weird handling of NaNs previously in dOTC. I have simplified the process (IMO). I only drop nans at the lowest level when it's needed, and put the Nans back in place again at the lower level when it's over It's really only one file, I think it's reasonable to ask Sarah to focus on this specific part |
@SarahG-579462 Can you check the changes in The changes concern the handling of nans in dOTC. I was getting some weird errors, I'm not sure the time arrays were appropriately preserved before. I have simplified the handling of Nans and I don't have problems anymore. |
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.
LGTM, though is it possible to override the default for _allow_diff_training_times and _allow_diff_time_sizes ?
I could imagine situations where you might want to use EmpiricalQuantileMapping with _allow_diff_time_sizes = False but _allow_diff_training_times = True, although it might not actually work without a lot of finicking.
(e.g. correcting your past based on the current conditions, which is a principle applied (manually) in our Portail Ingénieur tool)
Currently it would not work because of the I guess something like this could work: from xclim.sdba import EmpiricalQuantileMapping
EmpiricalQuantileMapping._allow_diff_training_times = True
EmpiricalQuantileMapping._allow_diff_time_sizes = False and we would need to change the TrainAdjust class if cls._allow_diff_training_times and not cls._allow_diff_time_sizes:
hist_time = hist.time
hist["time"] = ref["time"]
# compute compute compute ...
if cls._allow_diff_training_times and not cls._allow_diff_time_sizes:
scen["time"] = hist_time @aulemahal Any big objections on this one? This would be a hidden option, you would need to change default attrs to access this functionnality |
No objection here! It is fair that an "experimental" module like sdba allows these things, but does not publicize them much. |
@coxipi If you want to implement the changes, go for it. We can reschedule the release to next week (will coincide with our regular planning meeting), so no rush! |
Pull Request Checklist:
number
) and pull request (:pull:number
) has been addedWhat kind of change does this PR introduce?
ref
andhist
times do not matchref
andsim
times do not have the same sizeDoes this PR introduce a breaking change?
I'm not sure, I should check if the previous method was handling nans correctly. I have a suspicion that it was not. But this way is simpler, more in-line with other xclim methods, and technically what we want
Other information: