爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 11096|回复: 7

[作图] NCL作图无法出图求指点

[复制链接]
发表于 2016-11-18 12:29:43 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 zxholystar 于 2016-11-18 12:31 编辑

NCL画4000米的数据时显示可以读取数据,但是就是不出图,程序也不停止,画8000m数据时直接就报错了,有大神帮忙看一下嘛?谢谢
画8000m数据时报的错:Read inputfile /home/zx/test/uvwtrh/Blend_8000m_201611120600.nc successfully!
fatal:_NhlGetEndpointsAndStepSize: Max value less than or equal to min value
fatal:VectorPlotInitialize: error choosing spacing
fatal:VectorPlotInitialize: error getting vector level information
fatal:VectorPlotInitialize: error initializing dynamic arrays
fatal:Unable to initialize layer-Can't Create
fatal:Unable to access object with id:-4
fatal:_NhlDataUpdate:called for a non-DataComm class
fatal:PID #-4 can't be found in NhlSetValues
fatal:NhlGetValues:PID #-4 is invalid
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 2806 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 10916 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 12432 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 126 in file /home/zx/test/uvwtrh/draw.ncl



shell脚本:
#!/bin/bash
source ~/.bashrc
export WORKDIR=/home/zx/test/uvwtrh
export PRODUCTDIR=/home/zx/test/uvwtrh/products
#ncl 'params="src=/home/zx/test/uvwtrh/uvwtrh_100m_2016111200.nc"' $WORKDIR/draw.ncl
ncl 'params="src=/home/zx/test/uvwtrh/Blend_4000m_201611120600.nc"' $WORKDIR/draw.ncl


NCL 脚本:
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"
load "$WORKDIR/include/library.ncl"
begin
;坐标属性
undef ("setProperty")
procedure setProperty(olon, olat)
begin
    olon!0          = "lon"
    olon@long_name  = "lon"
    olon@units      = "degrees-east"
    olon&lon        = olon

    olat!0          = "lat"
    olat@long_name  = "lat"
    olat@units      = "degrees_north"
    olat&lat        = olat
end

;数据赋坐标
undef ("setCoordinate")
procedure setCoordinate(data,lon1,lat1)
begin
    data!0          = "lat"
    data&lat        = lat1

    data!1          = "lon"
    data&lon        = lon1              
