- 积分
- 1429
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-6-1
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
- ;******************************************************
- ; check and modify if a 1-d array is succession
- ;******************************************************
- undef("check_succession")
- function check_succession(x[*]:integer, n[1]:integer)
- local number_x, index, number_0, i
- begin
- number_x = dimsizes(x)
- index = ind(x .eq. 0)
- number_0 = dimsizes(index)
- do i = 0,number_0-2
- if((index(i+1) - index(i)) .le. n) then
- x(index(i):index(i+1)) = 0
- end if
- end do
- ; check 1 and end value
-
- if((x(0) .eq. 1) .and. (index(0) .lt. n)) then
- x(0:index(0)) = 0
- end if
- if((x(number_x-1) .eq. 1) .and. ((number_x-1) - index(number_0-1)) .lt. n ) then
- x(index(number_0-1):(number_x-1)) = 0
- end if
- return(x)
- end
- ;**********************************************************
- ; longitude index B1D for a single day
- ;**********************************************************
- undef("TM_OneDay")
- function TM_OneDay(x[*][*][*]:numeric, mid[1]:numeric, \
- ext[1]:numeric, dn[1]:numeric, dm[1]:numeric, \
- ds[1]:numeric, Emin[1]:numeric, Wmin[1]:numeric)
- local Zn, Zm, Zs, dims, ntime, nlon, xblock, GHGS, GHGN, i, j
- begin
- Zn = (mid + 1.5*ext) + dn
- Zm = (mid + 0.5*ext) + dm
- Zs = (mid - 0.5*ext) + ds
-
- dims = dimsizes(x)
- ntime = dims(0)
- nlon = dims(2)
-
- xblock = new((/ntime, nlon/), integer)
-
- do i = 0, ntime-1
- do j = 0, nlon-1
- GHGN = (x(i,{Zn},j) - x(i,{Zm},j)) / (Zn - Zm)
- GHGS = (x(i,{Zm},j) - x(i,{Zs},j)) / (Zm - Zs)
- if (GHGS .gt. Emin .and. GHGN .lt. Wmin) then
- xblock(i,j) = 1
- else
- xblock(i,j) = 0
- end if
- end do
- end do
- return(xblock)
- end
- ;*********************************************************
- ;*************************************************************
- 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"
- begin
- ; parameters----
- Minlon = 285
- Maxlon = 345
- B_days = 4
- B_lons = 10
- mid = 60
- ext = 15
- dn = 0
- dm = 0
- ds = 0
- Emin = 0
- Wmin = -5
- ; read data------
- f = addfile("./Z500_daily_deg1_1979_2013_JJA.nc", "r")
- geo = short2flt(f->z(:,:,{Minlon:Maxlon}))
- geo = geo / 9.8
- dims = dimsizes(geo)
- Zg = onedtond(ndtooned(geo), (/35,92,dims(1),dims(2)/))
-
- Zg!0 = "year"
- Zg&year = ispan(1979, 2013, 1)
- Zg!2 = "lat"
- Zg&lat = geo&latitude
- Zg!3 = "lon"
- Zg&lon = geo&longitude
-
- ; calculate oneday block
- block = TM_OneDay(Zg({2012},:,:,:), mid, ext, dn, dm, ds, Emin, Wmin)
- write_matrix(block, "61i1", False)
- ; check succession
-
- ndim = dimsizes(block)
- Ntime = ndim(0)
- Nlons = ndim(1)
- do i = 0, Nlons-1
- block(:,i) = check_succession(block(:,i), B_days)
- end do
- write_matrix(block, "61i1", False)
- do i = 0, Ntime-1
- block(i,:) = check_succession(block(i,:), B_lons)
- end do
- write_matrix(block, "61i1", False)
- ;----------------------------
- end
复制代码
这里读入数据时候如果纬度反向geo = short2flt(f->z(:,::-1,{Minlon:Maxlon}))运行结果会有很大差别,因为ext变量如果取奇数,存在舍入问题。
|
|