爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6727|回复: 6

[作图] 添加中国地图的另一种方法!

[复制链接]

新浪微博达人勋

发表于 2016-8-23 15:27:39 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 1649518749 于 2016-8-28 12:23 编辑

楼主推荐:http://bbs.06climate.com/forum.php?mod=viewthread&tid=47160

以前我画图add China map 的时候是采用 尽头的尽头http://bbs.06climate.com/forum.php?mod=viewthread&tid=11797的方法。


但是画wrfout数据的时候有时候会出现地图缺失的现象(像图1,没国界、省界、南海),不知道你们遇到没?

现在又找到另一种方法,在这感谢天行健大神http://bbs.06climate.com/forum.p ... =1935&extra=&page=1提供的方法,

顺利添加成功。效果图2/3。只是没有南海小地图,我下次再找找看,怎么添加进去。

其中我做了部分处理。代码模板如下:

你只要把红色地方复制到你脚本里面就行!

;   Example script to produce dbz plots for a WRF real-data run,

;   with the ARW coordinate dynamics option.

;   November 2008


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"

load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.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")


  wks = gsn_open_wks("ps","dbz")

;  gsn_define_colormap(wks,colors)       ; Overwrite the standard color map


; Set some basic resources

  res = True

  res@MainTitle                   = "REAL-TIME WRF"

  pltres = True

  mpres = True

;>==============set  for   map====================================<

  m=asciiread ("/home/fc/datafile/barmes.txt", (/25,29,3/) , "float")    注:/home/fc/datafile/barmes.txt  是地形文件路径,自己去天行健那里下载就行

     lat=fspan(10,70,25)

     lon=fspan(60,130,29)

     lat@units="degrees_north"

     lon@units="degrees_east"  

     m!0="lat"

     m!1="lon"

     m&lat=lat

     m&lon=lon

   

         mpres@mpLimitMode       = "LatLon"

         mpres@mpMinLatF         = 15         

         mpres@mpMaxLatF         = 55

         mpres@mpMinLonF         = 72

         mpres@mpMaxLonF         = 136



        mpres@mpDataBaseVersion="MediumRes"    ;MediumRes  ;;; Ncarg4_1            

        mpres@mpDataSetName="Earth..4"                        

        mpres@mpOutlineOn            = True

        mpres@mpOutlineSpecifiers=(/"China:states","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)      

        mpres@mpOutlineBoundarySets ="NoBoundaries"   

        mpres@mpAreaMaskingOn = True                          

        mpres@mpOceanFillColor = "white"                           

        mpres@mpLandFillColor         = "white"

        mpres@mpInlandWaterFillColor = "white"  

        mpres@mpNationalLineColor     = "Black"        ;guojie yan se

        mpres@mpUSStateLineColor          = "Black"   ;shengjie yanse

        mpres@mpGeophysicalLineColor  = "Black"     ; kao shui diyu yan se

        mpres@mpNationalLineThicknessF    = 1.5

        mpres@mpGeophysicalLineThicknessF = 1.5

        mpres@mpUSStateLineThicknessF     = 1.5

;>============================================================<

; Which times and how many time steps are in the data set?

  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file

  ntimes = dimsizes(times)         ; number of times in the file

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


  do it = 1,ntimes-1              ; 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        

; Both dbz and mdbz will be calculated using constant intercept parameters

; (as in early Reisner-2), with values of 8x10^6, 2x10^7, and 4x10^6 m^-4,

; for rain, snow, and graupel, respectively.


     mdbz = wrf_user_getvar(a,"mdbz",it)

     dbz = wrf_user_getvar(a,"dbz",it)


     opts = res                        

     opts@cnFillOn = True  

     opts@ContourParameters = (/ 5., 70., 5./)

     opts@cnFillColors = (/"white","white","cadetblue1","steelblue2","green","green4","yellow",\

                           "gold2", "orange","red","red3","red4","deeppink","magenta","gray0"/)

     contour = wrf_contour(a,wks,dbz(1,:,:),opts)     ; plot only lowest level

     plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)


     contour = wrf_contour(a,wks,mdbz,opts)

     plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)

   end do        ; END OF TIME LOOP

end


图1

图1

图2

图2

图3

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

新浪微博达人勋

发表于 2016-8-23 16:55:57 | 显示全部楼层
能不能加上地级市边界&#128516;
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-23 20:10:00 | 显示全部楼层
andrewsoong 发表于 2016-8-23 16:55
能不能加上地级市边界&#128516;

要是能找到市边界名就好了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-10-27 23:36:31 | 显示全部楼层
资料好,我也是遇到同样的问题,地图设置总显示缺失,谢谢楼主
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-10-28 14:08:33 | 显示全部楼层
怎么样将中国地图外面的mask掉
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-10-28 14:17:57 | 显示全部楼层
weiyuntao 发表于 2017-10-28 14:08
怎么样将中国地图外面的mask掉

mpres@mpOutlineBoundarySets ="NoBoundaries"
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-12-13 12:44:48 | 显示全部楼层
不错,学习了
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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