source: trunk/SRC/ToBeReviewed/GRILLE/v2t.pro @ 325

Last change on this file since 325 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.9 KB
Line 
1;+
2;
3; @file_comments
4; Allows to pass a field referring to the grid V on the grid T,
5; thanks to the average:
6; res = 0.5*(res + shift(res, 1, 0))
7;
8; @categories
9; Grid
10;
11; @param TEMP {in}{required}
12; A 2d, 3d or 4d array
13;
14; @returns
15; a 2d, 3d or 4d array
16;
17; @uses
18; common.pro
19;
20; @restrictions
21; Force parameters of the zoom on the grid V to be the same as
22; those on the grid T.
23;
24; @restrictions
25; Points which can not be calculated are put at the value NaN
26; consecrated by IDL: !values.f_nan
27;
28; @history
29; From Marina Levy's programs
30; Sebastien Masson (smasson\@lodyc.jussieu.fr):
31; Validation. 5/6/2000
32;
33; @version
34; $Id$
35;
36; @todo
37; seb: nom du input?
38;
39;-
40FUNCTION v2t, temp
41;
42  compile_opt idl2, strictarrsubs
43;
44@cm_4mesh
45@cm_4data
46@cm_4cal
47  IF NOT keyword_set(key_forgetold) THEN BEGIN
48@updatenew
49  ENDIF
50;---------------------------------------------------------
51   res = temp
52;We force nxt=nxv, etc ...
53   firstxt = firstxv
54   lastxt = lastxv
55   firstyt = firstyv
56   lastyt = lastyv
57   nxt = nxv
58   nyt = nyv
59   vargrid = 'T'
60   if NOT keyword_set(valmask) then valmask = 1e20
61   lat1 = gphit[0, firstyt]
62   lat2 = gphiv[0, lastyv]
63
64; case on tha array's size and application
65   taille = size(temp)
66   CASE taille[0] OF
67      1: res = -1
68      2: BEGIN
69         case 1 of
70            taille[1] eq nxv and taille[2] eq nyv:
71            taille[1] eq jpi and taille[2] eq jpj: $
72             res=res[firstxv:lastxv, firstyv:lastyv]
73            else: $
74             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
75         endcase
76         mask = (vmask())[firstxv:lastxv, firstyv:lastyv, 0]
77         terre = where(mask EQ 0)
78         IF terre[0] NE -1 THEN res[terre] = !values.f_nan
79         res = 0.5*(res + shift(res, 0, +1))
80         res[*, 0] = !values.f_nan
81         mask = tmask[firstxv:lastxv, firstyv:lastyv, 0]
82         terre = where(mask EQ 0)
83         IF terre[0] NE -1 THEN res[terre] = valmask
84      END
85      3: BEGIN
86         case 1 of
87            taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt:
88            taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk: $
89             res=res[*, *, firstzt:lastzt]
90            taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpt:
91            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $
92             res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt]
93            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $
94             res=res[firstxv:lastxv, firstyv:lastyv, *]
95            else: $
96             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
97         ENDCASE
98         if taille[3] EQ jpt then begin
99            mask = (vmask())[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)]
100            mask = temporary(mask[*])#replicate(1, jpt)
101            mask = reform(mask, nxv, nyv, jpt, /over)
102         ENDIF ELSE mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt]
103         terre = where(temporary(mask) EQ 0)
104         IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan
105         res = 0.5*(res + shift(res, 0, +1, 0))
106         res[*, 0, *] = !values.f_nan
107         if taille[3] EQ jpt then BEGIN
108            mask = tmask[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)]
109            mask = temporary(mask[*])#replicate(1, jpt)
110            mask = reform(mask, nxv, nyv, jpt, /over)
111         ENDIF ELSE mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt]
112         terre = where(temporary(mask) EQ 0)
113         IF terre[0] NE -1 THEN res[temporary(terre)] = valmask
114      END
115      4: BEGIN
116         case 1 of
117            taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt AND taille[4] EQ jpt:
118            taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk AND taille[4] EQ jpt: $
119             res=res[*, *, firstzt:lastzt, *]
120            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $
121             res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt, *]
122            else: $
123             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
124         ENDCASE
125         mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt]
126         mask = temporary(mask[*])#replicate(1, jpt)
127         mask = reform(mask, nxv, nyv, nzt, jpt, /over)
128         terre = where(temporary(mask) EQ 0)
129         IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan
130         res = 0.5*(res + shift(res, 0, +1, 0, 0))
131         res[*, 0, *, *] = !values.f_nan
132         mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt]
133         mask = temporary(mask[*])#replicate(1, jpt)
134         mask = reform(mask, nxv, nyv, nzt, jpt, /over)
135         terre = where(temporary(mask) EQ 0)
136         IF terre[0] NE -1 THEN res[temporary(terre)] = valmask
137      END
138   endcase
139
140   IF NOT keyword_set(key_forgetold) THEN BEGIN
141   @updateold
142   ENDIF
143
144    return, res
145END
Note: See TracBrowser for help on using the repository browser.