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

Indicator keyword for performing calendar conversion #653

Closed
Zeitsperre opened this issue Mar 9, 2021 · 2 comments
Closed

Indicator keyword for performing calendar conversion #653

Zeitsperre opened this issue Mar 9, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Zeitsperre
Copy link
Collaborator

  • xclim version: master
  • Python version: any

Something that has come up in the process of using xclim to calculate indices that are then fed to R is the incompatibilities of some calendars, specifically the notorious 360_day calendar. If non-standard calendars are not supported in the environment that uses this indicator data, problems ensue. While this is fine (users should be aware of calendar idiosyncrasies), I wonder if we could introduce a feature to make this a bit easier.

The specific case I want to address is when we perform a temporal aggregation (e.g. xclim.atmos.tg_mean(freq="MS")) with non-standard calendar data. Due to the way that the calendar is written (days since xxxx-yy-zz), we treat the first day of each month as the month itself. With non-standard calendars, this can lead to years in which we can see multiple values in a month or the slipping of dates backwards in time (especially with 360_day). None of this is new, and I don't suggest change this behaviour.

What I would like to see is a keyword in the calculations of indicators that allows for outputs to assume a standard calendar (ie: convert calendar being called). I understand that this already is triggered when performing ensemble analysis, but being able to change the calendar (called like xclim.atmos.some_indicator(freq="QS-DEC", to_calendar="proleptic_gregorian")) would make manual comparison of data much simpler.

@Zeitsperre Zeitsperre added the enhancement New feature or request label Mar 9, 2021
@aulemahal
Copy link
Collaborator

I think this could be interesting for some users indeed.
Currently, it is doable with:

import xclim as xc

out = xc.atmos.some_indicator(...)
out = xc.core.calendar.convert_calendar(out, 'proleptic_gregorian')

But adding this to the indicator call directly could be interesting, but I think we need to clean up the kwarg adding machinery before. Not much to do, just to decide on a clean way to inject those kwargs.

@aulemahal
Copy link
Collaborator

Documentation of the new xarray methods to be added while implementing #1010.

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

No branches or pull requests

2 participants