source: trunk/SRC/ToBeReviewed/GRILLE/f2v.pro @ 163

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

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; Allows to pass a field referring to the grid F on the grid V,
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 f2v, 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;We force nxt=nxf, etc ...
57   firstxv = firstxf
58   lastxv = lastxf
59   firstyv = firstyf
60   lastyv = lastyf
61   nxv = nxf
62   nyv = nyf
63   vargrid = 'V'
64   if NOT keyword_set(valmask) then valmask = 1e20
65   lon1 = glamv[firstxv, 0]
66   lon2 = glamf[lastxf, 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 nxf and taille[2] eq nyf:
75            taille[1] eq jpi and taille[2] eq jpj: $
76             res=res[firstxf:lastxf, firstyf:lastyf]
77            else: $
78             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
79         endcase
80         mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf EQ jpi) then res[0, *] = !values.f_nan
85         mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf and taille[2] eq nyf AND taille[3] EQ nzt:
92            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk: $
93             res=res[*, *, firstzt:lastzt]
94            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpt:
95            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $
96             res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
97            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $
98             res=res[firstxf:lastxf, firstyf:lastyf, *]
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 = (fmask())[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)]
104            mask = temporary(mask[*])#replicate(1, jpt)
105            mask = reform(mask, nxf, nyf, jpt, /over)
106         ENDIF ELSE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf EQ jpi) then res[0, *, *] = !values.f_nan
111         if taille[3] EQ jpt then BEGIN
112            mask = tmask[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)]
113            mask = temporary(mask[*])#replicate(1, jpt)
114            mask = reform(mask, nxf, nyf, jpt, /over)
115         ENDIF ELSE mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 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 nxf and taille[2] eq nyf AND taille[3] EQ nzt AND taille[4] EQ jpt:
122            taille[1] eq nxf and taille[2] eq nyf 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[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt, *]
126            else: $
127             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
128         ENDCASE
129         mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
130         mask = temporary(mask[*])#replicate(1, jpt)
131         mask = reform(mask, nxf, nyf, 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 nxf EQ jpi) then res[0, *, *, *] = !values.f_nan
136         mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
137         mask = temporary(mask[*])#replicate(1, jpt)
138         mask = reform(mask, nxf, nyf, 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.