Project

General

Profile

cdo merge adds an extra dimension when merging files. How do I remove it ?

Added by Ashwin D over 7 years ago

Hello,
I am trying to merge two netCDF files and I am getting a data error in the process.

This is the structure of one -

etcdf pres_sfc_2006_16_1_18Z {
dimensions:
lat = 73 ;
lon = 144 ;
dim_PS = 1 ;
time = UNLIMITED ; // (1 currently)
variables:

and the other is

netcdf PFile {
dimensions:
lon = 144 ;
lat = 73 ;
lev = 17 ;
time = UNLIMITED ; // (1 currently

When I merge these files using this cdo command

cdo merge pres_sfc_2006_16_1_18Z.nc PFIle.nc P_File.nc

I get this

netcdf P_File {
dimensions:
lon = 144 ;
lat = 73 ;
lon_2 = 144 ;
dim_PS = 1 ;
lev = 17 ;
time = UNLIMITED ; // (1 currently

There is already a lon dimension and so the extra lon_2 dimension is irrelevant. Can somebody guide me on how to remove it ?

Regards,
Ashwin.


Replies (20)

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

I am using the latest version of cdo i.e. 1.9 and my netCDF version is 4.5-rc1.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer over 7 years ago

Hi Ashwin,

possible causes can be different lon grid values or different coordinates attributes of the variables.

Please, send the output for both files you try to merge

cdo sinfo file1
cdo sinfo file2
ncdump -h file1
ncdump -h file2

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

Hi Karin,
Thanks for your prompt response. I have enclosed the information you requested. Please let me know if you need anything else.

Regards,
Ashwin.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer over 7 years ago

I can't see what is going wrong, yet.

The only difference is that a part in the cdo sinfo outputs is missing

lon : 0 to -2.5 degrees_east  circular
lon : 0 to 357.5 by 2.5 degrees_east  circular

but this can be a copy and paste error.

Could you please upload the files.

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer over 7 years ago

The longitudes differ:

PFile.nc

 lon = 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35, 
    37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70, 
    72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105, 
    107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135, 
    137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165, 
    167.5, 170, 172.5, 175, 177.5, -180, -177.5, -175, -172.5, -170, -167.5, 
    -165, -162.5, -160, -157.5, -155, -152.5, -150, -147.5, -145, -142.5, 
    -140, -137.5, -135, -132.5, -130, -127.5, -125, -122.5, -120, -117.5, 
    -115, -112.5, -110, -107.5, -105, -102.5, -100, -97.5, -95, -92.5, -90, 
    -87.5, -85, -82.5, -80, -77.5, -75, -72.5, -70, -67.5, -65, -62.5, -60, 
    -57.5, -55, -52.5, -50, -47.5, -45, -42.5, -40, -37.5, -35, -32.5, -30, 
    -27.5, -25, -22.5, -20, -17.5, -15, -12.5, -10, -7.5, -5, -2.5 ;

pres_sfc_2006_16_1_18Z.nc

 lon = 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35, 
    37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70, 
    72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105, 
    107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135, 
    137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165, 
    167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195, 
    197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225, 
    227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255, 
    257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285, 
    287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315, 
    317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345, 
    347.5, 350, 352.5, 355, 357.5 ;

You have to change the longitude value ordering by

  cdo sellonlatbox,0,357.5,-90,90 PFile.nc PFile_reorderd.nc

Then it is possible to merge the new file with the pres_sfc_2006_16_1_18Z.nc file

  cdo merge PFile_reorderd.nc pres_sfc_2006_16_1_18Z.nc data_merged.nc
>  ncdump -h data_merged.nc
netcdf data_merged {
dimensions:
    lon = 144 ;
    lat = 73 ;
    lev = 17 ;
    dim_PS = 1 ;
    time = UNLIMITED ; // (1 currently)
variables:
    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 lev(lev) ;
        lev:standard_name = "air_pressure" ;
        lev:long_name = "pressure" ;
        lev:units = "millibar" ;
        lev:positive = "down" ;
        lev:axis = "Z" ;
    float dim_PS(dim_PS) ;
        dim_PS:long_name = "generic" ;
        dim_PS:axis = "Z" ;
    float time(time) ;
        time:standard_name = "time" ;
        time:units = "hours since 1800-1-1 00:00:0.0" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
...

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

Hi Karin,
Thank you so much ! Really appreciate the prompt support !
Best regards,
Ashwin.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

Hi Karin,
I am sorry to report that there is a slight problem with my application requirement. It is the pres_sfc_2006_1_18Z.nc that needs to be reordered and not PFile.nc. My application requires that the longitude be from 0 to -2.5 and not from 0 to 357.5. When I reorder the pres_Sfc file using cdo sellonlatbox I still get the lon_2 coordinate in the merged file.

Regards,
Ashwin.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

Actually the longitude needs to go from -180 to 180 in the final merged file.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer over 7 years ago

The longitude values of PFile.nc are still the problem but there is a way to go ;)

You have to retrieve the grid information of one file and edit it only once when the grid should be the same grid for both files. To show you how they look like and to see the difference of the longitude values (xvals) of PFile.nc and pres_sfc_2006_16_1_18Z_reordered.nc both griddes outputs are shown below.

Save the grid information of the data file PFile.nc:

cdo griddes PFile.nc > mygrid_PFile

The mygrid_PFile file:

#
# gridID 1
#
gridtype  = lonlat
gridsize  = 10512
xsize     = 144
ysize     = 73
xname     = lon
xlongname = "longitude" 
xunits    = "degrees_east" 
yname     = lat
ylongname = "latitude" 
yunits    = "degrees_north" 
xvals     = 0 2.5 5 7.5 10 12.5 15 17.5 20 22.5 25 27.5 30 32.5 35 37.5 40 42.5 45 
            47.5 50 52.5 55 57.5 60 62.5 65 67.5 70 72.5 75 77.5 80 82.5 85 87.5 
            90 92.5 95 97.5 100 102.5 105 107.5 110 112.5 115 117.5 120 122.5 125 
            127.5 130 132.5 135 137.5 140 142.5 145 147.5 150 152.5 155 157.5 160 
            162.5 165 167.5 170 172.5 175 177.5 -180 -177.5 -175 -172.5 -170 -167.5 
            -165 -162.5 -160 -157.5 -155 -152.5 -150 -147.5 -145 -142.5 -140 -137.5 
            -135 -132.5 -130 -127.5 -125 -122.5 -120 -117.5 -115 -112.5 -110 -107.5 
            -105 -102.5 -100 -97.5 -95 -92.5 -90 -87.5 -85 -82.5 -80 -77.5 -75 -72.5 
            -70 -67.5 -65 -62.5 -60 -57.5 -55 -52.5 -50 -47.5 -45 -42.5 -40 -37.5 
            -35 -32.5 -30 -27.5 -25 -22.5 -20 -17.5 -15 -12.5 -10 -7.5 -5 -2.5
yfirst    = 90
yinc      = -2.5

Save the grid information of the data file pres_sfc_2006_16_1_18Z.nc:

cdo griddes pres_sfc_2006_16_1_18Z.nc > mygrid_pres

The mygrid_pres file:

#
# gridID 1
#
gridtype  = lonlat
gridsize  = 10512
xsize     = 144
ysize     = 73
xname     = lon
xlongname = "longitude" 
xunits    = "degrees_east" 
yname     = lat
ylongname = "latitude" 
yunits    = "degrees_north" 
xfirst    = 0
xinc      = 2.5
yfirst    = 90
yinc      = -2.5

Edit the file mygrid_pres and change the xfirst value to -180:

xfirst    = -180

Then use the changed mygrid_pres file to set the grid:

  cdo setgrid,mygrid_pres $infile1 PFile_reorderd.nc
  cdo setgrid,mygrid_pres $infile2 pres_sfc_2006_16_1_18Z_reordered.nc

Merge the files:

  cdo merge PFile_reorderd.nc pres_sfc_2006_16_1_18Z_reordered.nc outfile_merged.nc

-Karin

outfile_merged.nc (2.77 MB) outfile_merged.nc merged output file (PFile_reorderd.nc,pres_sfc_2006_16_1_18Z_reordered.nc)
mygrid_pres (282 Bytes) mygrid_pres edited grid information file

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D over 7 years ago

Karin - that works. The thing is that I had this working in a automated way i.e. download NOAA/NCAR reanalysis 2 files using OPeNDAP , then a whole bunch of cdo commands followed by nco commands. I had hoped to avoid human intervention. So I will have to do is use some regular expression python code to set the xfirst assignment to -180 so that the whole process can be automated.

Thanks again.

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer over 7 years ago

You only have to create the grid file once because all files have to have the same grid. Do it one time manually and then use it in your cdo call for all other files as shown above.

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by James Potemra about 7 years ago

Hi,

Following on this thread, I have a similar problem. I want to merge two netcdf files with identical dimensions. One has one 3D variable and one 4D variable; the other has three 4D variables. When a do a "cdo merge file1.nc file2.nc merged_file.nc" I get a new dimension. In my case the dimension is "depth" that gets changed to "depth_2". This happens to the second file in the merge list.

As a test, I copied file1.nc to a new file, then simply renamed the variables (not changing the dimensions at all), then repeated the same command above. I still get a new dimension on the merged data set. In this case the 4D variable has a dimension of 'depth' from the first file and 'depth_2' from the second. I would like to have a single dimension of just 'depth'.

Here's my versioning:

Climate Data Operators version 1.8.2 (http://mpimet.mpg.de/cdo)
Compiled: by root on apala.soest.hawaii.edu (x86_64-apple-darwin14.5.0) Jun 5 2017 11:24:32
Compiler: /usr/bin/clang -pipe -Os -arch x86_64 -D_THREAD_SAFE -pthread
version: unknown
Features: DATA PTHREADS HDF5 NC4/HDF5 OPeNDAP UDUNITS2 PROJ.4 CURL FFTW3 SSE3
Libraries: HDF5/1.10.1 proj/4.93 curl/7.55.1(h7.54.0)
Filetypes: srv ext ieg grb1 nc1 nc2 nc4 nc4c
CDI library version : 1.8.2 of Jun 5 2017 11:24:20
CGRIBEX library version : 1.7.6 of Dec 20 2016 19:55:24
NetCDF library version : 4.4.1.1 of Jul 15 2017 09:29:15 $
HDF5 library version : 1.10.1
SERVICE library version : 1.4.0 of Jun 5 2017 11:24:17
EXTRA library version : 1.4.0 of Jun 5 2017 11:24:16
IEG library version : 1.4.0 of Jun 5 2017 11:24:16
FILE library version : 1.8.3 of Jun 5 2017 11:24:16

And the ncdump from the initial two files (one is a direct copy, then renamed the variables, then cdo merge):

Input file 1:

netcdf sample1 {
dimensions:
    lon = 649 ;
    lat = 541 ;
    depth = 50 ;
    time = UNLIMITED ; // (1 currently)
variables:
    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 depth(depth) ;
        depth:standard_name = "depth" ;
        depth:units = "m" ;
        depth:positive = "up" ;
        depth:axis = "Z" ;
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "seconds since 2007-1-3 00:00:00" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    float SSH(time, lat, lon) ;
        SSH:standard_name = "sea_surface_height_above_geoid" ;
        SSH:long_name = "Sea Surface Height" ;
        SSH:units = "m" ;
        SSH:_FillValue = 1.e+18f ;
        SSH:missing_value = 1.e+18f ;
    float temperature(time, depth, lat, lon) ;
        temperature:standard_name = "sea_water_potential_temperature" ;
        temperature:long_name = "Temperature" ;
        temperature:units = "degrees_Celsius" ;
        temperature:_FillValue = 1.e+18f ;
        temperature:missing_value = 1.e+18f ;

// global attributes:
        :CDI = "Climate Data Interface version 1.7.2 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.4" ;
        :history = "Fri Sep 29 12:36:23 2017: cdo selname,temperature,SSH INDESO_PHYS_1dAV_20080828_20080101.nc /data/MODREG-3D/POTEMRA/SSH_TEMP/2008/INDESO_PHYS_1dAV_20080828_20080101.nc\n",
            "Created on 05 oct. 2015 09h14min" ;
        :source = "NEMO" ;
        :institution = "INDESO" ;
        :title = "Physical model daily" ;
        :references = "http://www.indeso.web.id" ;
        :contact = "contact@indeso.web.id" ;
        :author = "CLS" ;
        :credit = "© INDESO, 2013, a system implemented by CLS for Balitbang KP, all rights reserved" ;
        :CDO = "Climate Data Operators version 1.7.2 (http://mpimet.mpg.de/cdo)" ;
}

Input file 2, created as cp sample1.nc sample2.nc; ncrename -v temperature,temp; ncrename -v SSH,SSH2:

netcdf sample2 {
dimensions:
    lon = 649 ;
    lat = 541 ;
    depth = 50 ;
    time = UNLIMITED ; // (1 currently)
variables:
    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 depth(depth) ;
        depth:standard_name = "depth" ;
        depth:units = "m" ;
        depth:positive = "up" ;
        depth:axis = "Z" ;
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "seconds since 2007-1-3 00:00:00" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    float SSH2(time, lat, lon) ;
        SSH2:standard_name = "sea_surface_height_above_geoid" ;
        SSH2:long_name = "Sea Surface Height" ;
        SSH2:units = "m" ;
        SSH2:_FillValue = 1.e+18f ;
        SSH2:missing_value = 1.e+18f ;
    float temp2(time, depth, lat, lon) ;
        temp2:standard_name = "sea_water_potential_temperature" ;
        temp2:long_name = "Temperature" ;
        temp2:units = "degrees_Celsius" ;
        temp2:_FillValue = 1.e+18f ;
        temp2:missing_value = 1.e+18f ;

// global attributes:
        :CDI = "Climate Data Interface version 1.7.2 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.4" ;
        :history = "Thu Oct  5 15:22:41 2017: ncrename -v SSH,SSH2 sample2.nc\n",
            "Thu Oct  5 15:22:03 2017: ncrename -v temperature,temp2 sample2.nc\n",
            "Fri Sep 29 12:36:23 2017: cdo selname,temperature,SSH INDESO_PHYS_1dAV_20080828_20080101.nc /data/MODREG-3D/POTEMRA/SSH_TEMP/2008/INDESO_PHYS_1dAV_20080828_20080101.nc\n",
            "Created on 05 oct. 2015 09h14min" ;
        :source = "NEMO" ;
        :institution = "INDESO" ;
        :title = "Physical model daily" ;
        :references = "http://www.indeso.web.id" ;
        :contact = "contact@indeso.web.id" ;
        :author = "CLS" ;
        :credit = "© INDESO, 2013, a system implemented by CLS for Balitbang KP, all rights reserved" ;
        :CDO = "Climate Data Operators version 1.7.2 (http://mpimet.mpg.de/cdo)" ;
        :NCO = "4.6.6" ;
}

And the final from cdo merge sample1.nc sample2.nc sample3.nc:

netcdf sample3 {
dimensions:
    lon = 649 ;
    lat = 541 ;
    depth = 50 ;
    depth_2 = 50 ;
    time = UNLIMITED ; // (1 currently)
variables:
    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 depth(depth) ;
        depth:standard_name = "depth" ;
        depth:long_name = "depth_below_sea" ;
        depth:units = "m" ;
        depth:positive = "up" ;
        depth:axis = "Z" ;
    float depth_2(depth_2) ;
        depth_2:standard_name = "depth" ;
        depth_2:long_name = "depth_below_sea" ;
        depth_2:units = "m" ;
        depth_2:positive = "up" ;
        depth_2:axis = "Z" ;
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "seconds since 2007-1-3 00:00:00" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    float SSH(time, lat, lon) ;
        SSH:standard_name = "sea_surface_height_above_geoid" ;
        SSH:long_name = "Sea Surface Height" ;
        SSH:units = "m" ;
        SSH:_FillValue = 1.e+18f ;
        SSH:missing_value = 1.e+18f ;
    float temperature(time, depth, lat, lon) ;
        temperature:standard_name = "sea_water_potential_temperature" ;
        temperature:long_name = "Temperature" ;
        temperature:units = "degrees_Celsius" ;
        temperature:_FillValue = 1.e+18f ;
        temperature:missing_value = 1.e+18f ;
    float SSH2(time, lat, lon) ;
        SSH2:standard_name = "sea_surface_height_above_geoid" ;
        SSH2:long_name = "Sea Surface Height" ;
        SSH2:units = "m" ;
        SSH2:_FillValue = 1.e+18f ;
        SSH2:missing_value = 1.e+18f ;
    float temp2(time, depth_2, lat, lon) ;
        temp2:standard_name = "sea_water_potential_temperature" ;
        temp2:long_name = "Temperature" ;
        temp2:units = "degrees_Celsius" ;
        temp2:_FillValue = 1.e+18f ;
        temp2:missing_value = 1.e+18f ;

// global attributes:
        :CDI = "Climate Data Interface version 1.8.2 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.4" ;
        :history = "Thu Oct 05 15:23:11 2017: cdo merge sample3.nc sample2.nc big.nc\n",
            "Fri Sep 29 12:36:23 2017: cdo selname,temperature,SSH INDESO_PHYS_1dAV_20080828_20080101.nc /data/MODREG-3D/POTEMRA/SSH_TEMP/2008/INDESO_PHYS_1dAV_20080828_20080101.nc\n",
            "Created on 05 oct. 2015 09h14min" ;
        :source = "NEMO" ;
        :institution = "INDESO" ;
        :title = "Physical model daily" ;
        :references = "http://www.indeso.web.id" ;
        :contact = "contact@indeso.web.id" ;
        :author = "CLS" ;
        :credit = "© INDESO, 2013, a system implemented by CLS for Balitbang KP, all rights reserved" ;
        :CDO = "Climate Data Operators version 1.8.2 (http://mpimet.mpg.de/cdo)" ;
}

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer about 7 years ago

Hi James,

please, upload the two files. I think that the depth values are not the same.

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by James Potemra about 7 years ago

I've put the three files on ftp://ftp.soest.hawaii.edu/jimp/sample1.nc ftp://ftp.soest.hawaii.edu/jimp/sample2.nc and ftp//ftp.soest.hawaii.edu/jimp/sample3.nc
Again, sample2.nc is a direct copy of sample1.nc, just changed the name "temperature" to "temp2" and "SSH" to "SSH2"
Thanks for your quick reply!

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Karin Meier-Fleischer about 7 years ago

Hi James,

the problem seems to be the same attributes of the copied variables temperature and temp2. Changing the long_name attribute prevents the duplicate depth_2 dimension:

cdo setattribute,temp2@long_name="Temperature2" sample2.nc tmp.nc

cdo -O -f nc merge sample1.nc tmp.nc out_merged.nc

ncdump -h out_merged.nc

netcdf out_merge {
dimensions:
    lon = 649 ;
    lat = 541 ;
    depth = 50 ;
    time = UNLIMITED ; // (1 currently)
variables:
    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 depth(depth) ;
        depth:standard_name = "depth" ;
        depth:long_name = "depth_below_sea" ;
        depth:units = "m" ;
        depth:positive = "up" ;
        depth:axis = "Z" ;
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "seconds since 2007-1-3 00:00:00" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    float SSH(time, lat, lon) ;
        SSH:standard_name = "sea_surface_height_above_geoid" ;
        SSH:long_name = "Sea Surface Height" ;
        SSH:units = "m" ;
        SSH:_FillValue = 1.e+18f ;
        SSH:missing_value = 1.e+18f ;
    float temperature(time, depth, lat, lon) ;
        temperature:standard_name = "sea_water_potential_temperature" ;
        temperature:long_name = "Temperature" ;
        temperature:units = "degrees_Celsius" ;
        temperature:_FillValue = 1.e+18f ;
        temperature:missing_value = 1.e+18f ;
    float SSH2(time, lat, lon) ;
        SSH2:standard_name = "sea_surface_height_above_geoid" ;
        SSH2:long_name = "Sea Surface Height" ;
        SSH2:units = "m" ;
        SSH2:_FillValue = 1.e+18f ;
        SSH2:missing_value = 1.e+18f ;
    float temp2(time, depth, lat, lon) ;
        temp2:standard_name = "sea_water_potential_temperature" ;
        temp2:long_name = "Temperature2" ;
        temp2:units = "degrees_Celsius" ;
        temp2:_FillValue = 1.e+18f ;
        temp2:missing_value = 1.e+18f ;

// global attributes:
        :CDI = "Climate Data Interface version 1.9.0 (http://mpimet.mpg.de/cdi)" ;
        :Conventions = "CF-1.4" ;
        :history = "Fri Oct 06 14:20:46 2017: cdo -O -f nc merge sample1.nc tmp.nc out_merge.nc\n",
            "Fri Sep 29 12:36:23 2017: cdo selname,temperature,SSH INDESO_PHYS_1dAV_20080828_20080101.nc /data/MODREG-3D/POTEMRA/SSH_TEMP/2008/INDESO_PHYS_1dAV_20080828_20080101.nc\n",
            "Created on 05 oct. 2015 09h14min" ;
        :source = "NEMO" ;
        :institution = "INDESO" ;
        :title = "Physical model daily" ;
        :references = "http://www.indeso.web.id" ;
        :contact = "contact@indeso.web.id" ;
        :author = "CLS" ;
        :credit = "© INDESO, 2013, a system implemented by CLS for Balitbang KP, all rights reserved" ;
        :CDO = "Climate Data Operators version 1.9.0 (http://mpimet.mpg.de/cdo)" ;
}

-Karin

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Uwe Schulzweida about 7 years ago

This problem will be fixed in the next CDO release. Thanks for the report!

Cheers,
Uwe

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Ashwin D about 7 years ago

Thank you. I now have raised two bugs that have received your attention for a fix!

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Bidyut Goswami over 3 years ago

Hi Uwe,

I am encountering similar problem. I am trying to merge two files which are basically results from different ensembles. So I want the merged-dimension to be an indicator of ensemble numbers so that I can operate the cdo-ensemble operators on the resulting file. I am attaching the two files here. Can you please suggest?

My input files have dimensions:
time = UNLIMITED ; // (139 currently)
lon = 1 ;
lat = 1 ;

Merging which I am getting the following dimensions:
time = UNLIMITED ; // (139 currently)
lon = 1 ;
lat = 1 ;
sfc = 2 ;

I am using the following command to merge:
cdo merge *.nc output.nc

Thanks in advance for your help.

Bidyut

RE: cdo merge adds an extra dimension when merging files. How do I remove it ? - Added by Uwe Schulzweida over 3 years ago

You can not use the operator merge to merge File with the same variables. There is not CDO operator for this task.
For the ensemble operators in CDO, each ensemble member must be in a separate file. Here is an example for the mean over an ensemble:

cdo ensmean *.nc output.nc
Cheers,
Uwe

    (1-20/20)