请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9684|回复: 6

[作图] NCL绘图问题

[复制链接]

新浪微博达人勋

发表于 2017-6-27 17:03:35 | 显示全部楼层 |阅读模式

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

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

x
请教下如何绘制图2那种效果图,始终没找到合适的属性,图1为画出的实际效果图,对比图2少了很多东西,代码如下:

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"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
;***************************************

begin
;;;;
;;; read data from grib file
;;;;
    ;outfile = "$NCARG_ROOT/temp"
    grib_file="/home/0616.grib1"
    fin = addfile(grib_file,"r")
    ;printVarSummary(fin)
;;; get variables: temperature, longitude, latitude

    t2m = fin->2T_GDS0_SFC              ;加载欧洲中心数据绘制 2m 温度图
    lat = fin->g0_lat_0
    lot = fin->g0_lon_1
         

;;; prepare

    t2m = t2m-273.15    ; degrees

;;;;
    wks = gsn_open_wks("png","temperature_0616")    ; open wk station
    gsn_define_colormap(wks,"BkBlAqGrYeOrReViWh200")  ; load color table

;;; Font Style
    res1                 = True                                   ; plots modification on ; plot mods desired
    res1@txFont          = "Helvetica"
    res1@txFontQuality   = "High"

;;; Title 设置图片标题
    res1@tiMainFont           = "Helvetica"
    res1@tiMainOffsetYF       = 0.02                          ;set place for main title alongY,offset
    res1@tiMainFontHeightF    = 0.02                          ;set main title fontsize
    res1@gsnLeftString        = "2m Temperature"
    res1@gsnRightString       = "2017/06/16/00(UTC)"                       ;~S~o~N~C:表示温度单位℃
    res1@gsnMaximize          = True
    res1@gsnDraw              = False
    res1@gsnFrame             = False
    res1@gsnSpreadColors      = True
    res1@pmTickMarkDisplayMode = "Always"
    res1@mpGridAndLimbOn       = True                    ; open grid
    res1@mpGridLineDashPattern = 10
    res1@mpGridLatSpacingF     = 20
    res1@mpGridLineThicknessF   = 1.0
    res1@mpGridLineColor       = "grey"
    res1@mpGridLatSpacingF     = 20
    res1@mpGridLonSpacingF     = 20
   
    res1@mpOutlineOn           = True                     ; draw map outlines
    res1@mpFillOn              = True   
    res1@mpDataSetName         = "Earth..4"               ; high resolution
    res1@mpDataBaseVersion     = "MediumRes"      
   
    res1@mpProvincialLineColor  = 0
    res1@mpCountyLineColor      = 2
    ;设置经纬度范围,亚洲范围经纬度
    res1@mpLimitMode             = "latlon"
    res1@mpMinLatF               = 7               
    res1@mpMaxLatF               = 50
    res1@mpMinLonF               = 90
    res1@mpMaxLonF               = 135
    res1@mpOutlineSpecifiers     = (/"China:states"/)
    res1@mpGeophysicalLineColor  = "grey"       ; color of cont. outlines
                                                ; thickness of outlines
    ;加粗边界线。
    res1@mpGeophysicalLineThicknessF  = 1.         ; double the thickness of geophysical boundaries
    ;res1@mpNationalLineThicknessF    = 1.        ; double the thickness of national boundaries
  
    res1@gsnAddCyclic          = False             ; data already has cyclic point;为false表示不循环地球一周
                                                   ; this must also be set for any zoom
    res1@mpProjection          = "LambertConformal" ;兰伯特投影
    res1@mpLambertMeridianF    = 110
    res1@mpLambertParallel1F   = .001              ;default:.001
    res1@mpLambertParallel2F   = 89.999            ;default:89.999
   
   

    res1@mpAreaMaskingOn        = True                          ;是表示能填充覆盖
    res1@mpMaskAreaSpecifiers   = (/"China:states"/)            ;China:states
    ;res1@mpOceanFillColor       = 0                           ;用变色填充海洋 0是clormap的索引值
    ;res1@mpInlandWaterFillColor = 0                             ;用蓝色填充内陆湖水
    res1@mpLandFillColor        = 0



    res1@cnFillOn              = True             ; turn on color fill  
    res1@cnLinesOn             = False            ; turn off contour lines 显示等值线
    res1@cnInfoLabelOn         = False
    res1@cnLineLabelInterval   =  1
    res1@cnFillDrawOrder       = "PreDraw"        ; draw contour first
    res1@cnLevelSelectionMode = "ExplicitLevels"    ; set explicit contour levels
    res1@cnMinLevelValF        = -4.              ;set min contour level
    res1@cnMaxLevelValF        = 40.              ; set max contour level
    res1@cnLevelSpacingF       =  2.              ; set contour spacing
    res1@cnInfoLabelOrthogonalPosF = -0.07

    res1@lbOrientation         = "Vertical"
    res1@tmXTOn                 = False
    res1@tmYROn                 = False
    res1@tmXBLabelFontHeightF   = 0.035
    res1@tmYLLabelFontHeightF   = 0.0
   
    res1@cnLevels    = (/-4.,-2.,0.,2.,4.,6.,30.,32.,\
                                  34.,36.,38.,40./)   ; set levels

    res1@cnFillColors = (/ 35,39,63,48,53,61,0,99,123,\
                           130,135,143,150/)    ; set the colors to be used

    res1@pmLabelBarDisplayMode = "Always"            ; turns on label bar
    res1@lbLabelAutoStride     = True
    res1@pmLabelBarWidthF      = 0.1
    res1@pmLabelBarHeightF     = 0.55
    res1@lbLabelFontHeightF    = 0.015
    res1@lbPerimOn             = False
    res1@lbLabelFont           = "Helvetica"         ; label font
    res1@lbLabelStride         = 1
    res1@lbTitleOn             = False                                   ; turn on title
    res1@lbLabelStrings        = (/"-4","-2","0","2","4","6","30","32",\
                                  "34","36","38","40"/)   
    txres               = True         ; additional info
    txres@txFontHeightF = 0.015        ; size of meta data
    txres@txJust        = "CenterRight"
    gsn_text_ndc  (wks,"Valid Time:2017/06/16/00 + 024hrs" \
                     ,0.85 , 0.12, txres)   ; note when plotted
    txres@txFontHeightF = 0.015        ; size of meta data
    txres@txJust        = "CenterLeft"
   
    gsn_text_ndc  (wks,"FINE ECMWF 0.125~S~o~N~C*0.125~S~o~N~C" \
                     ,0.20 , 0.12, txres)   ; note when plotted
  
    plot = gsn_csm_contour_map_ce(wks, t2m, res1) ; create the plot
