[ncl-talk] reading binary files

Debasish Hazra debasish.hazra5 at gmail.com
Fri Dec 12 14:40:11 MST 2014


Once again, strange problem encountered with reading binary in NCL (6.21).
A week back, David Brown (@ncl)  helped with a script that read a
particular binary  file. However, After modifying a little, I could read
similar dataset (npp_aot550_edr_gridded_0.25_20130727.high.bin) with NCL,
but looks like something is going wrong either with griddng or colorbar.
Colorbar should be between  0 to 1, but it seems to be over 3 at some
unusual places. Data has been uploaded in ftp and a trial script, data read
help has been attached.

 Any help is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141212/fd4786dc/attachment.html 
-------------- next part --------------
VIIRS Aerosol Gridded EDR AOT
-----------------------------

The operational Visible, Infrared Imaging Radiometer Suite (VIIRS) 550-nm aerosol optical
thickness (AOT) Environmental Data Records (EDRs) at nominal 6-km resolution, and collected
during a 24-h period, are gridded on a regular 0.25 x 0.25-degree equal angle (~28x28 km at
the equator) grid. The gridding process uses only high quality AOT EDRs.


AOT EDR Gridding process
------------------------

Each EDR pixel is associated with geolocation data (LAT,LON) that describes the center of
the pixel. For each grid box (i,j), if (LAT,LON) falls within the boundary of a grid box
then this EDR AOT will be counted toward the mean AOT computation of that grid box (i,j).
The grid-box value of the AOT is the arithmetic average of all AOT EDRs falling into the
grid box. The gridded (mean) AOT value and the number of pixels used in the averaging are saved.

For any grid that does not have at least one high quality AOT EDR the gridded AOT is assigned a
missing value (-9999.0) and the number of AOT EDR pixels contributing is set to zero.


Grid Structure
--------------

The equal-angle map grid has equal 0.25-degree increments in both longitude and latitude. There are
1,036,800 cells in this grid: 720 latitude zones and 1,440 longitude intervals. Center coordinates
of cells are given as latitudes from -90 degrees (South) to +90 degrees (North) and longitudes from
-180 degrees (West) to +180 degrees (East). The center coordinate of the first cell is -89.875
degrees latitude and -179.875 degrees longitude. Cell numbering increases from west to east in
longitude direction then from south to north in latitude direction. The center coordinate of the
last cell is +89.875 degrees latitude and +179.875 degrees longitude.


Data File Type
--------------

The gridded data are written as little-endian binary files. They were produced by an Interactive
Data Language (IDL) code running on a Linux machine. The files are compressed with the utility
gzip.


File Naming Convention
----------------------

Files are named as npp_aot550_edr_gridded_0.25_yyyymmdd.high.bin.gz, where yyyy is the four-digit
year, mm is the two-digit month, and dd is the two-digit day of month.


Example Codes for Reading the Gridded AOT Data File
---------------------------------------------------

(a)  Spatial grid setup (example in IDL format)

     resolution = 0.25                    ; in degrees

     nLon = 1440                          ; number of cells in longitude (West-East)
     nLat = 720                           ; number of cells in latitude( (South-North)

     minLon = -179.875                    ; minimum longitude (degrees)
     maxLon =  179.875                    ; maximum longitude (degrees)
     minLat =  -89.875                    ; minimum latitude  (degrees)
     maxLat =   89.875                    ; maximum latitude  (degrees)

     Lon2D  = fltArr(nLon, nLat)          ; grid box center longitude 
     Lat2D  = fltArr(nLon, nLat)          ; grid box center latitude 

     FOR i = 0L, nlon-2 DO BEGIN
        Lon2D[i,*] = minLon + float(i) * resolution
     ENDFOR
     Lon2D[nlon-1,*] = maxLon

     FOR j = 0L, nlat-2 DO BEGIN
        Lat2D[*,j] = minLat + float(j) * resolution
     ENDFOR
     Lat2D[*,nlat-1] = maxLat


 (b) Reading in IDL
      =========================================================================================
         aot_edr    = fltArr(1440,720)   ; Gridded Mean of AOT EDR (single precision real)
         n_aot_edr  = lonArr(1440,720)   ; Number of EDR pixels used to calculate the mean AOT
                                         ; (long integer)

         InputFile='npp_aot550_edr_gridded_0.25_20130921.high.bin.gz'
         OpenR, lunin, InputFile, /GET_LUN, /compress
            readU, lunin, aot_edr
            readU, lunin, n_aot_edr
         Close, lunin
         Free_Lun, lunin

         n_aot_edr is useful for evaluating grid square situation and quality of AOT.
      =========================================================================================

 (c) Reading in FORTRAN 90/95 

         First unzip the data file, for example:
               > gzip -d npp_aot550_edr_gridded_0.25_20130921.high.bin.gz

         =========================================================================================
         integer, parameter :: nlon=1440, nlat=720
         character(Len=120) :: InputFile
         real(4),    dimension(nlon,nlat) ::   aot_edr    ; Gridded Mean of AOT EDR (single precision real)
         integer(4), dimension(nlon,nlat) :: n_aot_edr    ; Number of EDR pixels used to calculate the mean AOT
                                                          ; (long integer)
         integer    :: i, j
               
         InputFile='npp_aot550_edr_gridded_0.25_20130921.high.bin'
         open( 1, file=trim(InputFile), access='direct', recl=4*nlon*nlat, status='old' )
            read( 1, rec=1 )   aot_edr
            read( 1, rec=2 ) n_aot_edr
         close( 1 )
         =========================================================================================

 (d) Sample results for selected grids cells for checking reading gridded data for September 21, 2013; 
     file "npp_aot550_edr_gridded_0.25_20130921.high.bin.gz"

         Note: IDL indexes arrays starting with index 0 while this is index 1 in FORTRAN
         
         For IDL Reader : Printing values of 
           aot_edr[720,358],   aot_edr[720,359],   aot_edr[720,360],   aot_edr[720,361],   aot_edr[720,362]
         n_aot_edr[720,358], n_aot_edr[720,359], n_aot_edr[720,360], n_aot_edr[720,361], n_aot_edr[720,362]
               
         For FORTRAN Reader : Printing values of
           aot_edr(721,359),   aot_edr(721,360),   aot_edr(721,361),   aot_edr(721,362),   aot_edr(721,363)
         n_aot_edr(721,359), n_aot_edr(721,360), n_aot_edr(721,361), n_aot_edr(721,362), n_aot_edr(721,363)

         Values should be:
           -9999.000000      0.180460      0.157630  -9999.000000  -9999.000000
                      0             1             3             0             0
               
VIIRS Aerosol Data Status
-------------------------

     VIIRS Aerosol AOT product available at Beta Maturity Status
           from May 02, 2012 - January 22, 2013

     VIIRS Aerosol AOT product available at Provisional Maturity Status
           from January 23, 2013 to present

     We recommend to use the data in Provisional Maturity Status.

     Note: Due to a processing error, users are advised not to use data
           from October 15, 2012 to November 27, 2012.  Therefore data are not
           provided for this period from this website.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virsaot.ncl
Type: application/octet-stream
Size: 4766 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141212/fd4786dc/attachment.obj 


More information about the ncl-talk mailing list