[ncl-talk] Calculate Average value for a number of files
Ioannis Koletsis
koletsis at meteo.noa.gr
Mon Nov 23 07:44:24 MST 2015
Dear Jack,
Thanks for your time and your quick reply….
I had already checked my initial script before wrote to the list and group and of course I understood that something was going wrong with the definition and dimension of the new variable…..
I followed step by step your suggestions and ran your revised script….
However, the script didn’t work properly and something is going wrong with the calculation of the average value….
Into the All_Dust.txt file (output of readwrite_dust_all.ncl, https://www.dropbox.com/s/g8yscu2qvj3muuk/All_Dust.txt?dl=0 ), the dust_tot values for each lat, lon as well as for each file is written down in the 4th and 5th column.
According to the new script, at the output file Dust_NEW.txt (output of readwrite_dust_all_2_Jack…. https://www.dropbox.com/s/oe0dq61161zzpt8/Dust_NEW.txt?dl=0 ) the average value of the above columns is estimated which nevertheless doesn’t match with the real average value….
Moreover, I would like to calculate the average value for big number of files wrfoutput which it seems to be infeasible with the revised version of the script (readwrite_dust_all_2_Jack….)….
A sample of the wrfout files are attached (https://www.dropbox.com/s/g95nul82e1g8kzu/wrfout_d01_2015-09-12_18%253A00%253A00?dl=0 , https://www.dropbox.com/s/zrztjaqtjuo30wz/wrfout_d01_2015-09-12_21%253A00%253A00?dl=0 ).
I think that something should be changed in loop in order to work properly, but I cannot find it. May be is more easy that I think….
Dear Jack and other ncl users, have you got any idea?
Any help would be kindly appreciated
Best regards
Ioannis
From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of Jack Ogaja
Sent: Thursday, November 19, 2015 8:38 PM
To: Ioannis Koletsis
Cc: ncl-talk [ncl-talk]
Subject: Re: [ncl-talk] Calculate Average value for a number of files
Sorry. Change the following lines;
;===
dust_tot=(/dustJ1,dustJ2,dustJ3,dustJ4,dustJ5/)
to
dust_tot=dim_sum_n((/dustJ1,dustJ2,dustJ3,dustJ4,dustJ5/),0)
and
dustnew = dim_avg_n(dust_tot, (/0,1,2/))
to
dustnew = dim_avg_n(dust_tot, (/0,1/))
;===
Jack
On 19 Nov 2015, at 19:04, Jack Ogaja <jack.ogaja at gmail.com> wrote:
Dear Ioannis,
I think sometimes it is better if you just show the error message instead of asking people to download the data. For example your script simply generates the following error;
;=====
fatal:Number of subscripts do not match number of dimensions of variable,(2) Subscripts used, (1) Subscripts expected
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 77 in file readwrite_dust_all_2.ncl
;=====
which should be a clear message and indicating where the error occurs.
Anyway, since you are only interested in the numbers, I think you would understandably do away with the outer loop and try something like;
;=====
aJ = addfile(FILES(0)+".nc","r")
bJ = addfile(FILES(1)+".nc","r")
…
dustJ1 = (/wrf_user_getvar(aJ,"DUST_1",it), wrf_user_getvar(bJ,"DUST_1",it)/)
.
.
.
dustJ5 = …
dustnew = dim_avg_n(dust_tot, (/0,1,2/))
.
.
.
;=====
See the attached script with such lines(modified from your original script).
Jack
<readwrite_dust_all_2_Jack20151119.ncl>
On 19 Nov 2015, at 16:04, Ioannis Koletsis <koletsis at meteo.noa.gr> wrote:
Dear all,
I would like to write down the average value of a variable for each lat, lon point from a number of wrfoutput files….
The input files are the wrfoutput files which you can find here
( <https://www.dropbox.com/s/kgogk9jcn0m65e8/wrfout_d01_2015-09-12_12%253A00%253A00?dl=0> https://www.dropbox.com/s/kgogk9jcn0m65e8/wrfout_d01_2015-09-12_12%253A00%253A00?dl=0 , <https://www.dropbox.com/s/u8d0wkr2i2u7ydc/wrfout_d01_2015-09-12_15%253A00%253A00?dl=0> https://www.dropbox.com/s/u8d0wkr2i2u7ydc/wrfout_d01_2015-09-12_15%253A00%253A00?dl=0 )
and the variable that I want to calculate the average value from the input files is the dust_tot…
Have you got any idea what is going wrong with my script?
Any help would be appreciated …
Best Regards
Ioannis
Dr. Ioannis Koletsis
National Observatory of Athens
Institute for Environmental Research
Lofos Koufou
15236-Penteli
Athens-Greece
Tel: +30 2108109134
e-mail: koletsis at meteo.noa.gr
----------------------------------------------------------------------------------------
Weather forecasts: http://www.noa.gr/forecast (in english)
or http://www.meteo.gr <http://www.meteo.gr/> (in greek)
Weather forecasts for Europe: http://www.eurometeo.gr <http://www.eurometeo.gr/> (in english)
----------------------------------------------------------------------------------------
_____
<https://www.avast.com/antivirus> Avast logo
Αυτό το e-mail ελέγχθηκε για ιούς από το πρόγραμμα Avast antivirus.
<https://www.avast.com/antivirus> www.avast.com
<readwrite_dust_all_2.ncl>
_______________________________________________
ncl-talk mailing list
<mailto:ncl-talk at ucar.edu> ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
<http://mailman.ucar.edu/mailman/listinfo/ncl-talk> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
---
Αυτό το e-mail ελέγχθηκε για ιούς από το πρόγραμμα Avast antivirus.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151123/17436126/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readwrite_dust_all_2_Jack20151119.ncl
Type: application/octet-stream
Size: 2470 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151123/17436126/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readwrite_dust_all.ncl
Type: application/octet-stream
Size: 2359 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151123/17436126/attachment-0001.obj
More information about the ncl-talk
mailing list