爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1582|回复: 2

[作图] NCL用x11能正常出图,但是换成PDF,PS,EPS,PNG,全部报错

[复制链接]
发表于 2023-7-18 12:04:21 | 显示全部楼层 |阅读模式
100金钱
我是用ERA5数据画的,X11画的没有任何报错报错,换成PDF,PNG都报错,
这是换成pdf画的出现以下报错

                               
登录/注册后可看大图
,但是用NECP数据画就是正常出图。这是程序部分:   u_file = addfile("/mnt/d/SHUJU/U_quan.nc","r")    v_file = addfile("/mnt/d/SHUJU/V_quan.nc","r")

    uwnd1   = u_file->u(:,{850},:,:)
    vwnd1   = v_file->v(:,{850},:,:)
    uwnd2  = short2flt(uwnd1)
    vwnd2  = short2flt(vwnd1)
    uwnd   = uwnd2(:,{0:80},{60:240})
    vwnd   = vwnd2(:,{0:80},{60:240})
    dim = dimsizes(uwnd)
    ntim = dim(0)
    nlat = dim(1)  
    nlon = dim(2)
    ;-----------------------------------------------------------------------------去趋势(不循环结果一样)
    d_uwnd = new((/ntim,nlat,nlon/), "float", "No_FillValue")
    do i=0,11
        d_uwnd(i:ntim-1:12,:,:)  = dtrend_leftdim(uwnd(i:ntim-1:12,:,:), False)
    end do
    copy_VarCoords(uwnd, d_uwnd)

    d_vwnd = new((/ntim,nlat,nlon/), "float", "No_FillValue")
    do i=0,11
        d_vwnd(i:ntim-1:12,:,:)  = dtrend_leftdim(vwnd(i:ntim-1:12,:,:), False)
    end do
    copy_VarCoords(vwnd, d_vwnd)

;;---------------------------------------------------------------------------------选季节(去趋势和季节先后不影响)                        
    Tseason11 = month_to_season(d_uwnd, "SON")  
    Tseason22 = month_to_season(d_vwnd, "SON")

    ;;--------------------------------------------------------------------------------回归Iw REG 850
    r1       = regCoef_n(Pn(0:59),Tseason11(0:59,:,:),0,0)
    r1!0     = "latitude"
    r1&latitude   = uwnd&latitude
    r1!1     = "longitude"
    r1&longitude   = uwnd&longitude  
    ;r1@_FillValue = 9.96921e+36
    ;printVarSummary(r1)
   ;;----------------------------------
    tval    = onedtond(r1@tval , dimsizes(r1))   ; t-statistic of rc
    df      = onedtond(r1@nptxy, dimsizes(r1)) - 2  ; 自由度
    b       = tval    ; b must be same size as tval (and df)
    b       = 0.5
    prob1    = betainc(df/(df+tval^2),df/2.0,b)       ; prob1(nlatitude,nlon)
    prob1!0      = "latitude"    ; name dimensions
    prob1!1      = "longitude"
    prob1&latitude    = uwnd&latitude   ; assign coordinate values to named dimensions
    prob1&longitude    = uwnd&longitude
    ;prob1@long_name  =   "probability"
    ;printVarSummary(prob1)
  ;;-----------------------------
    r2       = regCoef_n(Pn(0:59),Tseason22(0:59,:,:),0,0)
    r2!0     = "latitude"
    r2&latitude   = vwnd&latitude
    r2!1     = "longitude"
    r2&longitude   = vwnd&longitude  
    ;r2@_FillValue = 9.96921e+36
    ;printVarSummary(r2)
   ;;------------------------
    tval    = onedtond(r2@tval , dimsizes(r2))   ; t-statistic of rc
    df      = onedtond(r2@nptxy, dimsizes(r2)) - 2  ; 自由度
    b       = tval    ; b must be same size as tval (and df)
    b       = 0.5
    prob2    = betainc(df/(df+tval^2),df/2.0,b)       ; prob2(nlatitude,nlon)
    prob2!0      = "latitude"    ; name dimensions
    prob2!1      = "longitude"
    prob2&latitude    = vwnd&latitude   ; assign coordinate values to named dimensions
    prob2&longitude    = vwnd&longitude
    ;prob2@long_name  =   "probability"
    ;printVarSummary(prob2)

    ;;===========================================================================v

    wks = gsn_open_wks("x11","UV850_Pn")
    res             = True               
    res@gsnDraw     = False           
    res@gsnFrame    = False
    res@gsnMaximize  = False
    res@gsnAddCyclic = False
    res@gsnLeftString  = ""
    res@gsnRightString = ""
    res@gsnCenterString = ""

    ;=======================================================================
    rest = res
    ;-----------------------------------------------------------------------
    rest@mpMinLatF       = 0
    rest@mpMaxLatF       = 80
    rest@mpMinLonF       = 60
    rest@mpMaxLonF       = 240
    rest@mpCenterLonF    = 180

    rest@mpFillOn        = True
    rest@mpLandFillColor            = "white"
    ;rest@tmYLValues      = ispan(-80, 80, 40) ;-10到60 ,每隔20
    ;rest@tmYLLabels      = (/"80S","40S","0","40E","80E"/)
    ;rest@tmYLLabels      = (/"20S","0","20~N~N","40~N~N",\
                            ;"60~N~N","80~N~N"/)
    rest@tmYLLabelFont = "times-roman"
    ;rest@tmXBMode        = "Explicit"  
    ;rest@tmXBValues      = ispan(40, 160, 10)
    ;rest@tmXBLabels      = (/"40~S~o~N~E","50~S~o~N~E","60~S~o~N~E","70~S~o~N~E","80~S~o~N~E","90~S~o~N~E","100~S~o~N~E",\
                            ;"110~S~o~N~E","120~S~o~N~E","130~S~o~N~E","140~S~o~N~E","150~S~o~N~E","160~S~o~N~E"/)
    rest@tmXBLabelFont = "times-roman"
    rest@tmXBLabelFontHeightF = 0.015
    rest@tmYLLabelFontHeightF = 0.015
    rest@cnInfoLabelOn = False

    ;-------------------------------------------------------------------------
    res1 = rest
    ;-------------------------------------------------------------------------
    res1@cnFillOn             = True
    res1@cnLinesOn            = False
    res1@cnLineLabelsOn       = False
    res1@cnMonoFillPattern    = False
    res1@cnLevelSelectionMode = "ExplicitLevels"
    res1@cnLevels             = (/0.05/)
    res1@cnFillPatterns       = (/0,-1/)
    res1@cnFillColors         = (/"steelblue4"/)
    res1@tmXUseBottom    = False
    res1@tmYUseLeft      = False
    res1@tmXTMinorOn     = False
    res1@tmYRMinorOn     = False
    res1@tmXTMajorLineColor = "white"
    res1@tmYRMajorLineColor = "white"
    res1@lbLabelBarOn       = False
    res1@cnSmoothingOn        = True
    res1@cnSmoothingDistanceF = 0.001
    res1@cnSmoothingTensionF  = 0.01
    res1@cnInfoLabelFontAspectF = 25
    res1@cnInfoLabelOn = False


    ;=============================================================================
    res2 = True
    ;-----------------------------------------------------------------------------出现警告得原因在这里
    res2@gsnAddCyclic = False
    res2@cnFillOn             = True
    res2@cnLinesOn            = False
    res2@cnLineLabelsOn       = False
    res2@cnMonoFillPattern    = False
    res2@cnLevelSelectionMode = "ExplicitLevels"
    res2@cnLevels             = (/0.05/)
    res2@cnFillPatterns       = (/0,-1/)
    res2@cnFillColors         = (/"steelblue4"/)
    res2@tmXUseBottom    = False
    res2@tmYUseLeft      = False
    res2@tmXTMinorOn     = False
    res2@tmYRMinorOn     = False
    res2@tmXTMajorLineColor = "white"
    res2@tmYRMajorLineColor = "white"
    ;res2@lbLabelBarOn       = False
    res2@cnSmoothingOn        = True
    res2@cnSmoothingDistanceF = 0.001
    res2@cnSmoothingTensionF  = 0.01
    res2@cnInfoLabelOn = False

    ;=============================================================================
    uvres1 = res
    ;-----------------------------------------------------------------------------
    uvres1@vcGlyphStyle="CurlyVector"
    ;uvres1@vcMinMagnitudeF = 0.3
    uvres1@gsnDraw     = False           
    uvres1@gsnFrame    = False
    uvres1@vcRefMagnitudeF = 2      
    uvres1@vcRefAnnoOrthogonalPosF = -1.0
    uvres1@vcRefAnnoString2 = ""
    ;uvres1@vcRefAnnoParallelPosF = 0.999
    uvres1@vcMinDistanceF  = 0.018
    uvres1@vcRefLengthF    = 0.045              ; define length of vec ref
    uvres1@vcMapDirection  = False
    ;uvres1@vcRefAnnoParallelPosF = 0.999
    uvres1@vcLineArrowThicknessF = 1.


    ;;----------------------------------------------------------------------------叠加地形
    resdx = res
    ;resdx@cnConstFEnableFill= True
    resdx@cnFillOn             = True
    resdx@cnLinesOn            = False
    resdx@cnLineLabelsOn       = False
    ;resdx@cnSmoothingOn        = True
    ;resdx@cnSmoothingDistanceF = 0.08
    ;resdx@cnSmoothingTensionF  = 0.01
    resdx@cnLevelSelectionMode = "ExplicitLevels"
    resdx@cnLevels  = (/3000/)
    resdx@cnFillColors = (/"-1","black"/)
    resdx@lbLabelBarOn  = False
    resdx@cnInfoLabelOn = False

    ;r;esdx@cnLevels  = (/3000/) ;画出3000m等值线
    ;resdx@cnLineColor = "black"
    ;resdx@cnLineThicknessF = 3

    ;=============================================================================
    ;resc@cnInfoLabelOn = False
    ;******************************************************************************
    ;绘制图案
    ;******************************************************************************

    plot = gsn_csm_contour_map_overlay(wks, prob2, prob1, res1, res2)
    plot0   = gsn_csm_vector(wks, r1, r2, uvres1)

    plotdixing = gsn_csm_contour(wks, elev, resdx)

    overlay(plot, plot0)

    ;;=====================================================================================

    plotdixing = gsn_csm_contour(wks, elev, resdx)
    overlay(plot, plotdixing)



密码修改失败请联系微信:mofangbao
 楼主| 发表于 2023-7-18 12:07:38 | 显示全部楼层
报错给我吞了,这是报错部分fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 3475 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8637]:Execute: Error occurred at or near line 114 in file reg_POD_on_850uv.ncl
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

 楼主| 发表于 2023-7-18 13:18:56 | 显示全部楼层
找到原因了,内存过载,所以不能创建工作台,删除不画的变量就可以了
具体如下:delete([/uwnd1,vwnd1,uwnd2,vwnd2,uwnd,vwnd,Tseason11,Tseason22,d_Tseason11,d_Tseason22/]);希望可以帮助到遇到同样问题的人
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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