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