-
Notifications
You must be signed in to change notification settings - Fork 61
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
_agro.standardized_precipitation_evapotranspiration_index creates NaNs #1474
Comments
Have you seen #1416 and could it be related ? If not, I would suggest trying to use the L-Moments method to fit the gamma distribution. This is not implemented at the moment though, but should be a simple fix if you're willing to tweak xclim (I suspect it would only require adding "PWM" to the |
Hi, thanks for reporting this. In this case #1416, the erroneous values obtained were ±np.inf, not NaN, so I'm not sure this is related. Also, the surrounding values of SPEI are not that extreme. Just to describe #1416, this is not a big computation error, essentially for very unlikely values (0.000001 or 0.999999 in the CDF), once precision limits imposed by float32 make it so that we have probabilities 0.0 or 1.0, we get ±np.inf. This precision limit is addressed in #1311 by capping the values for standardized indices to reflect this precision limit.
Ok, interesting (but those lower water_budget could still translate to larger SPEI values). The fact may still remain that you have very negative values of water_budget somewhere in the calibration for those pixels. The gamma fitting expects positive values. We have a fixed value shifting the water budget towards positive values, but this might not be enough. Could you try shifting the water_budget wb = wb - 1.01*wb.min() and see if the NaNs persist? |
L-moments are invalid for this dataset it seems.
This seems to have fixed the issue! Thank you very much for your swift assistance! |
Thanks to you and your detailed report, it helped troubleshooting! Just some last remarks for future discussions about this:
|
Generic Issue
Description
I am using ISIMIP chelsa-w5e5v1.0 30 arcsec resolution daily data from 1979 to 2016 (dimensions, time: 13880, y: 30, x: 57, bbox: [73.533, 18.967, 74.008, 19.217]) pr, tasmin and taxmax data to first calculate the pet (xci.potential_evapotranspiration) and the water budget (xci.agro.water_budget). No values are lost in these calculations and there are no NaNs present. However, when I then use xci.agro.standardized_precipitation_evapotranspiration_index to calculate the SPEI, two things happen:
The settings for the function are as follows:
What I Received
For example, timestep 54 and 94:


And with a window of 6:
Comparison of water budget and SPEI at the same timestep:
Does anyone know what could be going wrong?
Code of Conduct
The text was updated successfully, but these errors were encountered: