爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6893|回复: 2

运行兰溪大大画中国边界的测试程序出错,这怎么改啊?

[复制链接]
发表于 2019-1-24 11:44:31 | 显示全部楼层 |阅读模式

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

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

x
用的是这里面的程序:https://coding.net/u/huangynj/p/NCL-Chinamap/git
;***********************************************************;
;                                                           ;
;  This script is a example to plot contours on China map.  ;
;  Written by Huang Yongjie(IAP/CAS), 2016-05-22.           ;
;                                                           ;
;***********************************************************;
load "D:\NCL\cygwin\app\ncl\lib\ncarg\nclscripts\csm\gsn_code.ncl"
load "D:\NCL\cygwin\app\ncl\lib\ncarg\nclscripts\csm\gsn_csm.ncl"
load "D:\NCL\cygwin\app\ncl\lib\ncarg\nclscripts\csm\contributed.ncl"

begin

  f=addfile("pres.mon.ltm.nc","r")
  pres= f->pres(0,:,:)

;---------------------------------------------------------------
  wks = gsn_open_wks("x11","Correct_China_boundary")
  gsn_define_colormap( wks ,"gui_default")  

  res                            = True            
  res@gsnMaximize                = True
  res@gsnDraw                    = False
  res@gsnFrame                   = False

;---------------------------------------------------------------
; set for the map
  res@mpMinLatF                  = 0.                        
  res@mpMaxLatF                  = 55.
  res@mpMinLonF                  = 72.
  res@mpMaxLonF                  = 136.

  res@mpFillOn                   = True
  res@mpDataSetName              = "./database/Earth..4"
  res@mpDataBaseVersion          = "MediumRes" ; or "Ncarg4_1"
  res@mpAreaMaskingOn            = True
  res@mpMaskAreaSpecifiers       = (/"China"/)
  res@mpOutlineSpecifiers        = (/"China","China:Provinces"/)

  res@mpLandFillColor            = "white"
  res@mpInlandWaterFillColor     = "white"
  res@mpOceanFillColor           = "white"
  res@mpFillBoundarySets         = "NoBoundaries"
  res@mpOutlineBoundarySets      = "NoBoundaries"
  res@mpNationalLineColor        = "black"
  res@mpProvincialLineColor      = "black"
  res@mpGeophysicalLineColor     = "black"
  res@mpNationalLineThicknessF   = 2
  res@mpProvincialLineThicknessF = 1

;---------------------------------------------------------------
; set for the plot

  res@cnFillOn                   = True
  res@cnFillDrawOrder            = "PreDraw"
  res@cnLinesOn                  = False
  res@cnLineLabelsOn             = False
  res@cnLevelSelectionMode       = "ExplicitLevels"
  res@cnLevels                   = ispan(520,1080,20)
  res@cnFillPalette              = "gui_default"
  res@lbLabelAutoStride          = True
  res@pmTickMarkDisplayMode      = "Always"
  res@gsnRightString             = "hPa"

;---------------------------------------------------------------
; plot the full China map
  res@gsnLeftString              = "Surface pressure over full China Map"
  map = gsn_csm_contour_map(wks,pres,res)
  draw(map)
  frame(wks)

;---------------------------------------------------------------
; plot one part of China map with South China Sea subplot
  res@mpMinLatF                  = 17.
  res@gsnLeftString              = "Surface pressure over part China Map with SCS"
  map1 = gsn_csm_contour_map(wks,pres,res)

