source: trunk/SRC/Obsolete/lect.pro @ 118

Last change on this file since 118 was 118, checked in by pinsard, 18 years ago

add $ in Calendar, Grid, Interpolation, Obsolete and Postscript *.pro files, add svn:keywords Id to all these files, some improvements in header

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7;       lit les fichiers Vairmer de date1 a date2 et en sort un tableau
8;       1D, 2D ou 3D qui peut etre reutilise pour une courbe / hov / animation
9;cette fonction modifie aussi les variables globales:
10;varname: huit lettres: nom Vairmer du champ a tracer
11;vargrid:1 lettre : nom de la grille
12;varexp: trois lettres :nom de l'experience
13;
14; @obsolete
15;
16; @categories Graphics, lecture de fichier Vaimer
17;
18; @examples
19; IDL> resultat=lec('nom_Vairmer',date1,date2,'nomexp','direc',BOITE=boite)
20;
21; @param nomchamp {in}{required} nom de champ Vairmer (chaine de 8 caracteres
22; commencant par VO ou SO
23; @param date1 {in}{required} date de depart de la serie temporelle a
24; @param date2 {in}{required} date de fin (date2) de la serie temporelle a
25;             extraire
26; @param nomexp {in}{required} nom de l' experience a lire (prefix pardefaut)
27;
28; @param direc  {in}{required}
29; 'x' 'y' 'z' 'xy' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt' 'xzt'
30; 'yzt' 'xyzt' directions selon lesquelles effectuer les moyennes
31; (si rien n'est donne on n'effectue pas de moyenne)
32;
33; @keyword boite {in} boite sur laquelle integrer (par defaut tt le domaine)
34; @keyword  anom {in} type de fichiers ('SE','AN','') a relire pour calc une
35; anomalie
36; @keyword expanom {in} experience pour laquelle on veut calculer une anomalie
37; (par defaut la meme que nomexp)
38;
39; @uses common vraidate juldate
40;
41; @history Jerome Vialard (jv\@lodyc.jussieu.fr)
42; 2/7/98
43;
44; @version $Id$
45;
46;-
47;--------------------------------------------------------------
48;--------------------------------------------------------------
49;--------------------------------------------------------------
50;                  1      2      3    4      5
51function lect, nomchamp,date1,date2,nomexp,direc,BOITE=boite, $
52               ANOM=anom,EXPANOM=expanom
53;,REPEAT=repeat
54;
55  compile_opt idl2, strictarrsubs, obsolete
56;
57@common
58   tempsun = systime(1)         ; pour key_performance
59;
60   nomchamp = strupcase(nomchamp)
61   date1=vraidate(date1)
62   date2=vraidate(date2)
63;
64   dim=string(format='(a2)',nomchamp)
65;
66;------------------------------------------------------------
67; specification de la date et de l'experience
68;------------------------------------------------------------
69;
70   if fictype(date1) ne fictype(date2) then $
71    return, report('Les deux dates doivent correspondre au meme type de fic vairmer')
72   fictyp = fictype(date1)
73;-------------------------------------------------------------
74; creation du nom du fichier
75;-------------------------------------------------------------
76   if n_elements(nomexp) EQ 0 then nomexp = prefix
77   ficname=iodir+nomchamp+'.'+strcompress(date1,/remove_all)
78   ficname=ficname +'-'+fictyp+'-'+strcompress(date2,/remove_all)+'.'+nomexp
79   if (keyword_set(anom)) then ficname=ficname +'.'+anom
80   if (keyword_set(expanom)) then ficname=ficname +'-'+expanom
81   case n_elements(boite) of
82      4 : box = strcompress(string(format='(i4,"_",i4,"_",i4,"_",i4)',boite) $
83                            ,/remove_all)
84      6 : box = strcompress(string(format='(i4,"_",i4,"_",i4,"_",i4,"_",i4,"_",i4)',boite),/remove_all)
85      else: box= strcompress(string(format='(i4,"_",i4,"_",i4,"_",i4,"_",i4,"_",i4)',[lon1,lon2,lat1,lat2,prof1,prof2]),/remove_all)
86   ENDCASE
87   if n_elements(direc) EQ 0 then direc = ''
88   ficname=ficname+'.'+box+'.'+direc+'.hovdat'
89;-------------------------------------------------------------
90; Est ce que le fichier de hovmoller existe ?
91;-------------------------------------------------------------
92;
93; structure du fichier :
94; jpt (valeur de la dim temporelle), dimtableau (dimension du tableau)
95; dimttab[0], dimttab[1], ... (valeur des dim )
96; time (axe des tps), ttab (tableau a lire)
97; def du domaine (lon1,lon2,...  ,prof1,prof2)
98;
99   get_lun, numlec
100   openr, numlec, ficname, /get_lun,ERROR=err, /swap_if_little_endian
101   if (err eq 0) then begin
102      jpt = long(1)
103      dimtableau = long(1)
104      readu, numlec, jpt,dimtableau
105      case dimtableau of
106         1 : begin
107            n1 = long(1)
108            readu, numlec,n1
109            ttab = fltarr(n1)
110         end
111         2 : begin
112            n1 = long(1)
113            n2 = long(1)
114            readu, numlec,n1,n2
115            ttab = fltarr(n1,n2)
116         end
117         3 : begin
118            n1 = long(1)
119            n2 = long(1)
120            n3 = long(1)
121            readu, numlec,n1,n2,n3
122            ttab = fltarr(n1,n2,n3)
123         end
124      endcase
125      time = lonarr(jpt)
126; lecture axe des tps et du tableau
127      readu, numlec,time, ttab
128      newboite = fltarr(6)
129; lecture du domaine
130      readu, numlec,newboite
131      domdef, newboite
132; lecture info complementaire : nom du champs, de l'experience
133      varname='aaaaaaaa'
134      readu, numlec, varname
135      vargrid='a'
136      readu, numlec, vargrid
137      varexp='aaa'
138      readu, numlec, varexp
139;
140      close, numlec
141      free_lun, numlec
142      return, ttab
143   ENDIF
144   close, numlec
145   free_lun, numlec
146;-------------------------------------------------------------
147; changement de domaine
148;-------------------------------------------------------------
149   if keyword_set(boite) then BEGIN
150      Case 1 Of
151         N_Elements(Boite) Eq 1:bte=[lon1, lon2, lat1, lat2, 0.,boite[0]]
152         N_Elements(Boite) Eq 2:bte=[lon1, lon2, lat1, lat2, boite[0],boite[1]]
153         N_Elements(Boite) Eq 4:bte=[Boite, prof1, prof2]
154         N_Elements(Boite) Eq 5:bte=[Boite[0:3], 0, Boite[4]]
155         N_Elements(Boite) Eq 6:bte=Boite
156         Else: return, report('Mauvaise Definition de Boite')
157      endcase
158      oldboite = [lon1, lon2, lat1, lat2, prof1, prof2]
159      domdef, bte
160   ENDIF
161;-------------------------------------------------------------
162;   Boucle de lecture des fichiers
163;-------------------------------------------------------------
164   case fictyp of
165      'DA' : dec = 0.
166      'MO' : dec = 14.
167      'SE' : dec = 14.
168      'AN' : dec = 182.
169   endcase
170;initialisation des variables associees au tps
171   time = lonarr(jptmax)
172   jpt = 0
173   vdat = date1
174; debut de la boucle
175   while (vdat le date2) do begin
176;---------------------------------------------------------------
177; lecture du fichier a la date vdat (vairmer)
178;---------------------------------------------------------------
179      tab = lec(nomchamp,vdat,nomexp,ANOM=anom,EXPANOM=expanom)
180;---------------------------------------------------------------
181; attribution du mask et des tableaux de longitude et latitude...
182;---------------------------------------------------------------
183      if jpt EQ 0 THEN grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery,premierz,dernierx, derniery, dernierz
184;---------------------------------------------------------------
185      if (n_elements(tab) eq 1 and tab[0] eq -1) then begin
186         goto, incrdate
187      endif else begin
188         jpt = jpt + 1
189         if (jpt gt jptmax) then return, report('lect : augmenter jptmax')
190      endelse
191;--------------------------------------------------------
192; Moyenne du champs tab
193;--------------------------------------------------------
194      IF n_params() EQ 5 THEN if direc NE '' then BEGIN
195         if nx EQ 1 OR ny EQ 1 OR nz EQ 1 THEN BEGIN
196            if string(format='(a2)',nomchamp) EQ 'SO' then tab = reform(tab, nx, ny, /over) $
197            ELSE tab = reform(tab, nx, ny, nz, /over)
198         ENDIF
199         tab = moyenne(tab,direc)
200      endif
201      if (jpt eq 1) then begin
202         ttab = tab
203      endif else BEGIN
204         ttab = colle(ttab, tab, (size(tab))[0]+1 )
205      endelse
206      time[jpt-1] = juldate(vdat)+dec
207;--------------------------------------------------------
208; Incrementation de la date
209;--------------------------------------------------------
210      incrdate :
211      case fictyp of
212         'DA' : caldat,juldate(vdat)+1,month,day,year
213         'MO' : begin
214            caldat,julday(month,1,year)+jourdsmois(),month,day,year
215            day=0
216         end
217         'SE' : month=month+1
218         'AN' : year=year+1
219      endcase
220;------------------------------------------------------------
221;   Fin de boucle de lecture des fichiers
222;------------------------------------------------------------
223      vdat=long(10000)*year+long(100)*month+day
224   ENDWHILE
225   if ttab[0] EQ -1 then return, report('Aucun fichier n''a ete lu!')
226;------------------------------------------------------------
227;   Ecriture du fichier
228;------------------------------------------------------------
229   get_lun, numlec
230   openw, numlec, ficname, /get_lun, /swap_if_little_endian
231   taille = size(ttab)
232   writeu, numlec, long(jpt),long(taille[0])
233   case taille[0] of
234      1 : writeu, numlec,long(taille[1])
235      2 : writeu, numlec,long(taille[1]),long(taille[2])
236      3 : writeu, numlec,long(taille[1]),long(taille[2]),long(taille[3])
237   endcase
238   writeu, numlec,long(time[0:jpt-1]), ttab
239   writeu, numlec,float([lon1, lon2, lat1, lat2, prof1, prof2])
240; ecriture info complementaire : nom du champs, de l'experience
241   writeu, numlec, strmid(varname,0,8)
242   writeu, numlec, strmid(vargrid,0,1)
243   writeu, numlec, strmid(varexp,0,3)
244;
245   close, numlec
246   free_lun, numlec
247;-------------------------------------------------------
248;if keyword_set(repeat) then begin
249;   jpt = jpt * repeat
250;   if (jpt gt jptmax) then begin
251;     print, 'lect : augmenter jptmax'
252;     goto, fini
253;   endif
254;   tabadd = ttab
255;   ti
256;endif
257;--------------------------------------------------------
258   if n_elements(oldboite) NE 0 then domdef,  oldboite
259;
260   close, /all
261;
262   IF keyword_set(key_performance) THEN print, 'temps lect', systime(1)-tempsun
263;
264   return, ttab
265
266end
267
268
269
270
Note: See TracBrowser for help on using the repository browser.