爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4905|回复: 1

[作图] 等值线不显示

[复制链接]

新浪微博达人勋

发表于 2017-7-12 10:45:39 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 ekateril 于 2017-7-12 11:06 编辑

为什么等值线不显示呢?等值线属性开关都打开了,运行脚本会短暂出现黑白等值线的图,并且快速闪动一下而过,最终显示如下第一幅图,目标图为第二幅图

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
;;;;
;;; read data from grib file
;;;;
    ;outfile = "$NCARG_ROOT/temp"
    grib_file="/home/yama/0616.grib1"
    fin = addfile(grib_file,"r")
    ;printVarSummary(fin)
;;; get variables: temperature, longitude, latitude

    P = fin->SWVL1_GDS0_DBLY
    P = P*10
    ;printMinMax(P, 0)
;;;;
    wks = gsn_open_wks("x11","pic")    ; open wk station
    gsn_define_colormap(wks,"prcp_1")  ; load color table

;;; Font Style
    res1                              = True                                   ; plots modification on ; plot mods desired
    res1@gsnDraw               = False
    res1@gsnFrame             = False
    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         = "6h_Precipitation"
    res1@gsnRightString       = "2017/06/16/00(UTC)"          ;~S~o~N~C:表示温度单位℃
    res1@gsnMaximize          = True
   
    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@mpOutlineSpecifiers     = (/"Land"/)            ;
    res1@mpOceanFillColor       = 0                           ;用变色填充海洋 0是clormap的索引值
    ;res1@mpInlandWaterFillColor = 0                             ;用蓝色填充内陆湖水
    res1@mpLandFillColor        = 0

    res1@cnFillOn              = True             ; turn on color fill  
    res1@cnLinesOn             = True            ; turn on contour lines 显示等值线
    res1@cnLineLabelsOn        = True
    res1@cnInfoLabelOn         = False
    res1@cnLineLabelInterval   =  1
    res1@cnLineDrawOrder       = "PreDraw"        ; draw contour first
    ;res1@cnFillMode            = "RasterFill"
    res1@cnLevelSelectionMode  = "ExplicitLevels"    ; set explicit contour levels
    ;res1@cnMinLevelValF        = 1.              ;set min contour level
    ;res1@cnMaxLevelValF        = 120.              ; set max contour level
    ;res1@cnLevelSpacingF       =  2.              ; set contour spacing
    res1@cnInfoLabelOrthogonalPosF = -0.07
    ;res1@cnFillPalette          = "prcp_1"
    ;res1@cnLineLabelFormat      = "@^sg"
    res1@lbOrientation          = "Vertical"
    res1@tmXTOn                 = False
    res1@tmYROn                 = False
    res1@tmXBLabelFontHeightF   = 0.035
    res1@tmYLLabelFontHeightF   = 0.0
   
    ;;; color fill tresholds and colors 设置图例的配色方案
  
    res1@cnLevels               = (/1,4,13,25,60,120/)            ; set levels

    res1@cnFillColors           = (/2,6,8,4,5,16,15/)   ; 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
;--- add Changjiang and Huanghe river ---
    river                          = True
    river@gsLineThicknessF         = 1.0      
    river@gsLineColor              = "grey"

    plot  = gsn_csm_contour_map(wks, P, res1) ; create the plot
    plotrv = gsn_add_shapefile_polylines(wks,plot,"./river.nc",river)
    ;plot1 = gsn_csm_contour_map(wks, pressure, res2)
    ;overlay(plot, plot1)
    draw(plot)
    frame(wks)  
end
2.png 1.png

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

新浪微博达人勋

发表于 2017-7-14 17:00:08 | 显示全部楼层
res1@cnLineDrawOrder       = "PreDraw"        ; draw contour first ?会不会是这句话引起的
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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