Adding time axis to netcdf files
Added by nazanin tavakoli over 3 years ago
Hello,
I want to add time axis to monthly netcdf files which have longitude,latitude, and a variable called Band1. I have tried the following code:
cdo -setreftime,1900-01-01,00:00:00,1day \
-settaxis,1901-01-01,12:00:00,1month \
-setcalendar,standard \
out1.nc < 2001_1.nc
cdo -setreftime,1900-01-01,00:00:00,1day \
-settaxis,1901-02-01,12:00:00,1month \
-setcalendar,standard \
out2.nc < 2001_2.nc
cdo -mergetime out*.nc final.nc
and here is my errors:
cdo setreftime (Abort): Too few streams specified! Operator needs 1 input and 1 output streams.
cdo setreftime (Abort): Too few streams specified! Operator needs 1 input and 1 output streams.
cdo mergetime: Open failed on >out*.nc<
No such file or directory
Could anybody help me?
Replies (6)
RE: Adding time axis to netcdf files - Added by Brendan DeTracey over 3 years ago
cdo -setreftime,1900-01-01,00:00:00,1day -setdate,1900-01-01 -setcalendar,standard 2001_1.nc out1.nc cdo -setreftime,1900-01-01,00:00:00,1day -setdate,1900-02-01 -setcalendar,standard 2001_2.nc out2.nc cdo -O mergetime out*.nc test.nc
RE: Adding time axis to netcdf files - Added by nazanin tavakoli over 3 years ago
Dear Brendan DeTracy,
I have used the code you have suggested, but the time axis in my output file is 0001-01-01 and 0001-02-01 instead of 2001-01-01 and 2001-02-01.
RE: Adding time axis to netcdf files - Added by Brendan DeTracey over 3 years ago
Strange. It works for me...
$ ncdump -v time test.nc netcdf test { dimensions: time = UNLIMITED ; // (2 currently) lon = 559 ; lat = 1104 ; variables: double time(time) ; time:standard_name = "time" ; time:units = "days since 1900-1-1 00:00:00" ; time:calendar = "standard" ; time:axis = "T" ; double lon(lon) ; lon:standard_name = "projection_x_coordinate" ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; lon:axis = "X" ; double lat(lat) ; lat:standard_name = "projection_y_coordinate" ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; lat:axis = "Y" ; int crs ; crs:grid_mapping_name = "latitude_longitude" ; crs:long_name = "CRS definition" ; crs:longitude_of_prime_meridian = 0. ; crs:semi_major_axis = 6378137. ; crs:inverse_flattening = 298.257223563 ; crs:spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]" ; crs:GeoTransform = "151.104872700202 0.004589522999999992 0 -28.34431309500599 0 -0.004589522999999993 " ; float Band1(time, lat, lon) ; Band1:long_name = "GDAL Band Number 1" ; Band1:grid_mapping = "crs" ; Band1:_FillValue = -3.402823e+38f ; Band1:missing_value = -3.402823e+38f ; // global attributes: :CDI = "Climate Data Interface version 1.9.9 (https://mpimet.mpg.de/cdi)" ; :Conventions = "CF-1.5" ; :history = "Thu Apr 01 12:28:03 2021: cdo -O mergetime out1.nc out2.nc test.nc\n", "Thu Apr 01 12:27:36 2021: cdo -setreftime,1900-01-01,00:00:00,1day -setdate,1900-01-01 -setcalendar,standard 2001_1.nc out1.nc\n", "Wed Mar 31 11:18:42 2021: cdo divc,4 o2001_1.nc 2001_1.nc\n", "Wed Mar 31 11:18:42 2021: cdo -add t2001_1_1.nc -add t2001_1_25.nc -add t2001_1_9.nc t2001_1_17.nc o2001_1.nc\n", "Wed Mar 31 09:55:29 2021: cdo divc,8 o2001_1_1.nc t2001_1_1.nc\n", "Wed Mar 31 08:29:49 2021: cdo -setrtomiss,3276.1,3276.7 2001_1_1.nc o2001_1_1.nc\n", "Tue Mar 30 16:48:13 2021: GDAL CreateCopy( 2001_1_1.nc, ... )" ; :GDAL_AREA_OR_POINT = "Area" ; :GDAL_DataType = "Generic" ; :GDAL = "GDAL 2.4.2, released 2019/06/28" ; :CDO = "Climate Data Operators version 1.9.9 (https://mpimet.mpg.de/cdo)" ; data: time = 0, 31 ; }
Platform/version of cdo?
$ uname --all Linux hecla 4.15.0-136-generic #140-Ubuntu SMP Thu Jan 28 05:20:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux $ cdo -V Climate Data Operators version 1.9.9 (https://mpimet.mpg.de/cdo) System: x86_64-conda-linux-gnu CXX Compiler: /home/conda/feedstock_root/build_artifacts/cdo_1604652667339/_build_env/bin/x86_64-conda-linux-gnu-c++ -fPIC -DPIC -g -O2 -std=c++11 -fopenmp -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/brendan/miniconda3/envs/cmip6/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/cdo_1604652667339/work=/usr/local/src/conda/cdo-1.9.9 -fdebug-prefix-map=/home/brendan/miniconda3/envs/cmip6=/usr/local/src/conda-prefix -fopenmp -pthread CXX version : unknown C Compiler: /home/conda/feedstock_root/build_artifacts/cdo_1604652667339/_build_env/bin/x86_64-conda-linux-gnu-cc -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/brendan/miniconda3/envs/cmip6/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/cdo_1604652667339/work=/usr/local/src/conda/cdo-1.9.9 -fdebug-prefix-map=/home/brendan/miniconda3/envs/cmip6=/usr/local/src/conda-prefix -fopenmp -pthread -pthread C version : unknown F77 Compiler: /home/conda/feedstock_root/build_artifacts/cdo_1604652667339/_build_env/bin/x86_64-conda-linux-gnu-gfortran -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/brendan/miniconda3/envs/cmip6/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/cdo_1604652667339/work=/usr/local/src/conda/cdo-1.9.9 -fdebug-prefix-map=/home/brendan/miniconda3/envs/cmip6=/usr/local/src/conda-prefix F77 version : GNU Fortran (crosstool-NG 1.24.0.133_b0863d8_dirty) 9.3.0 Features: 62GB 24threads C++11 OpenMP45 Fortran PTHREADS HDF5 NC4/HDF5/threadsafe OPeNDAP UDUNITS2 PROJ XML2 CURL FFTW3 SSE3 Libraries: HDF5/1.10.6 proj/7.2.0 xml2/2.9.10 curl/7.71.1 Filetypes: srv ext ieg grb1 grb2 nc1 nc2 nc4 nc4c nc5 CDI library version : 1.9.9 cgribex library version : 1.9.5 ecCodes library version : 2.19.1 NetCDF library version : 4.7.4 of Oct 21 2020 19:55:48 $ hdf5 library version : 1.10.6 threadsafe exse library version : 1.4.1 FILE library version : 1.9.1
RE: Adding time axis to netcdf files - Added by Karin Meier-Fleischer over 3 years ago
Hi Nazanin and Brendan,
cdo -setreftime,2000-01-01,00:00:00,1day -settaxis,2001-01-01,12:00:00,1month -setcalendar,standard 2001_1.nc out1.nc
cdo -setreftime,2000-01-01,00:00:00,1day -settaxis,2001-02-01,12:00:00,1month -setcalendar,standard 2001_2.nc out2.nc
cdo -O -mergetime out*.nc final.nc
cdo sinfon final.nc File format : NetCDF -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v instant 1 1 617136 1 F32 : Band1 Grid coordinates : 1 : lonlat : points=617136 (559x1104) mapping : latitude_longitude lon : 151.1072 to 153.6681 by 0.004589523 degrees_east lat : -33.40885 to -28.34661 by 0.004589523 degrees_north Vertical coordinates : 1 : surface : levels=1 Time coordinate : 2 steps RefTime = 2000-01-01 00:00:00 Units = days Calendar = standard YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 2001-01-01 12:00:00 2001-02-01 12:00:00 cdo sinfon: Processed 1 variable over 2 timesteps [0.00s 7208KB].
Happy Easter!
RE: Adding time axis to netcdf files - Added by nazanin tavakoli over 3 years ago
Thank you both of you
Happy Easter, too!!
RE: Adding time axis to netcdf files - Added by Brendan DeTracey over 3 years ago
This chocolate rabbit tastes funny...