爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8319|回复: 5

[作图] ncl站点数据绘图的问题

[复制链接]
发表于 2016-8-29 15:29:00 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 zly4814624 于 2016-8-29 15:32 编辑

本人是新手,现在需要讲一个站点数据进行绘图,数据的格式是TXT,第一行是站点序号,第二行是经度,第三是维度,第四行是运用到的温度数据,请问如何将我希望运用到的温度数据变成带有经纬度信息的二维数组呢。望各路大神帮帮忙解答一下。以下是我的原始数据:

test_data.txt

835 Bytes, 下载次数: 24, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao
发表于 2016-8-29 16:02:25 | 显示全部楼层
本帖最后由 xuebiz 于 2016-8-29 16:06 编辑

http://www.ncl.ucar.edu/Applications/read_ascii.shtml
官网例子~~

可能这个例子比较像你的数据,供参考
stn_latlon.dat - a file with 980 rows and 10 columns of floating point data. (example)
http://www.ncl.ucar.edu/Applications/read_ascii.shtml#stn_latlon

stn_latlon.dat - a file with 980 rows and 10 columns of floating point data.

The first two methods show how to read this file if you know the exact number of rows and columns, and the third method shows how to read this file if you don't.

Method 1

; Read data into a 980 x 10 float array.
  nrows = 980
  ncols = 10
  data  = asciiread("stn_latlon.dat",(/nrows,ncols/),"float")
  printVarSummary(data)           ; Print information about file only.

; Two ways to print the data.
  print(data)                     ; Print data, one value per line
  write_matrix(data,ncols + "f7.2",0)   ; Formatted output

Method 2

This file is actually a file of latitude and longitude values, each dimensioned 70 x 70. The latitude values are written first on the file, followed by the longitude values. Given this information, here's another way to read in this file:

  nlat     = 70
  nlon     = 70
  latlon2d = asciiread("stn_latlon.dat",(/2,nlat,nlon/),"float")     ; 2 x 70 x 70
  lat2d    = latlon2d(0,:,:)    ; 70 x 70
  lon2d    = latlon2d(1,:,:)    ; 70 x 70

Method 3


Use the special contributed functions numAsciiCol and readAsciiTable function to first calculate the number of columns, and then to read the data into an array dimensioned nrows x ncols.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

  filename = "stn_latlon.dat"

; Calculate the number of columns.
  ncols = numAsciiCol(filename)

; Given the # of columns, we can use readAsciiTable to read this file.
  data = readAsciiTable(filename,ncols,"float",0)

  nrows = dimsizes(data(:,0))    ; calculate # of rows

  print("'" + filename + "' has " + nrows + " rows and " + ncols + \
        " columns of data.")

密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

发表于 2016-8-29 15:38:42 | 显示全部楼层
本帖最后由 xuebiz 于 2016-8-29 16:06 编辑

下载要扣5个金币哦,不舍得,差不多就是这样子吧,(*^__^*) 嘻嘻……
下次可以贴几行数据看看就好  ------  守财奴留


参考下:
以下来自  ------  NCL常用气象格式的数据读取及可视化
(本论坛有电子版下载http://bbs.06climate.com/forum.php?mod=viewthread&tid=10831

2.2文本数据

使用下面的 NCL 代码读取刚才生成的 test.txt 文件:
; NCL 脚本
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
  fiASC = "./test.txt"
  nrow = numAsciiRow(fiASC)
  ncol = numAsciiCol(fiASC)
  data = asciiread(fiASC, (/nrow, ncol/), "integer")
  print(data)
end
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-8-30 16:06:41 | 显示全部楼层
xuebiz 发表于 2016-8-29 16:02
http://www.ncl.ucar.edu/Applications/read_ascii.shtml
官网例子~~

谢谢。学习了。
密码修改失败请联系微信:mofangbao
发表于 2016-8-31 09:26:56 | 显示全部楼层
谢谢。学习了,很有用
密码修改失败请联系微信:mofangbao
发表于 2017-10-30 17:45:52 | 显示全部楼层
谢谢楼主分享
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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