; SW_S2B01667E.20031000005-20031000147.20061182243.hdf ; ; This NCL example program contours NASA PO.DAAC SeaWind swath. ; ; This file is similar to QuikSCAT swath. ; ; Author: Hyo-Kyung Lee (hyoklee@hdfgroup.org), revised by Yi Wang (yiwang6@uiuc.edu) ; ; Copyright (C) 2010 The HDF Group ; load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin hdf_file = addfile("SW_S2B01667E.20031000005-20031000147.20061182243.hdf", "r") ws = hdf_file->wind_speed ws@_FillValue=0h ws@_FillValue=-1h ; subset 3-D data and make 2-D. wss = ws(:,:,0) data = short2flt_hdf(wss) ; The wvc_lat is 16-bit integer and ; the short2flt_hdf() will apply scale_factor automatically. lat2d = short2flt_hdf(hdf_file->wvc_lat) ; Here's another way of applying scale_factor. ; lat2d = short2flt(hdf_file->wvc_lat) ; scale = hdf_file->wvc_lat@scale_factor ; lat2d = stringtofloat(scale) * lat2d; lat2d@units = "degrees_north" ; The wvc_lon is "unsigned" 16-bit integer. ; We can't use short2flt_hdf() blindly. ; lon2d = short2flt_hdf(hdf_file->wvc_lon) lon2d = int2flt(ushorttoint(hdf_file->wvc_lon)) scale = hdf_file->wvc_lon@scale_factor lon2d = stringtofloat(scale) * lon2d lon2d@units = "degrees_east" ; Check if scale_factor is applied correctly. ; You can verify values using HDFView. ; print(lon2d(:,44)) ; print(lat2d(:,44)) data@lat2d = lat2d data@lon2d = lon2d printVarSummary(data) ; ; ; Setting _FillValue=0 will generate warning in NCL. [1] ; data@_FillValue = 0; ; print(data(:,0)) xwks = gsn_open_wks("pdf","SW_S2B01667E.20031000005-20031000147.20061182243_wind_speed") setvalues NhlGetWorkspaceObjectId() "wsMaximumSize" : 500000000 end setvalues res=True ; plot mods desired res@cnFillOn=True ; enable contour fill res@cnLinesOn=False ; turn off contour lines res@gsnSpreadColors=True ; use the entire color spectrum res@cnFillMode="RasterFill" ; faster res@lbLabelAutoStride=True ; ensure labels do not overlap res@lbOrientation = "vertical" ; vertical labels res@cnMissingValFillPattern = 0 ; missing value pattern is set to "SolidFill" res@cnMissingValFillColor=0 ; white color for missing values gsn_define_colormap(xwks,"BlAqGrYeOrReVi200") ; define colormap res@tiMainString="SW_S2B01667E.20031000005-20031000147.20061182243.hdf" ; create title res@gsnLeftString = "FIELD NAME: " + data@long_name res@gsnRightString = "UNITS: " + data@units plot=gsn_csm_contour_map_ce(xwks,data,res) delete(plot) ; cleaning up resources used delete(xwks) delete(data) delete(res) delete(hdf_file) end ; References ; ; [1] http://www.ncl.ucar.edu/Document/Language/fillval.shtml