爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 11227|回复: 2

[作图] 绘制wrf数据,图和绘制的地图边框不匹配

[复制链接]

新浪微博达人勋

发表于 2020-12-11 16:17:32 | 显示全部楼层 |阅读模式

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

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

x

                               
登录/注册后可看大图

如图,地图边框正常显示,但是图变得特别小。
脚本如下:
; -----------------------------------------------------------------------------------
; this file is used to draw the wind field for vertical vorticity and horizontal wind
;------------------------------------------------------------------------------------
begin
    f1 = addfile("./wrfout_d05_2016-06-23_07_02_00.nc", "r")
    wks = gsn_open_wks("png", "/share/home/mxue/whuang/whuang/yancheng/0702_vor_try")
    ; So get the XY points of these points
    lats = (/  34.096,  34.113 /)
    lons = (/ 118.575, 118.605/)
    loc = wrf_user_ll_to_ij(f1, lons, lats, True)

    ; loc(0,;) is west-east (x) ; loc(1,:) is south-north (y)
    ; subtract one since we want to use it as an index in NCL
    ; subtract five since the projection is lambert, we need fiil the domain
    x_start = loc(0,0) - 1 - 5
    x_end   = loc(0,1) - 1 + 5
    y_start = loc(1,0) - 1 - 5
    y_end   = loc(1,1) - 1 + 5

    ;--------------------------------
    ;----read the data
    ;--------------------------------
    ;--vertical vorticity
    lon2d = f1->XLONG(0, y_start:y_end, x_start:x_end)
    lat2d = f1->XLAT(0, y_start:y_end, x_start:x_end)
    avo = wrf_user_getvar(f1, "avo", 0)
    avo_zoom = avo(0, y_start:y_end, x_start:x_end)
    delete(avo)
    avo_zoom@lat2d = lat2d
    avo_zoom@lon2d = lon2d
    avo_zoom_expand = avo_zoom*10^(-5)
    copy_VarMeta(avo_zoom, avo_zoom_expand)
    avo_zoom_expand@units = "s -1"
    ;--u and v
    u = wrf_user_getvar(f1, "ua", 0)
    v = wrf_user_getvar(f1, "va", 0)
    u_zoom = u(0, y_start:y_end, x_start:x_end)
    delete(u)
    u_zoom@lat2d = lat2d
    u_zoom@lon2d = lon2d
    v_zoom = v(0, y_start:y_end, x_start:x_end)
    delete(v)
    v_zoom@lat2d = lat2d
    v_zoom@lon2d = lon2d
    ;print(any(ismissing(v_zoom)))
    ;print(any(ismissing(u_zoom)))

    ;---------------------------------
    ;-----begin to draw
    ;---------------------------------
    mpres = True
    ;mpres@mpShapeMode      = "FreeAspect"
    mpres@gsnFrame          = False
    mpres@gsnDraw           = False
    mpres@mpMinLatF         = lats(0)
    mpres@mpMaxLatF         = lats(1)
    mpres@mpMinLonF         = lons(0)
    mpres@mpMaxLonF         = lons(1)
    mpres@mpFillOn          = False
   
    mpres = wrf_map_resources(f1,mpres) ; Set the map resources needed for native projection
    mpres@tfDoNDCOverlay    = True          ; Tell NCL you are doing a native plot
    ;mpres@gsnMinorLonSpacing   = 10
    map = gsn_csm_map(wks, mpres)

    res = True
    ;res@vpHeightF          = 0.6
    ;res@vpWidthF           = 0.6
    res@gsnDraw             = False
    res@gsnFrame            = False
    res@cnFillOn            = True
    res@lbLabelBarOn        = True
    ;res@mpFillDrawOrder    = "Predraw"
    res@cnFillPalette       = "WhiteBlueGreenYellowRed"
    ;res@pmTickMarkDisplayMode = "Always"
    res@cnFillDrawOrder     = "PostDraw"
    contour = gsn_csm_contour(wks, avo_zoom_expand, res)

    overlay(map, contour)
    draw(map)
    frame(wks)

end
一开始使用的是直接用gsn_csm_contour_map绘制(除此以外都是设置一样的),图形就能正常绘制。
这里展示的是先画地图,再画contour,将两者overlay,就出现上述错误。
之所以要换成这种方式绘图,是因为我想contour和vector(CurlyVector)叠加在一起,使用的是gsn_csm_contour_map+gsn_csm_vector,
但是绘制不出CurlyVector,而FillArrow就能绘制,所以按照官网的例子想要绘制出两者叠加在一起的图,官网使用的就是gsn_csm_map+
gsn_csm_contour+gsn_csm_vector。
我和官网的例子反复对照了也没有发现什么错误,希望有哪位大神能帮忙解决。







QQ图片20201211160643.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2020-12-11 21:37:57 | 显示全部楼层
我找到解决的办法了,加上mpres@mpLimitMode       = "LatLon"就可以了
但是还是无法解决画不了流线的问题,用不同的数据基本上类似的脚本就可以画出流线,真是让我很疑惑
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-3-19 14:23:05 | 显示全部楼层
感谢,之前一直调整经纬度画图也修改不了,解决了我的问题
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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