If you have "byte" data .....
   b = fbindirread(files(gg),0,-1,"byte")
   bhead= b(0:299)
   bdata = onedtond( b(300:), (/nCols,nRows/) )
Good Luck
chenXinbao wrote:
> Hi:
> 
> I have one question to solve quickly right now.I need you help.
> My bin format:One-byte (scaled, unsigned integer) flat binary arrays 
> preceded by a 300-byte header; no byte order/endianness. and the spatial 
> resolution is 304 by 448.
> 
> I followed the sample of script #2  at your website 
> 'http://www.ncl.ucar.edu/Applications/r-binary.shtml#FormatHints", there 
> is an error happened at finarr(gg,:,:) = 
> fbindirread(files(gg),0,(/nCols,nRows/),"integer") .
> 
> the error is that "the fatal:fbindirread: the size implied by the 
> dimension array and record number is greater than the size of file, 
> can't continue ....."
> 
> I think the reason is that the fbindirread function generally read 
> 4-byte record, so can i need  recompile the code with the option 
> "-frecord-marker=2"? what is "frecord-marker"? how can i set ahead the 
> value of the frecord-marker.
> 
> The code compiled by the follows:
> 
> begin
>     nRows = 448
>     nCols = 334
>     diri  = "c:/cygwin/home/xchen/PolarMap/SIC/ConversionBIN_BYNCL/BINDATA/"
>     files  = systemfunc("ls "+diri+"bt_200701*.bin")
>     ; predefine array for one year of monthly data
>     finarr = new((/dimsizes(files),nCols*nRows/),"integer")  
>    
>     do gg = 0,dimsizes(files)-1       ; loop thru each file
>        ;This will read the 300th record from "/BIN DATA/bt_*.bin" and 
> return a two-dimensional [334 by 448]
>        ;variable of type float to the variable "finarr".
>        fi narr(gg,:,:) = fbindirread(files(gg),0,(/nCols,nRows/),"integer")
>             
>     end do
>     print("Assigning coordinate variable information")
>     finarr!0 = "time"
>     finarr&time = ispan(1,dimsizes(files),1)
>     finarr!1 = "Col"
>     finarr&lat = ispan(-89,89,nCols)
>     finarr&lat@units = "degrees_north"
>     finarr!2 = "Row"
>     finarr&lon = ispan(0,359,nRows)
>     finarr&lon@units = "degrees_east"
> 
>     a = addfile("sample.nc","c")        ; write netCDF file
>     a@title = "1 year of monthly data"
>     a@source = "Your program name/location"
>     filedimdef(a,"time",-1,True)    ; make time an UNL IMITED dimension, 
> always recommended
>     a->SIC = finarr
> end
> 
> Thanks so much.
> Xinbao(Simbol) Chen
> 
> ------------------------------------------------------------------------
> 更多热辣资讯尽在新版MSN首页! 立刻访问! <http://cn.msn.com/>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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 Mar 15 22:27:54 2010
This archive was generated by hypermail 2.1.8 : Wed Mar 17 2010 - 13:00:16 MDT