爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7384|回复: 4

[作图] [求助][已解决]请问NCL一幅图能叠加画两次plot么?

[复制链接]
发表于 2016-4-11 11:12:32 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 xuebiz 于 2016-4-21 09:35 编辑

【已解决】第一种,画一个数据的contour,上面叠加同一个一个数据的另一个变量的vector
应给怎么设置参数?
------我用两次“polt = ”会给我输出两个图片。

第二种,画一个数据的contour或者vector,然后上面叠加另一个数据的contour(目的通过:mask值屏蔽掉一些无关区域),2套数据的经纬度定义不一样
有这种叠加画法么?应该怎么设置参数?
还是必须把经纬度插值到一样的才可以?

【已解决】第三种,有没有mask陆地或者者海洋的方法(即只保留陆地区域的数值,或者仅保留海洋区域的数值)。
变量里没有mask和陆海的相关定义。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 09:30:58 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-21 09:32 编辑

说多了都是泪啊,读书少。
今天跟overlay好好交流下~~

官网NCL_Tutorial_V1.1第60页也有类似的例子:
--------------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
f = addfile("$NCL/data/ECHAM5_OM_A1B_2001_0101-1001_2D.nc","r")
u = f->u10(0,:,:)      ;-- first time step
v = f->v10(0,:,:)      ;-- first time step
t = f->tsurf(0,:,:)      ;-- first time step
;-- define the workstation (graphic will be written to a file)
wks = gsn_open_wks("png","vectors_overlay")
;-- set plot resources
cnres = True
cnres@gsnDraw = False ; don't draw
cnres@gsnFrame = False ; don't advance frame
cnres@cnFillOn = True ; turn on color
cnres@cnLinesOn = False ; no contour lines
cnres@mpFillOn = False ; no map fill
cnres@gsnLeftString = "surface temperature" ; change left string
cnres@gsnRightString = t@units ; assign right string
cnres@tiMainString = "DKRZ NCL Workshop: vectors overlay on map"
vcres = True ; vector only resources
vcres@gsnDraw = False ; don't draw
vcres@gsnFrame = False ; don't advance frame
vcres@vcGlyphStyle = "CurlyVector" ; curly vectors
vcres@vcRefMagnitudeF = 20 ; define vector ref mag
vcres@vcRefLengthF    = 0.045 ; define length of vec ref
vcres@vcRefAnnoOrthogonalPosF = -.535 ; move ref vector into plot
vcres@gsnRightString = ""     ; turn off right string
vcres@gsnLeftString = ""     ; turn off left string
vcres@tiXAxisString = ""     ; turn off axis label
cplot = gsn_csm_contour_map_ce(wks,t,cnres)  ; contours over a map
vplot = gsn_csm_vector(wks,u,v,vcres)  ; vectors only
overlay(cplot,vplot)
draw(cplot)  ; cplot now contains both itself, and vplot
frame(wks)
end
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

发表于 2016-4-11 11:25:51 | 显示全部楼层
{:eb513:}{:eb513:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

 楼主| 发表于 2016-4-11 11:32:44 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-21 08:54 编辑

第三种自己搞定了。。。

比如填充陆地灰色:填充陆地灰色,填充地图绘图顺序为后画
  res@mpLandFillColor = "gray"  
  res@mpFillDrawOrder = "PostDraw"
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-4-21 08:51:42 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-21 09:34 编辑

第三种自己搞定了,在官网的绘图参考书册《NCL mini graphics manual》文档里就有写。
MARK一下,好好学习,天天向上!

----------------------------------------------------------
7.3 通过标量场或在标量场给矢量着色
在同一张图上画矢量场和标量场有四个接口:
gsn_csm_vector_scalar_map_ce
 gsn_csm_vector_scalar_map_polar
gsn_csm_vector_scalar_map
gsn_csm_pres_hgt_vector
这些接口的默认情况是通过标量场的大小给矢量定义颜色(图5d),设置gsnScalarContour = True
可以改变默认行为。

如果想要一个不同类型的图形,需要创建单独的等值线图和矢量图,然后使用overlay程序连接两者。

下面是一个生成两个图形对象的脚本。Overlay用来把它们连接成一个对象。注意gsnDraw 和
gsnFrame设置为False。生成图形的顺序不重要。Overlay有两个参数,每一个是图形对象。Overlay
程序将第二个对象添加到第一个对象上。Overlay完成后,需要手动画出连接对象且改进框架。
在一个图形资源列表中,应该关闭gsnLeftString 和 gsnRightString。否则两幅图的标签字符
串将会重叠。
; create vector plot
res   = True
res@vcRefMagnitudeF  = 30.0
res@vcRefLengthF   = 0.045
res@vcMinDistanceF    = .019
res@vcGlyphStyle    = "CurlyVector"
res@gsnDraw = False
res@gsnFrame = False
res@gsnLeftString  = ""
res@gsnRightString  = ""
plot = gsn_csm_vector(wks,u,v,res)
; create contour plot
resCN = True
resCN@cnFillOn = True
resCN@cnLinesOn = False
resCN@gsnSpreadColors = True
resCN@gsnDraw = False
base = gsn_csm_contour(wks,data,resCN)
;overlay vector plot onto contour plot
overlay(base,plot)
draw(base) ; draw the combined obj
frame(wks) ; advance the frame

成功创建一个overlay的关键是要确保两个图形中数据的坐标变量相同。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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