爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7262|回复: 3

wrf_times_c,time_axis_labels的用法

[复制链接]
发表于 2015-9-14 11:16:48 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 自己画横坐标,想直接用wrfout的时间来做横坐标,从网站上找到这个例子,看了函数讲解自己试着用了一下,还有一些不懂的
time_axis_labels(times,res,restick)怎么把wrf_times_c提取出来的时间数列转化啊,还有wrf_times_c的四种opt,0、1、2、3提取出来的时间格式都可以用time_axis_labels转化吗?
我看过提问的智慧: 看过
自己思考时长(天): 3

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

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

x
自己画横坐标,想直接用wrfout的时间来做横坐标,从网站上找到这个例子(如下),看了函数讲解自己试着用了一下,还有一些不懂的

time_axis_labels(times,res,restick)怎么把wrf_times_c提取出来的时间数列转化啊,还有wrf_times_c的四种opt,0、1、2、3提取出来的时间格式都可以用time_axis_labels转化吗?
我自己在例子的基础上改的,提取每个wrfout数据的前24个时间序列并把它们连起来,用time_axis_labels,wrf_times_c画图,提示fatal:Argument type mismatch on argument (0) of (time_axis_labels) can not coerce

可能是我对这两个函数还不是很熟悉,不知道问题出在哪了,求大神指点迷津

--------------------------------------------------------
; time_labels_3.ncl
;
; Concepts illustrated:
;   - Drawing a time series plot
;   - Labeling the X axis with nicely-formatted time labels
;   - Converting WRF Times variable to numeric values
;   - Removing trailing zeros from tickmark labels
;   - Changing the width and height of a plot
;----------------------------------------------------------------------
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
begin
;---Get some data to plot
  filename = "wrfout_d01_000000_25time.nc"
  a        = addfile(filename,"r")
  slp      = wrf_user_getvar(a,"slp",-1)   ; sea level pressure
  slp_avg  = dim_avg_n_Wrap(slp,(/1,2/))   ; Average across all lat/lon
;--------------------------------------------------
; The "Times" on the file are in the format:
;
;   2001-06-11_12:00:00
;   2001-06-11_13:00:00
;     ...
;
; Convert this to values representing
;   "hours since 2001-06-11 12:00:00"
;--------------------------------------------------
  times  = wrf_times_c(a->Times,0)
  ntimes = dimsizes(times)
;---Start the graphics
  wks = gsn_open_wks("ps","time_labels")
;---Plotting options for time series plot
  res             = True
  res@gsnMaximize = True
  res@vpWidthF    = 0.8
  res@vpHeightF   = 0.3
  res@tmXTOn      = False
  res@tmYLFormat  = "f"      ; remove trailing ".0"
;--------------------------------------------------
; The time_axis_label function adds additional
; resources to "res" to produce nicely-formatted
; time labels on X axis. This function only works
; if you have a time "units" recognized by the
; cd_calendar function.
;--------------------------------------------------
  restick           = True
  restick@ttmFormat = "%N/%D %H:%M"
  time_axis_labels(times,res,restick)
  ;print(res)
  res@tiMainString       = filename
  res@tiYAxisString      = "Average slp (" + slp_avg@units + ")"
  res@tiMainFontHeightF  = 0.025
  res@tiYAxisFontHeightF = 0.02
  plot = gsn_csm_xy(wks,times,slp_avg,res)
end
密码修改失败请联系微信:mofangbao
发表于 2015-9-14 12:20:21 | 显示全部楼层
This variable should have an attribute named "units". In other words, this variable holds the values of the coordinate axis 'time' along with the units.
时间变量。。。应该不是直接用浮点数就行的吧。。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-9-14 14:14:11 | 显示全部楼层
lxc0818 发表于 2015-9-14 12:20
This variable should have an attribute named "units". In other words, this variable holds the value ...

那该怎么用,例子里就直接提取用了,不知道该怎么改
密码修改失败请联系微信:mofangbao
发表于 2015-9-14 19:14:12 | 显示全部楼层
黄小仙儿 发表于 2015-9-14 14:14
那该怎么用,例子里就直接提取用了,不知道该怎么改

是不是要写一个
times@units=啥啥啥。。
我也没改过时间。。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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