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