monocongo/climate_indices

PET calculation fixed 365-day calendar

chrisbanze opened this issue · 2 comments

Calculating PET after thornthwaite works great except for one important detail. Having a dataset that uses a fixed 365-day calendar, there is currently no option to do the correct calculation defining all years as no-leap years.

Adding an argument for PET calculation to set the calendar to "gregorian" or in my case "365-days" would be ideal.

I have changed the code in eto.py to not check for leap years and that works, but it would be greatly appreciated if implemented into the package, so that it can be easily shared.

Thanks, @chrisbanze

If you want to submit a PR of your code with this option enabled then I'll certainly consider it for inclusion in the main branch. I assume you're thinking of a new CLI argument such as --use_gregorian which would only be applicable/relevant if we're computing daily values? A corresponding function argument should be added across all the functions that compute daily values, for consistency (i.e. it should work the same for all the indices and not just PET).

Personally, I'd first auto-detect it from the attributes of the time dimension, since xarray has all sorts of utilities for knowing what calendar is being used.