- 积分
- 2785
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-7-16
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位前辈,我想画一张垂直剖面随时间变化的图,大概是这样的效果
我画填色图用的命令是gsn_csm_contour,作图数据是二维数组,坐标是深度(行)和时间(列)。深度是不均匀的,比如第一行是0.4米,第二行是1米,第三行是10米。但是画出来发现它不识别我的垂直坐标,只是按行均匀的画图。
我在官网找了好久,只在 Data with 2D vertical coordinates 这里找到了一个类似的,照着改也能用。但对里面的
create
end create
以及gsnp_point_tickmarks_outward这个函数
不是很明白,然后也找不到相关的用法说明,希望有高手能指点一下
官网脚本如下
;**************************************************; 2dvertcoords.ncl;**************************************************; Concepts illustrated:; - Reading a C format data file; - Reordering variable dimensions; - Using the new color model; - Using NCL OOP statements;;**************************************************;; 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" ;**************************************************begin ;**************************************************; read in binary data;**************************************************; This setfileoption call assures the file is read; as a big endian file. This will happen by default; on a big endian machine.;************************************************** setfileoption("bin","ReadByteOrder","BigEndian") dims = (/3,4000,62/) data_array = cbinread("bin_output15_bigEndian",dims,"float") ;**************************************************; name variable dimensions, so we can reorder variable; and subscript.;************************************************** data_array!0 = "vars" ; variables (x-coord,z-coord,values) data_array!1 = "range" ; range off the shelf data_array!2 = "depth" ; depth d = data_array(vars|2,depth|:,range|:); d!0 = "depth"; d!1 = "cross_shelf";**************************************************; read in coordinates;************************************************** dims = (/2,4000,62/) coords = cbinread("bin_vgrid_bigEndian",dims,"float") coords!0 = "vcoords" ; name dimensions so we can reorder coords!1 = "range" coords!2 = "depth" range = coords(vcoords|0,depth|:,range|:); the challenge with this type of data is a two-dimensional vertical; coordinate. The gsn_csm high-level graphical interfaces can handle 2D ; lat/lon coordinates but are not currently adpated for 2D vertical coords. depth = coords(vcoords|1,depth|:,range|:);**************************************************; assign variable metadata;************************************************** wks = gsn_open_wks("png","2dvertcoords"); send graphics to PNG file res = True ; plot mods desired res@gsnMaximize = True res@sfXArray = range ; could be reduced to 1D res@sfYArray = depth ; 2D res@cnInfoLabelOn = False ; turn off contour info label res@cnFillOn = True ; turn on color res@cnFillPalette = "gui_default" ; set color map res@cnLineLabelsOn = False ; turn off line labels res@cnLinesOn = False ; turn off contour lines res@tiMainString = "original data (no tickmarks present)" ; add title res@lbOrientation = "vertical";; This first plot will produce a warning, which you can ignore.; The next plot will fix the problem.; plot = gsn_csm_contour(wks,d,res) ; contour the variable ; ; Linearize the plot by overlaying on a "logLinPlot" object. It's ; important to use the "curvilinear" grid type instead of the default ; 2D "spherical" grid type because the spherical grid type assumes ; that the X coordinates are modular and that the Y coordinates only ; range from -90 to 90. ; setvalues plot "trGridType" : "curvilinear" "tiMainString" : "linearized data" "tiXAxisString" : "Range across shelf (m)" ; x-axis title "tiYAxisString" : "Depth up from bottom (m)" ; y-axis title end setvalues ll = create "ll" logLinPlotClass wks "trXMinF" : min(range) "trXMaxF" : max(range) "trYMinF" : min(depth) "trYMaxF" : max(depth) "pmTickMarkDisplayMode" : "always" ; necessary in order to turn on tickmarks end create gsnp_point_tickmarks_outward(ll,False,-1.,-1.,-1.,-1.,-1.,-1.,True);; Overlaying the original plot on a "loglin" object will; linearize the axes.; overlay(ll, plot) draw(ll) frame(wks) end
|
|