xcdat icon indicating copy to clipboard operation
xcdat copied to clipboard

[Feature]: Consider generating new time bounds after temporal averaging

Open tomvothecoder opened this issue 2 years ago • 0 comments

Is your feature request related to a problem?

Related to #529 opened by @pochedls

Scenario A (xcdat v0.5.0 + xarray >=v2023.3.0)

This scenario affects xcdat v0.5.0 (regardless of xarray version). In this issue, xcdat does not create time_bounds for annually averaged data.

fn = '/p/css03/esgf_publish/CMIP6/CMIP/NCAR/CESM2/amip/r1i1p1f1/Amon/tas/gn/v20190218/tas_Amon_CESM2_amip_r1i1p1f1_gn_195001-201412.nc'
ds = xc.open_dataset(fn)
print('Time bounds in dataset: ', 'time_bnds' in ds.variables)
ds = ds.temporal.group_average('tas', freq='year')
print('Time bounds in dataset after taking annual average: ', 'time_bnds' in ds.variables)

Time bounds in dataset: True Time bounds in dataset after taking annual average: False

Describe the solution you'd like

We can try detecting how the original bounds were generated (midpoint or freq) then recreate them internally after grouping averaging.

Describe alternatives you've considered

No response

Additional context

No response

tomvothecoder avatar Aug 17 '23 16:08 tomvothecoder