I have two netCDF files. One file elevation.nc contains just the 'elevation' of an area. Other file climate.nc has ('lat', 'lon','prcp', 'temp'). I have used the following:
cdo merge elevation.nc climate.nc merged.nc
The merge.nc
file only has on single prcp
and temp
from the date that the elevation had been recorded.
How to get time varying prcp
and temp
in merged.nc similar to climate.nc but also with the static variable elevation
?
You only need to reverse the order of the input files to ensure that the multi-step file is the first input file as cdo
takes the dimensions from that. So this would work:
cdo merge climate.nc elevation.nc merged.nc
If you do it in the "wrong" order (i.e. the single timestep input file first) cdo
explicitly tells you in a warning that it is chopping off all the remaining steps of the time-dependent file in order to match the first input file:
cdo merge (Warning): Input stream 1 has 1 timestep. Stream 2 has more timesteps, skipped!
Reversing the input order to have the longest input file first, everything works fine and no warning is given.