爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5951|回复: 1

[作图] ncl HD5文件读取举例

[复制链接]

新浪微博达人勋

发表于 2019-4-16 09:13:06 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
从官网下载的读取hd5文件的程序,但是出现核心转存问题,不知道是不是内存原因:读取的是OMI数据
详情见下图 捕获.PNG


;******************************************************************
; hdf5eos_2.ncl
;
; Concepts illustrated:
;   - Reading HDF-EOS5 ['he5'] data
;   - Looping over variables and selecting 2D variables for panel plot
;   - Checking the variable type on the file prior to reading
;   - Plotting HE5 data
;   - Drawing raster contours

;************************************************
; Basic User input
;************************************************
diri = "E:/study/big sha/create/BC/"
fili = "OMI-Aura_L2-OMAERUV_2013m1129t0614-o49862_v003-2017m0722t040904.SUB.he5"

pltType  = "ps"
pltName  = "hdf5eos"   

         ; The following were obtained from "ncl_filedump"
varPlt   = (/ "AerosolAbsOpticalDepthVsHeight"       \
            , "AerosolOpticalDepthVsHeight"       \
            , "AerosolType"      \
            , "FinalAerosolAbsOpticalDepth"\
            , "FinalAerosolOpticalDepth" \
            , "UVAerosolIndex" /)

;************************************************
; Import Libraries
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"   
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
;************************************************
;             MAIN
;************************************************
begin

;************************************************
; plotting parameters
;************************************************
    wks   = gsn_open_wks (pltType,pltName)        ; open workstation
    gsn_define_colormap(wks,"amwg")               ; choose colormap

;****************************************************
; Standard contour with a few simple options
;****************************************************

    res                  = True                   ; plot mods desired
    res@gsnDraw          = False                 ; don't draw
    res@gsnFrame         = False                 ; don't advance frame

;---This resource not needed in V6.1.0
    res@gsnSpreadColors  = True

    res@cnFillOn         = True
    res@cnLinesOn        = False
    res@cnLineLabelsOn   = False
    res@cnFillMode       = "RasterFill"       ; faster
    res@cnRasterSmoothingOn = True

    res@lbLabelAutoStride= True
                                                  ; following not necessary
    res@pmLabelBarHeightF= 0.10                   ; slightly smaller than default
    res@pmLabelBarOrthogonalPosF =  0.075
    res@tiXAxisOffsetYF  = 0.15

    nPlt = dimsizes(varPlt)
    plot = new (nPlt, "graphic")

    resP = True
    resP@gsnMaximize  = True
    resP@txString     = fili

;****************************************************
; Open file; plot user specified variables
;****************************************************
    f = addfile(diri + fili, "r")

    vNam = getfilevarnames(f)                    ; all variables names on the file
   ;print(vNam)

    nVar = dimsizes(vNam)

    np = -1
    do nv=0,nVar-1                               ; loop over all variables
       if (any(varPlt.eq.vNam(nv))) then
           vType = getfilevartypes(f,vNam(nv))
                                                 ; 'blind' handle data types
           if (vType.eq."float") then
               x = f->$vNam(nv)$
           else
               if (vType.eq."short") then
                   x = short2flt( f->$vNam(nv)$ )
               else
                   x = byte2flt ( f->$vNam(nv)$ )
               end if
           end if

           printVarSummary(x)
           printMinMax(x, True)

           np       = np+1
           plot(np) = gsn_csm_contour_map(wks, x, res)

           delete(x)    ; size may change next oteration
       end if
    end do

    gsn_panel(wks,plot,(/3,2/),resP)         ; now draw as one plot
end

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-4-16 09:16:43 | 显示全部楼层
错误如图所示:
捕获.PNG
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表