;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; ; @file_comments ; Allows to pass a field referring to the grid V on the grid T, ; thanks to the average: ; res = 0.5*(res + shift(res, 1, 0)) ; ; @categories ; Grid ; ; @param TEMP {in}{required} ; A 2, 3 or 4d array ; ; @returns ; res, a 2, 3 or 4d array ; ; @uses ; common.pro ; ; @restrictions ; Force parameters of the zoom on the grid V to be the same as ; those on the grid T. ; ; @restrictions ; Points which can not be calculated are put at the value NaN ; consecrated by IDL: !values.f_nan ; ; @history ; From Marina Levy's programs ; Sebastien Masson (smasson\@lodyc.jussieu.fr): ; Validation. 5/6/2000 ; ; @version ; $Id$ ; ; @todo seb: nom du input? ; ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ FUNCTION v2t, temp ;--------------------------------------------------------- ; compile_opt idl2, strictarrsubs ; @cm_4mesh @cm_4data @cm_4cal IF NOT keyword_set(key_forgetold) THEN BEGIN @updatenew ENDIF ;--------------------------------------------------------- res = temp ;We force nxt=nxv, etc ... firstxt = firstxv lastxt = lastxv firstyt = firstyv lastyt = lastyv nxt = nxv nyt = nyv vargrid = 'T' if NOT keyword_set(valmask) then valmask = 1e20 lat1 = gphit[0, firstyt] lat2 = gphiv[0, lastyv] ; case on tha array's size and application taille = size(temp) CASE taille[0] OF 1: res = -1 2: BEGIN case 1 of taille[1] eq nxv and taille[2] eq nyv: taille[1] eq jpi and taille[2] eq jpj: $ res=res[firstxv:lastxv, firstyv:lastyv] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') endcase mask = (vmask())[firstxv:lastxv, firstyv:lastyv, 0] terre = where(mask EQ 0) IF terre[0] NE -1 THEN res[terre] = !values.f_nan res = 0.5*(res + shift(res, 0, +1)) res[*, 0] = !values.f_nan mask = tmask[firstxv:lastxv, firstyv:lastyv, 0] terre = where(mask EQ 0) IF terre[0] NE -1 THEN res[terre] = valmask END 3: BEGIN case 1 of taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt: taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk: $ res=res[*, *, firstzt:lastzt] taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpt: taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ res=res[firstxv:lastxv, firstyv:lastyv, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE if taille[3] EQ jpt then begin mask = (vmask())[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxv, nyv, jpt, /over) ENDIF ELSE mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] terre = where(temporary(mask) EQ 0) IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan res = 0.5*(res + shift(res, 0, +1, 0)) res[*, 0, *] = !values.f_nan if taille[3] EQ jpt then BEGIN mask = tmask[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxv, nyv, jpt, /over) ENDIF ELSE mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] terre = where(temporary(mask) EQ 0) IF terre[0] NE -1 THEN res[temporary(terre)] = valmask END 4: BEGIN case 1 of taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt AND taille[4] EQ jpt: taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk AND taille[4] EQ jpt: $ res=res[*, *, firstzt:lastzt, *] taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $ res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxv, nyv, nzt, jpt, /over) terre = where(temporary(mask) EQ 0) IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan res = 0.5*(res + shift(res, 0, +1, 0, 0)) res[*, 0, *, *] = !values.f_nan mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxv, nyv, nzt, jpt, /over) terre = where(temporary(mask) EQ 0) IF terre[0] NE -1 THEN res[temporary(terre)] = valmask END endcase IF NOT keyword_set(key_forgetold) THEN BEGIN @updateold ENDIF return, res END