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