end
    inputDir = getArgsPara(params,"src")
    if( .not. isfilepresent(inputDir))then
        myPrint("Inputfile "+inputDir+" does not exit!")
        return -1
    end if
    data = addfile(inputDir,"r")
    myPrint("Read inputfile "+inputDir+" successfully!")
    if (.not.isfilevar(data, "UGRD")) then
        myPrint("Variable U100 does not exist!")
        return -1
    end if
    u_wind= data->UGRD
    u_wind@_fillvalue="_"

    if (.not.isfilevar(data, "VGRD")) then
        myPrint("Variable V100 does not exist!")
        return -1
    end if
    v_wind= data->VGRD
    v_wind@_fillvalue="_"

    ; if (.not.isfilevar(data, "lev")) then
    ;     myPrint("Variable lev does not exist!")
    ;     return -1
    ; end if
    ; lev_wind= data->lev

    if (.not.isfilevar(data, "lat")) then
        myPrint("Variable lat does not exist!")
        return -1
    end if
    lat = data->lat

    if (.not.isfilevar(data, "lon")) then
        myPrint("Variable lon does not exist!")
        return -1
    end if
    lon = data->lon
     ; u1=u_wind(0,:,:)
     ; v1=v_wind(0,:,:)
     ; u1@_fillvalue=9.96921e+36
     ; v1@_fillvalue=9.96921e+36
     ; setProperty(lon,lat)
     ; setCoordinate(u1,lon,lat)                    ;给数据附属性
     ; setCoordinate(v1,lon,lat)                    ;给数据附属性


    ; print (lon)
    ; exit
    ;***********************************读取配置文件信息******************************
    ;配置文件名称
        ;outputPath="$PRODUCTDIR"
        outputPath="$WORKDIR"
        wks_type = "png"
        wks_type@wkWidth  = 1200          ;工作台宽度
        wks_type@wkHeight = 1200         ;工作台高度        
        vec_res  = True
         ; 左上角坐标
        vec_res@vpXF                      = 0.12
        vec_res@vpYF                      = 0.9
        ; 调节矩形的长宽
        vec_res@vpWidthF                  = 0.75
        vec_res@vpHeightF                 = 0.8
        vec_res@mpDataBaseVersion = "Ncarg4_1"           ; choose more recent database
        vec_res@mpDataSetName = "Earth..4"               ; high resolution
        vec_res@mpOutlineBoundarySets = "National"       ; National borders
        vec_res@mpNationalLineColor = "Black"            ; National borders color
        vec_res@mpOutlineOn           = True

        vec_res@gsnDraw               = False
        vec_res@gsnFrame              = False
        vec_res@gsnAddCyclic            = False              ; regional data
        vec_res@pmTickMarkDisplayMode  ="Never"
        vec_res@tmXBOn                    = False
        vec_res@tmXTOn                    = False
        vec_res@tmYLOn                    = False
        vec_res@tmYROn                    = False

        vec_res@vcMinFracLengthF      = 0.2

        vec_res@vcWindBarbScaleFactorF   = 2.5                 ;将单位转换为knots
        vec_res@vcWindBarbTickLengthF    = 0.3
        vec_res@vcWindBarbTickSpacingF   = 0.2

        vec_res@vcRefAnnoOn           = False
        vec_res@gsnRightString        = " "
        vec_res@gsnLeftString         = " "
        vec_res@txString              = " "

        vec_res@vcRefMagnitudeF         = 2.                ; make vectors larger
        vec_res@vcRefLengthF            = 0.02              ; ref vec length
        vec_res@vcGlyphStyle            = "windbarb"         ; select wind barbs
        vec_res@vcMinDistanceF          = 0.037              ; thin out windbarbs
        vec_res@vcWindBarbLineThicknessF= 2
        vec_res@vcWindBarbColor         ="Blue"
        outputfileName="Wind_vector"
        wks = gsn_open_wks(wks_type,outputPath+"/"+outputfileName)
        contour=gsn_csm_vector(wks, u_wind, v_wind,vec_res)
        draw(contour)
        frame(wks)
        ; cmd="convert -transparent white "+outputPath+"/"+outputfileName+".png"+" "+outputPath+"/"+outputfileName+"_T.png"
        ; system(cmd)


end


画8000m数据报的错

画8000m数据报的错
密码修改失败请联系微信:mofangbao
发表于 2016-12-19 10:08:45 | 显示全部楼层
能解释一下这一项是干嘛的吗  load "$WORKDIR/include/library.ncl",我在用ncl画图,看到很多人加载了这一项,但是我的运行时会显示不能打开这一项
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-12-22 09:31:09 | 显示全部楼层
礼乐王 发表于 2016-12-19 10:08
能解释一下这一项是干嘛的吗  load "$WORKDIR/include/library.ncl",我在用ncl画图,看到很多人加载了这一 ...

加载library,workdir是你自己在shell中定义的,你要换成你自己的路径
密码修改失败请联系微信:mofangbao
发表于 2016-12-22 11:06:43 | 显示全部楼层
zxholystar 发表于 2016-12-22 09:31
加载library,workdir是你自己在shell中定义的,你要换成你自己的路径

这个是干嘛用的?不加载library行不
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-12-22 13:46:52 | 显示全部楼层
礼乐王 发表于 2016-12-22 11:06
这个是干嘛用的?不加载library行不

行啊,只是有些函数没办法用,不过你可以自己在ncl脚本里定义
密码修改失败请联系微信:mofangbao
发表于 2017-10-12 11:19:52 | 显示全部楼层
本帖最后由 SG哭晕在厕所 于 2017-10-12 11:30 编辑

楼主你现在知道这个是什么问题了吗?
密码修改失败请联系微信:mofangbao
发表于 2018-8-13 15:59:37 | 显示全部楼层
请问楼主,问题解决了吗
密码修改失败请联系微信:mofangbao
发表于 2022-2-27 12:40:23 | 显示全部楼层
请问问题解决了么
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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