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