Project

General

Profile

merge 365 netcdf files

Added by nazanin tavakoli over 3 years ago

Hello,
I have 365 netcdf files and I want to merge them which have the following properties:

gridtype = lonlat
gridsize = 6480000
xname = lon
xlongname = longitude
xunits = degrees_east
yname = lat
ylongname = latitude
yunits = degrees_north
xsize = 3600
ysize = 1800
xfirst = -179.9451
xinc = 0.0989
yfirst = -89.94781
yinc = 0.0989

So, I used this code the following code but the latitude and longitude of the final NetCDF are changed.
cdo mergetime *.nc could_1_2001.nc
Could anybody help me with this problem?


Replies (6)

RE: merge 365 netcdf files - Added by Karin Meier-Fleischer over 3 years ago

Hi Nazanin,

can you upload a 2-3 files that we are able to reproduce your problem?

Have all files data on the same grid?

-Karin

RE: merge 365 netcdf files - Added by nazanin tavakoli over 3 years ago

I have just fixed the problem but now I want to merge 365 nc4 files in CDO. I have used the following code:
cdo mergetime *.nc4 2014p.nc4

I have these errors:
Warning (cdf_scan_var_attr): NetCDF: Variable not found - >nv<
Warning (cdf_set_var): Inconsistent variable definition for time_bnds!
Warning (set_calendar): calendar >julian< unsupported!
The properties of my netcdf4 files are:
gridtype = lonlat
gridsize = 6480000
xname = lon
xlongname = longitude
xunits = degrees_east
yname = lat
ylongname = latitude
yunits = degrees_north
xsize = 3600
ysize = 1800
xfirst = -179.9500
xinc = 0.1
yfirst = -89.9500
yinc = 0.1
and my variable is precipitationCal.

RE: merge 365 netcdf files - Added by Karin Meier-Fleischer over 3 years ago

The files are not CF-convention conform! Also NCO has problems with it

WARNING "bounds" attribute for variable /time is type NC_STRING, not NC_CHAR. This violates the CF convention for allowed datatypes (http://cfconventions.org/cf-conventions/cf-conventions.html#_data_types).

You have to convert the files from nc4 to nc2 and then merge the files.

cdo -f nc2 copy 3B-DAY.MS.MRG.3IMERG.20140101-S000000-E235959.V06.nc4 f1.nc
cdo -f nc2 copy 3B-DAY.MS.MRG.3IMERG.20140102-S000000-E235959.V06.nc4 f2.nc
cdo mergetime f1.nc f2.nc outfile.nc
cdo infon outfile.nc
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2014-01-01 00:00:00       0  6480000 1789350 :      0.0000      3.1146      547.65 : precipitationCal
     2 : 2014-01-01 00:00:00       0  6480000       0 :      0.0000      34.746      48.000 : precipitationCal_cnt
     3 : 2014-01-01 00:00:00       0  6480000       0 :      0.0000      4.9251      48.000 : precipitationCal_cnt_cond
     4 : 2014-01-01 00:00:00       0  6480000   42611 :      0.0000     0.72622      246.88 : HQprecipitation
     5 : 2014-01-01 00:00:00       0  6480000       0 :      0.0000      17.710      35.000 : HQprecipitation_cnt
     6 : 2014-01-01 00:00:00       0  6480000       0 :      0.0000      1.2248      28.000 : HQprecipitation_cnt_cond
     7 : 2014-01-01 00:00:00       0  6480000 1789350 :     0.82486      4.5169      235.78 : randomError   
     8 : 2014-01-01 00:00:00       0  6480000       0 :      0.0000      34.746      48.000 : randomError_cnt
     9 : 2014-01-02 00:00:00       0  6480000 1786936 :      0.0000      3.0886      507.97 : precipitationCal
    10 : 2014-01-02 00:00:00       0  6480000       0 :      0.0000      34.763      48.000 : precipitationCal_cnt
    11 : 2014-01-02 00:00:00       0  6480000       0 :      0.0000      5.1320      48.000 : precipitationCal_cnt_cond
    12 : 2014-01-02 00:00:00       0  6480000   42686 :      0.0000     0.68540      194.10 : HQprecipitation
    13 : 2014-01-02 00:00:00       0  6480000       0 :      0.0000      17.460      35.000 : HQprecipitation_cnt
    14 : 2014-01-02 00:00:00       0  6480000       0 :      0.0000      1.2214      31.000 : HQprecipitation_cnt_cond
    15 : 2014-01-02 00:00:00       0  6480000 1786936 :     0.49089      4.5546      230.54 : randomError   
    16 : 2014-01-02 00:00:00       0  6480000       0 :      0.0000      34.763      48.000 : randomError_cnt
cdo    infon: Processed 8 variables over 2 timesteps [0.96s 133MB].

RE: merge 365 netcdf files - Added by nazanin tavakoli about 3 years ago

Thank you for your help. When I use this code (cdo -f nc2 copy 3B-DAY.MS.MRG.3IMERG.20140101-S000000-E235959.V06.nc4 f1.nc), I have the following warning. Are they important?

Warning (cdf_scan_var_attr): NetCDF: Variable not found - >nv<
Warning (cdf_set_var): Inconsistent variable definition for time_bnds!
Warning (set_calendar): calendar >julian< unsupported!

RE: merge 365 netcdf files - Added by Brendan DeTracey about 3 years ago

I think the first warning only matters if you plan to interpolate using a conservative remapping. The second warning might affect temporal interpolations.

You can fix the last warning by using the setcalendar command (https://code.mpimet.mpg.de/projects/cdo/embedded/index.html#x1-2410002.6.4) e.g.

$ cdo mergetime -setcalendar,XXXX [ f1.nc f2.nc ] outfile.nc
Only you know what your julian calendar means. Compare it to the list of arguments for the setcalendar command.

    (1-6/6)