-
Notifications
You must be signed in to change notification settings - Fork 174
fix noise tapering and error handling #460
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #460 +/- ##
=======================================
Coverage 84.24% 84.24%
=======================================
Files 160 161 +1
Lines 13243 13256 +13
=======================================
+ Hits 11156 11168 +12
- Misses 2087 2088 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Hi @mats-knmi, fantastic, thanks a lot for picking this up! This seems to work, I think. Could you maybe also plot what the tapering looks like now? @bwalraven, would you like to have a look at it as well?
This is what the tukey tapering looks like now for our domain (765x700): |
Good and when |
Besides the former questions, good to go from my side, @mats-knmi, great work! |
Just to be sure @RubenImhoff, did you check that the other locations in the blending code that use pysteps/pysteps/blending/steps.py Lines 1333 to 1340 in 76539bb
pysteps/pysteps/blending/steps.py Lines 2118 to 2126 in 76539bb
pysteps/pysteps/blending/steps.py Lines 2160 to 2168 in 76539bb
|
Thanks @mats-knmi! This would indeed solve 'my' issue in #451! Perhaps a 'nice-to-have', with regards to @dnerini's comment about handling zero fields more graciously instead of raising an error I am wondering whether it would be useful to also generate a warning or more informative error message in the case that This might not happen very often now that the adapted In any case, thanks for proposing a solution that solves the issue! |
I have not tested it on real data yet (I would need to have a couple of good rain-no rain cases for that), but from what I can see, it will mainly change when we have or don't have |
The solution I proposed makes it so that if |
I am not familiar enough with the blending steps to say something about that, but I can have a look and test it for the simple nowcasting cases I have. But seeing @mats-knmi's resulting image of the adapted |
The default will still be |
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.
hi @mats-knmi, thanks a lot for taking this up!
The changes to the tapering windows make a lot of sense to me and definitely improve over the current version, very nice!
For the approach with zero precip, I agree that the best way to handle this is to account for the effect of the tapering window on the norain check. I only left a very small comment concerning the deprecation warning, which I think it could be safely removed.
pysteps/utils/check_norain.py
Outdated
from pysteps import utils | ||
|
||
|
||
def check_norain(precip_arr, precip_thr=None, norain_thr=0.0, win_fun="tukey"): |
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'd suggest to leave win_fun=None
as default, so to maintain the same behaviour. The default can then be changed in the call in the blending method
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.
Hmmm, yes but in the fftgenerators the default method is tukey
. So if a user uses an ensemble nowcast with default settings and then also the check_norain
method with default settings, you would expect it to work. Which it won't if the default is different here as in the fftgenerators. It would be ideal if they could somehow be synced, but I don't have a good idea for that right now.
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.
agreed, but in principle check_norain
is indipendent of the settings in the fftgenerators. So it'll be important to use the right win_fun argument in the nowcasting methods, but in itself I would still set the default to None here. Or am I missing on something?
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.
The reason I set the tapering method to tukey
by default is because this check_norain
method currently only exists for the purpose of running the fftgenerators. Since for the fftgenerators the tukey
method is the default, I thought it would make sense to have it as the default here as well.
Ofcourse the check_norain
method is a quite generic method that could be used for other purposes as well, in which case a default of None
would make more sense.
I think that if we call check_norain
from the nowcast methods, so that the user doesn't have to do that anymore, it should be fine to set the default to None
. But then we would have to update the error message in the fftgenerators as well to indicate to a user like @SKB-7 (who uses the fftgenerators directly) that in order to successfully check for no rain in the context of the fftgenerators, you will have to call check_norain
with the correct tapering method (which is tukey
by default for the fftgenerators).
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 think the best approach is to do what I typed in the last paragraph of my previous message, so I will implement that today.
@mats-knmi commit ee9a787 adds a test for the steps nowcast method with all zero inputs (it will fail), as a reminder that something needs to be still done for the use case, as discussed in #451. |
@dnerini Do you want me to add the And what should I do with the other 2 nowcast methods that use noise generators? I see linda only uses pbs, but sseps could use fft generated noise as well right? |
yes, I think this could be a good approach. What do you do with the blending? return an empty, all zero output?
in principle yes, but maybe a better approach is to include a dedicated test for these methods too, then we'll need to include the check only for those methods that fail? |
@dnerini I saw your new tests, thanks. I will implement the no rain check in all the nowcast methods that fail these tests and that should fix them. I will return only zeros when the norain check fails indeed. |
Note that currently the failing |
@dnerini I think I have fixed everything now, can you review the final version? If you are on board I would like to merge this and release this as a new version, since we want to start using this operationally. How do I do this? Do I just bump the version in the setup.py file and then merge this pull request? |
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 very good to me! Left only two super minor comments, then I believe this is ready to be merged
pysteps/nowcasts/sseps.py
Outdated
|
||
Notes | ||
----- | ||
Please be aware that this represents a (very) experimental implementation. |
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.
why remove this note? this is still a very experimental method ...
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 know how this happened. I did not mean to remove this part also I did not mean to add this line
pysteps.extrapolation.interface, pystepsemilagrangian
I am pretty confused, but I re-added this note.
Co-authored-by: Daniele Nerini <[email protected]>
@dnerini I will merge this then, how do I turn this into a release? Or is there something I need to wait on before doing that? |
So what I typically do:
do you rely on the conda-forge installation? this typically takes few extra days (if everything goes well) |
Thanks, I'll try that!
No we install pysteps through pip |
Great work!! |
Yes, the merge request fixing this is #405. |
Fixes #451
This applies the 2 solutions proposed in the issue. For the error handling I choose a more pragmatic approach than the one I proposed in the issue.
I define the no_precip booleans based on the zero mask of the tapering method provided. This should be exactly what we want, because these booleans are intended to represent whether we can use the specified field for the noise generation right?
@RubenImhoff: can you verify that this will not have unintented side effects?