【问题标题】:nco cut daily netcdf file to 10 minute filesnco 将每日 netcdf 文件剪切为 10 分钟文件
【发布时间】:2018-01-18 01:55:19
【问题描述】:

我有一个每日 netcdf 文件 (20060101),时间维度有 144 个步骤,因此文件中有 10 分钟的时间步骤。现在我想用 nco 为每 10 分钟时间步创建一个 netcdf 文件。所以最后它应该创建 144 个文件。

我已经在他们使用的地方发现了类似的问题

ncks -d time,min,max,stride infile.nc outfile.nc

但我不知道如何编写代码来创建这 144 个文件。 有人可以帮我弄这个吗? 感谢您的帮助!

【问题讨论】:

  • 您尝试过什么,哪里失败了?你熟悉 for 循环吗?在向我们展示您的尝试后,您更有可能获得帮助,而不是要求其他人为您编写代码。

标签: netcdf nco cdo-climate ncks


【解决方案1】:

找到解决方案:

start=1131580800 # first time step in seconds
for f in *_test.nc; do #$files
    echo 'Processing' $f 
    for i in {0..17}; do
    time=$(expr $start + 600 \* $i)                   #  calculates the next time step --> 600s correspond to 10 minute steps I wanted to have
    time_new=$(date -d @$time '+_%H%M')               # extracting the time variable from my file and convert it to use them in the file names
    outfile=$(echo $f|sed "s/_level2/$time_new/g")
    ncks -d time,$i,$i $f $outfile                    # split my original file to 10 min steps
    done
done

【讨论】:

    【解决方案2】:

    我没有测试过,但我认为你可以在 CDO 中使用一行代码:

    cdo splitsel,1 input.nc output
    

    “1”表示在每个输出文件中以 1 个时间步长分割文件,我认为这是您所要求的。

    【讨论】:

    • 是的,没错,但有时 cdo 会更改元数据,所以我一直在寻找另一种方法。
    • CDO 只有在字段不在“标准”纬度类型网格上时才会遇到麻烦,否则它应该可以正常工作。它确实将命令本身添加到全局属性字段历史记录中,但如果不需要,可以将其关闭。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 2019-06-19
    • 2018-09-02
    • 2017-02-14
    • 2018-07-04
    • 2014-12-02
    • 1970-01-01
    相关资源
    最近更新 更多