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

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

modification of some headers (+some corrections) to prepare usage of the new idldoc

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