2014年8月27日星期三

NCL 填色图笔记

现在不是那么烦NCL了,只是有一点烦,呵呵。

来自:http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/examples.shtml
以及http://blog.sina.com.cn/s/articlelist_1157087364_0_1.html


-------------------------------------------------------------------

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

begin

;-----------  基本必备的设置-----------------------------------------
  xwks = gsn_open_wks("x11","plot_name")      ; Open an X11 workstation.

  resources  = True       ; Indicate you want to set some
                                         ; resources.


;--------标题设定------------------
resources@tiMainString    = "Temperature (C)"  ; Create a title.
resources@tiMainString    = pres@long_name

resources@tiMainFont      = 26
resources@tiXAxisFont     = 26
resources@tiYAxisFont     = 26

;--------some useful settings-------------

 res@gsnMaximize        = True     ; maximize plot in frame

res@cnFillMode         = "MeshFill"   ; for faster draw 网眼填充
;--------坐标轴设定------------
  resources@tiXAxisString    = lon@long_name   ;x name
  resources@tiYAxisString    = lat@long_name   ;y name 注意这个@long_name的用法,很实用
  resources@sfXArray         = lon       ;指定X轴的变量
  resources@sfYArray         = lat


;-----------填色----------------------------------------

  resources@cnMonoLineColor = False      ; Turn off the drawing of
                                         ; contours lines in one color.
  resources@cnFillOn          = True        ; Turn on contour line fill.
  res@cnFillDrawOrder = "PreDraw"         ; draw contours first
  resources@cnMonoFillPattern = False       ; Turn off using a single fill
  resources@cnMonoFillPattern     = True     ; Turn solid fill back on.                                          ; pattern.

  resources@cnMonoFillColor   = True
  resources@cnMonoFillColor       = False    ; Use multiple colors.


  resources@cnMonoLineColor   = True


;使用特定的Level值和配色方案对等值区间进行设置
  res@cnLevelSelectionMode = "ExplicitLevels"       ; set explicit contour levels
  res@cnLevels    = (/-30.,-20.,-10.,0.,10.,20./) ; set levels
  res@cnFillColors = (/5,6,7,8,9,10,11/) ; set the colors to be used

;---------- Contour line ------------------------------------------


  resources@cnLineLabelsOn        = False    ; Turn off line labels.
  resources@cnInfoLabelOn         = False    ; Turn off informational
                                             ; label.
  resources@cnLinesOn             = False    ; Turn off contour lines. 等值线不显示

  resources@pmLabelBarDisplayMode = "Always" ; Turn on label bar.
  resources@lbPerimOn             = False    ; Turn off perimeter on
                                             ; label bar.




  plot = gsn_contour(xwks,Z,resources)    ; Draw a contour plot.

;---------- color map ------------------------------------------
;http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml


;---Using the color map to define colors for contours or vectors
  res@cnFillPalette = "BkBlAqGrYeOrReViWh200"
  res@vcLevelPalette = "BkBlAqGrYeOrReViWh200"

;---Reading the colormap into an N x 4 (RGBA) array
  cmap = read_colormap_file("ncl_default")

;---Using the color map to define a color map for the workstation
  gsn_define_colormap(wks,"BlueYellowRed")


;---define your own

  cmap = (/(/0.,0.,0./),(/1.,1.,1./),(/.1,.1,.1/),(/.15,.15,.15/),\
         (/.2,.2,.2/),(/.25,.25,.25/),(/.3,.3,.3/),(/.35,.35,.35/),\
         (/.4,.4,.4/),(/.45,.45,.45/),(/.5,.5,.5/),(/.55,.55,.55/),\
         (/.6,.6,.6/),(/.65,.65,.65/),(/.7,.7,.7/),(/.75,.75,.75/),\
         (/.8,.8,.8/),(/.85,.85,.85/)/)

  gsn_define_colormap(xwks,cmap)          ; Define a new color map.


;-----------------总算能绘图了-----------------------------------------------------
  plot = gsn_contour(xwks,pres,resources) ; Draw a contour plot.


;--------------叠加绘图的话------------------------------------------------------

gsn_csm_contour_map_overlay(wks,pdata,vdata,res,res2)

overlay(map,wplot) ;叠加plot给之前的map
  draw(map)

  delete(plot)       ; Clean up.
  delete(temp)
  delete(resources)
end

2014年8月4日星期一

关于学习以及个人提升

经常想不出中文的合适表达是怎么回事,难道以后我会变成那种中英文混杂的类型。。。。????

不管了,反正总算找个地方开始记录自己对这三年(or 两年半)的职业规划啦。

R 算是一个契机,让我好好地从头学习一门工具,虽然我会的也不少,但是精通的真的木有。

这个星期本身上课就够呛,结合课程内容,主要进行:统计分析和绘图两样(话说R的学习目标其实也就是这俩吧),入门知识掌握。

加油!休息五分钟后开始看分析,明天马上要用到了呢!