爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 11063|回复: 16

ncl中如何实现参考风矢量的圆盘表现形式?

[复制链接]
回帖奖励 70 金钱 回复本帖可获得 5 金钱奖励! 每人限 2 次(中奖概率 70%)

新浪微博达人勋

发表于 2014-4-20 16:16:44 | 显示全部楼层 |阅读模式
NCL
系统平台: NCL
问题截图:
问题概况: NCL中如何画出风场参考量的圆形时钟表示方式?(想来想去也只能这样说了)
我看过提问的智慧: 看过
自己思考时长(天): 1

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

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

x
看到一篇文献中有一张图(如截图所示),这张图中是用风场来表示最高蒸发量所出现的月份,如正南风表示12月,正西风表示3月, 风向盘如图中右下角所示!那在NCL中如何画出的这个风场的指向盘呢?grads能实现吗?我现在画出了风场,但是不知道怎么添加这个参照矢量,一天下来百思不得骑姐~遂来问问论坛里面的同僚们了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-21 13:36:36 | 显示全部楼层

回帖奖励 +5 金钱

sun_shine_Xia 发表于 2014-4-21 10:21
恩,不错,按照这个就画出来!!!膜拜~~还有个问题,他这个箭头的类型能设置吗?我研究了下wmsetp,wmve ...

给你一个另外的实现方式,供参考!
这个用到了gsn_csm_vector,可以比较灵活地控制箭头的属性。之前用wmvectmap的版本,正如你说的,箭头好像是没有太好的办法进行更改。

dir.png

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

begin
    lat = -30.
    lon = 90.

    len = .04

    fonthgt = .015

    wks = gsn_open_wks("png", "dir")

; map
    mapres = True
    mapres@gsnDraw = False
    mapres@gsnFrame = False

    plot = gsn_csm_map(wks, mapres)

; arrows
    u = (/(/0., 0., 0./), (/-10, 0., 10./), (/0., 0., 0./)/)
    v = (/(/0., 10., 0./), (/0., 0., 0./), (/0., -10., 0./)/)

    lat2 = lat + (/.01, 0., -.01/)
    lat2@units = "degrees_north"
    lon2 = lon + (/-.01, 0., .01/)
    lon2@units = "degrees_east"

    u!0 = "lat"
    u!1 = "lon"
    u&lat = lat2
    u&lon = lon2
    copy_VarCoords(u, v)

    vectres = True
    vectres@gsnDraw = False
    vectres@gsnFrame = False
    vectres@vcGlyphStyle = "FillArrow"
    vectres@vcFillArrowEdgeColor = "black"
    vectres@vcPositionMode = "ArrowTail"
    vectres@vcRefMagnitudeF = 10.
    vectres@vcRefLengthF = len * .9
    vectres@vcRefAnnoOn = False
    vectplot = gsn_csm_vector(wks, u, v, vectres)

    overlay(plot, vectplot)
    draw(plot)

; text
    xout = 0.
    yout = 0.
    datatondc(plot, lon, lat, xout, yout)

    len2 = len * 1.1

    txtres = True
    txtres@txFontHeightF = fonthgt
    txtres@txJust = "CenterLeft"
    gsn_text_ndc(plot, "3", xout + len2, yout, txtres)
    txtres@txJust = "TopCenter"
    gsn_text_ndc(plot, "6", xout, yout - len2, txtres)
    txtres@txJust = "CenterRight"
    gsn_text_ndc(plot, "9", xout - len2, yout, txtres)
    txtres@txJust = "BottomCenter"
    gsn_text_ndc(plot, "12", xout, yout + len2, txtres)

; circle
    rad = atan(1.0) / 45.
    npts = 361
    xcirc = new(npts, float)
    ycirc = xcirc
    xcirc = xout + len * cos(fspan(0, 360, npts) * rad)
    ycirc = yout + len * sin(fspan(0, 360, npts) * rad)

    gsn_polyline_ndc(wks, xcirc, ycirc, False)

    frame(wks)

