-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat: User defined output frequency #44
base: main
Are you sure you want to change the base?
Conversation
Documentation Preview: https://pymorize.readthedocs.io/en/feat-user_frequency/pymorize_saving_output.html |
Whats the difference between |
As far as I am aware, it controls the timestamp sampling (beginning vs. end) that is puts into the records: >>> import xarray as xr
>>> ds = xr.tutorial.load_dataset("air_temperature")
>>> ds.resample(time="MS").groups
{numpy.datetime64('2013-01-01T00:00:00.000000000'): slice(0, 124, None),
numpy.datetime64('2013-02-01T00:00:00.000000000'): slice(124, 236, None),
numpy.datetime64('2013-03-01T00:00:00.000000000'): slice(236, 360, None),
numpy.datetime64('2013-04-01T00:00:00.000000000'): slice(360, 480, None),
numpy.datetime64('2013-05-01T00:00:00.000000000'): slice(480, 604, None),
numpy.datetime64('2013-06-01T00:00:00.000000000'): slice(604, 724, None),
numpy.datetime64('2013-07-01T00:00:00.000000000'): slice(724, 848, None),
numpy.datetime64('2013-08-01T00:00:00.000000000'): slice(848, 972, None),
numpy.datetime64('2013-09-01T00:00:00.000000000'): slice(972, 1092, None),
numpy.datetime64('2013-10-01T00:00:00.000000000'): slice(1092, 1216, None),
numpy.datetime64('2013-11-01T00:00:00.000000000'): slice(1216, 1336, None),
numpy.datetime64('2013-12-01T00:00:00.000000000'): slice(1336, 1460, None),
numpy.datetime64('2014-01-01T00:00:00.000000000'): slice(1460, 1584, None),
numpy.datetime64('2014-02-01T00:00:00.000000000'): slice(1584, 1696, None),
numpy.datetime64('2014-03-01T00:00:00.000000000'): slice(1696, 1820, None),
numpy.datetime64('2014-04-01T00:00:00.000000000'): slice(1820, 1940, None),
numpy.datetime64('2014-05-01T00:00:00.000000000'): slice(1940, 2064, None),
numpy.datetime64('2014-06-01T00:00:00.000000000'): slice(2064, 2184, None),
numpy.datetime64('2014-07-01T00:00:00.000000000'): slice(2184, 2308, None),
numpy.datetime64('2014-08-01T00:00:00.000000000'): slice(2308, 2432, None),
numpy.datetime64('2014-09-01T00:00:00.000000000'): slice(2432, 2552, None),
numpy.datetime64('2014-10-01T00:00:00.000000000'): slice(2552, 2676, None),
numpy.datetime64('2014-11-01T00:00:00.000000000'): slice(2676, 2796, None),
numpy.datetime64('2014-12-01T00:00:00.000000000'): slice(2796, None, None)}
>>> ds.resample(time="ME").groups
{numpy.datetime64('2013-01-31T00:00:00.000000000'): slice(0, 124, None),
numpy.datetime64('2013-02-28T00:00:00.000000000'): slice(124, 236, None),
numpy.datetime64('2013-03-31T00:00:00.000000000'): slice(236, 360, None),
numpy.datetime64('2013-04-30T00:00:00.000000000'): slice(360, 480, None),
numpy.datetime64('2013-05-31T00:00:00.000000000'): slice(480, 604, None),
numpy.datetime64('2013-06-30T00:00:00.000000000'): slice(604, 724, None),
numpy.datetime64('2013-07-31T00:00:00.000000000'): slice(724, 848, None),
numpy.datetime64('2013-08-31T00:00:00.000000000'): slice(848, 972, None),
numpy.datetime64('2013-09-30T00:00:00.000000000'): slice(972, 1092, None),
numpy.datetime64('2013-10-31T00:00:00.000000000'): slice(1092, 1216, None),
numpy.datetime64('2013-11-30T00:00:00.000000000'): slice(1216, 1336, None),
numpy.datetime64('2013-12-31T00:00:00.000000000'): slice(1336, 1460, None),
numpy.datetime64('2014-01-31T00:00:00.000000000'): slice(1460, 1584, None),
numpy.datetime64('2014-02-28T00:00:00.000000000'): slice(1584, 1696, None),
numpy.datetime64('2014-03-31T00:00:00.000000000'): slice(1696, 1820, None),
numpy.datetime64('2014-04-30T00:00:00.000000000'): slice(1820, 1940, None),
numpy.datetime64('2014-05-31T00:00:00.000000000'): slice(1940, 2064, None),
numpy.datetime64('2014-06-30T00:00:00.000000000'): slice(2064, 2184, None),
numpy.datetime64('2014-07-31T00:00:00.000000000'): slice(2184, 2308, None),
numpy.datetime64('2014-08-31T00:00:00.000000000'): slice(2308, 2432, None),
numpy.datetime64('2014-09-30T00:00:00.000000000'): slice(2432, 2552, None),
numpy.datetime64('2014-10-31T00:00:00.000000000'): slice(2552, 2676, None),
numpy.datetime64('2014-11-30T00:00:00.000000000'): slice(2676, 2796, None),
numpy.datetime64('2014-12-31T00:00:00.000000000'): slice(2796, None, None)} |
Ok. Is the middle of a time period also defined? I cannot find this in the documentation. The middle is usually used, so e.g. yyyy-mm-15 or -16 in case of monthly output. See e.g. the documentation from cdo (e.g.
|
Not natively, we would need to implement that as a separate correction step. I'll see what I can do. |
Alright, I have something that sort-of works: Maybe @siligam can have a look and hook it up to the rest of his averaging functionality. |
Closes #9
@chrisdane: Can you see if this does what you want, and is adequately documented?