爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6419|回复: 9

[作图] 为什么地图和等值线填图没法叠加

[复制链接]
发表于 2015-4-23 23:25:55 | 显示全部楼层 |阅读模式

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

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

x
不知道为什么我画出来的地图和等值线填图没法叠加,ncl新手求大神看看脚本哪里不对,或者给个链接也行,多谢~


  1. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
  2. load "$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/cnmap.ncl"
  3. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
  4. load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

  5. begin
  6. ;
  7. ; The WRF ARW input file.  
  8. ; This needs to have a ".nc" appended, so just do it.
  9.   a = addfile("wrfout_d01_2008-07-22_19:00:00.nc","r")
  10.   b = addfile("wrfout_d01_2008-07-22_20:00:00.nc","r")


  11. ; We generate plots, but what kind do we prefer?
  12.   ;type = "x11"
  13. ; type = "pdf"
  14. type = "png"
  15. ;type="ps"
  16. ; type = "ncgm"
  17.   wks = gsn_open_wks(type,"plt_Precip")

  18. ; Set some basic resources
  19.   res = True
  20.   res@MainTitle = "REAL-TIME WRF"


  21.   pltres = True
  22.   mpres = True




  23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. ;First get the variables we will need        



  27.   ; Get non-convective, convective and total precipitation
  28.   ; Calculate tendency values   
  29.   ;-------------------------------------------------------------------------------------------------------------------                           
  30.     rain_exp1 = wrf_user_getvar(a,"RAINNC",0)
  31.     rain_con1 = wrf_user_getvar(a,"RAINC",0)
  32.     rain_exp2 = wrf_user_getvar(b,"RAINNC",0)
  33.     rain_con2 = wrf_user_getvar(b,"RAINC",0)
  34.     rain_exp=rain_exp2-rain_exp1
  35.     rain_con=rain_con2-rain_con1
  36.     rain_tot = rain_exp + rain_con
  37.     rain_tot@description = "Total Precipitation"

  38.   ;------------------------------------------------------------------------------------------------------------ -------------------

  39.       ; Plotting options for Precipitation
  40.         opts_r = res                        
  41.         opts_r@UnitLabel            = "mm"
  42.         opts_r@cnLevelSelectionMode = "ExplicitLevels"
  43.         opts_r@cnLevels             = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
  44.                                         12.8, 25.6, 51.2, 102.4/)
  45.         opts_r@cnFillColors         = (/"White","White","DarkOliveGreen1", \
  46.                                         "DarkOliveGreen3","Chartreuse", \
  47.                                         "Chartreuse3","Green","ForestGreen", \
  48.                                         "Yellow","Orange","Red","Violet"/)
  49.         opts_r@cnInfoLabelOn        = False
  50.         opts_r@cnConstFLabelOn      = False
  51.         opts_r@cnFillOn             = True
  52.    
  53.         lat  = wrf_user_getvar(a,"XLAT",0)
  54.         lon = wrf_user_getvar(a, "XLONG", 0)
  55. ;----------------------------------------------------------------------
  56. ; Plot full domain first.
  57. ;----------------------------------------------------------------------
  58.         opts_r@cnFillOn=True
  59.         contour = wrf_contour(a,wks,rain_tot,opts_r)
  60.      
  61. ;----------------------------------------------------------------------
  62. ; Plot partial domain.
  63. ;----------------------------------------------------------------------
  64.   opts_r@sfXArray = lon
  65.   opts_r@sfYArray = lat
  66.   contour = wrf_contour(a,wks,rain_tot,opts_r)

  67. ;---Set special resource to indicate we are using XLAT/XLONG coordinates.
  68.   pltres@LatLonOverlay = True

  69. ;---Zoom in on map, which we can do because we're using lat/lon coordinates.
  70.   mpres@mpLeftCornerLatF  =  28.
  71.   mpres@mpRightCornerLatF =  34.
  72.   mpres@mpLeftCornerLonF  = 110.
  73.   mpres@mpRightCornerLonF = 122.


  74. contour_tot = wrf_contour(a,wks, rain_tot, opts_r)
  75.       
  76. delete(opts_r)


  77. ; MAKE PLOTS                                       

  78. plot = wrf_map_overlays(a,wks,contour_tot,pltres,mpres)
  79.       
  80. ;--------------------------------------------------------------------------------------------------------------------------------------------

  81. ;---------------------------------------------------
  82. ;         add China map
  83. ;----------------------------------------------------

  84.   map=wrf_map(wks, a, mpres)
  85.   shp_name1="/usr/local/NCL/lib/ncarg/nclscripts/cnmap/cnmap.shp"
  86.   lnres1=True
  87.   lnres1@gsLineColor      = "black"
  88.   lnres1@gsLineThicknessF = 2.0   
  89.   poly1=gsn_add_shapefile_polylines(wks, map, shp_name1,lnres1)


  90.   shp_name2="/usr/local/NCL/lib/ncarg/nclscripts/cnmap/river.shp"
  91.   lnres2=True
  92.   lnres2@gsLineThicknessF = 2.0      
  93.   lnres2@gsLineColor = "blue"
  94.    poly2=gsn_add_shapefile_polylines(wks, map, shp_name2, lnres2)

  95.   shp_name3="/usr/local/NCL/lib/ncarg/nclscripts/cnmap/cnhimap.shp"
  96.   lnres3=True
  97.   lnres3@gsLineThicknessF = 2.0      
  98.   lnres3@gsLineColor = "black"
  99.    poly3=gsn_add_shapefile_polylines(wks, map, shp_name3, lnres3)
  100.    draw(map)
  101.    frame(wks)



  102. end
复制代码


plt_Precip.000001.png
plt_Precip.000002.png
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-4-24 14:11:42 | 显示全部楼层
是后面加地图的时候出了问题。已解决~
密码修改失败请联系微信:mofangbao
发表于 2015-4-24 17:19:08 | 显示全部楼层
ncl两幅图叠加需要overlay吧
密码修改失败请联系微信:mofangbao
发表于 2015-7-17 18:41:35 | 显示全部楼层
楼主解决方案没贴出来啊
密码修改失败请联系微信:mofangbao
发表于 2016-8-24 20:30:18 | 显示全部楼层
pltres = True 后加
pltres@FramePlot = False   ; do not frame plot - will do this manually later
密码修改失败请联系微信:mofangbao
发表于 2017-9-7 13:58:18 | 显示全部楼层
{:5_231:}{:5_231:}{:5_231:}{:5_231:}
密码修改失败请联系微信:mofangbao
发表于 2017-9-7 13:58:22 | 显示全部楼层
{:lxm_25:}{:lxm_25:}{:lxm_25:}{:lxm_25:}
密码修改失败请联系微信:mofangbao
发表于 2017-9-7 13:58:25 | 显示全部楼层
{:lxm_26:}{:lxm_26:}{:lxm_26:}{:lxm_26:}{:lxm_26:}
密码修改失败请联系微信:mofangbao
发表于 2017-10-18 18:12:25 | 显示全部楼层
按楼主的方法改了,是叠加在一起了,可是图的大小不一样
请问怎么改变大小啊
密码修改失败请联系微信:mofangbao
发表于 2017-10-22 13:42:12 | 显示全部楼层
占位…………
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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