Project

General

Profile

extract time series from nc file

Added by Saat Mubarrok over 3 years ago

Hello, let say we have an nc file with multivariable inside (temp,sali,prec,pres...etc). And I want to select the time series for a specific variable, at a specific level or depth, at a specific location or grid, at specific time or range, can we do that in one line command?

For example: my data contain 4 variable: temp,sali,prec,prec.
My grid i=1:180, j=1:90, k=1:50 (level), l=1:480(time)
I want to extract time series for temp variable at level 1 (surface) at grid let say j=20, i=100 (or lon=100, lat=20) for all the time.

I can achieve that by step-by-step which I think is a bit of hassle. My approach:
1. extract the variable from main nc file:

cdo select,name=temp data.nc test1.nc

2. select the level (surface):

cdo sellevidx,1 test1.nc test2.nc

3. extract the time series:

cdo -outputtab,date,lon,lat,value -remapnn,lon=100_lat=20 test2.nc > time.txt

I am new to cdo, so any help or comment would be appreciated.
Thank you.

Samu


Replies (2)

RE: extract time series from nc file - Added by Karin Meier-Fleischer over 3 years ago

Hi Saat,

you can do it at once with the operator chaining. In the following example the output of outputtab is redirected to a file.

cdo -s -outputtab,date,time,lon,lat,value -remapnn,lon=100_lat=20 -sellevidx,1 -selname,tsurf data.nc > time.txt

-Karin

RE: extract time series from nc file - Added by Saat Mubarrok over 3 years ago

Thank you

it work like a charm.

    (1-2/2)