source: trunk/LECTURE/nlec.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

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