爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8864|回复: 17

[作图] add China map 求助

[复制链接]

新浪微博达人勋

发表于 2016-8-19 09:33:57 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 1649518749 于 2016-8-24 15:42 编辑

推荐:利用shp文件画底图
但是我叠加中国地图是只有国界,没有省界。求大神看看。方法来源http://bbs.06climate.com/forum.php?mod=viewthread&tid=11797
代码如下:
;   Sample script to create and plot PW for WRF-ARW model output
;   November 2009
load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
  a = addfile("/home/fc/datafile/wrfoutdata/wrfout_d01_2016-08-17_18:00:00","r")

; We generate plots, but what kind do we prefer?
;  type = "x11"
type = "ps"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"pw")
;  gsn_define_colormap(wks,"gsdtol")

; Set some basic resources
  res = True
  res@MainTitle                   = "REAL-TIME WRF"
;  res@Footer = False
  pltres = True
  mpres = True
;;;;;;;;;;;;;;;;;set for map;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
res@mpMaxLatF= 55.

res@mpMinLatF= 15.

res@mpMaxLonF= 136.

res@mpMinLonF= 72.
mpres@mpFillOn                = True
mpres@mpOutlineOn             = True  ; Use outlines from shapefile
res@cnFillDrawOrder         = "PreDraw"
mpres@mpDataBaseVersion       = "MediumRes"
mpres@mpDataSetName           = "Earth..4"
mpres@mpAreaMaskingOn         = True
mpres@mpMaskAreaSpecifiers    = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
mpres@mpLandFillColor         = "white"
mpres@mpInlandWaterFillColor  = "white"
mpres@mpOceanFillColor        = "white"
mpres@mpOutlineBoundarySets   = "NoBoundaries"  ;or National
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  gas_const = 287. ; J/K/kg
  Cp        = 1004. ; J/K/kg

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; What times and how many time steps are in this data set?
  times = wrf_user_getvar(a,"times",-1)  ; get times in the file
  ntimes = dimsizes(times)         ; number of times in the file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  do it = 0,ntimes-1,2                       ; TIME LOOP

    print("Working on time: " + times(it) )
    res@TimeLabel = times(it)      ; Set Valid time to use on plots

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need        

    pres = wrf_user_getvar(a,"pres",it)                ; pressure in pa
    ph = wrf_user_getvar(a,"PH",it)                    ; pert. geopt
    phb = wrf_user_getvar(a,"PHB",it)                  ; base geopt
    th = wrf_user_getvar(a,"theta",it)                 ; theta (T+300)
    qvapor = wrf_user_getvar(a,"QVAPOR",it)   

; Calc height, pressure and virtual temperature
    height = (ph + phb)/9.81                           ; height at full levels
    temp = th * (pres/100000) ^ (gas_const/Cp)
    vtemp = (1 + 0.61*qvapor) * temp                   ; virtual temp

    zdiff=height(0,:,:)
    zdiff=0.
    pw_sfc_ptop=height(0,:,:)
    pw_sfc_ptop=0.

    dim = dimsizes(pres)
    do k=0,dim(0)-1
      zdiff(:,:)= (height(k+1,:,:) - height(k,:,:))
      pw_sfc_ptop(:,:) =  pw_sfc_ptop(:,:) + ((pres(k,:,:)/(gas_const * vtemp(k,:,:))) * qvapor(k,:,:) * zdiff(:,:))
    end do
    pw_sfc_ptop@description = "PW"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    opts = res                          
    opts@cnFillOn = True

    ;opts@lbTitleOn = False
    opts@lbLabelBarOn = True
    ;opts@lbLabelsOn = False
    ;opts@pmLabelBarDisplayMode = "NoCreate"
    contour  = wrf_contour(a,wks,pw_sfc_ptop,opts)
    delete(opts)

    ; MAKE PLOTS                                       
    plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;>============================================================<
