I am a very beginner of nco, and I want to split my .nc file (from 1996010110 to 2019123110) as daily file, from 10AM to 10PM. In that case, each split file contains YYYY-MM-DD:10:00
to YYYY-MM-(DD+1):10:00
. Note that the end hour of DD day is repeated in the beginning of next day. That is the data of YYYY-MM-DD:10:00
occurs twice in file_YYYY_MM_DD.nc
as the starting data and also the ending data of file_YYYY_MM_(DD-1).nc
.
Thanks!
问问题
77 次
2 回答
2
有一个 CDO 命令允许您选择小时的子范围:
cdo selhour,10/22 in.nc out.nc
这将回答问题的第一部分,但从我的评论中你会看到这个问题需要进一步澄清。
于 2021-09-21T20:46:47.710 回答
1
在 NCO 中执行此操作的方法是随着时间的推移循环使用 hyperslabber 的子循环形式来消除重复的时间戳,然后循环几天以创建类似于此处记录的示例的每个文件。对于第一个期望记录为索引 10 的输入,最后一个期望索引是无界的,重复序列中的记录数(即组之间的步幅)为 25,连续期望记录的数量(期望的子集group) 是 24,第一个命令是这样的:
ncrcat -d time,10,,25,24 in.nc out.nc
然后out.nc
将包含数千天的数据,没有重复的时间步长,您可以根据需要将该文件拆分为每日文件,包括ncrcat
包裹在一个循环中,例如
编辑 20210924:根据下面的说明,您可以忽略此消息的上述部分并直接进入此循环,该循环已被修改为每天提取 25 个时间步长。
for yr in {1996..2019}; do
for mth in {1..12}; do
for day in {1..${dpm[mth]}}; do # Days-per-month array exercise left for the reader :)
yyyy=`printf "%04d" $yr`
mm=`printf "%02d" $mth`
dd=`printf "%02d" $day`
ncrcat -d time,${yyyy}-${mm}-${dd}T10:00:00,${yyyy}-${mm}-${ddp1}T10:00:00 out.nc file_${yyyy}_${mm}_${dd}.nc
done
done
done
于 2021-09-23T20:31:17.377 回答