extract time series from nc file
Added by yali li about 2 years ago
Hello, let say we have an nc file includes 120 years in the form of month and multivariable inside (temp,prec,pres...etc). And I want to get the yearly average of each year for a specific variable, can we do that in one line command?
Raw data information
1.Split the multivariate nc file into multiple univariate layers, and select the desired variable layer of temp
cdo splitparam cru_1901_2021.nc cru_1901_2021_
2.Select the required temperature layer and calculate the annual average value
cdo yearmonmean cru_1901_2021_tmp.nc cru_1901_2021_tmp_avg.nc
result:
3.Divide data by year to get annual average value layers
*cdo splityear cru_tmp1901_2021.nc cru_tmp_avg *
Finally, we get 120 annual average temperature layers.
And i also want to know if NC format can be changed into tif format in batch with cdo?
I am new to cdo, so any help or comment would be appreciated.
Thank you.
yali
Replies (1)
RE: extract time series from nc file - Added by Karin Meier-Fleischer about 2 years ago
Hi Yali,
if you want to do that for one specific variable you do not need to split the file by its variables (1. step) you only need to use the selname operator. The operators are executed from right to left, each result is piped to the next operator. See docu.
The following command means
- select variable tmp
- compute the yearly monthly means
- split into single file per year
cdo -O -splityear -yearmonmean -selname,tmp cru_1901_2021.nc cru_tmp_avg_