Project

General

Profile

Cdo timmean adds an extra time dimension when doing a time average

Added by Ashwin D about 4 years ago

Hello,
It is similar to the problem I reported few years back - https://code.mpimet.mpg.de/boards/2/topics/5239?r=5246#message-5246 and I am using cdo 1.9.7. I am trying to merge several netCDF files. I have NCAR reanalysis files for uwnd, vwnd and air temperatures at different levels for a single day at different times.

netcdf uwnd_1000_2020_11_3_00Z {
dimensions:
time = UNLIMITED ; // (4 currently)
lat = 73 ;
level = 1 ;
lon = 144 ;

So I need to merge all uwnd files first, then vwnd files next and then air temp files finally. Then I need to merge all of the merged files together. This part works fine

Then I do a timmean on the merged file in Python in the following way -

cdo = Cdo()
cdo.timmean(input='PFile.nc',output='AFile.nc')

and I get a spurious dimension. Where am I going wrong ?

netcdf AFile {
dimensions:
time = UNLIMITED ; // (1 currently)
bnds = 2 ;
lon = 144 ;
lat = 73 ;
level = 17 ;
variables:
double time(time) ;
time:standard_name = "time" ;
time:long_name = "Time" ;
time:bounds = "time_bnds" ;
time:units = "hours since 1800-01-01 00:00:0.0" ;
time:calendar = "standard" ;
time:axis = "T" ;
double time_bnds(time, bnds) ;
float lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "Longitude" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
float lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "Latitude" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
float level(level) ;
level:standard_name = "air_pressure" ;
level:long_name = "Level" ;
level:units = "millibar" ;
level:positive = "down" ;
level:axis = "Z" ;
level:actual_range = 1000.f, 10.f ;
level:GRIB_id = 100s ;
level:GRIB_name = "hPa" ;
float air(time, level, lat, lon) ;
air:long_name = "4xDaily Air temperature" ;
air:units = "degK" ;
air:_FillValue = -9.96921e+36f ;
air:missing_value = -9.96921e+36f ;
air:precision = 2s ;
air:least_significant_digit = 1s ;
air:GRIB_id = 11s ;
air:GRIB_name = "TMP" ;
air:var_desc = "Air temperature" ;
air:level_desc = "Multiple levels" ;
air:statistic = "Individual Obs" ;
air:parent_stat = "Other" ;
air:dataset = "NCEP Reanalysis" ;
air:actual_range = 173.7f, 321.2f ;
air:_ChunkSizes = 1, 1, 73, 144 ;
float uwnd(time, level, lat, lon) ;
uwnd:long_name = "4xDaily U-wind" ;
uwnd:units = "m/s" ;
uwnd:_FillValue = -9.96921e+36f ;
uwnd:missing_value = -9.96921e+36f ;
uwnd:precision = 2s ;
uwnd:least_significant_digit = 1s ;
uwnd:GRIB_id = 33s ;
uwnd:GRIB_name = "UGRD" ;
uwnd:var_desc = "u-wind" ;
uwnd:level_desc = "Multiple levels" ;
uwnd:statistic = "Individual Obs" ;
uwnd:parent_stat = "Other" ;
uwnd:dataset = "NCEP Reanalysis" ;
uwnd:actual_range = -100.1f, 138.6f ;
uwnd:_ChunkSizes = 1, 1, 73, 144 ;
float vwnd(time, level, lat, lon) ;
vwnd:long_name = "4xDaily V wind" ;
vwnd:units = "m/s" ;
vwnd:_FillValue = -9.96921e+36f ;
vwnd:missing_value = -9.96921e+36f ;
vwnd:precision = 2s ;
vwnd:least_significant_digit = 1s ;
vwnd:GRIB_id = 34s ;
vwnd:GRIB_name = "VGRD" ;
vwnd:var_desc = "v-wind" ;
vwnd:level_desc = "Multiple levels" ;
vwnd:statistic = "Individual Obs" ;
vwnd:parent_stat = "Other" ;
vwnd:dataset = "NCEP Reanalysis" ;
vwnd:actual_range = -108.f, 100.1f ;
vwnd:_ChunkSizes = 1, 1, 73, 144 ;


Replies (3)

RE: Cdo timmean adds an extra time dimension when doing a time average - Added by Ralf Mueller about 4 years ago

hi Ashwin!

CDO generates CF-compliant netcdf. without the time bounds, a time-mean operation is not fully described, because the timestamp of the data can be anywhere within the time mean interval. so the bounds are needed to be sure what the time-mean field really is about.

hth
ralf

RE: Cdo timmean adds an extra time dimension when doing a time average - Added by Ashwin D about 4 years ago

Hi Ralph,
Thanks for your prompt response. Is there a CDO way to delete the dimension and the variable ? Or am I looking at using NCO or some python specific way using numpy or xarray ?

BR,
Ashwin.

RE: Cdo timmean adds an extra time dimension when doing a time average - Added by Ralf Mueller about 4 years ago

Ashwin D wrote:

Hi Ralph,
Thanks for your prompt response. Is there a CDO way to delete the dimension and the variable ? Or am I looking at using NCO or some python specific way using numpy or xarray ?

BR,
Ashwin.

for deleting a single dimension you have to use nco. In case you want to stay in the python realm, you can use this wrapper: https://github.com/nco/pynco

numpy/xarray have a different workflow and possibly not so many operators, but if this fits more to your needs or not - Idk. u should give them a try I guess.

cheers
ralf

    (1-3/3)