source: trunk/SRC/Obsolete/nlecmois.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: 6.8 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments lit les fichiers Net-Cdf  de moyenne mensuel  de
7; l'experience TOTEM/ECMWF qui sont sur
8; maia: /u/rech/eee/reee217/TOTEM/REF/OUTPUTS
9; @obsolete
10;
11; @keyword BOITE boite sur laquelle integrer (par defaut tt le domaine)
12;
13; @keyword GRILLE impose la grille a laquelle est rapporte le champ. rq permet
14; d'aller plus vite ds la lecture
15;
16; @keyword /TOUT oblige a lire le tableau entier en non pas celui reduit a domdef
17; @uses common.pro
18;
19; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
20;
21;-
22;------------------------------------------------------------
23;------------------------------------------------------------
24;REF.moyenne.mensuelle.79-81.grid.T.nc
25;------------------------------------------------------------
26function nlecmois,nom,numsortie79,nbretps ,BOITE=boite,GRILLE=grille,TOUT=tout, _EXTRA = ex
27@common
28;------------------------------------------------------------
29   res =-1
30;------------------------------------------------------------
31; annee du nom du 1er fichier
32;------------------------------------------------------------
33   annee = floor(floor((numsortie79-1)/12.)/3.)*3+79
34;------------------------------------------------------------
35; gestion du nom de la grille en testant les differentes possibilites
36; et ouverture du fichier
37;------------------------------------------------------------
38   if keyword_set(grille) then begin
39      vargrid=grille
40      nomfich=prefix+'.moyenne.mensuelle.'+strtrim(annee, 1)+'-'+strtrim(annee+2, 1)+'.grid.'+vargrid+'.nc'
41      IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+iodir+nomfich+' > /dev/null'
42      cdfid=ncdf_open(iodir+nomfich)
43      varcontient=ncdf_varinq(cdfid,nom)
44   endif else begin
45; liste des fichiers pouvant convenir
46      quelsfichiers = findfile(iodir+prefix+'.moyenne.mensuelle.'+strtrim(annee, 1)+'-'+strtrim(annee+2, 1)+'.grid.*')
47      IF quelsfichiers[0] EQ '' THEN $ ; liste vide
48         return, report('LES FICHIERS: '+iodir+prefix+'.moyenne.mensuelle.'+strtrim(annee, 1)+'-'+strtrim(annee+2, 1)+'.grid... n''existe pas.')
49      for i=0,n_elements(quelsfichiers)-1 do begin
50         IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+quelsfichiers[i]+' > /dev/null'
51         cdfid=ncdf_open(quelsfichiers[i])
52         contient=ncdf_inquire(cdfid)
53         for varid=0,contient.nvars-1 do BEGIN ; ds les fichiers existants on
54            varcontient=ncdf_varinq(cdfid,varid) ; cherche le nom des variables
55            if varcontient.name eq nom then BEGIN
56               vargrid=strmid(quelsfichiers[i],strpos(quelsfichiers[i],'grid')+5,1) ;nom de grille
57               goto, grilletrouvee
58            ENDIF
59         endfor
60         ncdf_close,cdfid
61      endfor
62      return, report('La variable '+nom+' n''existe pas ds les fichiers'+iodir+prefix+'.moyenne.mensuelle.'+strtrim(annee, 1)+'-'+strtrim(annee+2, 1)+'grid...')
63   endelse
64grilletrouvee:
65;------------------------------------------------------------
66; lecture de certains attributs et de l'axe des temps
67;------------------------------------------------------------
68   ncdf_attget,cdfid,nom,'title',value
69   varname=string(value)
70   ncdf_attget,cdfid,nom,'units',value
71   varunit=string(value)
72   if rstrpos(varname,'(') eq -1 then varname=varname+' ('+varunit+')'
73   varexp=prefix
74;------------------------------------------------------------
75; determination du domaine geographique
76;------------------------------------------------------------
77   if keyword_set(tout) then begin
78      nx=jpi
79      ny=jpj
80      nz=jpk
81      premierx=0
82      premiery=0
83      premierz=0
84   endif else BEGIN
85;------------------------------------------------------------
86; redefinition eventuelle du domaine ajuste a boite (a 6 elements)
87; + on recupere la dim du no9uveau domaine
88;------------------------------------------------------------
89      if keyword_set(boite) then BEGIN
90         Case N_Elements(Boite) Of
91            1:Domdef, lon1, lon2, lat1, lat2, 0.,boite[0],GRILLE=vargrid, _EXTRA = ex
92            2:Domdef, lon1, lon2, lat1, lat2, boite[0],boite[1],GRILLE=vargrid, _EXTRA = ex
93            4:Domdef, [Boite, prof1, prof2],GRILLE=vargrid, _EXTRA = ex
94            5:Domdef, [Boite[0:3], 0, Boite[4]],GRILLE=vargrid, _EXTRA = ex
95            6:Domdef, Boite,GRILLE=vargrid, _EXTRA = ex
96            Else:return,  report('Mauvaise Definition de Boite')
97         endcase
98      ENDIF
99      grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery, premierz
100   ENDELSE
101;------------------------------------------------------------
102; determination du nombre de pas de tps a extraire ds ce fichier
103;------------------------------------------------------------
104   numsortie = numsortie79-12.*(annee-79)
105   if nbretps+numsortie-1 gt 36 then nt=36-numsortie+1 $
106   else nt=nbretps
107   numsortie = numsortie79-12.*(annee-79)
108;------------------------------------------------------------
109    if varcontient.ndims eq 3 then $
110    ncdf_varget,cdfid,nom,res,offset=[premierx,premiery,numsortie-1],count=[nx,ny,nt] else $
111    ncdf_varget,cdfid,nom,res,offset=[premierx,premiery,premierz,numsortie-1],count=[nx,ny,nz,nt]
112;------------------------------------------------------------
113; rappel en boucle de nlec si il faut ouvrir de nouveaux fichiers
114; pour constituer la serie temporelle
115;------------------------------------------------------------
116   if nbretps gt 36-numsortie+1 then begin
117      if varcontient.ndims eq 3 then $
118       res = [[[res]] $
119              ,[[nlecmois(nom,numsortie79+nt,nbretps-nt,tout=tout,GRILLE=vargrid,BOITE=boite)]]] $
120      else BEGIN
121         res=[res[*] $
122              ,(nlecmois(nom,numsortie79+nt,nbretps-nt,tout=tout,GRILLE=vargrid,BOITE=boite))[*]]
123         
124         res=reform(res,nx,ny,nz,nbretps, /over)
125      ENDELSE
126      ncdf_varget,cdfid,'time_counter',temps, offset = [numsortie-1],count=[nt]
127      time = [long(temps)+julday(12, 31, 1978), time]
128      jpt=nt+jpt
129   endif else BEGIN
130      ncdf_varget,cdfid,'time_counter',temps, offset = [numsortie-1],count=[nt]
131      time = long(temps)+julday(12, 31, 1978)
132      jpt=nt
133   endelse
134;------------------------------------------------------------
135   ncdf_close,cdfid
136   IF n_elements(time) EQ 1 THEN BEGIN
137      caldat, time, m, d, y
138      if m lt 10 then m='0'+string(format='(i1)',m) $
139      else m=    string(format='(i2)',m)
140      if n_elements(langage) EQ 0 then langage = 'non definit'
141      if langage EQ 'gb' then vardate = strtrim(y, 1)+' '+string(format='(C(CMoA))',31*(m-1)) $
142      ELSE vardate = string(format='(C(CMoA))',31*(m-1))+' '+strtrim(y, 1)
143   endif
144;------------------------------------------------------------
145   return,res
146;------------------------------------------------------------
147;------------------------------------------------------------
148end
Note: See TracBrowser for help on using the repository browser.