<div dir="ltr"><div><div>The 3B40<b>RT</b> (<b>R</b>eal <b>T</b>ime) product is a big-endian binary file containing
variables of mixed types: type character, type short and type byte.
NCL can be used to read the data but it is a bit cumbersome because
NCL's binary read functions only read one variable type. They lack the
necessay 'granularity' to partition the different variable
types. The approach is to read the <i>entire file as a single type</i>
and extract the appropriate information.
The same record must be read for <i>each</i> type specification.
Hence, the user must keep track of the byte counts.<br><br></div>Examples for 3B42RT and 3B40RT are at the bottom of: <br> <a href="http://www.ncl.ucar.edu/Applications/HiResPrc.shtml">http://www.ncl.ucar.edu/Applications/HiResPrc.shtml</a><br><br></div><div>The trmm_3B42RT_1 and 3B40RT_1 examples read & plot the data. The nc file<br></div><div>contains unpacked data.<br><br>The trmm_3B42RT_2 and 3B40RT_2 examples are a 'translation' of the<br></div><div>big-endian binary to netCDF. The variable types are maintained.<br></div><div>This is **MUCH** better than binary!!<br><br></div><div>Good luck<br></div><a href="http://www.ncl.ucar.edu/Applications/Scripts/trmm_3B40RT_2.ncl"> </a></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 26, 2014 at 3:36 AM, <a href="mailto:dyjbean@gmail.com">dyjbean@gmail.com</a> <span dir="ltr"><<a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<table style="padding:10px;background-color:transparent" background="cid:_Foxmail.1@030e346b-08f2-7057-27e4-73f9d039be65" border="0" cellpadding="0" cellspacing="0" height="100%" width="99.99%">
<tbody><tr>
<td style="width:100%;height:100%" valign="top">
<div>
<div><span style="font-size:16px;background-color:rgba(0,0,0,0)">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:
<br>
<br>block byte_count integer_byte
<br>1 2880 2
<br>2 2073600 2
<br>3 2073600 1
<br>4 1036800 1
<br>5 1036800 1
<br>6 1036800 1
<br>7 1036800 1
<br>+++++++++++++++++++++++++++++++++++++++
<br>i have a test using ncl prompt,as follows:
<br>
<br>ncl 0> nlat=720
<br>ncl 1> nlon=1440
<br>ncl 2> filn="3B40RT.2001012212.7R2.bin"
<br>ncl 3> ncha=2880
<br>ncl 4> dims=(/nlon,nlat/)
<br>ncl 5> nbyt=nlon*nlat
<br>ncl 6> setfileoption("bin","ReadByteOrder","BigEndian")
<br>ncl 7> ff=fbindirread(filn,0,-1,"byte")
<br>ncl 8> printVarSummary(ff)
<br>
<br>Variable: ff
<br>Type: byte
<br>Total Size: 8297280 bytes
<br> 8297280 values
<br>Number of Dimensions: 1
<br>Dimensions and sizes: [8297280]
<br>Coordinates:
<br>
<br>+++++++++++++++++++++++++++++++++++++
<br>there is 8297280 bytes in file.
<br>
<br>
<br>
<br>
<br>but when i want to extract the six variable with ncl script,the below is my ncl code:
<br>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
<br>
<br>begin
<br> nlat=720
<br> nlon=1440
<br> filn="3B40RT.2001012212.7R2.bin"
<br> ncha=2880
<br> dims=(/nlon,nlat/)
<br> nbyt=nlon*nlat
<br> setfileoption("bin","ReadByteOrder","BigEndian")
<br> ff=fbindirread(filn,0,-1,"byte")
<br> ffhead=ff(0:ncha-1)
<br>
<br> pr=new(dims,"float")
<br> pr@_FillValue=-31999
<br>
<br> pe=new(dims,"float")
<br> pe@_FillValue=-31999
<br>
<br> tp=new(dims,"float")
<br> tp@_FillValue=-31999
<br>
<br> ap=new(dims,"float")
<br> ap@_FillValue=-31999
<br>
<br> rp=new(dims,"float")
<br> rp@_FillValue=-31999
<br>
<br> sr=new(dims,"float")
<br> sr@_FillValue=-31999
<br>
<br>
<br> pr=byte2flt(onedtond(ff(ncha:ncha+nbyt*2-1),dims))
<br> pe=byte2flt(onedtond(ff(ncha+nbyt*2:ncha+nbyt*4-1),dims))
<br> tp=byte2flt(onedtond(ff(ncha+nbyt*4:ncha+nbyt*5-1),dims))
<br> ap=byte2flt(onedtond(ff(ncha+nbyt*5:ncha+nbyt*6-1),dims))
<br> rp=byte2flt(onedtond(ff(ncha+nbyt*6:ncha+nbyt*7-1),dims))
<br> sr=byte2flt(onedtond(ff(ncha+nbyt*7:ncha+nbyt*8-1),dims))
<br>
<br>end
<br>
<br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br>
<br>there come to two warnings:
<br>warning:onedtond : output dimension sizes have fewer elements than input, some data not copied
<br>warning:onedtond : output dimension sizes have fewer elements than input, some data not copied
<br>
<br><font color="#0000ff"><b>what i'm confused is the "rec_num" set in function fbindirread, is it a byte position or integer position?</b></font> <br></span></div>
<div><br></div><hr style="width:210px;min-height:1px" align="left" color="#b5c4df" size="1"><span class="HOEnZb"><font color="#888888">
<div><span><div style="FONT-FAMILY:verdana;FONT-SIZE:10pt">
<div><a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a></div></div></span></div>
<div></div></font></span></div>
</td>
</tr>
</tbody></table>
</div><br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>