请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6156|回复: 5

求助:提取关键区海温回归至风场

[复制链接]

新浪微博达人勋

发表于 2017-4-29 18:06:42 | 显示全部楼层 |阅读模式

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

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

x
之前的计算过程是对亚洲中纬度纬向风进行eof分析,将eof第1-3模态的时间序列与海温计算相关系数,通过95%信度检验的区域定义为关键区。
现在下一步要做的是将关键区的海温回归至风场,出现了下面的问题,对于ismissing函数我也理解的不太好
fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function
fatal:["Execute.c":7743]:Execute: Error occurred at or near line 94 in file recoef.ncl


下面是我未完成的脚本:
; ***********************************************
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/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
; ***********************************************
begin

  yrStrt = 1963
  yrLast = 2012
  neof   = 3        ; number of EOFs
  optEOF = True      
  optEOF@jopt = 0   ; This is the default; most commonly used; no need to specify.
  optETS = False
  season = "JJA"
  f1     = addfile ("/data2/home/lzb/DATA/20C/uwnd.nc", "r")
  f2     = addfile ("/data2/home/lzb/DATA/Hadlsst/sst.nc","r")
  f3     = addfile ("/data2/home/lzb/DATA/20C/11grid/wind-level.nc.nc","r")
  sst    = f2->sst(1116:1715,:,:)
  sstt   = month_to_season(sst,season)   
  TIME   = f1->time
  YYYY   = cd_calendar(TIME,-1)/100               
  iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
  uwn    = f1->uwnd(iYYYY,16,:,:)     
  uu     = f3->uwnd(1344:1943,16,:,:)   
  uwnd   = month_to_season(uwn,season)         
  uuuu   = month_to_season(uu,season)           
  latS   = 20.
  latN   = 60.
  lonL   = 10.
  lonR   = 180.
  lata   = -60
  latb   = 60

  rad    = 4.*atan(1.)/180.
  clat   = f1->lat           
  clat   = sqrt(cos(rad*clat))                 ; gw for gaussian grid

  wuwnd   = uwnd                                   ; copy meta data
  wuwnd!0 = "time"
  wuwnd&time = uwnd&time
  wuwnd!1 = "lat"
  wuwnd&lat = uwnd&lat
  wuwnd!2 = "lon"
  wuwnd&lon = uwnd&lon
  wuwnd   = uwnd*conform(uwnd,clat,1)
  wuwnd@long_name = "Wgt: "+wuwnd@long_name
  x = wuwnd({lat|latS:latN},{lon|lonL:lonR},time|:)
  UU     = dim_avg_n_Wrap(uwnd,(/0/))
  xAno  = uwnd
  do i=0,49
    xAno(i,:,:) = uwnd(i,:,:) - UU
  end do
  xAnom = xAno({lat|latS:latN},{lon|lonL:lonR},time|:)
  eof    = eofunc_Wrap(xAnom,neof,optEOF)
  eof_ts = eofunc_ts_Wrap (xAnom,eof,optETS)                         ; examine EOF variables
  eof_ts = dim_standardize_n(eof_ts,1,1)      ; normalize
  eof_regres = eof                               ; create an array w meta data
  do ne=0,neof-1
     eof_regres(ne,:,:) = (/regCoef(eof_ts(ne,:),xAnom(:,:,:))/)
  end do

eof_ts1 = eof_ts(0,:)
y = sstt({latitude|:},{longitude|:},time|:)
ccr = escorc(eof_ts1,y)
ccr!0 = "lat"
ccr&lat = y&latitude
ccr!1 = "lon"
ccr&lon = y&longitude
z = uuuu({lat|:},{lon|:},time|:)

tval  = 0.
nptxy = 0
maxx = 0.25
minn = -0.25                                  ;      y-sst       z-uwind


do j = 0,359
    do k = 0,179
if(any(ccr(k,j).ge.maxx .and. ccr(k,j).le.minn)) then
  print(ccr)
rc = regcoef(y(k,j,:),z(k,j,:),tval,nptxy)
    lon_labels = new(dimsizes(lon_values),string)  
    lonW_index = ind(-180.lt.lon_values.and.lon_values.lt.  0)
    lonE_index = ind(   0.lt.lon_values.and.lon_values.lt.180)  
    if(.not.all(ismissing(lonW_index)))
    lon_labels(lonW_index) = fabs(lon(lonW_index)) + "W"  ; west
    end if  
    if(.not.all(ismissing(lonE_index)))
    lon_labels(lonE_index) = lon_values(lonE_index) + "E"  ; east
    end if                                                                                         ;;;;第94行
    delete(lonW_index)
    delete(lonE_index)
    delete(lon0_index)
end if
    end do
end do

printVarSummary(rc)

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

新浪微博达人勋

发表于 2017-5-7 16:28:15 | 显示全部楼层
请问 escorc  这个求相关的函数,它是自动计算标准化后求的相关,还是没有?

因为我平时直接用这个函数,用之前没有标准化,不知道对不对??
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-5-1 10:40:29 | 显示全部楼层
顶一下。。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-5-1 13:23:23 | 显示全部楼层
已解决,正确做法:

do j = 0,359
    do k = 0,179
if( .not.ismissing(ccr(k,j)).and.ccr(k,j).ge.maxx .and. ccr(k,j).le.minn) then
        yy(k,j,:) = y(k,j,:)
else
if(.not.ismissing(ccr(k,j)).and.ccr(k,j).lt.maxx .and. ccr(k,j).gt.minn) then
   yy(k,j,:) = value_miss
end if
end if
    end do
end do
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-2 08:41:25 | 显示全部楼层

回帖奖励 +1 金钱

多谢楼主分享{:5_213:}
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-5-7 20:44:45 | 显示全部楼层
qq469015280 发表于 2017-5-7 16:28
请问 escorc  这个求相关的函数,它是自动计算标准化后求的相关,还是没有?

因为我平时直接用这个函数 ...

没有自动标准化
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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