爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5944|回复: 4

[作图] 请高手指导利用fnl资料画散度图

[复制链接]

新浪微博达人勋

发表于 2019-2-24 18:41:18 | 显示全部楼层 |阅读模式

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

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

x
NCL小白,在官网上看到计算散度的例子(http://www.ncl.ucar.edu/Applications/Scripts/wind_5.ncl),经过努力修改终于出图,但却不知道对不对,两个图哪个是平时个例分析用的散度,敬请高手指导!附脚本:
;*************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; 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
;*************************************************
; open file and read in data: data are on a gaussian grid
;*************************************************
  f    = addfile (".\fnl_20180730_18_00.grib2", "r")
  u    = short2flt(f->UGRD_P0_L100_GLL0({30000},:,:))              ; (time,lev,lat,lon)

  v    = short2flt(f->VGRD_P0_L100_GLL0({30000},:,:))

lat = f->lat_0
lon = f->lon_0
;*************************************************
; Reorder from N-S to S->N
;*************************************************
  ;u    = u(:,:,::-1,:)
  ;v    = v(:,:,::-1,:)
  printVarSummary(u)
  printVarSummary(v)

;*************************************************
; calculate divergence on a gaussian grid
; divs - spherical harmonics
; divf - finite difference
;*************************************************
  divs = uv2dvG_Wrap(u,v)               
  divs@long_name = "divergence: uv2dvG"
  print("divs: min="+min(divs)+"  max="+max(divs))
  printVarSummary(divs)
  divf = uv2dv_cfd (u,v,lat,lon, 3)
  copy_VarCoords(u,divf)
  divf@long_name = "divergence: uv2dv_cfd"
  print("divf: min="+min(divf)+"  max="+max(divf))
printVarSummary(divf)

;*************************************************
; plot results
;*************************************************   
  wks  = gsn_open_wks("png","wind")             ; send graphics to PNG file

  plot = new(2,graphic)                         ; create a plot array

  res                      = True
  res@mpMaxLatF            =60
  res@mpMinLatF            =15
  res@mpMaxLonF            =140
  res@mpMinLonF            =70
  res@pmTickMarkDisplayMode = "Always"
  res@mpFillOn                = True
  res@mpOutlineOn             = False  ; Use outlines from shapefile

  res@mpDataSetName               = "Earth..4"
res@mpDataBaseVersion           = "MediumRes"
res@mpOutlineOn                 = True
res@mpOutlineSpecifiers         = (/"China:states","Taiwan"/)
res@mpGeophysicalLineThicknessF = 2
res@mpNationalLineThicknessF    = 2
res@mpFillOn                    = True
res@mpFillAreaSpecifiers        = (/"water",       "land" /)
res@mpSpecifiedFillColors       = (/"skyblue1","white"/)
; res@mpSpecifiedFillColors      = (/100,0/)
res@mpMaskAreaSpecifiers        = (/"China:states","Taiwan"/)
res@pmTickMarkDisplayMode         = "Always"  

  res@gsnDraw              = False              ; don't draw
  res@gsnFrame             = False              ; don't advance frame

  res@cnFillOn             = True               ; color on (default for 6.1.0 onward)  
  res@cnFillPalette        = "BlAqGrYeOrRe"      ; set color map
  res@cnLinesOn            = False              ; turn off contour lines
  res@cnLineLabelsOn       = False              ; turn off contour line labels
  ;res@cnFillMode           = "RasterFill"      
  res@cnInfoLabelOn        = False              ; turn off cn info label
  res@lbLabelBarOn         = False             ; turn off individual cb's

; to have a common label bar, both plots should be set to the same interval
; b/c the label bar is drawn by default from the interval of the first plot.
; Here, the levels are set manually

  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF       = -3e-05   
  res@cnMaxLevelValF       =  3e-05   
  res@cnLevelSpacingF      =  1e-06  
  ;res@lbLabelStrings= sprintf(“%4.1f”,ispan(-3e-05,3e-05,1e-06))
  res@lbBoxEndCapStyle ="TriangleBothEnds"
  ;res@cnFillPalette ="BlueWhiteOrangeRed"; 选择中间带白色的彩色地图

  nt      =0                                       ; plot 1st time step only
  plev    = 700
  ;res@gsnCenterString = plev+"hPa"
  ;plot(0) = gsn_csm_contour_map(wks,divs(20:50,60:120),res)
  ;plot(1) = gsn_csm_contour_map(wks,divf(20:50,60:120),res)

  plot(0) = gsn_csm_contour_map(wks,divs(:,:),res)
  plot(1) = gsn_csm_contour_map(wks,divf(:,:),res)
;************************************************
; create panel
;************************************************
  resP                     = True                ; modify the panel plot
  resP@gsnPanelMainString  = "Insert your own title here"
  resP@gsnMaximize         = True                ; make ps, eps, pdf large
  resP@gsnPanelLabelBar    = True                ; add common colorbar


  gsn_panel(wks,plot,(/2,1/),resP)               ; now draw as one plot


  ;draw(plot)  
  ;frame(wks)

end


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

新浪微博达人勋

 楼主| 发表于 2019-2-24 22:25:29 | 显示全部楼层
自己先顶起来,请各位高手不吝指导
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-2-25 08:39:20 | 显示全部楼层
http://www.ncl.ucar.edu/Document ... -in/uv2dv_cfd.shtml
官网上是这么说的:
If the data are global and no missing values are present then it is highly recommended that the spherical harmonic functions uv2dvG and uv2dvF be used. They are more accurate.
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-2-25 15:19:48 | 显示全部楼层
我不喜欢吃生姜 发表于 2019-2-25 08:39
http://www.ncl.ucar.edu/Document/Functions/Built-in/uv2dv_cfd.shtml
官网上是这么说的:
If the data ...

感谢指导,给了我信心
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-5-14 16:13:57 | 显示全部楼层
请问解决了吗 应该用哪个函数呀
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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