[ncl-talk] read multiple binary files and plot on a x-y plot

Guido Cioni guidocioni at gmail.com
Sat Mar 18 08:40:38 MDT 2017


Hey Gaeun,
that is certainly possible. 
If the files are not too big I don't see any problem in saving everything into one variable. Just make sure that the machine where you're running NCL has enough memory. Ideally you need to loop over the directories and over the file names, read the file, save into the variable. That's it! 

dirs=tostring(ispan(1979, 2009, 1))
fils=tostring(ispan(1,12,1))

nlat=100
nlon=100
ntime=dimsizes(fils)*dimsizes(dirs)

data=new((/ntime,nlat,nlon/), double)

k=0
do i=0,dimsizes(dirs)-1
    do j=0,dimsizes(fils)-1
        data(k,:,:)= fbindirread(dirs(i)+"/"+fils(j)+".bin", nlat*nlon, (/nlat,nlon/), "double")
        k=k+1
    end do 
end do 

This is just an idea, of course. I did not test this and you have to adapt it to your needs. Have a look here https://www.ncl.ucar.edu/Applications/r-binary.shtml <https://www.ncl.ucar.edu/Applications/r-binary.shtml>. 

Good luck

Guido Cioni
http://guidocioni.altervista <http://guidocioni.altervista/>.org

> On 18 Mar 2017, at 14:35, 김가은 <gaeun.kim0921 at gmail.com> wrote:
> 
> Dear NCL users,
> 
> I have multiple binary files stored like below:
> directory 1979 has 12 binary files (monthly temp.)
> directory 1980 has 12 binary files
> ...
> directory 2009 has 12 binary files
> --> 31 directories, each contains 12 binary files
> 
> I want to draw a X-Y plot (time series) with those data.
> So I was thinking that maybe I could open all of it and save each data in a variable(3d:(/371,lat,lon/))
> But I'm not sure it is possible and I'm lost..!
> Would you give me an idea how I should start with this?
> 
> Best Regards,
> Gaeun
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170318/696847f5/attachment.html 


More information about the ncl-talk mailing list