Re: read binary files

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 16 2012 - 09:02:48 MST

ntim = 12
nlat = 46
mlon = 72

var = new( (/ntim,nlat,mlon/), "float", -999.9)
do nt=0,ntim-1
    var(nt,:,:) = fbindirread( (nt+1)+".bin", 0, (nlat,mlon/), "float")
end do

var_avg = dim_num_n(var, 0)

http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_num_n.shtml

On 1/16/12 8:47 AM, Xiaoyan Ma wrote:
> Dear NCl community,
>
> I read quite a few binary files, e.g. 12 files, I read them as below,
>
> var1=fbindirread("1.bin",0, (/46,72/), "float")
> var2=fbindirread("2.bin",0, (/46,72/), "float")
> ...
> var12=fbindirread("12.bin",0, (/46,72/), "float")
>
> in which there are some grid cells with missing data, i.e.
>
> var1@FillValue = -999.9
> var2@FillValue = -999.9
> ...
> var12@FillValue = -999.9
>
> Now I want to calculate the average from these 12 files, for those grid
> points without missing data. For those points with missing data, I set
> them as
>
> var@FillValue = -999.9
>
> if I use the way below, it will calculate the average for all the grid
> points.
> var =(var1+var2+...+var12)/12
>
> Any simple way to calculate the average ONLY for the grid points without
> missing data?
>
> Thank you very much,
>
> Xiaoyan
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 16 09:03:02 2012

This archive was generated by hypermail 2.1.8 : Wed Jan 18 2012 - 09:21:55 MST