0

Is there any command in cdo or nco (which I am not very familiar with) to add some timesteps at the beginning of a long time series? Let's say I have a long time series (1959-2021) within summer season (JJA) and I want to add from 24-30 August 2021 at the beginning of 1959 and from 1-8 June at the end of 2021. I was thinking to selec the days with cdo but then I am not sure how to do this with a cdo command (cdo mergetime I think will merge it at the end only), so I was wondering if there is any command in nco or even cdo that can do this?

Thanks in advance !!

add days at the beginning of a time series and at the end.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86

2 Answers2

1

The question needs a little clarification, you mean that the 1-8 June is from 1959 and you want to post it to the end of the series? In other words you want to make the series cyclic? And what is the frequency of the data, daily? hourly? And also when you paste it to the start, you mean you want it pasted to 24-30 aug 1958, or the last days of May in 1959, in which case that will be your only May days? Please try to be specific and detailed when posting. Think of your question as a cake recipe you need to specify, we need to know the ingredients :-)

So, guessing what you want to do, and assuming hourly data frequency... I think you could do this by selecting the steps you want, resetting the time axis and then doing mergetime (here I just paste the end to the start, duplicate for the other direction):

cdo seldate,2021-08-24,2021-08-30 in.nc out1.nc
cdo settaxis,1958-08-24,00:00:00,1hour out1.nc out2.nc
cdo mergetime out2.nc in.nc merged.nc 

An alternative, if you want to shift the end to 1958, same dates is to use shifttime, then the code is :

cdo seldate,2021-08-24,2021-08-30 in.nc out1.nc
cdo shifttime,-63years out1.nc out2.nc
cdo mergetime out2.nc in.nc merged.nc 

It seems a strange thing to do though... I'm guessing from your date range that you are playing with ERA5 reanalysis. If you want to do this because you want to apply a running mean and don't want to get a shorter output, then it is more appropriate to pad the data at the start with the first x days repeated, same thing if you want to apply an FFT.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • Yes!Actually I want to do a running percentile, but it's a bit confusing for me to use the ydrunpercentile command of cdo.My data is daily maximum temperature from ERA5. So basically what I was doing is selecting the time steps from 25 may to 7 september to calculate the 90th percentile centered in a 15 day window with cdo for the summer season,but appereantly this was not completely right? I want to select the first days of june from 1959 and add them to the end of 31 august 2021 and select the days of 24-30 august 2021 and add them at the beginning of 1june 1959, im not sure this is correct – AccioNimbus Jan 19 '23 at 11:07
  • why make it cyclic? Usually you would pad the start by repeating the first day or X days at the start of the series, making it a tapered window. I'm actually in the process of making a video on this topic for my channel, hopefully it will be done and posted by Feb... – ClimateUnboxed Jan 20 '23 at 14:20
1

See the NCO documentation about selecting date ranges:

ncrcat -d time,2021-08-24,2021-08-30 in.nc august2021.nc
ncrcat -d time,1958-06-01,1958-06-08 in.nc june1958.nc
ncrcat august2021.nc in.nc june1958.nc out.nc
Charlie Zender
  • 5,929
  • 14
  • 19