;--- add Changjiang and Huanghe river ---
     river                          = True
     river@gsLineThicknessF         = 1.0      
     river@gsLineColor              = "grey"
     plotrv = gsn_add_shapefile_polylines(wks,plot,"./river.nc",river)
     draw(plot)
     frame(wks)
     end

图1

图1

图1


图2

图2

图2


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

新浪微博达人勋

发表于 2017-6-28 10:41:22 | 显示全部楼层
图二显然只是多了等值线吧,楼主在阴影的基础上加上等值线就好啦
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-28 13:54:08 | 显示全部楼层
贫道敬孔 发表于 2017-6-28 10:41
图二显然只是多了等值线吧,楼主在阴影的基础上加上等值线就好啦

加了等值线代码还是不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-28 15:28:30 | 显示全部楼层
贫道敬孔 发表于 2017-6-28 10:41
图二显然只是多了等值线吧,楼主在阴影的基础上加上等值线就好啦

如何添加,谢谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-3 10:54:15 | 显示全部楼层
填色部分其实只有6以下啊,6到30是白色,原图的等值线是8到28的线,加等值线是加这8 12 16 20 24 28这几条线
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-3 15:30:22 | 显示全部楼层
{:5_275:}{:5_275:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-7-4 15:05:09 | 显示全部楼层
看青藏高原地区,有0.-4.4的等值线,所以等值线应该是数值全画,数值间隔为4,颜色为rainbow类的?
  res@cnLinesOn  = True ; 打开线条  对应你的程序中的   res1@cnLinesOn             = False            ; turn off contour lines 显示等值线
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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