-
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
NA values for UTCI - issue with mean radiant temperature calculations? #1496
Comments
Hi @emsonali ! This looks like the errors I tried to fix in #1399 this summer. The changes were included in xclim 0.44. However, I kinda focused on the arctic circle-related problems, I might have overlooked issues stemming form the equator... Would you be able to test your code again with the latest xclim version ? |
Hi @aulemahal I checked the environment that we used to run the UTCI calculations and we have xclim 0.45 there. xclim 0.41 was from another environment not used for the calculations, apologies for the mixup |
Hi @aulemahal I reran the calculation again with xclim 0.45 just to be sure and the issue still persists. Please let me know if I can provide further information that might help with your debugging |
TL;DR Try passing Hi @emsonali, I think I found why you're getting these errors, but if I'm right, that would mean UTCI has been broken for a while... Therefore, I'm invoking @ludwiglierhammer into this thread, as original author of the function. I see that the broken parts were my suggestion / addition, clearly there was something I didn't understand. The issue has to do with the "stat" argument that UTCI passes to The solar zenith angle is the angle the sun makes with the vertical. Thus, at sunset the angle is 90° and at sunrise, 90° again. Thus the cosine can only be negative during the night, when the angle is greater than 90°. But, I might have broken that when I fixed the cosine calculations for the arctic circles. Sorry. @ludwiglierhammer , are you able to confirm my intuition? That "stat='average'" as it is coded now makes no sense and it should be "sunlit" for any requested interval ? The other choice ('instant') is for when we compute the instantaneous value of the MRT. |
Hi @emsonali, could you please plot |
What exactly does In the docstrings of both mean_radiant_temperature and universal_thermal_climate_index |
@aulemahal @ludwiglierhammer I plotted the
|
@ludwiglierhammer I don't remember where I saw a usage of I went back in the sources and there's something I don't quite understand. Liljegren 2008 state the equations that we use, but when they speak of The average of the cosine of the solar zenith angle over a day will be smaller than 0 when the night is longer than the day. Haha, this is not a uncommon phenomenon, it happens half of the time ;). xclim/xclim/indices/_conversion.py Line 1912 in e4d6346
In Liljegren there is a If I understand correctly, the idea is to mask with 0 if the sun is not over the horizon. In an average idea, that would be : if Of we could use the fact that the sunlit average of the cosine is 0 if the sun does not shines in the interval. I thus suggest to simply drop |
@aulemahal In the notebook example they mention in block 20:
Liliegren 2008 talks about instantaneous data and, as you mentioned, they do not differentiate between
Don't we need a differentation before calling this function?
And don't we need to call this function with:
since we have this:
|
Nice! As for the "integral" case, I think the @emsonali Are you able to test your code with xclim installed from the pip install git+https://github.com/ouranosinc/xclim.git@fix-mrt |
@aulemahal It was new to me that you can simply pass a boolean as a positional arg by using those 2 equal signs. Thanks for the explanation. |
Hi @aulemahal I tested with the Here are the ouputs with the different stat settings. Please let me know if it's working as you expected, especially for
|
I'm not sure I fully understand your comment sorry. In the Thanks! |
<!--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: - [x] This PR addresses an already opened issue (for bug fixes / features) - This PR fixes #1496 - [x] Tests for the changes have been added (for bug fixes / features) - [x] (If applicable) Documentation has been added / updated (for bug fixes / features) - [x] CHANGES.rst has been updated (with summary of main changes) - [x] Link to issue (:issue:`number`) and pull request (:pull:`number`) has been added ### What kind of change does this PR introduce? I believe #1399 changed the meanings of argument `stat` which made the default option of `mean_radiant_temperature` incorrect. This PR removes the "average" option and changes the default to 'sunlit'. ### Does this PR introduce a breaking change? Yes, outputs will change. However, I think previous output was incorrect. An announcement has been added to the CHANGES. ### Other information:
Thanks very much @aulemahal @ludwiglierhammer for your help with this! |
Setup Information
Context
I'm calculating UTCI for Southeast Asia and noticed that there are quite a lot of NA values, but this varies spatially and temporally, for parts of the year the northern hemisphere in Southeast Asia has missing values, and other parts of the year the southern hemisphere in Southeast Asia has missing values (see attached screenshots). Could this be due an issue with the mean radiant temperature, as it is influenced by latitude? There's a clear cutoff at the equator.
Code of Conduct
The text was updated successfully, but these errors were encountered: