[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
[127] | 5 | ; @file_comments |
---|
| 6 | ; lit les series temporelles se rapportant a une variable |
---|
[118] | 7 | ; sur maia: /u/rech/eee/reee217/TOTEM/REF/OUTPUTS |
---|
[127] | 8 | ; |
---|
[97] | 9 | ; @obsolete |
---|
[2] | 10 | ; |
---|
[97] | 11 | ; @categories lecture de NETCDF |
---|
[2] | 12 | ; |
---|
[118] | 13 | ; @examples |
---|
[97] | 14 | ; IDL> res=nlecserie(nom, date1, date2) |
---|
[2] | 15 | ; |
---|
[97] | 16 | ; @param nom {in}{required} nom du tableau contenant le champ que l'on veut (le |
---|
[2] | 17 | ; trouver avec ncdflec,fichier,/var |
---|
| 18 | ; |
---|
[127] | 19 | ; @param date1 {in}{required} |
---|
| 20 | ; @param date2 {in}{required} |
---|
| 21 | ; les dates vermairs qui delimitent la serie temporelle |
---|
[2] | 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.sss.grid.T.nc |
---|
| 47 | ;------------------------------------------------------------ |
---|
| 48 | function nlecserie, nom, date1, date2,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 |
---|
| 59 | ; et ouverture du fichier |
---|
| 60 | ;------------------------------------------------------------ |
---|
| 61 | ; liste des fichiers pouvant convenir |
---|
| 62 | quelsfichiers = findfile(iodir+prefix+'.'+nom+'.grid.*') |
---|
| 63 | IF quelsfichiers[0] EQ '' THEN BEGIN ; liste vide |
---|
| 64 | ; print, 'LES FICHIERS: '+iodir+prefix+'.'+nom+'.grid... n''existe pas.' |
---|
| 65 | return, -1 |
---|
[118] | 66 | ENDIF ELSE BEGIN |
---|
[2] | 67 | vargrid=strmid(quelsfichiers[0],strpos(quelsfichiers[0],'grid')+5,1) ;nom de grille |
---|
[44] | 68 | IF !version.OS_FAMILY EQ 'unix' THEN spawn, '\file '+quelsfichiers[0]+' > /dev/null' |
---|
[2] | 69 | cdfid=ncdf_open(quelsfichiers[0]) |
---|
[118] | 70 | ENDELSE |
---|
[2] | 71 | ;------------------------------------------------------------ |
---|
| 72 | ; lecture de certains attributs et de l'axe des temps |
---|
| 73 | ;------------------------------------------------------------ |
---|
| 74 | ncdf_attget,cdfid,nom,'title',value |
---|
| 75 | varname=string(value) |
---|
| 76 | ncdf_attget,cdfid,nom,'units',value |
---|
| 77 | varunit=string(value) |
---|
| 78 | if rstrpos(varname,'(') eq -1 then varname=varname+' ('+varunit+')' |
---|
| 79 | ncdf_attget,cdfid,'file_name',value,/global |
---|
| 80 | varexp=string(value) |
---|
| 81 | varexp=strmid(varexp, 0, strpos(varexp, '.')) |
---|
| 82 | ;------------------------------------------------------------ |
---|
| 83 | ; lecture de l'axe des temps en entier on ja reperer la place des |
---|
| 84 | ; dates debut et fin pour faire l''extraction temporelle |
---|
| 85 | ;------------------------------------------------------------ |
---|
| 86 | ncdf_varget,cdfid,'time_counter',time |
---|
| 87 | time = long(time)+julday(1, 5, 1979) |
---|
| 88 | ; debut = where(time EQ juldate(date1)) |
---|
| 89 | ; fin = where(time EQ juldate(date2)) |
---|
| 90 | debut = where(time EQ date1) |
---|
| 91 | fin = where(time EQ date2) |
---|
| 92 | if debut[0] EQ -1 then $ |
---|
| 93 | return, report('l''axe des temps ne contient pas la date de debut '+strtrim(date1, 1)) |
---|
| 94 | if fin[0] EQ -1 then $ |
---|
| 95 | return, report('l''axe des temps ne contient pas la date de fin '+strtrim(date2, 1)) |
---|
| 96 | time = time[debut[0]:fin[0]] |
---|
| 97 | jpt=fin[0]-debut[0]+1 |
---|
| 98 | IF jpt EQ 1 THEN BEGIN |
---|
| 99 | caldat, time[0], month, day, year |
---|
| 100 | case 1 of |
---|
| 101 | year lt 10: s_year ='0'+string(format='(i1)',year) |
---|
| 102 | year lt 100 and year ge 10 :s_year = string(format='(i2)',year) |
---|
| 103 | year ge 100: s_year = string(format='(i2)',year-1900) |
---|
| 104 | endcase |
---|
| 105 | if month lt 10 then s_month='0'+string(format='(i1)',month) $ |
---|
| 106 | else s_month= string(format='(i2)',month) |
---|
| 107 | if day lt 10 then s_day='0'+string(format='(i1)',day) $ |
---|
| 108 | else s_day= string(format='(i2)',day) |
---|
| 109 | vardate=s_year+s_month+s_day |
---|
| 110 | endif |
---|
| 111 | ;------------------------------------------------------------ |
---|
| 112 | ;------------------------------------------------------------ |
---|
| 113 | ; extraction du tableau qui nous interesse |
---|
| 114 | ;------------------------------------------------------------ |
---|
| 115 | ;------------------------------------------------------------ |
---|
| 116 | ;------------------------------------------------------------ |
---|
| 117 | ; determination du domaine geographique |
---|
| 118 | ;------------------------------------------------------------ |
---|
| 119 | if keyword_set(tout) then begin |
---|
| 120 | nx=jpi |
---|
| 121 | ny=jpj |
---|
| 122 | nz=jpk |
---|
| 123 | premierx = 0 |
---|
| 124 | premiery = 0 |
---|
| 125 | premierz = 0 |
---|
[118] | 126 | endif else BEGIN |
---|
[2] | 127 | ;------------------------------------------------------------ |
---|
| 128 | ; redefinition eventuelle du domaine ajuste a boite (a 6 elements) |
---|
| 129 | ; + on recupere la dim du no9uveau domaine |
---|
| 130 | ;------------------------------------------------------------ |
---|
[118] | 131 | if keyword_set(boite) then BEGIN |
---|
[2] | 132 | Case N_Elements(Boite) Of |
---|
| 133 | 1:Domdef, lon1, lon2, lat1, lat2, 0.,boite[0],GRILLE=vargrid, _EXTRA = ex |
---|
| 134 | 2:Domdef, lon1, lon2, lat1, lat2, boite[0],boite[1],GRILLE=vargrid, _EXTRA = ex |
---|
| 135 | 4:Domdef, [Boite, prof1, prof2],GRILLE=vargrid, _EXTRA = ex |
---|
| 136 | 5:Domdef, [Boite[0:3], 0, Boite[4]],GRILLE=vargrid, _EXTRA = ex |
---|
| 137 | 6:Domdef, Boite,GRILLE=vargrid, _EXTRA = ex |
---|
| 138 | Else:return, report('Mauvaise Definition de Boite') |
---|
| 139 | endcase |
---|
| 140 | ENDIF |
---|
| 141 | grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery |
---|
| 142 | ENDELSE |
---|
| 143 | ;------------------------------------------------------------ |
---|
| 144 | ncdf_varget,cdfid,nom,res $ |
---|
| 145 | ,offset=[premierx,premiery,debut[0]] $ |
---|
| 146 | ,count=[nx,ny,fin[0]-debut[0]+1] |
---|
| 147 | ;------------------------------------------------------------ |
---|
| 148 | ncdf_close,cdfid |
---|
| 149 | return,res |
---|
| 150 | ;------------------------------------------------------------ |
---|
| 151 | ;------------------------------------------------------------ |
---|
| 152 | end |
---|