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