source: trunk/SRC/ToBeReviewed/GRILLE/u2t.pro @ 157

Last change on this file since 157 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

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