爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5807|回复: 5

[作图] 关于ncl画图(grib2格式的数据,文件中指定是兰伯特投影)

[复制链接]

新浪微博达人勋

发表于 2016-8-17 15:00:47 | 显示全部楼层 |阅读模式

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

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

x

grib文件原件

grib文件原件

上图是grib2文件, 变量的结构,其中坐标变量有x,y(没有lon,lat)
但是grib2中指定了,这个是兰伯特投影,还有一些参数,这个图怎么画?

grib2转成nc文件

grib2转成nc文件

上图是grib2文件转成的nc文件,变量中有gridlon_0,gridlat_0(都是二维数组1801x1901),温度值也是一个二维数组(1801x1901)


画出来的图

画出来的图


上图是我尝试着画出来的,感觉不大对,



部分ncl代码: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/cnmap/cnmap.ncl"
;----------------------------------------------------------------------
; This function creates a cylindrical equidistant map of Australia
; so you you can add polylines, polygons, or point data to it later.
;----------------------------------------------------------------------

;----------------------------------------------------------------------
; Main code
;----------------------------------------------------------------------
begin

path = "/usr/local/ncl/NCL/nc_read/"  
filename = "out.nc"
path=path+filename
;------------------------------------------------------------------------------------------------------------------
;read data from grb
  a = addfile(path,"r")
  datas=a->TMP_P0_L103_GLC0
;-----------------------------------------------------------------------------------------------------------------
;--- Open workstation.
  xwks="png"
  wks = gsn_open_wks(xwks,"shapefiles")
  gsn_define_colormap(wks,"custom_grib2_20160817")
;============================================

  res               = True
  res@tfDoNDCOverlay=True
  res@gsnMaximize   = True
  res@gsnDraw       = False
  res@gsnFrame      = False

  res@mpOutlineOn   = True                 ;show outline (boundary)
  res@mpFillOn      = True  
  res@mpDataBaseVersion = "MediumRes"

res@cnFillOn                = True               
res@cnLineLabelsOn    = True             ; turn off contour lines
res@cnLevelSelectionMode = "ExplicitLevels"        
res@cnLevels=(/270.6,277.3,284.1,290.9,297.6,304.4,311.1/)
;---Turn on fancier tickmark labels.
  res@pmTickMarkDisplayMode = "Always"
;------------------------------------------------------------------------------------------------
  res@mpProjection="LambertConformal"
  res@mpLambertParallel1F = 30.
  res@mpLambertParallel2F = 60.
  res@mpLambertMeridianF = 102.

;---Zoom in on area of interest
  res@mpLimitMode = "Corners"
  res@tiMainString          = "         "           ;map name

;---------------------------------------------------------------------------------------------------------

;---Create map.
  map=gsn_csm_contour_map(wks,datas,res)

;=================================================
cnres           = True
cnres@china     = True       ;draw china map or not叠加中国边界(shp)

chinamap = add_china_map(wks,map,cnres)
;---Drawing the map will also draw the attached polygons.
  draw(map)
  frame(wks)
end
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-17 16:13:37 | 显示全部楼层
你这是用什么转的啊?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-17 17:07:07 | 显示全部楼层
1649518749 发表于 2016-8-17 16:13
你这是用什么转的啊?

用的是ncl官网的一个例子
后面的是代码:
begin
;***********************************************
; get variable names from grib file
;***********************************************
   path = "/usr/local/ncl/NCL/nc_read/data/"  
   ;filename = "WAFS_blended_2016080718f18.grib2"
   filename = "MSP3_PMSC_LAPS3KM_ME_L88_CHN_201607142000_00000-00000.grib2"
   path=path+filename

   grib_in  = addfile(path,"r")   
   names    = getfilevarnames(grib_in); extract all variable names
;***********************************************
; create output netcdf file
;***********************************************
  ; system("rm out.nc") ; remove any pre-existing file
   ncdf_out = addfile("out.nc" ,"c")       ; create output netCDF file
;***********************************************
; loop through variables and output each to netcdf
;***********************************************
   do i = 0, dimsizes(names)-1  
   ncdf_out->$names(i)$ = grib_in->$names(i)$
   end do   
end
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-10-8 21:34:03 | 显示全部楼层
谢谢{:5_213:}{:5_213:}{:5_213:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-10-20 16:23:24 | 显示全部楼层
你好  想问下  您这个  add_china_map  是自带吗  还是额外写的代码?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2024-4-24 16:00:28 | 显示全部楼层
请问关于这个问题你解决了吗?会用python 处理吗?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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