- 积分
- 1888
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-3-10
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
今天使用NCL读取AMO和PDO的txt数据文件,并绘制时间序列图。
数据结构如下:列是月份,行是年份
提取的代码如下:
begin
DIR = "/share/home/guowd/kangzj/Scripts/NCLHub/PDO/"
MYFILES = systemfunc("ls " + DIR +"*.txt")
AMO_FILE = MYFILES(0)
PDO_FILE = MYFILES(1)
AMO_RD = asciiread(AMO_FILE,-1,"string")
PDO_RD = asciiread(PDO_FILE,-1,"string")
;processing the raw data
nfields = str_fields_count(AMO_RD(1)," ")
AMO_my = new((/67,12/),float)
PDO_my = new((/67,12/),float)
do i=0,11
AMO_my(:,i) = stringtofloat(str_get_field(AMO_RD(1:67),i+2," "))
PDO_my(:,i) = stringtofloat(str_get_field(PDO_RD(1:67),i+2," "))
end do
; resource settings
x_array = fspan(1948,2014,804)
wks = gsn_open_wks("png","AMO")
;plot 1
res = True
res@gsnMaximize = True
res@vpWidthF = 0.8
res@vpHeightF = 0.4
res@xyLineThicknessF = 3.5
res@xyDashPattern = 0.0
res@xyLineColor = "red"
res@trXMaxF = max(x_array)
res@trXMinF = min(x_array)
;set X Labels
res@tmXBMode = "Explicit"
res@tmXBValues = (/1948,1958,1968,1978,1988,1998,2008/)
res@tmXBLabels = "" + res@tmXBValues
res@tiMainString = "Atlantic multidecadal Oscillation Index from 1948 to 2014"
res@tiMainFontHeightF = 0.022
;res@gsnLeftString = "AMO Index"
plot = gsn_csm_xy(wks,x_array,reshape(AMO_my,804),res)
end
出的图如下:
|
|