quit ncl f = addfile("air.day.ltm.nc","r") TT := f->air ; (time | 365] x [lat | 73] x [lon | 144] TT = TT-273.15 TT@units = "degC" ymd = cd_calendar(TT&time, -2) ; yyyymmdd t = TT ; local [deleted upon exit] if (.not.isatt(t,"_FillValue")) t@_FillValue = 1e20 end if dimt = dimsizes(t) rankt= dimsizes(dimt) ntim = dimt(0) testValue=0 ;;;;;pick the testvalue if (rankt.eq.3) then ; T[*][*][*] => T(time,lat,lon) nlat = dimt(1) mlon = dimt(2) it3 = new((/nlat,mlon/), "integer", -999) copy_VarCoords(t(0,:,:),it3) it3@long_name = "temporal index for Cross-Over" if (.not.(all(t.le.testValue) .or. all(t.ge.testValue))) then do nl=0,nlat-1 do ml=0,mlon-1 t3= t(:,nl,ml) if (.not.(all(t3.le.testValue) .or. all(t3.ge.testValue))) then t3= where(t3.ge.testValue, t3@_FillValue, t3); t3 = where(.not.ismissing(t3),testValue,t3) it3(nl,ml) = dim_maxind(t3,0) ; !!!!!indices of last occurence of testValue end if end do end do return(it3) end if end if if (rankt.eq.3) then ; T[*][*][*] => T(time,lat,lon) nlat = dimt(1) mlon = dimt(2) it = new((/nlat,mlon/), "integer", -999) copy_VarCoords(t(0,:,:),it) it@long_name = "temporal index for Cross-Over" if (.not.(all(t.le.testValue) .or. all(t.ge.testValue))) then do nl=0,nlat-1 do ml=0,mlon-1 t1 = t(:,nl,ml) if (.not.(all(t1.le.testValue) .or. all(t1.ge.testValue))) then t1= where(t1.le.testValue, t1@_FillValue, t1); t1 = where(.not.ismissing(t1),testValue,t1) it(nl,ml) = dim_minind(t1,0) ; !!!!!indices of 1st occurence of testValue end if end do end do return(it) end if end if test=it3-it ;;;;;;;;test the indices printMinMax(test,0) dimITT = dimsizes(it) nlat = dimITT(0) mlon = dimITT(1) lat = TT&lat lon = TT&lon date=new((/73,144/),float) do nl=0,nlat-1 do ml=0,mlon-1 nt = it(nl,ml) if (.not.ismissing(nt)) then date(nl,ml)=ymd(nt) ; print("("+nl+","+ml+"): ("+lat(nl)+","+lon(ml)+") nt="+nt+" ymd="+ymd(nt)+" TT(nt,nl,ml)="+TT(nt,nl,ml)) else date(nl,ml)=-999 ;print("("+nl+","+ml+") has no cross-over") end if end do end do