end

密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-4-20 21:53:35 | 显示全部楼层
本帖最后由 longlivehj 于 2014-4-20 22:21 编辑

简单写了个示例,供你参考!
程序中头几行,lat和lon用于设定圆盘中心经纬度,len用于设定圆盘半径(NDC坐标,箭头长度会同步变化),fonthgt设置圆盘周围数字大小(NDC坐标)。
dir.png
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin
    lat = -30.
    lon = 90.

    len = .04

    fonthgt = .015

    wks = gsn_open_wks("png", "dir")

; map
    mapres = True
    mapres@gsnFrame = False

    plot = gsn_csm_map(wks, mapres)

; arrows
    u = (/10., 0., 0., -10./)
    v = (/0., 10., -10., 0./)

    latin = new(4, "float")
    lonin = latin
    latin(:) = lat
    lonin(:) = lon

    wmsetp("vrn", len)
    wmvectmap(wks, latin, lonin, u, v)

; text
    xout = 0.
    yout = 0.
    datatondc(plot, lon, lat, xout, yout)

    txtres = True
    txtres@txFontHeightF = fonthgt
    txtres@txJust = "CenterLeft"
    gsn_text_ndc(plot, "3", xout + len, yout, txtres)
    txtres@txJust = "TopCenter"
    gsn_text_ndc(plot, "6", xout, yout - len, txtres)
    txtres@txJust = "CenterRight"
    gsn_text_ndc(plot, "9", xout - len, yout, txtres)
    txtres@txJust = "BottomCenter"
    gsn_text_ndc(plot, "12", xout, yout + len, txtres)

; circle
    rad = atan(1.0) / 45.
    npts = 361
    xcirc = new(npts, float)
    ycirc = xcirc
    xcirc = xout + len * cos(fspan(0, 360, npts) * rad)
    ycirc = yout + len * sin(fspan(0, 360, npts) * rad)

    gsn_polyline_ndc(wks, xcirc, ycirc, False)

    frame(wks)

end

密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-4-20 16:51:38 | 显示全部楼层

回帖奖励 +5 金钱

原图的罗盘很简陋,看上去不像程序自动生成的,个人猜想是后期处理时补上去的,我只知道MATLAB和ArcGIS有类似的东西,LZ完全可以自己画一个在上面
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-4-20 16:58:53 | 显示全部楼层
沙颖凯 发表于 2014-4-20 16:51
原图的罗盘很简陋,看上去不像程序自动生成的,个人猜想是后期处理时补上去的,我只知道MATLAB和ArcGIS有类 ...

我也觉得后期处理一个上去很简单,要不把图里面这个截屏下来放上去也容易。但是这样担心会破坏图片的分辨率,变模糊了~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-20 20:45:53 | 显示全部楼层

回帖奖励 +5 金钱

你可以自己制作 物理量的风矢量,再画出来
自己设置12个u v 分别对应12个月份的矢量格式,就行了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-20 20:47:24 | 显示全部楼层

回帖奖励 +5 金钱

哦 看错问题了,圆盘只能自己花了 画4个箭头一个圆 4个数字 grads可以实现
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-20 21:06:08 | 显示全部楼层

回帖奖励 +5 金钱

虽然不知道想拿点金钱可以么?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-4-20 21:26:20 来自手机 | 显示全部楼层
lxlxllx89 发表于 2014-4-20 20:47
哦 看错问题了,圆盘只能自己花了 画4个箭头一个圆 4个数字 grads可以实现

grads的话就只有一个圆,一个数字的添加了吧~四个不同指向的剪头咋画?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-4-20 21:28:15 来自手机 | 显示全部楼层
阿木木 发表于 2014-4-20 21:06
虽然不知道想拿点金钱可以么?

关键时刻莫要捣蛋~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-21 09:39:39 | 显示全部楼层

回帖奖励 +5 金钱

9楼太牛了~~~
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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