爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 15588|回复: 13

关于gsn_add_polyline函数的一些疑问

[复制链接]
发表于 2014-4-22 11:55:34 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 想画平面分布图某一连线的剖面图,但是gsn_add_polyline(wks, plot, x, y, plres)函数要求x,y是经纬度数值。但是我用wrfout数据都是算格点数,来做剖面图
我看过提问的智慧: 看过
自己思考时长(天): 1

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

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

x
想画平面分布图某一连线的剖面图但是gsn_add_polyline(wks, plot, x, y, plres)函数要求x,y是经纬度数值。
但是我用wrfout数据都是算格点数,来做剖面图

比如:
plane = (/  2,71, 199,71  /)                  ;  start x;y & end x;y point
rh_plane = wrf_user_intrp3d(rh,z,"v",plane,0.,opts)

所以想问一下各位想画下图这种指定某两点连线的剖面图,要怎么知道这两点的格点数或者经纬度。
又怎样在相对应的平面图上画出剖面线(下图为蓝色)呢?
QQ图片20140422114814.jpg
密码修改失败请联系微信:mofangbao
发表于 2014-4-22 12:01:51 | 显示全部楼层
wrf_user_ij_to_ll
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-4-22 15:38:40 | 显示全部楼层

刚刚试用了下,可以。不仅格点可以转为经纬度,还可以ll_to_ij。太感谢了~
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-4-23 18:36:19 | 显示全部楼层

大神再问你一个问题:
我添加了
lnres = True
   lnres@gsLineThicknessF = 3.0
   lnres@gsLineColor = "Red"
   gsn_polyline(wks,plot,(/30.3,103.3/),(/32.,105./),lnres)
来画剖面线,没有报错。但是图上没有剖面线出现。看了半天没看出什么错,请问你知道是什么原因吗?
我是不是又忽略了什么东西?
密码修改失败请联系微信:mofangbao
发表于 2014-4-23 18:51:41 | 显示全部楼层
黄小仙儿 发表于 2014-4-23 18:36
大神再问你一个问题:
我添加了
lnres = True

gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-4-23 21:53:48 | 显示全部楼层
longlivehj 发表于 2014-4-23 18:51
gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)

改了之后还是不显示~~
密码修改失败请联系微信:mofangbao
发表于 2014-4-23 23:02:18 | 显示全部楼层
黄小仙儿 发表于 2014-4-23 21:53
改了之后还是不显示~~

能把代码贴上来么?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-4-24 15:01:47 | 显示全部楼层
longlivehj 发表于 2014-4-23 23:02
能把代码贴上来么?


;   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"

begin
;
; The WRF ARW input file.  
; This needs to have a ".nc" appended, so just do it.
  a = addfile("/home/Huanglei/data/d032"+".nc","r")

; We generate plots, but what kind do we prefer?
  type = "pdf"
; type = "pdf"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"plt_dbz23")
  gsn_define_colormap(wks,"WhViBlGrYeOrReWh")

; Set some basic resources
  res = True
  res@MainTitle                   = "REAL-TIME WRF"

  pltres = True
pltres@PanelPlot  = True   ; Tells wrf_map_overlays not to remove overlays
  mpres = True
mpres@mpOutlineOn = False  ; Turn off map outlines
mpres@mpFillOn    = False  ; Turn off map fill
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; 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 intercept parameters
; for rain, snow, and graupel, which are consistent with
; Thompson, Rasmussen, and Manning (2004, Monthly Weather Review,
; Vol. 132, No. 2, pp. 519-542.)
;        First "1" in wrf_user_getvar
; Frozen particles that are at a temperature above freezing will be
; assumed to scatter as a liquid particle.
;        Second "1" in wrf_user_getvar

     mdbz = wrf_user_getvar(a,(/"mdbz","1","1"/),it)
     dbz = wrf_user_getvar(a,(/"dbz","1","1"/),it)

     opts = res                        
     opts@cnFillOn = True  
     opts@ContourParameters = (/ 5., 75., 5./)
    ; 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)
;>============================================================<
;                      add China map
;>------------------------------------------------------------<

     
  shp_name1    = "/home/Huanglei/map/China/diquJie_polyline.shp"

  lnres                  = True
  lnres@gsLineColor      = "gray25"
  lnres@gsLineThicknessF = 0.5   

id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)
  shp_name2    = "/home/Huanglei/map/China/cnmap/cnhimap.shp"

  prres=True
  prres@gsLineThicknessF = 2.0      
  prres@gsLineColor = "black"
  plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)
   lnres = True
   lnres@gsLineThicknessF = 3.0
   lnres@gsLineColor = "Red"
  gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)

   
  tes = True
  tes@returnInt = False                             ; return real values
  loc1  = wrf_user_ll_to_ij(a, 103.3, 30.3, tes)
  print("X/Y location is: " + loc1)
  loc2  = wrf_user_ll_to_ij(a, 105., 32., tes)
  print("X/Y location is: " + loc2)
  draw(plot)       ; This will draw the map and the shapefile outlines.
  frame(wks)
   delete(opts)


   end do        ; END OF TIME LOOP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
密码修改失败请联系微信:mofangbao
发表于 2014-4-24 15:10:53 | 显示全部楼层
   lnres = True
   lnres@gsLineThicknessF = 3.0
   lnres@gsLineColor = "Red"
  gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)

位置放错了,放到frame之前!
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-4-24 15:32:21 | 显示全部楼层
longlivehj 发表于 2014-4-24 15:10
lnres = True
   lnres@gsLineThicknessF = 3.0
   lnres@gsLineColor = "Red"

哇,出来了。请问这个前后顺序也有影响吗?
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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