爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9779|回复: 17

ncl读取某个经纬度附近的温度值

[复制链接]
发表于 2016-6-15 09:31:41 | 显示全部楼层 |阅读模式

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

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

x
但是一直报错,所以代码和报错贴出来,希望有大神能给点意见
代码:begin
a = addfile("/usr/local/wrf/WRFV3/test/em_real/wrfout_d01_2015-11-01_00:00:00.nc","r")
T2=wrf_user_getvar(a,"T2",0)
times = wrf_user_getvar(a,"times",-1)
xlat=wrf_user_getvar(a,"XLAT",0)
xlon=wrf_user_getvar(a,"XLONG",0)
locationij=wrf_user_ll_to_ij(a,121.7854194,31.19645278,True);
;print(locationij)
lonlat=wrf_user_ij_to_ll(a,locationij(0),locationij(1),True);
print(lonlat)
;xx=xlat(locationij(1)-1,locationij(0)-1)
;print(xx)
t=T2(:,locationij(1)-1,locationij(0)-1)
print(t)
asciiwrite("test.txt",t)
end
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-6-15 09:32:43 | 显示全部楼层
报错:
Copyright (C) 1995-2013 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.1.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.


Variable: lonlat
Type: float
Total Size: 8 bytes
            2 values
Number of Dimensions: 1
Dimensions and sizes:   [lon_lat_location | 2]
Coordinates:
(0)     121.6453
(1)     31.39188
fatal:["Execute.c":7432]:performASSIGN_VAR_VAR_OP: Number of subscripts on rhs do not match
                        number of dimensions of variable, (3) Subscripts used, (2)

fatal:["Execute.c":8128]:Execute: Error occurred at or near line 17 in file test.ncl


提示是t=T2(:,locationij(1)-1,locationij(0)-1)这一句有问题
密码修改失败请联系微信:mofangbao
发表于 2016-6-15 17:27:44 | 显示全部楼层
改为 t=T2(locationij(1)-1,locationij(0)-1)

你只读了一个时次
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-6-16 07:33:17 | 显示全部楼层
freekiller 发表于 2016-6-15 17:27
改为 t=T2(locationij(1)-1,locationij(0)-1)

你只读了一个时次

出现了新的问题:读取T2是发生错误
Copyright (C) 1995-2013 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.1.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.


Variable: lonlat
Type: float
Total Size: 8 bytes
            2 values
Number of Dimensions: 1
Dimensions and sizes:   [lon_lat_location | 2]
Coordinates:
(0)     121.6453
(1)     31.39188
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading T2
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 17 in file test.ncl
密码修改失败请联系微信:mofangbao
发表于 2016-6-16 08:56:45 | 显示全部楼层
没看懂,不过还是mark一下,日后好相见
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-6-16 09:55:45 | 显示全部楼层
Juliustan 发表于 2016-6-16 08:56
没看懂,不过还是mark一下,日后好相见

我也不懂。。。
密码修改失败请联系微信:mofangbao
发表于 2016-6-16 11:08:51 | 显示全部楼层
hahahahaha 发表于 2016-6-16 07:33
出现了新的问题:读取T2是发生错误
Copyright (C) 1995-2013 - All Rights Reserved
University Corp ...

经纬度写反了, 不在模式区域了               

评分

参与人数 1金钱 +20 收起 理由
hahahahaha + 20 终于明白你说的意思了

查看全部评分

密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-6-16 12:29:48 | 显示全部楼层
本帖最后由 hahahahaha 于 2016-6-16 14:15 编辑
freekiller 发表于 2016-6-16 11:08
经纬度写反了, 不在模式区域了

但是我用了WPS中namelist.wps里设置的经纬度,还是同样的报错,好奇怪
密码修改失败请联系微信:mofangbao
发表于 2016-6-16 14:50:33 | 显示全部楼层
hahahahaha 发表于 2016-6-16 12:29
但是我用了WPS中namelist.wps里设置的经纬度,还是同样的报错,好奇怪

你再试试,否则这么简单的脚本,不应该出错
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-6-16 17:06:54 | 显示全部楼层
freekiller 发表于 2016-6-16 14:50
你再试试,否则这么简单的脚本,不应该出错

试了,确实还是那样。不管加不加:,  
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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