Reputation: 49
I have a monthly .nc file from ISIMIP. Here's the time series:
time = "2000-01-01", "2000-02-01", "2000-03-01", "2000-04-01", "2000-05-01",
"2000-06-01", "2000-07-01", "2000-08-01", "2000-09-01", "2000-10-01",
"2000-11-01", "2000-12-01", "2001-01-01", "2001-02-01", "2001-03-01"
... until 2014-12-01.
I need to duplicate every month and make a new time after 15 days. So, I will get 2 times in a month with the same value like:
2000-01-01, 2000-01-16, 2000-02-01, 2000-02-16, 2000-03-01, 2000-03-16....
The times of each month are the same values.
I tried:
cdo inttime,2000-01-01,12:00,15days my_file.nc interpolated_file.nc
ncks -F -d time,,,2 original_file.nc first_days.nc
ncks -F -d time,1,,2 interpolated_file.nc sixteenth_days.nc
ncrcat first_days.nc sixteenth_days.nc final_file.nc
But it did not work. I'd appreciate any suggestions.
Upvotes: 2
Views: 67
Reputation: 8107
Not sure this is the most efficient way to do this, but why not shift the timestamp by 15 days and then merge the files back together again?
# shift the timestamp
cdo shifttime,15days in.nc in_shift.nc
# merge together
cdo mergtime in.nc in_shift.nc out.nc
Or in one line using piping (I hope this works as the mergetime may not work well with piping, I seem to recall that commands with flexible numbers of input files like cat can't be combined with piping)
cdo mergetime in.nc -shifttime,15days in.nc out.nc
Note that this soln of course gives you the second slice always on the 15th, regardless of the month length.
Upvotes: 3