Project

General

Profile

Time bounds versus time axis causing problems with selmon

Added by Mark Payne almost 5 years ago

Dear CDO,

I have an .nc file that consists of monthly averages of CESM data. The file contains the following note about the way that time is handled:

:cell_methods = "cell_methods = time: mean ==> the variable values are averaged over the time interval between the previous time coordinate and the current one.

The file has two different time variables "time" and "time_bounds" that reflect this. So, for to take one layer, for example, the date is "2017-08-01" and the time bounds run from "2017-07-01" to "2017-08-01".

The problem comes when I use "selmon" to extract the August temperature from the dataset - it appears to be doing this based on the "time" axis, and so takes the layer with the date "2017-08-01" - however, as I noted here, this actually corresponds to the July average, not the August average.

How do I work around this problem? There are two solutions I can see

1. Use cdo shifttime,-15day to move everything manually. An practical solution, but perhaps not very robust from a programming perspective

2. Write the time axis so that the value corresponds to the middle of the period, rather than the end. However, I can't see any good way to do this.

Does anyone have any commments / suggestions?

Thanks,

Mark


Replies (4)

RE: Time bounds versus time axis causing problems with selmon - Added by Ralf Mueller almost 5 years ago

hi Mark!

if this is still an issue, please upload some sample data we can play with and talk about, thx.

cheers
ralf

RE: Time bounds versus time axis causing problems with selmon - Added by Mark Payne almost 5 years ago

Hi,

I have uploaded one example file here.

The following command should in principle select the months of August:

cdo selmon,8 b.e11.BDP.f09_g16.2015-11.040.pop.h.SST.201511-202512.nc out.nc

which it appears to have done:

cdo showdate out.nc

2016-08-01 2017-08-01 2018-08-01 2019-08-01 2020-08-01 2021-08-01 2022-08-01 2023-08-01 2024-08-01 2025-08-01
cdo showdate: Processed 20 variables over 10 timesteps [0.01s 46MB]

However, if we look at the time_bounds variable, we can see that these actually actually correspond to averages over the previous month:

ncdump -v time_bnds out.nc

time_bnds =
736021, 736052,
736386, 736417,
736751, 736782,
737116, 737147,
737481, 737512,
737846, 737877,
738211, 738242,
738576, 738607,
738941, 738972,
739306, 739337 ;

Which is accordance with the description in the metadata:

:cell_methods = "cell_methods = time: mean ==> the variable values are averaged over the time interval between the previous time coordinate and the current one.

How would you recommend that I go forward with processing this data to extract monthly values in a way that is robust to this configuration?

Mark

RE: Time bounds versus time axis causing problems with selmon - Added by Karin Meier-Fleischer almost 5 years ago

Hi Mark,

I would shift the time to the middle of the previous month provided that the time bounds are correct.

cdo -f nc -selmon,8 -shifttime,-17days -selvar,SST infile outfile

-Karin

RE: Time bounds versus time axis causing problems with selmon - Added by Mark Payne almost 5 years ago

Thanks Karin,

That was also the work-around that I came up with. I was just wondering if there were any other more "elegant" solutions, and particularly if there was anything automatic flags that could be raised in this type of situation - I was caught rather by surprise by this!

Mark

    (1-4/4)