爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7037|回复: 5

[其他] 请教一下关于用NCL求每日最高温的问题

[复制链接]

新浪微博达人勋

发表于 2019-3-7 20:16:02 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 Safiiylla 于 2019-3-7 20:18 编辑

我初学Ncl,还有很多没弄清楚。我知道这个问题应该很小白但是很抱歉我真的搞了很久没弄出来 希望有大佬帮我解解惑 卡了好久TAT
是这样的,我下载的是1日4个时次的温度数据。我想的是循环1-4个数据找出最大的存入新数组第一位数据,然后在循环5-8找出最大存入新数组第二位数据,这样循环下去。但是出了很多问题。
我的程序如下



begin

f = addfile ("2009Daily1.nc", "r")
t2m = f
;读入 t2m

dimll = dimsizes(t2m)
tem = new((/31,dimll(1),dimll(2)/),short)
;tem 31 days
copy_VarAtts(t2m, tem)    ;将t2m变量的属性复制给tem
tem@long_name="the highest temperature"
tem@units="K"
tem@_FillValue=t2m@_FillValue
tem!0="time"
tem!1="atitude"
tem!2="longitude"
printVarSummary(tem)

i=0            
j=0

do while(i<123)
tem(j,:,:).eq.t2m(i,:,:)
if(t2m(i+1,:,:).gt.tem(j,:,:))then
tem(j,:,:).eq.t2m(i+1,:,:)
end if
if(t2m(i+2,:,:).gt.tem(j,:,:))then
tem(j,:,:).eq.t2m(i+2,:,:)
end if
if(t2m(i+3,:,:).gt.tem(j,:,:))then
tem(j,:,:).eq.t2m(i+3,:,:)
end if
i=i+4
j=j+1
end do

fout=addfile("2009_1_tmax.nc","c")
fout->t=tem

end





这是报的错
fatal:syntax error: line 23 in file Tmax.ncl before or near .eq.
tem(j,:,:).eq.
-------------^

fatal:syntax error: possibly an undefined procedure
fatal:syntax error: line 25 in file Tmax.ncl before or near .eq.
tem(j,:,:).eq.
--------------^

fatal:syntax error: possibly an undefined procedure
fatal:syntax error: line 28 in file Tmax.ncl before or near .eq.
tem(j,:,:).eq.
--------------^

fatal:syntax error: possibly an undefined procedure
fatal:syntax error: line 31 in file Tmax.ncl before or near .eq.
tem(j,:,:).eq.
--------------^

fatal:syntax error: possibly an undefined procedure
fatal:Syntax Error in block, block not executed
fatal:error at line 40 in file Tmax.ncl





密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-3-7 20:46:47 | 显示全部楼层
运行后的图片贴出来吧   感觉这个程序前面也有点问题。。。。获取数组极值是有函数的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-3-7 21:24:18 | 显示全部楼层
好久不见 发表于 2019-3-7 20:46
运行后的图片贴出来吧   感觉这个程序前面也有点问题。。。。获取数组极值是有函数的

获取数组极值的我好像知道是哪个函数 但是我这里是每四个数找一个极值 就有点不知道怎么弄 结果我贴在下面了谢谢!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-3-7 21:26:41 | 显示全部楼层
这是运行结果 谢谢回复!
QQ截图20190307212238.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-3-7 21:37:24 | 显示全部楼层
你的语法错误应该是.eq.的用法   这个不能用作赋值的     你可以尝试一下reshape这个函数 把数据弄成4*n的数组  就可以用函数选极值了  再改一下循环  没必要用这么多
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-3-8 08:45:20 | 显示全部楼层
[quote][url=forum.php?mod=redirect

好的!谢谢!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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