- 积分
- 1898
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-20
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 朝夕木兰 于 2015-10-27 09:16 编辑
ncl 画时间-经度图,大家可能会和我一样碰到时间坐标转换的问题。将时间转换,并且显示在图上,主要需要两部分命令。
一是加载 load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
二是坐标轴转换
restick = True
restick@ttmFormat = "%Y"
restick@ttmAxis = "YL"
restick@ttmMajorStride = 30
time_axis_labels( var&time, res, restick )
代码贴出来供大家参考。
- ; ===========================================
- ; hov.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/csm/shea_util.ncl"
- load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
- ; ===========================================
- begin
- f = addfile("sst_ff.nc", "r")
- var = f->sst(:,10,:)
- ;time = cd_calendar(f->time,-1)
- ;print (time)
- ;==============================================
- ; create color plot
- ;=============================================
- wks = gsn_open_wks ("x11", "sst" ) ; open ps file
- gsn_define_colormap(wks,"BlWhRe") ; choose colormap
- res = True ; plot mods desired
- res@cnFillOn = True ; turn on color fill
- res@trYReverse = True ; reverses y-axis
- ;------------------time convert for axis-----------------
- restick = True
- restick@ttmFormat = "%Y"
- restick@ttmAxis = "YL"
- restick@ttmMajorStride = 30
- time_axis_labels( var&time, res, restick )
- ;---------------- modulate details -----------------------
- res@gsnStringFont = "helvetica"
- res@tmXBLabelFont = "helvetica"
- res@tmYLLabelFont = "helvetica"
- res@gsnSpreadColors = True ; use full range of colors
- res@lbOrientation = "vertical"
- res@lbLabelFont = "helvetica"
- res@lbLabelFontHeightF = 0.02
- res@tiYAxisString = "Year"
- res@tiYAxisFont = "helvetica"
- ;-----------------------plot-----------------------------
- plot = gsn_csm_hov(wks, var, res)
- end
复制代码
|
评分
-
查看全部评分
|