[ncl-talk] reading binary data
shea at ucar.edu
Wed May 11 11:37:51 MDT 2016
The NCL equivalent of what you sent is:
nlat = 180
mlon = 360
lat = fspan(-89.5,89.5,nlat)
lon = fspan(-179.5, 179.5,mlon)
fili = "2015161_highQc_aot550_eps.dat" ; total size 259200 (=
var1f = fbindirread(fili,0,(/nlat,mlon/),"float")
; or .... these are equivalent in this case
var1c = cbinread(fili,(/nlat,mlon/),"float")
No error messages!! Everything looks great!
...... NOT .....
The golden rule of data processing is ***Look at your data***.
Did you try to print the min and max values in IDL?
Likely, they would be 'nice' numbers.
Did you try to print the min and max values in NCL?
If you did, you would see
(0) min=nan max=nan
IDL (Matlab too!) recognizes NaN (nan) as values to be ignored. AKA
NCL recognizes the netCDF _FillValue attribute. This can *not* be a NaN.
You *must* change the NaNs to a real number for NCL.
Please read the following.
Add the following at the end of the above. This is one example of how to
*Look at your data* !
nNaN = num(isnan_ieee(var1f)) ; # of NaN
pcNaN = (tofloat(nNaN)/(nlat*mlon))*100 ; % NaN
(0) nNaN=33395 pcNaN=51.5355% ; 51.5% ... more
printMinMax(var1f,0) ; BEFORE
(0) min=nan max=nan
if (any(isnan_ieee(var1f))) then
value = 1.e20
replace_ieeenan (var1f, value, 0)
var1f at _FillValue = value
printMinMax(var1f,0) ; AFTER
The _FillValue attribute is fundamental to NCL.
Please read the documentation at:
The official Reference manual
Also, the two DKRZ Manuals at the above site.
Further, the NCL plot code you sent in thye initial email whicj I think you
cut and pasted from some example will likely not yield a nice plot.
Likely, you will have to use raster mode.
res at cnFillMode = "RasterFill" ; Raster Mode
On Wed, May 11, 2016 at 9:52 AM, Debasish Hazra <debasish.hazra5 at gmail.com>
> Thanks Dennis. But it still does no produce any figures. I have attached
> the script of ncl. Found the following instruction of how to read that in
> iDL :
> res = 1.0 ; 1.0 degree spatial resolution
> nlon = ROUND(360./res) ; number of columns (-180,180)
> nlat = ROUND(180./res) ; number of rows (-90, 90)
> lonFirst = -180+0.5*res ; west boundary (first column)
> latFirst = -90+0.5*res ; south boundary (first row)
> dailyGriddedAod550 = FLTARR(nlon, nlat)
> date = '2015161' ; string in YYYYDDD format
> fileName = date+'_highQc_aot550_eps.dat'
> OPENR, lun, /GET_LUN, fileName
> READU, lun, dailyGriddedAod550
> CLOSE, lun
> FREE_LUN, lun
> On Tue, May 10, 2016 at 4:21 PM, Dennis Shea <shea at ucar.edu> wrote:
>> Did you look at the size of your file??
>> 259200 2015161_highQc_aot550_eps.dat
>> float or integer are 4 bytes
>> 4*180*360 = 259200 so **one** float or integer variable
>> You are using
>> var1 =
>> var2 =
>> For two integer or float variables the size should be: 259200 + 259200 =
>> At the very least, you should have been getting an NCL error message
>> about wrong size.
>> On Tue, May 10, 2016 at 12:32 PM, Debasish Hazra <
>> debasish.hazra5 at gmail.com> wrote:
>>> I am trying to read binary data with ncl (v6.3) but not sure whether it
>>> is reading it right. Also, it does not produce any plots. Attached are the
>>> script presently working on and sample data. Any help on this is well
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ncl-talk