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