[Thread Prev][Thread Next][Index]

Re: [ferret_users] Averaging multi variables



Hi Saat,
G'day

There is a function in CDO called as "ensmean" which can solve your problem if you want to average (ensemble mean) the variable/s. 

let suppose you have files as sst1.nc sst2.nc sst3.nc ......... sstn.nc

you can do like this using the wild card in CDO.

cdo -r -f nc4 ensmean sst*.nc ensemble_mean_output.nc

here *.nc covers all the files that you want to average with the help of * wild card. You have to be careful while using wild card " * " because if you are using *.nc it will take all the netcdf files present in the folder. So better that you make a separate folder that contains only those files that you want to use for a particular operation. 

this is the direct way to do mean of variable/s across multiple files. 

let me know if this doesn't work. we will try something else also with the help of ferret.

cheers, saurabh

On Tue, Jul 23, 2019 at 10:21 AM Saat Mubarrok <saatmubarrok@xxxxxxxxx> wrote:
Dear Satyesh,

Thank you very much for your reply.
But if I have more variables like 30 or even 100, should I do manually also?

Best regards,
Saat M.


On Mon, Jul 22, 2019 at 8:00 PM Satyesh Ghetiya <satyeshghetiya@xxxxxxxxx> wrote:
Following types of expressions are not allowed in Ferret unlike other programming languages : "let ave=ave+2"

For the loop, you may do this:

repeat/name=me/range=1:6 (\
let tempid=temp[i=`me`];\
use "`tempid`.temp.regrid.nc";\
)
let sst_ave=(sst[d=1]+sst[d=2]+sst[d=3]+sst[d=4]+sst[d=5]+sst[d=6])/6

This is usual way for limited number of variables (e.g. here 6)

Regards,
G Satyesh


On Mon, Jul 22, 2019 at 2:24 PM Saat Mubarrok <saatmubarrok@xxxxxxxxx> wrote:
Dear community,

I am new to ferret and trying to do a summation using repeat. Let say I have 6 datasets with same variable on it (sst). I want to averaging those variables. What is the best method to do that in ferret?

set region/x=20e:120e/y=30s:30n/k=1
let temp= {"2002","2003","2004","2006","2007","2010"}

repeat/name=me/range=1:6 (\
let tempid=temp[i=`me`];\
use "`tempid`.temp.regrid.nc";\
let ave`me`=sst[d=`me`];\
let ave=ave+ave`me`;\
)
fill/nolab/lev=(-inf)(23,32,2)(inf) ave/6


the error I get is 

**ERROR: stack overflow

Any lead is much appreciate. Thank you

Saat M.









--


REGARDS

Saurabh Rathore
Research Scholar (PhD.)
Centre For Oceans, Rivers, Atmosphere & Land Science Technology
Indian Institute Of Technology, Kharagpur
contact :- 91- 8345984434

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement