爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5482|回复: 8

在等值线图上画一根剖线,怎么让这根剖线最前显示呢

[复制链接]
发表于 2014-10-22 10:50:36 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 想在已经画好的等值线图上画一根剖线,但剖线总是被等值线覆盖,试过调整脚本顺序,设置了opts@cnLineDrawOrder = "PreDraw" 剖线总是会被等值线覆盖,没辙了,求教家园的各位高手
我看过提问的智慧: 看过
自己思考时长(天): 2

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

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

x
想在已经画好的等值线图上画一根剖线,但剖线总是被等值线覆盖,试过调整脚本顺序,设置了opts@cnLineDrawOrder       = "PreDraw" 剖线总是会被等值线覆盖,没辙了,求教家园的各位高手
图如下:
QQ图片20141022105044.png
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-22 10:51:39 | 显示全部楼层
脚本:
;   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_dbzaddlightning")
  gsn_define_colormap(wks,"sunshine_9lev")
; gsn_define_colormap(wks, "wgne15")       ; choose colormap
; 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 = 48,ntimes-1               ; TIME LOOP
    it=48
     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@cnLineColor = "Black"
      opts@cnFillOn         = False
      opts@gsnSpreadColors  = False
      opts@cnMonoLineColor = False
  ;   opts@cnFillOn = True
      opts@pmLabelBarDisplayMode="Always"
          opts@cnLineLabelsOn             = False  
      opts@pmLabelBarWidthF      = 0.06               ; default is shorter
      opts@pmLabelBarHeightF     = 0.8               ; default is taller
      opts@lbLabelFontHeightF    = 0.0001             ; default is HUGE
          opts@cnLineDrawOrder       = "PreDraw"
     ; opts@cnLineLabelBackgroundColor = "white"  
          opts@lbPerimOn             = False
     opts@ContourParameters = (/ 5., 65.,10./)
     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)
;draw(plot)

   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.
lnres = True
   lnres@gsLineThicknessF = 5.0
   lnres@gsLineColor = "Red"
  gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)
;draw(plot)   

ascii_filename = "/home/Huanglei/data/new16jia.txt"
  seismic = asciiread(ascii_filename,(/521,3/),"float")   
  
    y = seismic(:,0)  ; Column 1 of file contains X values.
    x = seismic(:,1)  ; Column 2 of file contains Y values.
    z = seismic(:,2)  ; Column 3 of file contains Z values.
  txres2  = True
  txres2@txFont  = 0.01
  txres2@txFontHeightF =0.01
  txres2@txFontColor = "Red"
idx = ind(z .gt. 0)
print(idx)
if .not. all(ismissing(idx))
    str = new(dimsizes(idx), "string")
    str = "+"
    txdum1 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if
txres2@txFontColor = "Blue"

idx := ind(z .lt. 0)
if .not. all(ismissing(idx))
    str := new(dimsizes(idx), "string")
    str = "-"   
    txdum2 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if



draw(plot)


frame(wks)
delete(opts)




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
密码修改失败请联系微信:mofangbao
发表于 2014-10-22 13:43:30 | 显示全部楼层
tfPolyDrawOrder
密码修改失败请联系微信:mofangbao
发表于 2014-10-22 13:59:21 | 显示全部楼层
The tfPolyDrawOrder resource is a special one for primitives (polygons, polylines, and polymarkers)
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-22 15:43:01 | 显示全部楼层

恩,已出图。多谢~
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-22 15:43:13 | 显示全部楼层
尽头的尽头 发表于 2014-10-22 13:59
The tfPolyDrawOrder resource is a special one for primitives (polygons, polylines, and polymarkers)

恩,已出图,多谢~
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-22 16:32:10 | 显示全部楼层

还想问您一个问题,我用这个脚本同样的方法给风暴螺旋度等值线图上叠加闪电,但是只有等值线,没有表示闪电的“-”“+”号出现。改了N久,还是不行。。麻烦您看看:
这是我的脚本:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;load "./WRFUserARW.ncl"

begin

  a = addfile("/home/Huanglei/data/d032"+".nc","r")

; type = "x11"
type = "pdf"
; type = "ps"
; type="png"

  wks = gsn_open_wks(type,"plt_helicityaddlightning")
  gsn_define_colormap(wks, "sunshine_diff_12lev")

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

  pltres = True
  mpres = True

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

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

str = new(ntimes, "string")

   it=48
    res@tiMainString = times(it)           ; Set Valid time to use on plots
    ;sreh = wrf_user_getvar(a,"helicity",it)                            ; here a default of 3km is used
    sreh = wrf_user_getvar(a,(/"helicity","3000"/),it)            ; here 3km is specifically set - same as above
    ;sreh = wrf_user_getvar(a,(/"helicity","1000"/),it)            ; here a height of 1km is used
   ; ssreh = dim_sum_n_Wrap(sreh, 0)
    cnres                      = res
    cnres@cnFillOn             = False
    cnres@cnSmoothingOn        = True
    cnres@cnMonoLineColor = False
  ;   opts@cnFillOn = True
      cnres@pmLabelBarDisplayMode="Always"
          cnres@cnLineLabelsOn             = False  
      cnres@cnSmoothingDistanceF = .005
      cnres@pmLabelBarWidthF      = 0.06               ; default is shorter
      cnres@pmLabelBarHeightF     = 0.8               ; default is taller
      cnres@lbLabelFontHeightF    = 0.0001             ; default is HUGE
          cnres@cnLineThicknesses = 6.0
  ; cnres@ContourParameters    = (/ -20., 90., 5./)
  ; cnres@gsnSpreadColorEnd    = -3  ; End 3rd from the last color in color map

    contour = wrf_contour(a,wks,sreh,cnres)
    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)

draw(plot)       ; This will draw the map and the shapefile outlines.
ascii_filename = "/home/Huanglei/data/new16jia.txt"
  seismic = asciiread(ascii_filename,(/521,3/),"float")   
  
    y = seismic(:,0)  ; Column 1 of file contains X values.
    x = seismic(:,1)  ; Column 2 of file contains Y values.
    z = seismic(:,2)  ; Column 3 of file contains Z values.
  txres2  = True
  txres2@txFont  = 0.01
  txres2@txFontHeightF =0.01
  txres2@txFontColor = "Red"
idx = ind(z .gt. 0)
print(idx)
if .not. all(ismissing(idx))
    str = new(dimsizes(idx), "string")
    str = "+"
    txdum1 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if
txres2@txFontColor = "Blue"

idx := ind(z .lt. 0)
if .not. all(ismissing(idx))
    str := new(dimsizes(idx), "string")
    str = "-"   
    txdum2 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if



draw(plot)

  frame(wks)
;end do

end
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-22 16:34:59 | 显示全部楼层

提示错误:
fatal:Dimension sizes of left hand side and right hand side of assignment do not  match
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 98 in file /hom                    e/Huanglei/wrf_helicity_add_lightning.ncl
我看了下是这一行:    str = new(dimsizes(idx), "string")
但是我画上一个图的时候就没有问题,不知道怎么了
密码修改失败请联系微信:mofangbao
发表于 2014-10-22 23:44:13 | 显示全部楼层
黄小仙儿 发表于 2014-10-22 16:34
提示错误:
fatal:Dimension sizes of left hand side and right hand side of assignment do not  matc ...

str已经定义过了str = new(ntimes, "string")
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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