[ncl-talk] question about fbindirread reading byte for multiple variables in one file?

dyjbean at gmail.com dyjbean at gmail.com
Fri Sep 26 03:36:42 MDT 2014


i have one trmm data file, whose file has seven blocks(2880-byte header and six variables with the same dimension 1440*720),as follows: 

block byte_count integer_byte 
1 2880 2 
2 2073600 2 
3 2073600 1 
4 1036800 1 
5 1036800 1 
6 1036800 1 
7 1036800 1 
+++++++++++++++++++++++++++++++++++++++ 
i have a test using ncl prompt,as follows: 

ncl 0> nlat=720 
ncl 1> nlon=1440 
ncl 2> filn="3B40RT.2001012212.7R2.bin" 
ncl 3> ncha=2880 
ncl 4> dims=(/nlon,nlat/) 
ncl 5> nbyt=nlon*nlat 
ncl 6> setfileoption("bin","ReadByteOrder","BigEndian") 
ncl 7> ff=fbindirread(filn,0,-1,"byte") 
ncl 8> printVarSummary(ff) 

Variable: ff 
Type: byte 
Total Size: 8297280 bytes 
8297280 values 
Number of Dimensions: 1 
Dimensions and sizes: [8297280] 
Coordinates: 

+++++++++++++++++++++++++++++++++++++ 
there is 8297280 bytes in file. 




but when i want to extract the six variable with ncl script,the below is my ncl code: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 

begin 
nlat=720 
nlon=1440 
filn="3B40RT.2001012212.7R2.bin" 
ncha=2880 
dims=(/nlon,nlat/) 
nbyt=nlon*nlat 
setfileoption("bin","ReadByteOrder","BigEndian") 
ff=fbindirread(filn,0,-1,"byte") 
ffhead=ff(0:ncha-1) 

pr=new(dims,"float") 
pr at _FillValue=-31999 

pe=new(dims,"float") 
pe at _FillValue=-31999 

tp=new(dims,"float") 
tp at _FillValue=-31999 

ap=new(dims,"float") 
ap at _FillValue=-31999 

rp=new(dims,"float") 
rp at _FillValue=-31999 

sr=new(dims,"float") 
sr at _FillValue=-31999 


pr=byte2flt(onedtond(ff(ncha:ncha+nbyt*2-1),dims)) 
pe=byte2flt(onedtond(ff(ncha+nbyt*2:ncha+nbyt*4-1),dims)) 
tp=byte2flt(onedtond(ff(ncha+nbyt*4:ncha+nbyt*5-1),dims)) 
ap=byte2flt(onedtond(ff(ncha+nbyt*5:ncha+nbyt*6-1),dims)) 
rp=byte2flt(onedtond(ff(ncha+nbyt*6:ncha+nbyt*7-1),dims)) 
sr=byte2flt(onedtond(ff(ncha+nbyt*7:ncha+nbyt*8-1),dims)) 

end 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

there come to two warnings: 
warning:onedtond : output dimension sizes have fewer elements than input, some data not copied 
warning:onedtond : output dimension sizes have fewer elements than input, some data not copied 

what i'm confused is the "rec_num" set in function fbindirread, is it a byte position or integer position? 



dyjbean at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140926/0431084a/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 46225 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140926/0431084a/attachment.jpe 


More information about the ncl-talk mailing list