source: trunk/SRC/Obsolete/nlec5j.pro @ 97

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

start to modify headers of Obsolete *.pro files for better idldoc output

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments lit les fichiers Net-Cdf de l'experience TOTEM/ECMWF qui
6; contiennent les sorties a 5j regroupees par type de grille par
7; paquets de 6 mois.
8; sur maia: /u/rech/eee/reee217/TOTEM/REF/OUTPUTS
9; @obsolete
10;
11; @categories lecture de NETCDF
12;
13; @examples
14; IDL> res=nlec5j( nom, numsortie, nbretps)
15;
16; @param nom {in}{required} nom du tableau contenant le champ que l'on veut (le
17; trouver avec ncdflec,fichier,/var
18;  @param numsortie {in}{required}le numero du pas de temps que l'on veut sortir du
19; fichier (compte a partir de 1) a partir de year
20; @param nbretps {in}{required} nombre de pas de temps a extraire
21;
22;
23;       @keyword BOITE boite sur laquelle integrer (par defaut tt le domaine)
24;
25; @keyword GRILLE impose la grille a laquelle est rapporte le champ. rq permet
26; d'aller plus vite ds la lecture
27;
28; @keyword /TOUT oblige a lire le tableau entier en non pas celui reduit a domdef
29;
30; @returns tableau 2d (qd on ne demande pas de serie) ou 3d ou 4d ds le cas dune serie
31;
32; @uses common.pro
33;
34; @restrictions appele par nlec
35;
36; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
37;
38;-
39;------------------------------------------------------------
40;------------------------------------------------------------
41;------------------------------------------------------------
42function nlec5j, nom, numsortie, nbretps,BOITE = boite, GRILLE=grille,TOUT=tout, _EXTRA = ex
43@common
44;------------------------------------------------------------
45   res=-1
46   anneedepart=1979
47;------------------------------------------------------------
48; gestion du nom du fichier
49;------------------------------------------------------------
50   if numsortie le 36 then BEGIN
51      mmdd='0101'
52      numsort=numsortie
53   ENDIF  else BEGIN
54      if leapyr(year) then mmdd='0629' else mmdd='0630'
55      numsort=numsortie-36
56   endelse
57   case 1 of
58      year lt 10:                 s_year ='0'+string(format='(i1)',year)
59      year lt 100 and year ge 10 :s_year =    string(format='(i2)',year)
60      year ge 100:                s_year =    string(format='(i2)',(year-1900)*(year LT 2000))
61   endcase
62   numfich=(year-anneedepart)*2+7+(mmdd ne '0101')
63   s_date=s_year+mmdd
64   if numfich lt 10 then numfich='0'+string(format='(i1)',numfich) $
65   else numfich=    string(format='(i2)',numfich)
66;------------------------------------------------------------
67; gestion du nom de la grille en testant les differentes possibilites
68; et ouverture du fichier
69;------------------------------------------------------------
70   if keyword_set(grille) then begin
71      vargrid=grille
72      nomfich=prefix+'.'+numfich+'.'+s_date+'.grid.'+vargrid+'.nc'
73      IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+iodir+nomfich+' > /dev/null'
74      cdfid=ncdf_open(iodir+nomfich)
75      varcontient=ncdf_varinq(cdfid,nom)
76   endif else begin
77; liste des fichiers pouvant convenir
78      quelsfichiers = findfile(iodir+prefix+'.'+numfich+'.'+s_date+'.grid.*')
79      IF quelsfichiers[0] EQ '' THEN BEGIN ; liste vide
80         if keyword_set(bavard) then $
81          ras = report('LES FICHIERS: '+iodir+prefix+'.'+numfich+'.'+s_date+'.grid... n''existe pas.')
82         return,  -1
83      ENDIF
84      for i=0,n_elements(quelsfichiers)-1 do begin
85         IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+quelsfichiers[i]+' > /dev/null'
86         cdfid=ncdf_open(quelsfichiers[i])
87         contient=ncdf_inquire(cdfid)
88         for varid=0,contient.nvars-1 do BEGIN ; ds les fichiers existants on
89            varcontient=ncdf_varinq(cdfid,varid) ; cherche le nom des variables
90            if varcontient.name eq nom then BEGIN
91               vargrid=strmid(quelsfichiers[i],strpos(quelsfichiers[i],'grid')+5,1) ;nom de grille
92               goto, grilletrouvee
93            ENDIF
94         endfor
95         ncdf_close,cdfid
96      endfor
97      if keyword_set(bavard) then $
98       ras = report('La variable '+nom+' n''existe pas ds les fichiers'+iodir+prefix+'.'+numfich+'.'+s_date+'.grid...')
99      return,  -1
100   endelse
101grilletrouvee:
102;------------------------------------------------------------
103; lecture de certains attributs
104;------------------------------------------------------------
105   ncdf_attget,cdfid,nom,'title',value
106   varname=string(value)
107   ncdf_attget,cdfid,nom,'units',value
108   varunit=string(value)
109   if rstrpos(varname,'(') eq -1 then varname=varname+' ('+varunit+')'
110   if month lt 10 then s_month='0'+string(format='(i1)',month) $
111   else s_month=    string(format='(i2)',month)
112   if day lt 10 then s_day='0'+string(format='(i1)',day) $
113   else s_day=    string(format='(i2)',day)
114   vardate=s_year+s_month+s_day
115   ncdf_attget,cdfid,'file_name',value,/global
116   varexp=string(value[0:(where(value EQ (byte('.'))[0]))[0]-1])
117;------------------------------------------------------------
118;------------------------------------------------------------
119; extraction du tableau qui nous interesse
120;------------------------------------------------------------
121;------------------------------------------------------------
122; determination du domaine geographique
123;------------------------------------------------------------
124   if keyword_set(tout) then begin
125      nx=jpi
126      ny=jpj
127      nz=jpk
128      premierx = 0
129      premiery = 0
130      premierz = 0
131   endif else BEGIN
132;------------------------------------------------------------
133; redefinition eventuelle du domaine ajuste a boite (a 6 elements)
134; + on recupere la dim du no9uveau domaine
135;------------------------------------------------------------
136      if keyword_set(boite) then BEGIN
137         Case  N_Elements(Boite) Of
138            1:Domdef, lon1, lon2, lat1, lat2, 0.,boite[0],GRILLE=vargrid, _EXTRA = ex
139            2:Domdef, lon1, lon2, lat1, lat2, boite[0],boite[1],GRILLE=vargrid, _EXTRA = ex
140            4:Domdef, [Boite, prof1, prof2],GRILLE=vargrid, _EXTRA = ex
141            5:Domdef, [Boite[0:3], 0, Boite[4]],GRILLE=vargrid, _EXTRA = ex
142            6:Domdef, Boite,GRILLE=vargrid, _EXTRA = ex
143            Else: return, report('Mauvaise Definition de Boite')
144         endcase
145      ENDIF
146      grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery, premierz, dernierx, derniery, dernierz
147   ENDELSE
148;------------------------------------------------------------
149; determination du nombre de pas de tps a extraire ds ce fichier
150;------------------------------------------------------------
151   if nbretps gt 36+1*(mmdd ne '0101')-numsort+1 then nt=36+1*(mmdd ne '0101')-numsort+1 $
152   else nt=nbretps
153;------------------------------------------------------------
154;
155   if varcontient.ndims eq 3 then $
156    ncdf_varget,cdfid,nom,res,offset=[premierx,premiery,numsort-1],count=[nx,ny,nt] $
157   else $
158    ncdf_varget,cdfid,nom,res,offset=[premierx,premiery, premierz,numsort-1],count=[nx,ny,nz,nt]
159;------------------------------------------------------------
160; rappel en boucle de nlec si il faut ouvrir de nouveaux fichiers
161; pour constituer la serie temporelle
162;------------------------------------------------------------
163   if nbretps gt 36+1*(mmdd ne '0101')-numsort+1 then begin
164      if mmdd ne '0101' then year = year+1
165      if varcontient.ndims eq 3 then $
166       res = [[[res]] $
167              ,[[nlec5j(nom,1+36*(mmdd eq '0101'),nbretps-nt,tout=tout,GRILLE=vargrid,BOITE=boite)]]] $
168      ELSE BEGIN
169       res=[res[*] $
170            ,(nlec5j(nom,1+36*(mmdd eq '0101'),nbretps-nt,tout=tout,GRILLE=vargrid, BOITE=boite))[*]]
171       res=reform(res,nx,ny,nz,nbretps, /over)
172    ENDELSE
173      ncdf_varget,cdfid,'time_counter',temps, offset = [numsort-1],count=[nt]
174      time = [long(temps)+julday(1, 5, 1979), time]
175      jpt=nt+jpt
176   endif else BEGIN
177      ncdf_varget,cdfid,'time_counter',temps, offset = [numsort-1],count=[nt]
178      time = long(temps)+julday(1, 5, 1979)
179      jpt=nt
180   endelse
181;------------------------------------------------------------
182   ncdf_close,cdfid
183   return,res
184;------------------------------------------------------------
185;------------------------------------------------------------
186end
Note: See TracBrowser for help on using the repository browser.