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