Skip to content
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

Excluding areas above/below certain latitude #45

Open
JannisHoch opened this issue Jan 18, 2023 · 3 comments
Open

Excluding areas above/below certain latitude #45

JannisHoch opened this issue Jan 18, 2023 · 3 comments

Comments

@JannisHoch
Copy link

JannisHoch commented Jan 18, 2023

For 'simple' methods like Hamon, the resulting PET estimates can exclude areas above and below a certain latitude (i.e. returns NaNs), even though the input data ranges between -90 and 90.

The area excluded changes depending on the date of the input data.

So probably that has to do with sunlight hours derived from latitude at a given date? Not per se wrong, but maybe good to either return 0 instead of NaNs (if that makes sense) or throw a warning so the user knows why this happens.

Also, probably good to specify this behaviour in the documentation somewhere.

@mvremec
Copy link
Contributor

mvremec commented Jan 24, 2023

Hi Jannis,

This is a good point! Thank you for bringing this up!
We currently use the FAO-56 method to estimate daylight hours based on latitude.
However, as you wrote, it turns out this method returns NaN values for the subpolar/polar belt for the polar night period.

I will correct this in the new release.

Thanks,
Matevz

  • [ correct daylight_hours for subpolar/polar belt]

@artessen
Copy link

artessen commented Dec 1, 2023

Dear Matevz,

Thank you for your reply.
I believe the issue is still present in the current version, but in case you have not already fixed, here is a possible solution:

  • Substitute lines 338-342 in pyet/meteo_utils.py with the following:
    if isinstance(lat, DataArray):
        lat = lat.expand_dims(dim={"time": sol_dec.index}, axis=0)
        return arccos(clip(-tan(sol_dec.values) * tan(lat).T, -1, 1)).T
    else:
        return arccos(clip(-tan(sol_dec) * tan(lat), -1, 1))
  • Substitute lines 5-6 in pyet/meteo_utils.py with the following:
from numpy import tan, cos, pi, sin, arccos, mod, exp, log, nanmax, isnan, \
    where, clip

This essentially sets the range of values to be between -1 and 1 for the arccos computation and avoid the NaN issue.
Hope it helps
Best
Arthur

@mvremec
Copy link
Contributor

mvremec commented Feb 2, 2024

Dear @artessen,

Thank you very much for this suggestion, and apologies for the late response—I somehow missed this comment.
I have implemented your suggestion in the dev branch, and it will be integrated into the v1.3 PyEt version.

Thank you again and all the best,
Matevz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants