-
Notifications
You must be signed in to change notification settings - Fork 168
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
Can you help me understand how to fix the ValueError: L-Moments invalid
error?
#312
Comments
Thanks, @tommylees112. I appreciate the detailed info on how to acquire the input data that causes this issue to appear. I have seen this error before and to be honest I'm not sure yet what causes it. I will look into this, and in the mean time if you have any insights please share. Stay tuned... |
Thanks for your quick response @monocongo ! Did you manage to solve the issue last time? Is there anything that you think I should try? Thanks again! (love the package btw) |
It looks like this came up another time before in issue #251, I think it was a units error that time but looking at the above your units appear to be fine (mm), and besides that issue was around SPEI (temperature units in Kelvin throwing off the PET calculations, if I remember correctly). Unfortunately this is happening in the bowels of the lmoments3 package that I've used within the Pearson fitting code, and I don't have a solid grasp of that codebase. I had my own code for L-moments before (derived from the same Fortran by Hosking as was lmoments3) but I eventually replaced it with lmoments3, assuming that it was probably more robust (the math is more or less voodoo to me), but I'm really not sure if this is true of not. That project appears to be dormant/unsupported (for example I've had a PR there waiting since last October) and it might behoove me to go back to using my old L-moments code for the Pearson fitting. |
I'm having trouble retrieving the data, @tommylees112 (described here). Once that's resolved I will look into whether or not there are negative (or otherwise wonky) data values, as this may be the cause of the error (pure conjecture at this point). |
We had some functions in a notebook file here that worked for me? I don't know if they're any help to you at all? |
Is it possible to post the input data file someplace so I can avoid working out the bugs with the retrieval code, @tommylees112? That will expedite an investigation into this issue, which I hope to resolve pronto. It may be that I just go back to using the L-moments code I had in place before switching over to lmoments3 which hasn't been as trouble-free as I expected... |
@monocongo https://drive.google.com/file/d/1MQor6rCrhvUTDCh-RFTybMHZ5L1-i9eB/view?usp=sharing Here's the data! thanks very much
|
@monocongo are there notebooks that show how to interact with your package through python as opposed to via the command line? wanted to incorporate the code more as a python package! Might be a really silly question! |
Check this out @tommylees112, let me know if I can help. |
It turns out that there are negative values in the input dataset, and this was causing the error with the L-Moments calculation. I have now added some checks for negative values that clip negative values to zero, and this appears to have fixed the issue. Also, I've replaced the lmoments3 package with the previous version of L-Moments code I was using before (lmoments3 has started causing other issues so it is high time to excise that package from this code). |
How to craft a useful, minimal bug report
Describe the bug
Using climate data from the Copernicus Data Store I want to create a gridded SPI product. However, I get an error saying that
ValueError: L-Moments invalid
.To Reproduce
Steps to reproduce the behaviour:
NOTE: Need to have cdsapi installed
pip install cdsapi
ERROR TRACE:
Expected behavior
Expect to produce a gridded SPI product.
Screenshots*
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: