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

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

typo and links in header in some pro files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1;+
2;
3; @file_comments
4; Allows to pass a field referring to the grid F on the grid V,
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 2, 3 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;-
37;
38FUNCTION f2v, temp
39;
40  compile_opt idl2, strictarrsubs
41;
42@cm_4mesh
43@cm_4data
44@cm_4cal
45  IF NOT keyword_set(key_forgetold) THEN BEGIN
46@updatenew
47  ENDIF
48;---------------------------------------------------------
49   res = temp
50;We force nxt=nxf, etc ...
51   firstxv = firstxf
52   lastxv = lastxf
53   firstyv = firstyf
54   lastyv = lastyf
55   nxv = nxf
56   nyv = nyf
57   vargrid = 'V'
58   if NOT keyword_set(valmask) then valmask = 1e20
59   lon1 = glamv[firstxv, 0]
60   lon2 = glamf[lastxf, 0]
61
62; case on tha array's size and application
63   taille = size(temp)
64   CASE taille[0] OF
65      1: res = -1
66      2: BEGIN
67         case 1 of
68            taille[1] eq nxf and taille[2] eq nyf:
69            taille[1] eq jpi and taille[2] eq jpj: $
70             res=res[firstxf:lastxf, firstyf:lastyf]
71            else: $
72             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
73         endcase
74         mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 0]
75         terre = where(mask EQ 0)
76         IF terre[0] NE -1 THEN res[terre] = !values.f_nan
77         res = 0.5*(res + shift(res, 1, 0))
78         if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *] = !values.f_nan
79         mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 0]
80         terre = where(mask EQ 0)
81         IF terre[0] NE -1 THEN res[terre] = valmask
82      END
83      3: BEGIN
84         case 1 of
85            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt:
86            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk: $
87             res=res[*, *, firstzt:lastzt]
88            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpt:
89            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $
90             res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
91            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $
92             res=res[firstxf:lastxf, firstyf:lastyf, *]
93            else: $
94             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
95         ENDCASE
96         if taille[3] EQ jpt then begin
97            mask = (fmask())[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)]
98            mask = temporary(mask[*])#replicate(1, jpt)
99            mask = reform(mask, nxf, nyf, jpt, /over)
100         ENDIF ELSE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
101         terre = where(temporary(mask) EQ 0)
102         IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan
103         res = 0.5*(res + shift(res, 1, 0, 0))
104         if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *] = !values.f_nan
105         if taille[3] EQ jpt then BEGIN
106            mask = tmask[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)]
107            mask = temporary(mask[*])#replicate(1, jpt)
108            mask = reform(mask, nxf, nyf, jpt, /over)
109         ENDIF ELSE mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
110         terre = where(temporary(mask) EQ 0)
111         IF terre[0] NE -1 THEN res[temporary(terre)] = valmask
112      END
113      4: BEGIN
114         case 1 of
115            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt AND taille[4] EQ jpt:
116            taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk AND taille[4] EQ jpt: $
117             res=res[*, *, firstzt:lastzt, *]
118            taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $
119             res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt, *]
120            else: $
121             return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
122         ENDCASE
123         mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
124         mask = temporary(mask[*])#replicate(1, jpt)
125         mask = reform(mask, nxf, nyf, nzt, jpt, /over)
126         terre = where(temporary(mask) EQ 0)
127         IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan
128         res = 0.5*(res + shift(res, 1, 0, 0, 0))
129         if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *, *] = !values.f_nan
130         mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt]
131         mask = temporary(mask[*])#replicate(1, jpt)
132         mask = reform(mask, nxf, nyf, nzt, jpt, /over)
133         terre = where(temporary(mask) EQ 0)
134         IF terre[0] NE -1 THEN res[temporary(terre)] = valmask
135      END
136   endcase
137
138   IF NOT keyword_set(key_forgetold) THEN BEGIN
139   @updateold
140   ENDIF
141
142   return, res
143END
Note: See TracBrowser for help on using the repository browser.