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
?
3
Answers
the main issue was found to be that the
elevation.nc
has a single time step attribute. It is essential to remove this attribute before the merge. hence, the steps shall involve (usingncks
fromnco
):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: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:Reversing the input order to have the longest input file first, everything works fine and no warning is given.
This would be more concise, though you’ll have to test it to be sure it works as expected: