;+ ; ; @file_comments ; Allows to pass a field referring to the grid F on the grid V, ; 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 ; a 2d, 3d 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 f2v, 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=nxf, etc ... firstxv = firstxf lastxv = lastxf firstyv = firstyf lastyv = lastyf nxv = nxf nyv = nyf vargrid = 'V' if NOT keyword_set(valmask) then valmask = 1e20 lon1 = glamv[firstxv, 0] lon2 = glamf[lastxf, 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 nxf and taille[2] eq nyf: taille[1] eq jpi and taille[2] eq jpj: $ res=res[firstxf:lastxf, firstyf:lastyf] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') endcase mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf EQ jpi) then res[0, *] = !values.f_nan mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 0] terre = where(mask EQ 0) IF terre[0] NE -1 THEN res[terre] = valmask END 3: BEGIN case 1 of taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt: taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk: $ res=res[*, *, firstzt:lastzt] taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpt: taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ res=res[firstxf:lastxf, firstyf:lastyf, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE if taille[3] EQ jpt then begin mask = (fmask())[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxf, nyf, jpt, /over) ENDIF ELSE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf EQ jpi) then res[0, *, *] = !values.f_nan if taille[3] EQ jpt then BEGIN mask = tmask[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxf, nyf, jpt, /over) ENDIF ELSE mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf and taille[2] eq nyf AND taille[3] EQ nzt AND taille[4] EQ jpt: taille[1] eq nxf and taille[2] eq nyf 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[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt, *] else: $ return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') ENDCASE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxf, nyf, 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 nxf EQ jpi) then res[0, *, *, *] = !values.f_nan mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] mask = temporary(mask[*])#replicate(1, jpt) mask = reform(mask, nxf, nyf, 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