;+ ; ; @file_comments ; Allows to pass a field referring to the grid U 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$ ; ;- ; FUNCTION u2t, temp ; compile_opt idl2, strictarrsubs ; @cm_4mesh @cm_4data @cm_4cal IF NOT keyword_set(key_forgetold) THEN BEGIN @updatenew ENDIF ;--------------------------------------------------------- res = temp ;on force nxt=nxu, etc ... firstxt = firstxu lastxt = lastxu firstyt = firstyu lastyt = lastyu nxt = nxu nyt = nyu vargrid = 'T' if NOT keyword_set(valmask) then valmask = 1e20 lon1 = glamt[firstxt, 0] lon2 = glamu[lastxu, 0] ; ; 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 nxu and taille[2] eq nyu: taille[1] eq jpi and taille[2] eq jpj: $ res=res[firstxu:lastxu, firstyu:lastyu] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') endcase mask = (umask())[firstxu:lastxu, firstyu:lastyu, 0] terre = where(mask EQ 0) IF terre[0] NE -1 THEN res[terre] = !values.f_nan res = 0.5*(res + shift(res, 1, 0)) if NOT (keyword_set(key_periodic) AND nxu EQ jpi) then res[0, *] = !values.f_nan mask = tmask[firstxu:lastxu, firstyu:lastyu, 0] terre = where(mask EQ 0) IF terre[0] NE -1 THEN res[terre] = valmask END 3: BEGIN case 1 of taille[1] eq nxu and taille[2] eq nyu AND taille[3] EQ nzt: taille[1] eq nxu and taille[2] eq nyu AND taille[3] EQ jpk: $ res=res[*, *, firstzt:lastzt] taille[1] eq nxu and taille[2] eq nyu AND taille[3] EQ jpt: taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ res=res[firstxu:lastxu, firstyu:lastyu, firstzt:lastzt] taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ res=res[firstxu:lastxu, firstyu:lastyu, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE if taille[3] EQ jpt then begin mask = (umask())[firstxu:lastxu, firstyu:lastyu, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxu, nyu, jpt, /over) ENDIF ELSE mask = (umask())[firstxu:lastxu, firstyu:lastyu, 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, 1, 0, 0)) if NOT (keyword_set(key_periodic) AND nxu EQ jpi) then res[0, *, *] = !values.f_nan if taille[3] EQ jpt then BEGIN mask = tmask[firstxu:lastxu, firstyu:lastyu, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxu, nyu, jpt, /over) ENDIF ELSE mask = tmask[firstxu:lastxu, firstyu:lastyu, 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 nxu and taille[2] eq nyu AND taille[3] EQ nzt AND taille[4] EQ jpt: taille[1] eq nxu and taille[2] eq nyu 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[firstxu:lastxu, firstyu:lastyu, firstzt:lastzt, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE mask = (umask())[firstxu:lastxu, firstyu:lastyu, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxu, nyu, 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, 1, 0, 0, 0)) if NOT (keyword_set(key_periodic) AND nxu EQ jpi) then res[0, *, *, *] = !values.f_nan mask = tmask[firstxu:lastxu, firstyu:lastyu, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxu, nyu, 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