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

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

improvements/corrections of some *.pro headers

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