NCO:是否有任何一行命令可以更改整个数组的时间维度索引(而不是通过 for 循环)?
我有一个 netCDF 文件 FORCING.nc
,其中包含维度“时间”,其值如下:[ 841512., 841513., 841514., ..., 1051893., 1051894.,1051895.]
。但我想将时间戳从绝对值更改为从 841512 开始的相对值,例如将其更改为 [0, 1, 2,...,1051895-841512]=[0, 1, 2,。 ...,210383]
。那么有没有一行nco
命令可以做到这一点? 多谢!
一些代码示例,但在 python 中(抱歉我不熟悉 nco...):
import numpy as np
from netCDF4 import Dataset
file_small = Dataset('./FORCING.nc')
file_small['time'][:]
然后我可以获得如下输出:
Out[5]:
masked_array(data=[ 841512., 841513., 841514., ..., 1051893., 1051894.,
1051895.],
mask=False,
fill_value=1e+20,
dtype=float32)
我想做的,是将 time
的值从 [ 841512.、841513.、841514.、...、1051893.、1051894.、1051895.]
至[0,1,2,...,1051895-841512]=[0,1,2,...,210383]
。谢谢!
I have a netCDF file FORCING.nc
containing dimension "time" with values like: [ 841512., 841513., 841514., ..., 1051893., 1051894.,1051895.]
. But I want to change the time stamps from the absolute value to relative values starting from 841512, say change it to [0, 1, 2,...,1051895-841512]=[0, 1, 2,...,210383]
. So is there any one-line nco
command to do it?
Thanks a lot!
Some code example but in python (sorry I am not familiar with nco...):
import numpy as np
from netCDF4 import Dataset
file_small = Dataset('./FORCING.nc')
file_small['time'][:]
Then I can get output like:
Out[5]:
masked_array(data=[ 841512., 841513., 841514., ..., 1051893., 1051894.,
1051895.],
mask=False,
fill_value=1e+20,
dtype=float32)
What I want to do, is change the value of time
from [ 841512., 841513., 841514., ..., 1051893., 1051894.,1051895.]
to [0, 1, 2,...,1051895-841512]=[0, 1, 2,...,210383]
. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读ncap2文档在这里。
Read the ncap2 documentation here.