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!
Read the ncap2 documentation here.
ncap2 -s 'time-=841512' in.nc out.nc