;--- add South China Sea ---
  nhres                          = True
  nhres@gsnFrame                 = False
  nhres@gsnDraw                  = False

  nhres@vpHeightF                = 0.18   
  nhres@vpWidthF                 = 0.18

  nhres@mpMinLatF                =   2.0   
  nhres@mpMaxLatF                =  23.0
  nhres@mpMinLonF                = 105.0
  nhres@mpMaxLonF                = 123.0

  getvalues map1
    "mpDataSetName"              : nhres@mpDataSetName
    "mpDataBaseVersion"          : nhres@mpDataBaseVersion
    "mpFillOn"                   : nhres@mpFillOn
    "mpFillDrawOrder"            : nhres@mpFillDrawOrder
    "mpAreaMaskingOn"            : nhres@mpAreaMaskingOn
    "mpMaskAreaSpecifiers"       : nhres@mpMaskAreaSpecifiers
    "mpOutlineSpecifiers"        : nhres@mpOutlineSpecifiers
    "mpOutlineBoundarySets"      : nhres@mpOutlineBoundarySets
    "mpLandFillColor"            : nhres@mpLandFillColor      
    "mpOceanFillColor"           : nhres@mpOceanFillColor      
    "mpInlandWaterFillColor"     : nhres@mpInlandWaterFillColor
    "mpNationalLineColor"        : nhres@mpNationalLineColor   
    "mpProvincialLineColor"      : nhres@mpProvincialLineColor
  end getvalues

  getvalues map1@contour
    "cnFillOn"                   : nhres@cnFillOn
    "cnLevelSelectionMode"       : nhres@cnLevelSelectionMode
    "cnLevels"                   : nhres@cnLevels
    "cnFillColors"               : nhres@cnFillColors
    "cnFillDrawOrder"            : nhres@cnFillDrawOrder
    "cnLinesOn"                  : nhres@cnLinesOn
    "cnLineLabelsOn"             : nhres@cnLineLabelsOn
  end getvalues

  nhres@lbLabelBarOn             = False
  nhres@tmXBOn                   = False
  nhres@tmYLOn                   = False
  nhres@tmYROn                   = False
  nhres@tmXTOn                   = False
  nhres@gsnLeftString            = ""
  nhres@gsnRightString           = ""

  map_nanhai = gsn_csm_contour_map(wks,pres,nhres)

  adres                          = True
  adres@amParallelPosF           = 0.495 ; -0.5 is the left edge of the plot.
  adres@amOrthogonalPosF         = 0.49  ; -0.5 is the top edge of the plot.
  adres@amJust                   = "BottomRight"

  plotnh = gsn_add_annotation(map1,map_nanhai,adres)
  draw(map1)
  frame(wks)

;---------------------------------------------------------------
; Mask Xinjiang plot
  res@mpMaskAreaSpecifiers       = "Xinjiang Uygur"
  res@gsnLeftString              = "Surface pressure in Xinjiang with NCL Mask"
  map2 = gsn_csm_contour_map(wks,pres,res)

;---------------------------------------------------------------
; Mask Xizang plot
  res@mpMaskAreaSpecifiers       = "Xizang"
  res@gsnLeftString              = "Surface pressure in Xizang with NCL Mask"
  map3 = gsn_csm_contour_map(wks,pres,res)

;---------------------------------------------------------------
; Mask Beijing plot
  res@mpOutlineSpecifiers       := "Beijing Shi"
  res@mpMaskAreaSpecifiers       = "Beijing Shi"
  res@mpMinLatF                  = 39.4
  res@mpMaxLatF                  = 41.15
  res@mpMinLonF                  = 115.25
  res@mpMaxLonF                  = 117.6
  res@mpShapeMode                = "FreeAspect"
  res@gsnLeftString              = "Surface pressure in Beijing with NCL Mask and shp boundaries"
  res@gsnRightString             = ""
  map4 = gsn_csm_contour_map(wks,pres,res)

;--- add shp file boundaries ---
  ShpDir = "./cnmap/" ;"D:\NCL\cygwin\app\ncl\lib\ncarg\nclscripts\cnmap\"
  cnres                       = True
  cnres@gsLineThicknessF      = 2.0
  cnres@gsLineColor           = "red"

  getvalues map4
    "mpMinLatF" : cnres@minlat
    "mpMaxLatF" : cnres@maxlat
    "mpMinLonF" : cnres@minlon
    "mpMaxLonF" : cnres@maxlon
  end getvalues

  plotshp = gsn_add_shapefile_polylines(wks,map4,ShpDir+"cnhimap.shp",cnres)

;---------------------------------------------------------------

  gsn_panel(wks,(/map1,map2,map3,map4/),(/2,2/),True)

end  


我感觉是这里出错

我感觉是这里出错

从map=这句开始报错的

从map=这句开始报错的

错误

错误
密码修改失败请联系微信:mofangbao
发表于 2021-12-15 14:24:42 | 显示全部楼层
楼主你好,我在作图时也遇到这种情况,请问你现在解决这个问题了吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2022-1-5 16:45:03 | 显示全部楼层
好像 我说好像 应该是最开始load的时候 需要load一个他给的cnmap
具体我记不得了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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