source: trunk/SRC/Obsolete/nlec.pro @ 378

Last change on this file since 378 was 370, checked in by pinsard, 16 years ago

improvemnts of headers (typo, links)

  • Property svn:keywords set to Id
File size: 10.8 KB
Line 
1;+
2;
3; @file_comments
4; lit les fichiers Net-Cdf de l'experience TOTEM/ECMWF qui sont sur
5; maia: /u/rech/eee/reee217/TOTEM/REF/OUTPUTS
6;
7; @obsolete
8;
9; @param name {in}{required}
10; nom du tableau contenant le champ que l'on veut (le
11; trouver avec ncdflec,fichier,/var
12;
13; @param debut {in}
14; nombres de 6 ou 8 chiffres (anneemoisjour, par ex:19980507)
15;
16; @param fin {in}
17; nombres de 6 ou 8 chiffres (anneemoisjour, par ex:19980507)
18;
19; @param nomexperience {in}{optional}
20; trois lettres designant le nom de l'experience
21;
22; @keyword BOITE
23; boite sur laquelle integrer (par defaut tt le domaine)
24;
25; @keyword DIREC
26; 'x' 'y' 'z' 'xy' 'xz' 'yz' 'xyz' directions selon lesquelles
27; effectuer les moyennes (si rien n'est donne on n'effectue pas de moyenne)
28;
29; @keyword GRILLE
30; impose la grille a laquelle est rapporte le champ. rq permet
31; d'aller plus vite ds la lecture
32;
33; @keyword TOUT
34; oblige a lire le tableau entier en non pas celui reduit a <pro>domdef</pro>
35;
36; @keyword STRUCTURE
37;
38; @keyword SEUILMIN
39;
40; @keyword SEUILMAX
41;
42; @keyword NAN
43;
44; @keyword _EXTRA
45; Used to pass keywords
46;
47; @uses
48; <pro>common</pro>
49; <pro>vraidate</pro>
50; <pro>juldate</pro>
51; <pro>nlec5j</pro>
52; <pro>nlecserie</pro>
53;
54; @history
55; Sebastien Masson (smasson\@lodyc.jussieu.fr)
56;   14/8/98
57;
58; @version
59; $Id$
60;
61;-
62FUNCTION nlec, name, debut, fin, nomexperience $
63             , BOITE=boite, DIREC=direc, GRILLE=grille, TOUT=tout $
64             , STRUCTURE=structure, SEUILMIN=seuilmin, SEUILMAX=seuilmax $
65             , NAN=nan $
66             , _EXTRA=ex
67;
68;------------------------------------------------------------
69;REF.07.790101.grid.T.nc
70;REF.07.790101.grid.U.nc
71;REF.07.790101.grid.V.nc
72;REF.07.790101.grid.W.nc
73;------------------------------------------------------------
74  compile_opt idl2, strictarrsubs, obsolete
75;
76@common
77;------------------------------------------------------------
78   tempsun = systime(1)         ; pour key_performance
79   nom=strlowcase(name)
80;------------------------------------------------------------
81; specification de la date et de l'experience
82;------------------------------------------------------------
83   case n_params() of
84      1:BEGIN
85         year=year+1900*(year ne 0 and year ne -1 and year lt 100)
86         date = day+100*month+10000*year
87      end
88      2:BEGIN
89         if size(debut, /tname) EQ 'STRING' then begin
90            prefix = strupcase(debut)
91            year=year+1900*(year ne 0 and year ne -1 and year lt 100)
92            date = day+100*month+10000*year
93         ENDIF ELSE BEGIN
94            date = debut
95            rien=juldate(date)
96         ENDELSE
97      end
98      3:begin
99         date = debut
100         rien=juldate(date)
101         if size(fin, /tname) EQ 'STRING' then begin
102            prefix = strupcase(fin)
103         ENDIF ELSE BEGIN
104            date2=vraidate(fin)
105            year2=date2/10000
106            month2=date2/100 - year2*100
107            day2=date2 - year2*10000 - month2*100
108         ENDELSE
109      end
110      4:BEGIN
111         date = debut
112         rien=juldate(date)
113          if size(nomexperience, /tname) EQ 'STRING' then begin
114            prefix = strupcase(nomexperience)
115            date2 = fin
116         ENDIF ELSE BEGIN
117            prefix = strupcase(fin)
118            date2 = nomexperience
119         ENDELSE
120         date2=vraidate(date2)
121         year2=date2/10000
122         month2=date2/100 - year2*100
123         day2=date2 - year2*10000 - month2*100
124      end
125   endcase
126   date = long(date)
127   if n_elements(date2) NE 0 then date2 = long(date2)
128   if n_elements(date2) NE 0 then if date2 eq date then tempvar = SIZE(TEMPORARY(date2))
129;------------------------------------------------------------
130; verification de la coherence des dates
131;------------------------------------------------------------
132   if n_elements(date2) ne 0 then begin
133      if (day    EQ 0 AND day2  NE 0) OR (month EQ 0 AND month2 NE 0) OR $
134       (year   EQ 0 AND year2 NE 0) or (day2  EQ 0 AND day    NE 0) OR $
135       (month2 EQ 0 AND month NE 0) OR (year2 EQ 0 AND year   NE 0) then $
136       return,  report('verifier la coherence des dates')
137      if date2 le date then return, report('date2 doit etre posterieure a date')
138   endif
139;------------------------------------------------------------
140; case sur le type de fichiers que l'on veut lire.
141; determination ds chaque cas de numsortie et nbretps
142;------------------------------------------------------------
143   if day NE 0 then begin       ; SORTIES A 5 JOURS
144;------------------------------------------------------------
145; numsortie
146;------------------------------------------------------------
147testjour:
148      numsortie=((1+julday(month,day,year)-julday(1,1,year))/5.)[0]
149      if numsortie ne floor(numsortie) then begin
150         if n_elements(date2) ne 0 then begin
151            caldat,julday(month,day+1,year),month,day,year
152            goto, testjour
153         endif
154         return,  -1
155      ENDIF
156      numsortie = long(numsortie)
157;------------------------------------------------------------
158; determination du nombre de pas de tps a extraire pour la serie temporelle
159; entiere: nbretps
160;------------------------------------------------------------
161      if n_elements(date2) ne 0 then begin
162         testjour2:
163         numsortie2=(1+julday(month2,day2,year2)-julday(1,1,year2))/5.
164         if numsortie2 ne floor(numsortie2) then begin
165            caldat,julday(month2,day2-1,year2),month2,day2,year2
166            goto, testjour2
167         endif
168         if year eq year2 then nbretps=numsortie2-numsortie+1 else $
169          nbretps=(73-numsortie+1)+(year2-year-1)*73+numsortie2
170         numsortie2 = long(numsortie2)
171      endif else nbretps=1
172      nbretps = long(nbretps)
173;------------------------------------------------------------
174; si on fait une serie temporelle on cherche a lire plutot un fichier
175; contenant deja une serie temporelle par contre pour une sortie
176; unique on cherche d'abord a lire un fichier contenant toutes les variables.
177;------------------------------------------------------------
178      IF n_elements(date2) ne 0 THEN BEGIN
179         serie:
180         IF n_elements(dejaserie) eq 1 then return, -1
181         datejul = 5*numsortie-1+julday(1, 1, year)
182         if n_elements(date2) ne 0 then date2jul = 5*numsortie2-1+julday(1, 1, year2) $
183         ELSE date2jul = datejul
184         res = nlecserie(nom, datejul, date2jul,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
185         IF res[0] EQ -1 THEN BEGIN
186            dejaserie = 1
187            GOTO,  passerie
188         ENDIF
189      ENDIF ELSE BEGIN
190         passerie:
191         IF n_elements(dejapasserie) eq 1 then return, -1
192         res =   nlec5j( nom, numsortie  , nbretps,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
193         IF res[0] EQ -1 THEN BEGIN
194            dejapasserie = 1
195            GOTO,  serie
196         ENDIF
197      endelse
198   ENDIF ELSE BEGIN
199      CASE 1 of
200         month NE 0 AND year NE 0:BEGIN ; SORTIES MENSUELLES
201            numsortie79 = (year-1979)*12+month
202            if n_elements(date2) ne 0 then nbretps = month2-month+1+12*(year2-year) $
203            ELSE nbretps = 1
204            res = nlecmois(nom,numsortie79,nbretps ,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
205         end
206         month EQ 0 AND year NE 0:BEGIN ; SORTIES ANNUELLES
207            numsortie79 = (year-1978)
208            if n_elements(date2) ne 0 then nbretps = year2-year+1 $
209            ELSE nbretps = 1
210            res = nlecan(nom,numsortie79,nbretps ,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
211         end
212         month NE 0 AND year EQ 0:BEGIN ; SORTIES SAISONNIERES
213            numsortie79 = month
214            if n_elements(date2) ne 0 then nbretps = month2-month+1 $
215            ELSE nbretps = 1
216            res = nlecsaison(nom,numsortie79,nbretps ,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
217         end
218         month EQ 0 AND year EQ 0:BEGIN ; SORTIES CLIMATOLOGIQUE
219            numsortie79 = 13
220            nbretps = 1
221            res = nlecsaison(nom,numsortie79,nbretps ,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex)
222         end
223      endcase
224   endelse
225;------------------------------------------------------------
226;  seuil
227;------------------------------------------------------------
228   if n_elements(seuilmin) NE 0 then BEGIN
229      if n_elements(valmask) EQ 0 then valmask = 1e20
230      terre = where(res GT valmask/10.)
231      res = seuilmin > res
232      if terre[0] NE -1 then res[terre] = valmask
233      undefine, terre
234   endif
235   if n_elements(seuilmax) NE 0 then begin
236      if n_elements(valmask) EQ 0 then valmask = 1e20
237      terre = where(res GT valmask/10.)
238      res = res < seuilmax
239      if terre[0] NE -1 then res[terre] = valmask
240      undefine, terre
241   endif
242;------------------------------------------------------------
243; points a mettre a nan
244;------------------------------------------------------------
245   if n_elements(nan) NE 0 then BEGIN
246      if n_elements(valmask) EQ 0 then valmask = 1e20
247      if abs(valmask) LT 1e6 then terre = where(abs(res) GT abs(valmask)/10.) $
248      ELSE terre = where(res EQ valmask)
249      if abs(nan) LT 1e6 then notan = where(res EQ nan) $
250      ELSE notan = where(abs(res) GT abs(nan))
251      if notan[0] NE -1 then res[notan] = !values.f_nan
252      notan = notan[0] NE -1
253      if terre[0] NE -1 then res[terre] = valmask
254      undefine, terre
255   endif
256;------------------------------------------------------------
257; ajustement de niveau pour les tableau 2d simples
258;------------------------------------------------------------
259   if jpt EQ 1 then begin
260      taille = size(res)
261      IF taille[0] EQ 2 THEN niveau = 1
262   endif
263;------------------------------------------------------------
264; moyenne eventuelle
265;------------------------------------------------------------
266   IF keyword_set(direc) THEN BEGIN
267      IF jpt EQ 1 THEN res = moyenne(res,direc,BOITE=boite, nan = notan) $
268      ELSE res = grossemoyenne(res,direc,BOITE=boite, nan = notan)
269   ENDIF
270;------------------------------------------------------------
271; mise en placer des parametres pour le trace...
272;------------------------------------------------------------
273;   if keyword_set(boite) then legende_pltt = boite ELSE legende_pltt = [lon1, lon2, lat1, lat2]
274;------------------------------------------------------------
275;   IF n_elements(res) NE 1 THEN res = reform(res,/over)
276   IF NOT keyword_set(direc) THEN domdef, lon1, lon2, lat1, lat2, prof1, prof2, _extra = ex, grille = vargrid $
277   ELSE if direc eq 't' then domdef, lon1, lon2, lat1, lat2, prof1, prof2, _extra = ex, grille = vargrid
278;------------------------------------------------------------
279   if keyword_set(structure) then res = {tab:res, grille:vargrid, unite:varunit, experience:varexp, nom:varname}
280;------------------------------------------------------------
281   if keyword_set(key_performance) THEN print, 'temps nlec', systime(1)-tempsun
282   time = time-2l
283   return,res
284;------------------------------------------------------------
285;------------------------------------------------------------
286end
Note: See TracBrowser for help on using the repository browser.