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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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