简体   繁体   English

如何使用 cdo/nco 将时间步长添加到时间序列的开始和结束?

[英]how to add time steps to the beginning and end of a time series with cdo/nco?

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? cdo 或cdo (我不是很熟悉)中是否有任何命令可以在长时间nco的开头添加一些时间步长? 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?假设我在夏季 (JJA) 中有一个很长的时间序列 (1959-2021),我想在 1959 年初的 2021 年 8 月 24 日至 30 日和 2021 年底的 6 月 1 日至 8 日添加。我在想使用cdo选择日期,但我不确定如何使用 cdo 命令执行此操作( cdo我认为只会在最后合并它),所以我想知道nco甚至 cdo 中是否有任何命令可以做这个?

Thanks in advance !!提前致谢 !!

add days at the beginning of a time series and at the end.在时间序列的开头和结尾添加天数。

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?这个问题需要澄清一下,你的意思是 6 月 1-8 日是 1959 年的,你想把它贴到系列的结尾? 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?而且,当您将其粘贴到开头时,您的意思是您希望将其粘贴到 1958 年 8 月 24 日至 30 日,或者 1959 年五月的最后几天,在这种情况下,那将是您唯一的五月天? 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:另一种方法,如果你想将结束时间移到 1958 年,相同的日期是使用 shifttime,那么代码是:

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.不过,这似乎是一件奇怪的事情......我从你的日期范围猜测你正在玩 ERA5 再分析。 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.如果你想这样做是因为你想应用运行平均值并且不想得到更短的 output,那么在开始时填充数据更合适,重复前 x 天,如果你想应用 FFT。

See the NCO documentation about selecting date ranges:请参阅有关选择日期范围的 NCO文档

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM