[ncl-talk] writing out ushort and uint to netcdf4

Archana Dayalu adayalu at seas.harvard.edu
Wed Nov 4 17:30:14 MST 2015


Hi there,
I am trying to write out some MODIS09A1 variables (QA flags) to netcdf4
(not the classic model). The QA flag and SQA flag are in uint and ushort
format respectively. I am using NCLv6.2.1. I've correctly set my file
option to NetCDF4 prior to creating the ncdf file.
The problem is, in its native hdf format and when I read it in to ncl I get
the following:

;;;;;;;;;;;;;;;;;;;;; QAFLAG ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Variable: QAFLAG
Type: uint
Total Size: 645120000 bytes
            161280000 values
Number of Dimensions: 2
Dimensions and sizes: [YDim_MOD_Grid_500m_Surface_Reflectance | 9600] x
[XDim_MOD_Grid_500m_Surface_Reflectance | 16800]
Coordinates:
Number Of Attributes: 7
  _FillValue : 4294967295
  long_name : Surface_reflectance_500m_quality_control_flags
  units : bit field
  valid_range : ( 0, 4294966531 )


;;;;;;;;;;;;;;;;;;;;;;;;; SQAFLAG ;;;;;;;;;;;;;;;;;;;;;;;
Variable: SQAFLAG
Type: ushort
Total Size: 322560000 bytes
            161280000 values
Number of Dimensions: 2
Dimensions and sizes: [YDim_MOD_Grid_500m_Surface_Reflectance | 9600] x
[XDim_MOD_Grid_500m_Surface_Reflectance | 16800]
Coordinates:
Number Of Attributes: 7
  _FillValue : 65535
  long_name : Surface_reflectance_500m_state_flags
  units : bit field
  valid_range : ( 0, 57343 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


But, when I write out these variables to netcdf4 and then view them using
ncl_filedump, they are output as QAFLAG as float (and I don't specify this
anywhere) and SQAFLAG as something else (doesn't look like float?):

;;;;;;;;;;;;;;;;;;;;; QAFLAG ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Variable: QAFLAG
    Type: uint
    Total Size: 161280000 values
                645120000 bytes
    Number of Dimensions: 2
    Dimensions and sizes: [ 9600 <YDim> x 16800 <XDim> ]
    Coordinates:
        Number of Attributes:        8
            missing_value : -1
            _FillValue : -1
            long_name : sur_refl_qc_500m
            units : bit field
            valid_range : ( 0, -765 )

;;;;;;;;;;;;;;;;;;;;; SQAFLAG ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Variable: SQAFLAG
    Type: ushort
    Total Size: 161280000 values
                322560000 bytes
    Number of Dimensions: 2
    Dimensions and sizes: [ 9600 <YDim> x 16800 <XDim> ]
    Coordinates:
        Number of Attributes:        8
            missing_value :
            _FillValue :
            long_name : sur_refl_state_500m
            units : bit field
            valid_range : ( 0, -8193 )
            QA_bitmap_index :


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

However, when I read these converted .nc files *back* into NCL, it's all
fine ... and looks like the output from the native hdf file. Could you
explain why this is happening? Does it have something to do with the data
compression? I just want to make sure it is not impacting the contents of
the variables.

(On a side note, the reason I am going through all this is I am eventually
reading these objects into R to QC filter my MODIS reflectance data. Is
there pre-existing NCL code that allows for application of QC criteria
within ncl? It might be faster and would avoid all this ... )

Thanks for any help!

Regards,
Archana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151104/c5e923fd/attachment.html 


More information about the ncl-talk mailing list