[ncl-talk] hdf to netcdf coords

Vanúcia Schumacher vanucia-schumacher at hotmail.com
Thu Feb 14 05:44:27 MST 2019


Hi NCL team,

I would like to convert hdf data to netcdf.
I tried to use ncl_convert2nc, but it did not work:

Classic mode NetCDf does not support unsigned integer types: LST will be written as type short
Classic mode NetCDf does not support unsigned integer types: QC will be written as type short
Classic mode NetCDf does not support unsigned integer types: Error_LST will be written as type byte
Classic mode NetCDf does not support unsigned integer types: Emis_31 will be written as type byte
Classic mode NetCDf does not support unsigned integer types: Emis_32 will be written as type byte
Classic mode NetCDf does not support unsigned integer types: View_angle will be written as type byte
Classic mode NetCDf does not support unsigned integer types: View_time will be written as type byte

I also tried this script and it did not work

     fils   = ("MOD11_L2.A2008009.0435.006.2015337174400.hdf")
        f   = addfile(fils, "r")
     var  = short2flt_hdf(f->LST)
  lat2d  = f->Latitude
  lon2d = f->Longitude

var!0                = "latitude"
var!1                = "longitude"
var&latitude      = lat2d(:,0)
var&longitude   = lon2d(0,:)
var at lat2d        = lat2d
var at lon2d       = lon2d

newfile = "of.nc"
new_var = var
file_create = addfile(newfile, "c")
file_create->LST= new_var

fatal:Coordinate variables must have one dimension only
fatal:No coordinate variable exists for dimension (latitude) in variable (var)

print(f):
 identifier_product_doi : 10.5067/MODIS/MOD11_L2.006
      identifier_product_doi_authority : http://dx.doi.org
   dimensions:
      Coarse_swath_lines_5km_MOD_Swath_LST = 410
      Coarse_swath_pixels_5km_MOD_Swath_LST = 271
      Along_swath_lines_1km_MOD_Swath_LST = 2050
      Cross_swath_pixels_1km_MOD_Swath_LST = 1354
   variables:
      float Latitude ( Coarse_swath_lines_5km_MOD_Swath_LST, Coarse_swath_pixels_5km_MOD_Swath_LST )
         long_name : Latitude of every 5 scan lines and 5 pixels
         units : degree
         Number_Type : float32
         valid_range : ( -90, 90 )
         _FillValue : -999
         Cell_Along_Swath_Sampling : 3, 2048, 5
         Cell_Across_Swath_Sampling : 3, 1353, 5
         hdf_name : Latitude

      float Longitude ( Coarse_swath_lines_5km_MOD_Swath_LST, Coarse_swath_pixels_5km_MOD_Swath_LST )
         long_name : Longitude of every 5 scan lines and 5 pixels
         units : degree
         Number_Type : float32
         valid_range : ( -180, 180 )
         _FillValue : -999
         Cell_Along_Swath_Sampling : 3, 2048, 5
         Cell_Across_Swath_Sampling : 3, 1353, 5
         hdf_name : Longitude

      ushort LST ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Land-surface Temperature
         units : K
         Number_Type : uint16
         valid_range : ( 7500, 65535 )
         _FillValue : 0
         LST : LST data * scale_factor
         scale_factor : 0.02
         add_offset :    0
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : LST

      ushort QC ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Quality control for daytime LST and emissivity
         Number_Type : uint16
         valid_range : ( 0, 65535 )
         hdf_name : QC

      ubyte Error_LST ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Land-surface Temperature Error
         units : K
         Number_Type : uint8
         valid_range : ( 1, 255 )
         _FillValue : 0
         Error_LST : Error_LST data * scale_factor
         scale_factor : 0.04
         add_offset :    0
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : Error_LST

      ubyte Emis_31 ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Band 31 emissivity
         Number_Type : uint8
         valid_range : ( 1, 255 )
         _FillValue : 0
         Emis_31 : Emis_31 data * scale_factor + add_offset
         scale_factor : 0.002
         add_offset : 0.49
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : Emis_31

      ubyte Emis_32 ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Band 32 emissivity
         Number_Type : uint8
         valid_range : ( 1, 255 )
         _FillValue : 0
         Emis_32 : Emis_32 data * scale_factor + add_offset
         scale_factor : 0.002
         add_offset : 0.49
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : Emis_32

      ubyte View_angle ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : zenith angle of MODIS viewing at the pixel
         units : deg
         Number_Type : uint8
         valid_range : ( 0, 180 )
         _FillValue : 255
         View_angle : View_angle data * scale_factor
         scale_factor :  0.5
         add_offset :    0
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : View_angle

      ubyte View_time ( Along_swath_lines_1km_MOD_Swath_LST, Cross_swath_pixels_1km_MOD_Swath_LST )
         long_name : Time of Land-surface Temperature observation
         units : hrs
         Number_Type : uint8
         valid_range : ( 0, 240 )
         _FillValue : 255
         View_time : View_time data * scale_factor
         scale_factor :  0.1
         add_offset :    0
         scale_factor_err :    0
         add_offset_err :    0
         calibrated_nt : 5
         hdf_name : View_time


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190214/cab5e7df/attachment.html>


More information about the ncl-talk mailing list