;                      add China map
;>------------------------------------------------------------<
cnres           = True
cnres@china     = True       ;draw china map or not
cnres@river     = True       ;draw changjiang&huanghe or not
cnres@province  = True       ;draw province boundary or not
cnres@nanhai    = True       ;draw nanhai or not
cnres@diqu      = False       ; draw diqujie or not

chinamap = add_china_map(wks,plot,cnres)
;>============================================================<
  end do  ;       end of the time loop

end


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

新浪微博达人勋

 楼主| 发表于 2016-8-19 10:16:13 | 显示全部楼层
这幅图,国界都没有。
precipitation.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-19 11:15:16 | 显示全部楼层
我画的和你的一样 也没有地图
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-19 11:16:44 | 显示全部楼层
xyan88 发表于 2016-8-19 11:15
我画的和你的一样 也没有地图

如果不是用wrfout数据,画出来倒是有省界。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-19 11:22:16 | 显示全部楼层
1649518749 发表于 2016-8-19 11:16
如果不是用wrfout数据,画出来倒是有省界。

一次画多张就不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-19 14:14:39 | 显示全部楼层
andrewsoong 发表于 2016-8-19 11:22
一次画多张就不行

没用啊,我还叠加了海平面气压场,还是没国界
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-19 16:14:41 | 显示全部楼层
1649518749 发表于 2016-8-19 11:16
如果不是用wrfout数据,画出来倒是有省界。

请问那怎么解决啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-19 16:18:19 | 显示全部楼层
xyan88 发表于 2016-8-19 16:14
请问那怎么解决啊

我都茫然了。你贴个脚本来看看,一起研究研究
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-19 16:50:16 | 显示全部楼层
好的 我在测试下  好了贴上来
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-19 18:24:37 | 显示全部楼层
1649518749 发表于 2016-8-19 16:18
我都茫然了。你贴个脚本来看看,一起研究研究

;   Sample script to create and plot PW for WRF-ARW model output
;   November 2009
load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;

  a=addfile("wrfout_d01_2015-01-01_00:00:00.nc","r")
  wks = gsn_open_wks("pdf","0819")

; Set some basic resources
res = True
mpres = True
pltres= True

res@MainTitle = "Real-TIME WRF-Chem"
res@cnFillDrawOrder = "PreDraw"
times = wrf_user_getvar(a,"times",-1)  ; get times in the file
res@cnFillOn = True
res@TimeLabel = times(0)      ; Set Valid time to use on plots

;;;;;;;;;;;;;;;;;set for map;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mpres@mpMaxLatF= 25.
mpres@mpMinLatF= 15.
mpres@mpMaxLonF= 136.
mpres@mpMinLonF= 72.
mpres@mpFillOn                = True
mpres@mpOutlineOn             = True  ; Use outlines from shapefill
mpres@mpDataBaseVersion       = "MediumRes"
mpres@mpDataSetName           = "Earth..4"
mpres@mpAreaMaskingOn         = True
mpres@mpMaskAreaSpecifiers    = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
;mpres@mpMaskAreaSpecifiers    = (/"Hunan","Anhui"/)
mpres@mpLandFillColor         = "white"
mpres@mpInlandWaterFillColor  = "white"
mpres@mpOceanFillColor        = "white"
mpres@mpOutlineBoundarySets   = "NoBoundaries"  ;or National

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
data = a->PM10(0,0,:,:)
contour  = wrf_contour(a,wks,data,res)
plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;>============================================================<
;                      add China map
;>------------------------------------------------------------<
cnres           = True
cnres@china     = True       ;draw china map or not
cnres@river     = True       ;draw changjiang&huanghe or not
cnres@province  = True       ;draw province boundary or not
cnres@nanhai    = True       ;draw nanhai or not
cnres@diqu      = False       ; draw diqujie or not

chinamap =  add_china_map(wks,plot,cnres)
;>============================================================<

end
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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