- 积分
- 5997
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-3-7
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
学了ncl也有快两年时间了,这是我从来没涉足的问题.单纯的如果读一个文件进行循环照葫芦画瓢我还行.现在是读多个文件,文件行数不一样,列是一样的话,画不同文件的轨迹,我就犯了难了,一下是我个人的困难和思考,希望大家予以指导!
画一个文件的轨迹图
- begin
- wks = gsn_open_wks("png","traj1") ; send graphics to PNG file
- data=asciiread("1.txt", (/38,13/), "float")
- lon = data(:,2)
- lat = data(:,3)
-
- res = True ; plot mods desired
- res@gsnFrame = False ; don't advance yet
- res@gsnMaximize = True
- res@gsnDraw = False ; so we can add poly stuff
- res@mpDataBaseVersion = "MediumRes" ;
- res@mpPerimOn = False ;-- don't draw the box around the plot
- res@gsnPolar="SH"
- res@mpCenterLonF = 0 ;-- center at lon=10
- res@mpMaxLatF = -30
- res@mpGridLineColor = "grey30" ;-- set grid line color
- res@tiMainString = "" ;
- res@gsnCenterString = "" ; center string
- res@mpFillOn = False ; 打开之后线才会显现
- res@mpOutlineOn = True ; turn on continental outline打开后图变清晰了
- map = gsn_csm_map(wks,res) ; gsn_csm_map_ce
- pres = True ; polyline resources
- pres@gsLineThicknessF = 2.0 ; line thickness
-
- pres@gsLineColor = "red"
- gsn_polyline(wks,map,lon,lat,pres) ; draw the traj
- draw(map)
- frame(wks)
-
- end
复制代码 如果读多个文件呢,行数不一样,如何利用循环进行数据的可视化.目前只找到一个代码- fils = systemfunc ("ls *.txt")
- ; print(fils)
- ; print(dimsizes(fils))
- cols=13
- do i=0,dimsizes(fils)-1
- print(i+"Now reading..."+fils(i)) ;过程监控
- <div class="blockcode"><blockquote>data = asciiread(fils(i),-1,"float") ;读成一整列
- rows=dimsizes(data)/cols
- nfile=onedtond(data,(/rows,cols/))
复制代码
delete(data)
delete(nfile)
delete(rows)
end do
请问中间核心的三行代码是什么意思呢?不是非常的懂这个循环该如何写,思考时间睡觉都在思考!谢谢!
|
-
-
-
1.txt
5.55 KB, 下载次数: 10, 下载积分: 金钱 -5
-
-
2.txt
5.53 KB, 下载次数: 6, 下载积分: 金钱 -5
|