爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5214|回复: 4

ncl提取临近站点数据时出错

[复制链接]
回帖奖励 6 金钱 回复本帖可获得 2 金钱奖励! 每人限 1 次(中奖概率 20%)

新浪微博达人勋

发表于 2018-3-26 18:23:26 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 刀客白刃 于 2018-3-26 20:34 编辑

;***********************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;***********************************************
begin
;***********************************************

a = addfile("/home/18qinc/test/wrfout_d03_2014-01-01_00:00:00","r")

;-----------------------------------------------------------------------

  tt = wrf_user_getvar(a,"times",-1)
  write_file  = "20140101-Lanzhouxq.txt"

; Find the ij location for the point if interest
  llres = True
  llres@ReturnInt = True   ; Return integer values
  locij = wrf_user_ll_to_ij(a, 103.6532, 36.5914, llres)
  locij = locij - 1        ; array pointers in NCL space
  locX = locij(0)
  locY = locij(1)

  taus = ispan(0,144,1)     ; create a time reference
  wd_station= new(1,float)
; get time information and strip out the day and hour
  times_in_file = a->Times
  dims = dimsizes(times_in_file)
  times = new(dims(0),string)
  do i=0,dims(0)-1
    times(i) = chartostring(times_in_file(i,8:12))
  end do

;-----------------------------------------------------------------------
  t2    = wrf_user_getvar(a,"T2",-1)    ; get t2 for all times
  u10 = wrf_user_getvar(a,"U10",-1)
  v10 = wrf_user_getvar(a,"V10",-1)


  t2_point   = t2(:,locY,locX)           ; extract a time series at a point
  ua_station  = u10(:,locY,locX)
  va_station  = v10(:,locY,locX)
  WindVeo = sqrt(ua_station*ua_station+va_station*va_station)

  pi=3.1415926
pi=3.1415926

do i=0,144
  if (ua_station(i).eq.0.0 .and. va_station(i).ge.0.0)then
      wd_station(i) = 0.0
  end if
  if (ua_station(i).eq.0.0 .and. va_station(i).lt.0.0)then
      wd_station(i) = 180.0
  end if

  if (va_station(i).eq.0.0 .and. ua_station(i).ge.0.0)then
      wd_station(i) = 90.0
  end if
  if (va_station(i).eq.0.0 .and. ua_station(i).lt.0.0)then
      wd_station(i) = 270.0
  end if

  if (ua_station(i).gt.0.0 .and. va_station(i).gt.0.0)then
      wd_station(i) = atan(abs(ua_station(i)/va_station(i)))*180/pi
  end if

  if (ua_station(i).gt.0.0 .and. va_station(i).lt.0.0)then
      wd_station(i) = atan(abs(va_station(i)/ua_station(i)))*180/pi+90.0
  end if

  if (ua_station(i).lt.0.0 .and. va_station(i).lt.0.0)then
      wd_station(i) = atan(abs(ua_station(i)/va_station(i)))*180/pi+180.0
  end if

  if (ua_station(i).lt.0.0 .and. va_station(i).gt.0.0)then
      wd_station(i) = atan(abs(va_station(i)/ua_station(i)))*180/pi+270.0
  end if
end do

do i=0,144
   alist = [/tt,t2,u10,v10,WindVeo,wd_station/]
   write_table(write_file, "a", alist, "%5d  %5d  %5d  %5d  %5d  %5d")

   print(tt+" is ok")

  end do

;-----------------------------------------------------------------------

  end               


错误
fatal:Subscript out of range, error in subscript #0
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 75 in file tqljzd1.ncl



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

新浪微博达人勋

发表于 2018-3-27 09:16:08 | 显示全部楼层
打印一下locY,locX
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-3-27 09:17:51 | 显示全部楼层
我遇到一个错误,locY,locX返回值都在网格之外,提取不到变量值
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-3-27 09:51:39 | 显示全部楼层

我疏忽了,已经解决了,谢谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-3-29 10:36:13 | 显示全部楼层
刀客白刃 发表于 2018-3-27 09:51
我疏忽了,已经解决了,谢谢

你这个是什么错误
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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