爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6581|回复: 7

[作图] NCL画南海子图颜色不匹配

[复制链接]

新浪微博达人勋

发表于 2020-9-25 14:49:08 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 xlilium 于 2020-9-26 08:32 编辑

各位好,使用了兰溪大神的脚本想画中国地图,由于想用Lambert投影所以对脚本进行了更改,但是在画南海小图的时候出了问题,小图的填充颜色和大图不符,想请问下应该如何解决呢?请各位大佬指点~谢谢

下面是我的部分代码:        
    var = wrf_user_getvar(a1, "xxx", -1)*1000   
    lat2d=a1[:]->XLAT(0,:,:)
    lon2d=a1[:]->XLONG(0,:,:)
    nlat=dimsizes(lat2d(:,0))
    nlon=dimsizes(lon2d(0,:))

    wks = gsn_open_wks("eps","./pictures/xxx")
    cmap = read_colormap_file("MPL_RdBu")

    res                      = True
    res@gsnDraw              = False
    res@gsnFrame             = False
    res@gsnMaximize          = True
    res@gsnAddCyclic         = False
    res@cnFillPalette = cmap(::-1,:)     ; reverse color map
    res@tfDoNDCOverlay      = "NDCViewport"

    res@cnFillOn             = True  
    res@cnLinesOn            = False
    res@cnFillDrawOrder      = "PreDraw"
    res@cnLevelSelectionMode = "ManualLevels"
    res@cnLevelSpacingF      = 0.5
    res@cnMaxLevelValF       = 4
    res@cnMinLevelValF       = -6

    ;---Contour levels to use.
    data_levels = (/-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4/)
    res@lbLabelStrings       = sprintf("%5.1f",data_levels)   ; Format the labelbar labels  

    res@lbOrientation        = "Vertical"
    res@tiMainOffsetYF        = -0.03           ; Move the title down
;
    res@tmYLLabelFontHeightF = 0.02
    res@tmXBLabelFontHeightF = 0.02
    res@tmXTOn  = False
    res@tmYROn  = False
    res@pmTickMarkDisplayMode = "Always"        ; nicer tickmarks

    res@mpProjection        = "LambertConformal"
    res@mpLambertParallel1F = 20.
    res@mpLambertParallel2F = 50.
    res@mpLambertMeridianF  = 105.5
    res@mpLimitMode         = "Corners"
    res@mpLeftCornerLatF    = lat2d(0,0)
    res@mpLeftCornerLonF    = lon2d(0,0)
    res@mpRightCornerLatF    = lat2d(nlat-1,nlon-1)
    res@mpRightCornerLonF    = lon2d(nlat-1,nlon-1)

    res@mpFillOn                   = True
    res@mpDataSetName              = "Earth..4"
    res@mpDataBaseVersion          = "MediumRes" ; or "Ncarg4_1"
    res@mpAreaMaskingOn            = True
    res@mpMaskAreaSpecifiers       = (/"China"/)
    res@mpOutlineSpecifiers        = (/"China","China:Provinces"/)
;
    res@mpLandFillColor            = "white"
    res@mpInlandWaterFillColor     = "white"
    res@mpOceanFillColor           = "white"
    res@mpFillBoundarySets         = "NoBoundaries"
    res@mpOutlineBoundarySets      = "NoBoundaries"
    res@mpNationalLineColor        = "black"
    res@mpProvincialLineColor      = "black"
    res@mpGeophysicalLineColor     = "black"
    res@mpGeophysicalLineThicknessF = 2
    res@mpNationalLineThicknessF   = 2
    res@mpProvincialLineThicknessF = 1
    res@mpGridAndLimbOn       = True
    res@mpGridLineColor       = "Grey"
    res@mpGridLatSpacingF     = 5
    res@mpGridLonSpacingF     = 5
    res@mpGridLineThicknessF  = 2
    res@mpGridMaskMode        = "MaskFillArea"

    map = gsn_csm_contour_map(wks,var,res)

  ;--- add South China Sea ---
    nhres                          = res
    nhres@gsnMaximize              = False
    nhres@vpHeightF                = 0.15   
    nhres@vpWidthF                 = 0.15

;若为以下四行则小图为大图的缩小版,并不是南海区域
    ;nhres@mpMinLatF                =   2.0   
    ;nhres@mpMaxLatF                =  23.0
    ;nhres@mpMinLonF                = 105.0
    ;nhres@mpMaxLonF                = 123.0

    nhres@mpRightCornerLonF        = 123.0
    nhres@mpRightCornerLatF        = 23.0
    nhres@mpLeftCornerLonF         = 105.0
    nhres@mpLeftCornerLatF         = 2.0

;
    nhres@mpGridAndLimbOn          = False
    nhres@mpOutlineOn              = True
    nhres@lbLabelBarOn             = False
    nhres@tmXBOn                   = False
    nhres@tmXTOn                   = False
    nhres@tmYLOn                   = False
    nhres@tmYROn                   = False
    nhres@gsnLeftString            = ""
    nhres@gsnRightString           = ""
    nhres@cnLineLabelsOn       = False

    map_nanhai = gsn_csm_contour_map(wks,var,nhres)

    adres                          = True
    adres@amParallelPosF           = 0.5 ; -0.5 is the left edge of the plot.0.495
    adres@amOrthogonalPosF         = 0.5  ; -0.5 is the top edge of the plot.0.49
    adres@amJust                   = "BottomRight"
    plotnh = gsn_add_annotation(map,map_nanhai,adres)

出图:



F1.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2020-9-25 15:02:20 | 显示全部楼层
本帖最后由 xlilium 于 2020-9-25 15:10 编辑

如果修改以下2行看看其他地方的填充:
    nhres@mpRightCornerLatF
    nhres@mpLeftCornerLatF
发现整个就是不对,求指点~~
test.jpg
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 成长值: 0
发表于 2020-9-26 00:11:39 | 显示全部楼层

回帖奖励 +5 金钱

帮你顶一顶
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-9-26 09:00:33 | 显示全部楼层

回帖奖励 +5 金钱

应该是南海小图取值间隔不一样,对应色标的范围也就不一样,可以尝试手动把两个图的间隔调成一致的
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-9-26 10:03:22 | 显示全部楼层
尽头的尽头 发表于 2020-9-26 09:00
应该是南海小图取值间隔不一样,对应色标的范围也就不一样,可以尝试手动把两个图的间隔调成一致的

你好,谢谢回复!
我试过的,出来还是这样,而且我设置了nhres=res呀,print(nhres)后显示间隔也是大图那样的
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-9-26 11:00:57 | 显示全部楼层
请问楼主解决了吗?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-9-26 17:02:06 | 显示全部楼层
杰西卡·芬 发表于 2020-9-26 11:00
请问楼主解决了吗?

还没有,打算小图不填充颜色了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-9-29 09:34:06 | 显示全部楼层
nhres@mpAreaMaskingOn            = False   ;设为为False,小地图才会覆盖底图

你试试加上这句
DIV.png
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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