Ignore:
Timestamp:
08/09/06 12:12:54 (18 years ago)
Author:
navarro
Message:

english and nicer header (3a)

Location:
trunk/SRC/ToBeReviewed/LECTURE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/LECTURE/GRIB/bit2int.pro

    r134 r150  
     1;+ 
     2; 
     3; @todo 
     4; seb 
     5; 
     6;- 
    17FUNCTION bit2int, bitin, checkneg = checkneg 
    28; 
  • trunk/SRC/ToBeReviewed/LECTURE/read_ftp.pro

    r142 r150  
    3838;+ 
    3939; 
    40 ; Syntax: 
     40; @file_comments 
    4141;   READ_FTP, remote_host [, files] [, directory] [,/FILE] [,DATA=variable] 
    4242;              [,USER=string] [,PASS=string] [,/PTR] 
     
    118118; $Id$ 
    119119; 
    120 ; @todo seb: que fait-on de "syntax" au debut du header? 
     120; @todo  
     121; seb: que fait-on de "syntax" au debut du header? 
     122; give examples with date in year 0 (should not exists but may happen) 
    121123;  
    122124;- 
  • trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro

    r142 r150  
    1 ;------------------------------------------------------------ 
    2 ;------------------------------------------------------------ 
    3 ;------------------------------------------------------------ 
    41;+ 
    5 ; 
    6 ; PURPOSE:fonction de lecture pour fichier net_cdf. 
    7 ; Ce programme, est moins universel que ncdf_lec (il fait appelle au 
    8 ; variables declarees dans common.pro) mais il est du cop bcp plus 
    9 ; facile d''utilisation. Il prend en compte la declaration des 
    10 ; differents zoom qui ont ete definis (ixminmesh...premierx...) la 
    11 ; declaration de la variable key_shift... bref le resultat de 
    12 ; read_ncdf peut dorectement etre utilise dans plt... 
    13 ; C''est aussi ce programme qui est utilise par defaut dans mes 
    14 ; widgets pour la partie lecture. 
    15 ; 
    16 ; CATEGORY:lecture de fichiers NetCdf 
    17 ; 
    18 ; CALLING SEQUENCE:res = read_ncdf(name,debut[,fin]) 
    19 ;  
    20 ; INPUTS: name: un string definissant le champ a lire. 
    21 ;         debut et fin: sont relatifs a l''axe des temps. Ce peut etre 
    22 ;         - 2 dates du type yyyymmdd et ds ce cas on selectionne les 
    23 ;         dates qui sont comprisent entre ces 2 dates. 
    24 ;         - 2 indices qui definissent entre quel et quel pas de temps 
    25 ;           on doit extraire la dimension temporelle. 
    26 ;         exp: ne sert a rien! 
    27 ; 
    28 ; KEYWORD PARAMETERS: utilisables hors du contexte des widgets 
    29 ; 
    30 ;        BOXZOOM: contient la boxzoom sur laquelle on doit faire la 
    31 ;        lecture 
    32 ;        FILENAME: string contennant le nom du fichier 
    33 ;        /INIT; to call automatically initncdf, filename and thus 
    34 ;        redefine all the grid parameters 
    35 ;        GRID='[UTVWF]' to specify the type of grid. Defaut is (1) 
    36 ;        based on the name of the file if the file ends by 
    37 ;        GRID[._][TUVFW].NC (not case sensible) or (2) T if case (1) 
    38 ;        is not found. 
    39 ;        IODIRECTORY;a string giving the name of iodirectory (see 
    40 ;        isafile.pro for all possibilities). default value is common  
    41 ;        variable iodir 
    42 ;        TIMESTEP:activer pour specifier que debut et fin font 
    43 ;        reference a des indices de l''axe du temps et non pas a des 
    44 ;        dates.  
    45 ;        TOUT: activer si on veut lire le ficher sur l''ensemble du 
    46 ;        domaine sans tenir compte du sous domaine definit par boxzoom 
    47 ;        ou lon1,lon2,lat1,lat2,vert1,vert2. 
    48 ;        NOSTRUCT: activer si on ne veut pas que read_ncdf reourne 
    49 ;        une structure mais uniquement le tableau se rapportant au 
    50 ;        champ.  
    51 ;        TIMEVAR: a string to define the name of the variable that 
    52 ;        contains the time axis. This keyword can be usefull if there 
    53 ;        is no unlimited dimension or if the time axis selected by defaut 
    54 ;        (the first 1D array with unlimited dimension) is not the good one 
    55 ;  
    56 ; 
    57 ; OUTPUTS:une stucture lisible par litchamp.pro ou un simple tableau 
    58 ; si /NOSTRUCT est active  
    59 ; 
    60 ; COMMON BLOCKS:common.pro 
    61 ; 
    62 ; SIDE EFFECTS: 
    63 ; 
    64 ; RESTRICTIONS:le champ doit avoir une dimension temporelle 
    65 ; 
    66 ; EXAMPLE: 
    67 ; 
    68 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 
    69 ;                      15/10/1999 
     2; @file_comments 
     3; Reading function for the file net_cdf. 
     4; This program is less universal than ncdf_lec (it appeal to declarated  
     5; variables in common.pro) but it is very easier to be used. It considerate 
     6; the declaration of the different zooms which have been defined 
     7; (ixminmesh...premierx...), the declaration of the variable key_shift... 
     8; To put it in a nutshell, the result of read_ncdf can be directly used in plt... 
     9; This is also this program which is used by default inour reading widgets.   
     10; 
     11; @categories 
     12; reading 
     13; 
     14;  
     15; @param NAME {in}{required} 
     16; It is a string defining the field to be read. 
     17; 
     18; @param BEGINNING {in}{required} 
     19; Relative with the time axis. 
     20; These can be 
     21;  - 2 date of the  type yyyymmdd and in this case, we select dates  
     22;  which are included between these two dates. 
     23;  - 2 indexes which define between which and which time step we have  
     24;  to extract the telporal dimension. 
     25; 
     26; @param ENDING  {in}{required} 
     27; Relative with the time axis. 
     28; See BEGINNING. 
     29;  
     30; @param COMPATIBILITY {in}{required} 
     31; Useless 
     32 
     33; @keyword BOXZOOM  
     34; Contain the boxzoom on which we have to do the reading  
     35;  
     36; @keyword FILENAME 
     37; It is a string containing the file's name. 
     38;  
     39; @keyword INIT 
     40; To call automatically initncdf, filename and thus 
     41; redefine all the grid parameters 
     42;  
     43; @keyword GRID 
     44; ='[UTVWF]' to specify the type of grid. Defaut is (1) 
     45; based on the name of the file if the file ends by 
     46; GRID[._][TUVFW].NC (not case sensible) or (2) T if case (1) 
     47; is not found. 
     48;  
     49; @keyword  IODIRECTORY 
     50; It isa string giving the name of iodirectory (see isafile.pro  
     51; for all possibilities). default value is common variable iodir. 
     52;  
     53; @keyword TIMESTEP 
     54; We activate to specify that BEGINNING and ENDING refer to indexes 
     55; of the time axis and not to dates 
     56; 
     57; @keyword TOUT 
     58; We activate it if we want to read the file on the whole domain without  
     59; considerate the sub-domain defined by the boxzoom or  
     60; lon1,lon2,lat1,lat2,vert1,vert2. 
     61;  
     62; @keyword NOSTRUCT 
     63; We activate it if we do not want that read_ncdf send back a structure  
     64; but only the array refering to the field. 
     65;  
     66; @keyword TIMEVAR 
     67; It is a string which define the name of the variable that 
     68; contains the time axis. This keyword can be usefull if there 
     69; is no unlimited dimension or if the time axis selected by defaut 
     70; (the first 1D array with unlimited dimension) is not the good one. 
     71; 
     72; @keyword _EXTRA 
     73; Used to pass your keywords  
     74; 
     75; @returns 
     76; Structure readable by litchamp.pro or an array if NOSRUCT is activated. 
     77;  
     78; @uses 
     79; common.pro 
     80;  
     81; @restrictions 
     82; The field must have a temporal dimension. 
     83;  
     84; @history 
     85; Sebastien Masson (smasson@lodyc.jussieu.fr) 
     86;                      15/10/1999  
     87;  
     88; @version 
     89; $Id$  
    7090;- 
    71 ;------------------------------------------------------------ 
    72 ;------------------------------------------------------------ 
    73 ;------------------------------------------------------------ 
    74 FUNCTION read_ncdf, name, debut, fin, pour_etre_compatible, BOXZOOM = boxzoom, FILENAME = filename $ 
     91;--------------------------------------------------------- 
     92;--------------------------------------------------------- 
     93;--------------------------------------------------------- 
     94 
     95FUNCTION read_ncdf, name, beginning, ending, compatibility, BOXZOOM = boxzoom, FILENAME = filename $ 
    7596                    , PARENTIN = parentin, TIMESTEP = timestep, TIMEVAR = timevar $ 
    7697                    , TOUT = tout, NOSTRUCT = nostruct, CONT_NOFILL = CONT_NOFILL, INIT = init $ 
     
    98119  filename = isafile(filename = filename, IODIRECTORY = iodir, _EXTRA = ex) 
    99120;------------------------------------------------------------ 
    100 ; ouverture du fichier nom 
     121; Opening of the name file 
    101122;------------------------------------------------------------ 
    102123  if size(filename, /type) NE 7 then $ 
     
    118139  if keyword_set(init) THEN initncdf, filename, _extra = ex 
    119140;------------------------------------------------------------ 
    120 ; check the time axis and the debut and fin dates 
    121 ;------------------------------------------------------------ 
    122   if n_elements(debut) EQ 0 then begin 
    123     debut = 0 
     141; check the time axis and the debut and ending dates 
     142;------------------------------------------------------------ 
     143  if n_elements(beginning) EQ 0 then begin 
     144    beginning = 0 
    124145    timestep = 1 
    125146  endif 
    126147  if keyword_set(timestep) then begin 
    127     firsttps = debut[0] 
    128     if n_elements(fin) NE 0 then lasttps = fin[0] ELSE lasttps = firsttps 
     148    firsttps = beginning[0] 
     149    if n_elements(ending) NE 0 then lasttps = ending[0] ELSE lasttps = firsttps 
    129150    jpt = lasttps-firsttps+1 
    130151    time = julday(1, 1, 1) + lindgen(jpt) 
     
    136157      currentfile = (where(filelist EQ filename))[0] 
    137158      time = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter 
    138       date1 = date2jul(debut[0]) 
    139       if n_elements(fin) NE 0 then date2 = date2jul(fin[0]) ELSE date2 = date1 
     159      date1 = date2jul(beginning[0]) 
     160      if n_elements(ending) NE 0 then date2 = date2jul(ending[0]) ELSE date2 = date1 
    140161      firsttps = where(time EQ date1) & firsttps = firsttps[0] 
    141162      lasttps = where(time EQ date2) & lasttps = lasttps[0] 
     
    159180; we find the FIRST time axis       
    160181        timeid = 0 
    161         repeat BEGIN       ; tant que l''on a pas trouve une variable qui n''a qu'' 
    162                                 ; une dimension: la dimension infinie 
    163           timecontient = ncdf_varinq(cdfid, timeid) ; que contient la variable 
     182        repeat BEGIN       ; As long as we have not find a variable having only one dimension: the infinite one 
     183          timecontient = ncdf_varinq(cdfid, timeid) ; that the variable contain. 
    164184          timeid = timeid+1 
    165185        endrep until (n_elements(timecontient.dim) EQ 1 $ 
     
    188208; 
    189209; now we try to find the attribut called calendar... 
    190 ; the the attribute "calendar" exists? 
     210; the attribute "calendar" exists? 
    191211; If no, we suppose that the calendar is gregorian calendar 
    192212; 
     
    248268        end 
    249269      ENDCASE 
    250       date1 = date2jul(debut[0]) 
    251       if n_elements(fin) NE 0 then date2 = date2jul(fin[0]) ELSE date2 = date1 
     270      date1 = date2jul(beginning[0]) 
     271      if n_elements(ending) NE 0 then date2 = date2jul(ending[0]) ELSE date2 = date1 
    252272      time = double(time) 
    253273      firsttps = where(time GE date1) & firsttps = firsttps[0] 
     
    271291  ENDELSE 
    272292;------------------------------------------------------------ 
    273 ; nom de la grille a laquelle se rapporte le champ 
     293; Name of the grid on which the field refer to. 
    274294;------------------------------------------------------------ 
    275295  IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE BEGIN 
     
    294314 
    295315;--------------------------------------------------------------- 
    296 ; redefinition du domaine  
     316; redefinition of the  domain 
    297317;--------------------------------------------------------------- 
    298318  if keyword_set(tout) then begin 
     
    331351    ENDIF 
    332352    grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 
    333     undefine, glam & undefine, gphi & ; on libere un peu de memoire! 
     353    undefine, glam & undefine, gphi & ; We liberate some memoty! 
    334354  ENDELSE 
    335355;--------------------------------------------------------------------- 
    336 ; on initialise les ixmindta, iymindta au besoin 
     356; We initializate ixmindta, iymindta if needed 
    337357;--------------------------------------------------------------------- 
    338358  if n_elements(jpidta) EQ 0 THEN jpidta = jpiglo 
     
    352372  IF izmaxdta EQ -1 then izmaxdta = jpkdta-1 
    353373;---------------------------------------------------------------- 
    354 ; on va lire le fichier 
     374; We will read the file 
    355375;--------------------------------------------------------------- 
    356376  if n_elements(key_stride) LE 2 then key_stride = [1, 1, 1] 
     
    401421    AND (strupcase(vargrid) EQ 'U' OR strupcase(vargrid) EQ 'F') THEN key_shift =  key_shift+1 
    402422;--------------------------------------------------------------------- 
    403 ; on definit les variables globales rattachees a la variable 
     423; We define global variable joined with the variable. 
    404424;--------------------------------------------------------------------- 
    405425; varname 
     
    434454  ENDELSE 
    435455; vardate 
    436 ; on construit une belle date lisible en fonction du langage specifie !!! 
    437   year = long(debut[0])/10000 
    438   month = (long(debut[0])/100) MOD 100 
    439   day = (long(debut[0]) MOD 100) 
     456; We make a legible date in function of the specified language. 
     457  year = long(beginning[0])/10000 
     458  month = (long(beginning[0])/100) MOD 100 
     459  day = (long(beginning[0]) MOD 100) 
    440460  vardate = string(format = '(C(CMoA))', 31*(month-1))+' '+strtrim(day, 1)+', '+strtrim(year, 1) 
    441461  varexp = file_basename(filename) 
     
    446466  if keyword_set(key_zreverse) AND (size(res))[0] EQ 4 THEN res = reverse(temporary(res), 3) 
    447467 
    448 ; on applique la valeur valmask sur les points terre 
     468; We apply the value valmask on land points. 
    449469  if NOT keyword_set(cont_nofill) then begin 
    450470    valmask = 1e20 
     
    482502;    ENDIF ELSE missing = -1 
    483503  ENDIF ELSE missing = -1 
    484 ; on applique les add_offset, scale_factor et missing_value 
     504; we apply add_offset, scale_factor and missing_value  
    485505  if scale_factor NE 1 then res = temporary(res)*scale_factor 
    486506  if add_offset NE 0 then res = temporary(res)+add_offset 
  • trunk/SRC/ToBeReviewed/LECTURE/xncdf_lec.pro

    r134 r150  
     1;------------------------------------------------------------ 
     2;------------------------------------------------------------ 
     3;------------------------------------------------------------ 
     4;+ 
     5; 
     6; @file_comments 
     7; Reading of a Net Cdf file with widgets !  
     8; 
     9; @categories  
     10; widget 
     11; 
     12; @param NAME {in}{optional} 
     13; It is a string giving the name of the file to be opened. If NAME  
     14; does not contain the separating character of directories ('/' under  
     15; unix for example), the file will be looked for in the current directory. 
     16; 
     17; @keyword IODIR 
     18; It is a string containing the directory where to go look for the file to be read. 
     19; If NAME does not contain the separating character of directories ('/' under  
     20; unix for example), the file will be called iodir+nom_fichier. 
     21; 
     22; @keyword COUNT 
     23; An optional vector containing the counts to be used in 
     24; reading Value. COUNT is a 1-based vector with an element for 
     25; each dimension of the data to be written.The default matches 
     26; the size of the variable so that all data is written out. 
     27; 
     28; @keyword GROUP 
     29; The widget ID of the widget that calls XNCDF_LEC. When 
     30; this ID is specified, a death of the caller results in a death 
     31; of XNCDF_LEC.  
     32; 
     33; @keyword OFFSET 
     34; An optional vector containing the starting position 
     35; for the read. The default start position is [0, 0, ...]. 
     36; 
     37; @keyword SHIFT 
     38; A vector of integers, specifing for each dimension how much we have to shift it.  
     39; By default, it is [0,0,...]. See the function shift for more explanations. BEWARE,  
     40; the shift is done on the biggest array before a possible reduction determinated  
     41; by OFFSET and COUNT. On the other hand, it is done after the possible extraction  
     42; created by the STRIDE. 
     43; 
     44; @keyword STRIDE 
     45; An optional vector containing the strides, or sampling 
     46; intervals, between accessed values of the netCDF variable. The 
     47; default stride vector is that for a contiguous read, [1, 1,...]. 
     48; 
     49; @returns 
     50;  2 different cases: 
     51;       1) None attribute has been selected. In this case, res is the array we 
     52;       wanted to read. 
     53;       2) Some attributes has been selected. In this case, res is a structure  
     54;       whose the first element having the name of the variable is the values  
     55;       array and the other arguments are the select arguments. 
     56; 
     57; @uses 
     58; wididbase, infovariable, resultat, motcle 
     59; 
     60; @examples 
     61; help, xncdf_lec() 
     62; 
     63; @history 
     64; Sebastien Masson (smasson@lodyc.jussieu.fr) 
     65;                      24/8/1999 
     66; 
     67; @version 
     68; $Id$ 
     69;- 
     70;------------------------------------------------------------ 
     71;------------------------------------------------------------ 
     72;------------------------------------------------------------ 
     73FUNCTION xncdf_lec, name, ATT = att, COUNT = count, GROUP = group, OFFSET = offset, IODIR = iodir, SHIFT = shift,  STRIDE = stride, VAR = var 
     74; 
     75  compile_opt idl2, strictarrsubs 
     76; 
     77   COMMON wididbase, base 
     78   COMMON infovariable, cdfid, listename, contient, nomdim, tailledim, varid, varcontient 
     79   COMMON resultat, res 
     80   COMMON motcle, mcatt, mccount, mcoffset, mciodir, mcshift, mcstride, mcvar 
     81;------------------------------------------------------------ 
     82; Trick for using keywords (we pass by variables declarated in a common) 
     83;------------------------------------------------------------ 
     84   res = -1 
     85   if keyword_set(att) then mcatt = att ELSE mcatt = 0 
     86   if keyword_set(count) then mccount =count  ELSE mccount = 0 
     87   if keyword_set(offset) then mcoffset = offset ELSE mcoffset = 0 
     88   if keyword_set(shift) then mcshift = shift ELSE mcshift = 0 
     89   if keyword_set(stride) then mcstride = stride ELSE mcstride = 0 
     90   if keyword_set(var) then mcvar = var ELSE mcvar = 0 
     91;------------------------------------------------------------ 
     92; choice of the file's name 
     93;------------------------------------------------------------ 
     94; What type of machine is used 
     95   thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
     96   CASE thisOS of 
     97      'MAC':sep = ':' 
     98      'WIN':sep = '\' 
     99      ELSE: sep = '/' 
     100   ENDCASE 
     101; If IODIR is not defined, we initialize it at the current directory 
     102   if NOT keyword_set(iodir) then cd,  current = iodir 
     103   mciodir = iodir 
     104; We complete IODIR with a separating character if needed. 
     105   IF rstrpos(iodir, sep) NE strlen(iodir)-1 THEN iodir = iodir+sep  
     106   if n_elements(name) EQ 0 then BEGIN ; If NAME is not defined, we find one thanks to the program dialog_pickfile. 
     107      name = dialog_pickfile(filter = iodir+'*.nc')  
     108      if name[0] EQ '' then return,  -1 ;If we do not have find anything, we go out. 
     109;We complete NAME by IODIR if NAME does not contain any directory separating character. 
     110   ENDIF ELSE if strpos(name, sep) EQ -1 then name = iodir+name 
     111   test = findfile(name)         ; Does the name looked for correspond to a file? 
     112   while test[0] EQ '' OR n_elements(test) GT 1 do BEGIN ; We look for one as long as it correspond to nothing! 
     113      test = test[0] 
     114      name = dialog_pickfile(filter = iodir+'*.nc') 
     115      if name EQ '' then return,  -1 
     116      test = findfile(name) 
     117   endwhile 
     118;------------------------------------------------------------ 
     119; Opening of the file name. 
     120;------------------------------------------------------------ 
     121   cdfid=ncdf_open(name) 
     122   contient=ncdf_inquire(cdfid) 
     123;------------------------------------------------------------ 
     124; What does this file contain?? 
     125;------------------------------------------------------------ 
     126; Opening of the base window as columns 
     127   if n_elements(group) EQ 0 then base = widget_base(/column, title='Fichier: '+name, /align_left) $ 
     128   ELSE base = widget_base(/column, title='Fichier: '+name, /align_left, GROUP_LEADER = group) 
     129; Opening of base sub-windows ; 
     130;------------------------------------------------------------ 
     131; base 1 title having the file's name 
     132;------------------------------------------------------------ 
     133   base1 = widget_base(base, /column, /align_center) 
     134   rien = widget_label(base1, value = 'Net Cdf filename', /align_center)  
     135   rien = widget_text(base1, value = name, /align_center, uvalue=1, /editable) ;File's name we can change 
     136   rien = widget_label(base1, value = ' ') ; We jump a line 
     137;------------------------------------------------------------ 
     138; base 2 General informations on the file 
     139;------------------------------------------------------------ 
     140   base2 = widget_base(base, /column) 
     141;------------------------------------------------------------ 
     142; Informations on global attributes 
     143;------------------------------------------------------------ 
     144   if contient.ngatts NE -1 then begin 
     145      rien = widget_label(base2, value = 'Nombre de attributs globaux: '+ strtrim(contient.ngatts,1), /align_left) 
     146      for attiq=0,contient.ngatts-1 do BEGIN ; Loop on  the number of global attributes 
     147         name=ncdf_attname(cdfid,attiq,/global) ;Attribute's name 
     148         ncdf_attget,cdfid,name,value,/global ;Attribute's value 
     149         rien = widget_text(base2, value = name+': '+strtrim(string(value),1), xsize = 60, /scroll, /wrap, /align_right) 
     150      endfor 
     151      rien = widget_label(base2, value = ' ') 
     152   endif 
     153;------------------------------------------------------------ 
     154;  Informations on dimensions 
     155;------------------------------------------------------------ 
     156   rien = widget_label(base2, value = 'Nombre de dimensions: '+strtrim(contient.ndims,1), /align_left) 
     157   if contient.recdim NE -1 then begin ;  Loop on  the number of global attributes 
     158      ncdf_diminq,cdfid,contient.recdim,name,value ; Name and value of the dimension 
     159      rien = widget_label(base2, value = 'name de la dimension infinie: '+name, /align_left) 
     160   endif 
     161; 
     162   nomdim   =strarr(contient.ndims) ; Vector containing dimensions's name 
     163   tailledim=lonarr(contient.ndims) ; Vector containing dimensions's value 
     164   for dimiq=0,contient.ndims-1 do begin ; Loop on the number of dimensions 
     165      ncdf_diminq,cdfid,dimiq,name,value ; Name and value of the dimension 
     166      nomdim[dimiq]=name 
     167      tailledim[dimiq]=value 
     168      rien = widget_label(base2, value = name+' de taille: '+strtrim(value,1), /align_right) 
     169   ENDFOR 
     170   rien = widget_label(base2, value = ' ') ; We jump a line 
     171;------------------------------------------------------------ 
     172; base 3 choice of the variable 
     173;------------------------------------------------------------ 
     174   base3 = widget_base(base, /column) 
     175   rien = widget_label(base3, value = 'Nombre de variables: '+strtrim(contient.nvars,1), /align_left) 
     176   base31 = widget_base(base3, /row, /align_center) 
     177;Creation of a listename containing the name of all file's variables 
     178   listename = strarr(contient.nvars) 
     179   for varid=0,contient.nvars-1 do begin 
     180      varcontient=ncdf_varinq(cdfid,varid) ; that the variable contain 
     181      listename[varid] = varcontient.name 
     182   endfor 
     183   rien= widget_label(base31, value = 'variable') 
     184; Creation of a button with a pop-up menu. 
     185   base311=widget_droplist(base31,value=listename, uvalue=2) 
     186   rien = widget_label(base3, value = '') 
     187;------------------------------------------------------------ 
     188; base 4 button done 
     189;------------------------------------------------------------ 
     190   base4 = widget_base(base, /row) 
     191   base42=widget_button(base4,value='done', uvalue=3, /align_right) 
     192;Execution of the base window and of sub-windows 
     193   widget_control,base,/realize 
     194;------------------------------------------------------------ 
     195   xmanager,'xncdf_lec',base 
     196;------------------------------------------------------------ 
     197;------------------------------------------------------------ 
     198;------------------------------------------------------------ 
     199   return, res 
     200end 
     201; 
    1202; La lecture de ce programme se fait de bas en haut: 
    2203;   1) xncdf_lec 
     
    5206;            --> wid_var_event 
    6207; 
     208;+ 
     209; @file_comments 
     210; Procedure called by xmanager when we press on a button of a second widget created by wid_var. 
     211;  
     212; @param EVENT {in}{required} 
     213; A structure caracterizing the type of event which arrive to a widget number1 2 
     214; 
     215; @uses 
     216; wididbase,resultat,infovariable,indicewid,motcle 
     217;  
     218; @version 
     219; $Id$ 
     220;- 
     221;------------------------------------------------------------ 
     222;------------------------------------------------------------ 
     223;------------------------------------------------------------ 
    7224pro wid_var_event,  event 
    8 ; NAME:wid_var_event 
    9 ; 
    10 ; PURPOSE:procedure appele par xmanager qd on appuie sur un bouton du 
    11 ; 2eme widget cree par wid_var 
    12 ;  
    13 ; INPUTS: event, une structure caracterisant le type d''evenement qui 
    14 ; arrive au widget numero1 2 
    15 ; 
    16 ; COMMON BLOCKS:wididbase,resultat,infovariable,indicewid,motcle 
    17 ;------------------------------------------------------------ 
    18 ;------------------------------------------------------------ 
    19 ;------------------------------------------------------------ 
    20225; 
    21226  compile_opt idl2, strictarrsubs 
     
    27232   COMMON motcle, mcatt, mccount, mcoffset, mciodir, mcshift, mcstride, mcvar 
    28233; 
    29 ; quel est le type d''evenement? 
     234; What is the type of event? 
    30235   widget_control, event.id, get_uvalue=uval 
    31236   tailledimvar = tailledim[varcontient.dim] 
    32237   if n_elements(uval) EQ 0 then return 
    33 ; case sur le type d''evenement 
     238; case on the type of event. 
    34239   case uval OF 
    35       1:BEGIN                   ; on change des valeurs dans le tableau 
    36 ; on controle que les valeurs mises dans le tableau ne sont pas 
    37 ; completement fausses 
     240      1:BEGIN                   ; We change values in the array 
     241; We check that values put in the array are not totally false. 
    38242         widget_control, widbase1, get_value = table 
    39 ; agument du bon type ? 
    40 ; si le type est mauvais on change automatiquement par des valeurs par 
    41 ; defaut 
     243; Is it the good type of argument? 
     244; If the type is wrong, we automatically change it by default values. 
    42245         if event.x GT (size(table))[1] then return 
    43246         if event.y GT (size(table))[2] then return 
     
    50253             , use_table_select = [event.x, event.y, event.x, event.y], set_value = 0 
    51254         endif 
    52 ; agument avec une valeur nom debile? 
     255; Argument with a wrong name value? 
    53256         table = fix(table) 
    54257         case event.x of 
    55             0:BEGIN             ; on a touche a l''offset: 
     258            0:BEGIN             ; We touched the offset 
    56259               if table[0, event.y] LT 0 then BEGIN 
    57260                  table[0, event.y] = 0 
    58261                  widget_control, widbase1, use_table_select = [0, event.y, 0, event.y] $ 
    59262                   , set_value = 0 
    60                endif 
    61 ; si il depasse la dim du tableau on le met au max et le cont a 1 
     263              endif 
     264; If it exceed the dimension of the array, we put it at the max and the cont at 1. 
    62265               if table[0, event.y] GT tailledimvar[event.y]/table[3, event.y] then begin 
    63266                  widget_control, widbase1, use_table_select = [0, event.y,1, event.y] $ 
    64267                   , set_value = [tailledimvar[event.y]/table[3, event.y], 1] 
    65                ENDIF ELSE BEGIN 
    66 ; si avec le nouvel offset le count est trop grand, on le diminue juste 
    67 ; de ce qu''il faut! 
     268              ENDIF ELSE BEGIN 
     269; If, with the new offset, the cont is too big, we reduce it  until it goes well! 
    68270                  if table[1, event.y] GT $ 
    69271                   (tailledimvar[event.y]/table[3, event.y])-table[0, event.y] then begin 
     
    73275               ENDELSE 
    74276            END 
    75             1:BEGIN             ;on a touche au count 
     277            1:BEGIN             ;We touched the cont. 
    76278               if table[1, event.y] LT 1 then BEGIN 
    77279                  table[1, event.y] = 1 
     
    79281                   , set_value = 1 
    80282               endif 
    81 ; si il est trop grand, on le diminue juste de ce qu''il faut! 
     283; If it is too big, we reduce it  until it goes well! 
    82284               if table[1, event.y] GT $ 
    83285                (tailledimvar[event.y]/table[3, event.y])-table[0, event.y] then BEGIN 
     
    86288               endif 
    87289            END 
    88             2:BEGIN             ; on a touche au shift 
     290            2:BEGIN             ;We touched the shift. 
    89291               widget_control, widbase1, use_table_select = [2, event.y, 2, event.y] $ 
    90292                , set_value = table[2, event.y] MOD (tailledimvar[event.y]/table[3, event.y]) 
    91293            END 
    92             3:BEGIN             ; on touche au stride 
     294            3:BEGIN             ;We touched the stride. 
    93295               if table[3, event.y] LT 1 then BEGIN 
    94296                  table[3, event.y] = 1 
     
    96298                   , set_value = 1 
    97299               endif 
    98                if table[3, event.y] EQ 0 then $ ; il ne doit pas etre nul 
     300               if table[3, event.y] EQ 0 then $ ;It must not be null. 
    99301                widget_control, widbase1, use_table_select = [3, event.y, 3, event.y] $ 
    100302                , set_value = 1 
    101 ; il ne doit pas etre trop grand 
     303; It must not be too big. 
    102304               if table[3, event.y] GT tailledimvar[event.y] then $ 
    103305                widget_control, widbase1, use_table_select = [0, event.y,3, event.y] $ 
     
    114316         endcase 
    115317      END 
    116       2111:BEGIN                ;on a touche aux boutons oui/non 
    117 ; on actualise le vecteur selectatt a 0 ou 1 pour l''attribut concerne 
    118 ; (numero event.id) 
     318      2111:BEGIN                ;We touched buttons yes/no 
     319; We update the vector selectatt at 0 or 1 for the concerned attribute (number event.id). 
    119320         selectatt[where(widbase2111 EQ event.id)] = event.select 
    120321      end 
    121       31:BEGIN                  ;on a appuye sur 'get' 
     322      31:BEGIN                  ;We pressed on 'get' 
    122323         widget_control, widbase1, get_value = table 
    123324         table = fix(table) 
     
    126327         mccount = table[1, *] 
    127328         mcstride = table[3, *] 
    128          if mcshift[0] NE -1 then BEGIN ; il y a des shifts 
    129 ; on lit l''integralite des dimensions pour lesquelles il y a un shift 
     329         if mcshift[0] NE -1 then BEGIN ; There are some shifts. 
     330; We read the wholeness of dimensions for which ones there is a shift. 
    130331            mcoffset[mcshift] = 0 
    131332            mccount[mcshift] = tailledimvar[mcshift] 
    132 ; on active pas stride qd il n''y en a pas besoin car ca fait ecrire a 
    133 ; l''ecran qqch de louche... 
     333; We do not activate stride when there is no need because it makes write something weird on the screen. 
    134334            if total(mcstride) EQ n_elements(mcstride) then $ 
    135335             ncdf_varget, cdfid, varid, res, OFFSET = mcoffset, COUNT = mccount $ 
    136336            ELSE $ 
    137337             ncdf_varget, cdfid, varid, res, OFFSET = mcoffset, COUNT = mccount, STRIDE = mcstride 
    138 ; pour faire le shift 
     338; To do the shift 
    139339            mcshift = table[2, *] 
    140340            mcoffset = table[0, *] 
    141341            mccount = table[1, *] 
    142 ; on definit commende qui permet de faire un shift 
     342; We define the command allowing to do a shift. 
    143343            commande = 'res=shift(res' 
    144344            for dim = 0, varcontient.ndims-1 do commande = commande+','+string(table[2,dim]) 
    145345            commande = commande+')' 
    146346            rien = execute(commande) 
    147 ; on redefinit commnade qui permet de couper les dimensions qui n''ont 
    148 ; pas ete encore coupees (c''est celles que l''on shift) 
    149             commande = 'res=res[' ; initialisation de la commende 
     347; We redefine the command allowing to cut dimensions which has not been cut yet (ones we shift). 
     348            commande = 'res=res[' ; initialization of the command 
    150349            for dim = 0, varcontient.ndims-1 do BEGIN  
    151350               if mcshift[dim] EQ 0 then commande = commande+'*,' $ 
     
    154353            commande = strmid(commande, 0, strlen(commande)-1)+']' 
    155354            rien = execute(commande) 
    156 ; cas sans shift, on lit directement le bon bout de tableau 
     355; Case without shift, we read directly the good part of the array. 
    157356         ENDIF ELSE BEGIN 
    158357            if total(mcstride) EQ n_elements(mcstride) then $ 
     
    161360             ncdf_varget, cdfid, varid, res, OFFSET = mcoffset, COUNT = mccount, STRIDE = mcstride 
    162361         ENDELSE 
    163 ; faut-il constituer une structure avec les attributs qui on ete selectionnes 
    164          if total(selectatt) NE 0 then BEGIN ; il y a des attributs selectionnes 
    165             res = create_struct(varcontient.name, res) ; on cree la structure 
    166             selectatt = where(selectatt EQ 1) ; on trouve les attributs selectiones  
    167             for attid = 0,  n_elements(selectatt)-1 do BEGIN ; pour lesquels on prend 
    168                widget_control, widbase212[selectatt[attid]], get_value = attname ; le nom 
    169                widget_control, widbase213[selectatt[attid]], get_value = attvalue ; la valeur 
    170               res = create_struct(res, attname[0], attvalue[0]) ; on concatene la structe 
     362; Do we have to constitute a structure with selected attributes. 
     363         if total(selectatt) NE 0 then BEGIN ; There are selected attributes 
     364            res = create_struct(varcontient.name, res) ; We create the structure 
     365            selectatt = where(selectatt EQ 1) ; We find selected attributes 
     366            for attid = 0,  n_elements(selectatt)-1 do BEGIN ; for which we take 
     367               widget_control, widbase212[selectatt[attid]], get_value = attname ; the name 
     368               widget_control, widbase213[selectatt[attid]], get_value = attvalue ; the value 
     369              res = create_struct(res, attname[0], attvalue[0]) ; We concatenate the structure 
    171370            endfor 
    172371         endif 
    173          widget_control, event.top, /destroy ;on ferme le 2eme widget 
    174          widget_control, base, /destroy ;on ferme le 1eme widget 
     372         widget_control, event.top, /destroy ;We shut the second widget. 
     373         widget_control, base, /destroy ;We shut the first widget. 
    175374         ncdf_close,cdfid 
    176375      END 
    177       32:                       ;cas de l''affichage d''un held (avec xdisplayfile) 
    178       33:widget_control, event.top, /destroy ;on ferme le 2eme widget 
     376      32:                       ;Case of the display of a held (with xdisplayfile) 
     377      33:widget_control, event.top, /destroy ;We shut the second widget. 
    179378      ELSE: 
    180379   endcase 
     
    183382;------------------------------------------------------------ 
    184383;------------------------------------------------------------ 
     384;------------------------------------------------------------ 
     385;+ 
     386; @file_comments 
     387; This procedure manage the second created whiget when we call xncdf_lec.  
     388; This widget concern the reading of the variable. 
     389; 
     390; @param WIDID_PERE {in}{required} 
     391; It is a scalar containing the identity of the father widget which was  
     392; created by xncdf_lec and which has allowed to select the variable to be read. 
     393; 
     394; OUTPUTS: indirectement res (le tableau ou la structure resultat) 
     395; 
     396; @uses  
     397; resultat,infovariable,indicewid_var,motcle 
     398; 
     399; @version 
     400; $Id$ 
     401;- 
     402;------------------------------------------------------------ 
     403;------------------------------------------------------------ 
     404;------------------------------------------------------------ 
    185405PRO wid_var, widid_pere 
    186 ;------------------------------------------------------------ 
    187 ;------------------------------------------------------------ 
    188 ;------------------------------------------------------------ 
    189 ; NAME: wid_var 
    190 ; 
    191 ; PURPOSE: cette procedure gere le 2eme widget cree qd on appelle 
    192 ; xncdf_lec. ce widget concerne la lecture de la variable 
    193 ; 
    194 ; INPUTS: widid_pere: un scalere contenant l'identite du widget pere 
    195 ; qui a etait cree par xncdf_lec et qui a permis de selectionner la 
    196 ; variable a lire. 
    197 ; 
    198 ; OUTPUTS: indirectement res (le tableau ou la structure resultat) 
    199 ; 
    200 ; COMMON BLOCKS:resultat,infovariable,indicewid_var,motcle 
    201 ; 
    202 ;------------------------------------------------------------ 
    203 ;------------------------------------------------------------ 
    204 ;------------------------------------------------------------ 
    205406; 
    206407  compile_opt idl2, strictarrsubs 
     
    212413   res = -1 
    213414;------------------------------------------------------------ 
    214 ; ouverture de la fenetre de base sous forme de colonnes 
    215 ;------------------------------------------------------------ 
     415; Opening of the base window as columns. 
    216416   widbase = widget_base(/column, title='variable: '+varcontient.name, /align_center, group_leader = widid_pere) 
    217417;------------------------------------------------------------ 
    218 ; ouverture de  sous-fenetres de base ; 
    219 ;------------------------------------------------------------ 
    220 ; widbase1 tableau des offsets 
    221 ;------------------------------------------------------------ 
    222    rien = widget_label(widbase, value = ' ') ; on saute une ligne 
    223 ; defintion des lables des lignes du tableau 
     418; Opening of the base subwindow  
     419;------------------------------------------------------------ 
     420; widbase1 array of offsets 
     421;------------------------------------------------------------ 
     422   rien = widget_label(widbase, value = ' ') ; We jump a line 
     423; Definition of labels of lines of the array 
    224424   rowlab = string(tailledim[varcontient.dim]) 
    225425   for i = 0,  n_elements(rowlab)-1 do rowlab[i] = strtrim(rowlab[i], 1) 
    226426   rowlab = nomdim[varcontient.dim]+replicate(': ', n_elements(varcontient.dim))+rowlab 
    227 ; definition des valeurs initiales du tableau 
     427; Definition of array's initial values 
    228428   valinit = lonarr(4, n_elements(varcontient.dim)) 
    229 ; colonne 0 : les offset 
     429; column 0 : offsets 
    230430   if keyword_set(mcoffset) AND n_elements(mcoffset) EQ varcontient.ndims THEN $ 
    231431    valinit[0,*]=mcoffset ELSE valinit[0, *] = 0 
    232 ; colonne 1 : les counts 
     432; colomn 1 : counts 
    233433   if keyword_set(mccount) AND n_elements(mccount) EQ varcontient.ndims THEN  $ 
    234434    valinit[1,*]=mccount ELSE valinit[1, *] = tailledim[varcontient.dim] 
    235 ; colonne 2 : les shifts 
     435; column 2 : shifts 
    236436   if keyword_set(mcshift) AND n_elements(mcshift) EQ varcontient.ndims THEN $ 
    237437    valinit[2,*]=mcshift ELSE valinit[2, *] = 0 
    238 ; colonne 3 : les strides 
     438; column 3 : strides 
    239439   if keyword_set(mcstride) AND n_elements(mcstride) EQ varcontient.ndims THEN $ 
    240440    valinit[3,*]=mcstride ELSE valinit[3, *] = 1 
    241 ; test des valeurs initiales du tableau 
     441; test of initial values of the array 
    242442   valinit = fix(valinit) 
    243    valinit[3, *] = 1 > valinit[3, *] < tailledim[varcontient.dim] ; test des strides 
    244    valinit[0, *] = 0 > valinit[0, *] < tailledim[varcontient.dim] ; test des offsets 
    245 ; test des counts 
     443   valinit[3, *] = 1 > valinit[3, *] < tailledim[varcontient.dim] ; test of strides 
     444   valinit[0, *] = 0 > valinit[0, *] < tailledim[varcontient.dim] ; test of offsets 
     445; test of counts 
    246446   valinit[1, *] = 1 > valinit[1, *] < ((tailledim[varcontient.dim]/valinit[3, *])-valinit[0, *]) 
    247    valinit[2, *] = valinit[2, *] MOD (tailledim[varcontient.dim]/valinit[3, *]) ; test des shifts 
    248 ; declaration du tableau 
     447   valinit[2, *] = valinit[2, *] MOD (tailledim[varcontient.dim]/valinit[3, *]) ; test of shifts 
     448; declaration of the array 
    249449   widbase1 = widget_table(widbase, row_labels = rowlab, value = valinit, /editable $ 
    250450                           , column_labels = ['Offset', 'Count', 'Shift', 'Stride'], uvalue = 1) 
     
    253453   rien = widget_label(widbase, value = 'du tableau ou des textes soient bien prises en compte', /align_center) 
    254454;------------------------------------------------------------ 
    255 ; widbase2 choix des attributs 
    256 ;------------------------------------------------------------ 
    257    rien = widget_label(widbase, value = ' ') ; on saute une ligne 
     455; widbase2 choice of attributes 
     456;------------------------------------------------------------ 
     457   rien = widget_label(widbase, value = ' ') ; We jump a line 
    258458   widbase2 = widget_base(widbase, /column) 
    259 ; pour chaque attribut, on cree un widget (widbase21) qui contient en ligne un 
    260 ; bouton oui/non (widbase211), et deux wigdet text (widbase212, 
    261 ; widbase213)comportant le nom et la valeur de l''attribut. 
     459; To each attribute, we created a widget (widbase21) containing in line a button  
     460; yes/no (widbase211), and two wigdet text (widbase212, widbase213) comprising the  
     461; name and the value of the attribute. 
    262462   widbase21 = lonarr(varcontient.natts) 
    263463   widbase211 = lonarr(varcontient.natts) 
    264464   widbase2111 = lonarr(varcontient.natts) 
    265 ; vecteur qui serviera a savoir quels boutons oui/non sont 
    266 ; selectiones. cf. wid_var_event 
     465; Vector which will serve to know which yes/no are selected. see. wid_var_event 
    267466   selectatt = lonarr(varcontient.natts) 
    268467   selectatt[*] = 0 
    269468   widbase212 = lonarr(varcontient.natts) 
    270469   widbase213 = lonarr(varcontient.natts) 
    271    for attid = 0, varcontient.natts-1 do BEGIN ;boucle sur le nombre d''attributs 
     470   for attid = 0, varcontient.natts-1 do BEGIN ;Lop on the number of attribute. 
    272471      widbase21[attid] = widget_base(widbase2, /row) 
    273472      name=ncdf_attname(cdfid,varid,attid) 
     
    279478   endfor 
    280479;------------------------------------------------------------ 
    281 ; widbase3 boutons du bas 
     480; widbase3 buttons of the bottom. 
    282481;------------------------------------------------------------ 
    283482   widbase3 = widget_base(widbase, /row,/align_center) 
     
    286485   widbase33=widget_button(widbase3,value='DONE', uvalue=33) 
    287486;------------------------------------------------------------ 
    288 ;execution de la fentre de base et des sous-fenetres 
     487;execution of the base window and of sub-window. 
    289488;------------------------------------------------------------ 
    290489   widget_control,widbase,/realize 
     
    295494;------------------------------------------------------------ 
    296495 
     496;------------------------------------------------------------ 
     497;------------------------------------------------------------ 
     498;------------------------------------------------------------ 
     499;+ 
     500; @file_comments 
     501; Procedure called by xmanager when we press a button of the first widget  
     502; created by par xncdf_lec 
     503;  
     504; @param EVENT 
     505; A structure caracterising the event type which arrive at the widget number 1. 
     506; 
     507; @uses 
     508; resultat, infovariable, motcle 
     509; 
     510; @version 
     511; $Id$ 
     512;- 
     513;------------------------------------------------------------ 
     514;------------------------------------------------------------ 
     515;------------------------------------------------------------ 
    297516PRO xncdf_lec_event, event 
    298 ;------------------------------------------------------------ 
    299 ;------------------------------------------------------------ 
    300 ;------------------------------------------------------------ 
    301 ; NAME:xncdf_lec_event 
    302 ; 
    303 ; PURPOSE: procedure appele par xmanager qd on appuie sur un bouton du 
    304 ; 1ere widget cree par xncdf_lec 
    305 ;  
    306 ; INPUTS: event, une structure caracterisant le type d''evenement qui 
    307 ; arrive au widget numero1 
    308 ; 
    309 ; COMMON BLOCKS:resultat, infovariable, motcle 
    310 ; 
    311 ;------------------------------------------------------------ 
    312 ;------------------------------------------------------------ 
    313 ;------------------------------------------------------------ 
    314517; 
    315518  compile_opt idl2, strictarrsubs 
     
    318521   COMMON infovariable, cdfid, listename, contient, nomdim, tailledim, varid, varcontient 
    319522   COMMON motcle, mcatt, mccount, mcoffset, mciodir, mcshift, mcstride, mcvar 
    320 ; quel est le type d''evenement? 
     523; What is the type of event? 
    321524   widget_control, event.id, get_uvalue=uval 
    322 ; case sur le type d''evenement 
     525; case on the type of event. 
    323526   case uval of 
    324       1:BEGIN                   ; on veut lire un autre fichier 
    325          widget_control, event.id, get_value = nom ; on recupere le nom 
    326          widget_control, event.top, /destroy ;on ferme le widget 
    327          ncdf_close,cdfid       ; on ferme le mauvais fichier qui a ete ouvert 
    328 ; on reapelle xncdf_lec 
     527      1:BEGIN                   ; We want to read an other file 
     528         widget_control, event.id, get_value = nom ; We recuperate the name. 
     529         widget_control, event.top, /destroy ;We shut the widget. 
     530         ncdf_close,cdfid       ;We shut the wrong file which has been opened. 
     531;We call back xncdf_lec 
    329532         res = xncdf_lec(nom[0], ATT = mcatt, COUNT = mccount, OFFSET = mcoffset, IODIR = mciodir $ 
    330533                         , SHIFT = mcshift,  STRIDE = mcstride, VAR = mcvar)  
    331534         return 
    332535      END 
    333       2:BEGIN                   ; une variable est selectionee 
    334          varid = event.index    ; on recupere son numero ds le fichier Netcdf 
     536      2:BEGIN                   ; A variable is selected. 
     537         varid = event.index    ; We recuperat its number in the file Netcdf 
    335538         varcontient = ncdf_varinq(cdfid,varid) 
    336          wid_var, event.top     ; on appelle le programme qui lance le 2eme widget. cf. + haut 
     539         wid_var, event.top     ; We call the program which launch the second widget. See sooner. 
    337540      END 
    338       3:BEGIN                   ; bouton done 
    339          widget_control, event.top, /destroy ; on tue le widget 
    340          ncdf_close,cdfid       ; on ferme le fichier 
     541      3:BEGIN                   ; button done 
     542         widget_control, event.top, /destroy ; We delete the widget 
     543         ncdf_close,cdfid       ; We shut the file. 
    341544      END 
    342545      ELSE: 
     
    344547   return 
    345548end 
    346 ;------------------------------------------------------------ 
    347 ;------------------------------------------------------------ 
    348 ;------------------------------------------------------------ 
    349 ;+ 
    350 ; NAME: xncdf_lec 
    351 ; 
    352 ; PURPOSE: lecture d''un fichier Net Cdf avec des widgets !  
    353 ; 
    354 ; CATEGORY: lecture de fichiers avec widgets 
    355 ; 
    356 ; CALLING SEQUENCE: res=xncdf_lec([nom_fichier]) 
    357 ;  
    358 ; INPUTS:  
    359 ;      OPTIONNEL, nom_fichier: c''est un string qui donne le nom du 
    360 ;       fichier a ouvrir.Si nomfichier ne contient pas le caractere 
    361 ;       separateur de repertoirte ('/' sous unix par ex), Le fichier 
    362 ;       sera cherche ds le repertoire courant 
    363 ; 
    364 ; KEYWORD PARAMETERS: 
    365 ; 
    366 ;       IODIR: string contenant le repertoire ou aller chercher le 
    367 ;       fichier a lire. Si nomfichier ne contient pas le caractere 
    368 ;       separateur de repertoirte ('/' sous unix par ex), Le fichier 
    369 ;       cherche s''appelera iodir+nom_fichier. 
    370 ; 
    371 ;       COUNT: An optional vector containing the counts to be used in 
    372 ;       reading Value. COUNT is a 1-based vector with an element for 
    373 ;       each dimension of the data to be written.The default matches 
    374 ;       the size of the variable so that all data is written out. 
    375 ; 
    376 ;       GROUP: The widget ID of the widget that calls XNCDF_LEC. When 
    377 ;       this ID is specified, a death of the caller results in a death 
    378 ;       of XNCDF_LEC.  
    379 ; 
    380 ;       OFFSET: An optional vector containing the starting position 
    381 ;       for the read. The default start position is [0, 0, ...]. 
    382 ; 
    383 ;       SHIFT: un vecteur d''entiers, specifiant pour chaque dimension 
    384 ;       de combien il faut la shifter. Par defaut c''est 
    385 ;       [0,0,...]. cf. la fonction shift pour + 
    386 ;       d''explications. ATTENTION, le shift est effectue sur le 
    387 ;       tableau de taille maximum avant la reduction eventuelle 
    388 ;       determinee par OFFSET et COUNT. Par contre il est effectue 
    389 ;       apres l''extraction eventuelle cree par le STRIDE. 
    390 ; 
    391 ;       STRIDE: An optional vector containing the strides, or sampling 
    392 ;       intervals, between accessed values of the netCDF variable. The 
    393 ;       default stride vector is that for a contiguous read, [1, 1, 
    394 ;       ...]. 
    395 ; 
    396 ; OUTPUTS: 2 cas possibles: 
    397 ;       1) aucun attributs n''a ete selectionne. Dans ce cas res est 
    398 ;       le tableau que l''on voulait lire. 
    399 ;       2) Des attributs ont ete selectionnes. Dans ce cas res est une 
    400 ;       structre dont le premier element portant le nom de la variable 
    401 ;       est le tableau de valeurs et les autre auguments sont les 
    402 ;       arguments selectiones 
    403 ; 
    404 ; COMMON BLOCKS: wididbase, infovariable, resultat, motcle 
    405 ; 
    406 ; SIDE EFFECTS: 
    407 ; 
    408 ; RESTRICTIONS: 
    409 ; 
    410 ; EXAMPLE: help, xncdf_lec() 
    411 ; 
    412 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 
    413 ;                      24/8/1999 
    414 ;- 
    415 ;------------------------------------------------------------ 
    416 ;------------------------------------------------------------ 
    417 ;------------------------------------------------------------ 
    418 FUNCTION xncdf_lec, nom, ATT = att, COUNT = count, GROUP = group, OFFSET = offset, IODIR = iodir, SHIFT = shift,  STRIDE = stride, VAR = var 
    419 ; 
    420   compile_opt idl2, strictarrsubs 
    421 ; 
    422    COMMON wididbase, base 
    423    COMMON infovariable, cdfid, listename, contient, nomdim, tailledim, varid, varcontient 
    424    COMMON resultat, res 
    425    COMMON motcle, mcatt, mccount, mcoffset, mciodir, mcshift, mcstride, mcvar 
    426 ;------------------------------------------------------------ 
    427 ; bidouille pour utiliser les mots cles (on passe par des variables 
    428 ; declarees ds un common) 
    429 ;------------------------------------------------------------ 
    430    res = -1 
    431    if keyword_set(att) then mcatt = att ELSE mcatt = 0 
    432    if keyword_set(count) then mccount =count  ELSE mccount = 0 
    433    if keyword_set(offset) then mcoffset = offset ELSE mcoffset = 0 
    434    if keyword_set(shift) then mcshift = shift ELSE mcshift = 0 
    435    if keyword_set(stride) then mcstride = stride ELSE mcstride = 0 
    436    if keyword_set(var) then mcvar = var ELSE mcvar = 0 
    437 ;------------------------------------------------------------ 
    438 ; choix du nom du fichier 
    439 ;------------------------------------------------------------ 
    440 ; Quel type de machine est utiliee 
    441    thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    442    CASE thisOS of 
    443       'MAC':sep = ':' 
    444       'WIN':sep = '\' 
    445       ELSE: sep = '/' 
    446    ENDCASE 
    447 ; si iodir n''est pas definit on l''initialise au repertoire courant 
    448    if NOT keyword_set(iodir) then cd,  current = iodir 
    449    mciodir = iodir 
    450 ; on complete iodir d''un caractere separateur de repertoire si besoin 
    451 ; est. 
    452    IF rstrpos(iodir, sep) NE strlen(iodir)-1 THEN iodir = iodir+sep  
    453    if n_elements(nom) EQ 0 then BEGIN ; si nom n''est pas definit 
    454 ; on en trouve un grace au programme dialog_pickfile 
    455       nom = dialog_pickfile(filter = iodir+'*.nc')  
    456       if nom[0] EQ '' then return,  -1 ; si on a rien trouve on sort 
    457 ;on complete nom par iodir si nom ne contient pas de caractere 
    458 ;separateur derepertoire 
    459    ENDIF ELSE if strpos(nom, sep) EQ -1 then nom = iodir+nom 
    460    test = findfile(nom)         ; le nom cherche correspond bien a un fichier? 
    461    while test[0] EQ '' OR n_elements(test) GT 1 do BEGIN ; on en cherche un tant qu''il ne correspond a rien! 
    462       test = test[0] 
    463       nom = dialog_pickfile(filter = iodir+'*.nc') 
    464       if nom EQ '' then return,  -1 
    465       test = findfile(nom) 
    466    endwhile 
    467 ;------------------------------------------------------------ 
    468 ; ouverture du fichier nom 
    469 ;------------------------------------------------------------ 
    470    cdfid=ncdf_open(nom) 
    471    contient=ncdf_inquire(cdfid) 
    472 ;------------------------------------------------------------ 
    473 ; que contient le fichier?? 
    474 ;------------------------------------------------------------ 
    475 ; ouverture de la fenetre de base sous forme de colonnes 
    476    if n_elements(group) EQ 0 then base = widget_base(/column, title='Fichier: '+nom, /align_left) $ 
    477    ELSE base = widget_base(/column, title='Fichier: '+nom, /align_left, GROUP_LEADER = group) 
    478 ; ouverture de  sous-fenetres de base ; 
    479 ;------------------------------------------------------------ 
    480 ; base 1 titre portant le nom du fichier 
    481 ;------------------------------------------------------------ 
    482    base1 = widget_base(base, /column, /align_center) 
    483    rien = widget_label(base1, value = 'Net Cdf filename', /align_center) ; blabla 
    484    rien = widget_text(base1, value = nom, /align_center, uvalue=1, /editable) ;nom du fichier que l''on peut changer  
    485    rien = widget_label(base1, value = ' ') ; on saute une ligne 
    486 ;------------------------------------------------------------ 
    487 ; base 2 informations generales sur le fichier 
    488 ;------------------------------------------------------------ 
    489    base2 = widget_base(base, /column) 
    490 ;------------------------------------------------------------ 
    491 ; informations sur les attributs globaux 
    492 ;------------------------------------------------------------ 
    493    if contient.ngatts NE -1 then begin 
    494       rien = widget_label(base2, value = 'Nombre de attributs globaux: '+ strtrim(contient.ngatts,1), /align_left) 
    495       for attiq=0,contient.ngatts-1 do BEGIN ; bouble sur le nombre d'attributs globaux 
    496          name=ncdf_attname(cdfid,attiq,/global) ;nom de l''atribut 
    497          ncdf_attget,cdfid,name,value,/global ;valeur de l''atribut 
    498          rien = widget_text(base2, value = name+': '+strtrim(string(value),1), xsize = 60, /scroll, /wrap, /align_right) 
    499       endfor 
    500       rien = widget_label(base2, value = ' ') 
    501    endif 
    502 ;------------------------------------------------------------ 
    503 ;  informations sur les dimensions 
    504 ;------------------------------------------------------------ 
    505    rien = widget_label(base2, value = 'Nombre de dimensions: '+strtrim(contient.ndims,1), /align_left) 
    506    if contient.recdim NE -1 then begin ; bouble sur le nombre de dimensions 
    507       ncdf_diminq,cdfid,contient.recdim,name,value ; nom et valeur de la dimension 
    508       rien = widget_label(base2, value = 'nom de la dimension infinie: '+name, /align_left) 
    509    endif 
    510 ; 
    511    nomdim   =strarr(contient.ndims) ; vecteur contenant le nom des dimensions 
    512    tailledim=lonarr(contient.ndims) ; vecteur contenant la valeur des dimensions 
    513    for dimiq=0,contient.ndims-1 do begin ; bouble sur le nombre de dimensions 
    514       ncdf_diminq,cdfid,dimiq,name,value ; nom et valeur de la dimension 
    515       nomdim[dimiq]=name 
    516       tailledim[dimiq]=value 
    517       rien = widget_label(base2, value = name+' de taille: '+strtrim(value,1), /align_right) 
    518    ENDFOR 
    519    rien = widget_label(base2, value = ' ') ; on saute une ligne 
    520 ;------------------------------------------------------------ 
    521 ; base 3 choix de la variable 
    522 ;------------------------------------------------------------ 
    523    base3 = widget_base(base, /column) 
    524    rien = widget_label(base3, value = 'Nombre de variables: '+strtrim(contient.nvars,1), /align_left) 
    525    base31 = widget_base(base3, /row, /align_center) 
    526 ;creation d'un vecteur listename contenant le nom de toutes les 
    527 ;variables du fichier 
    528    listename = strarr(contient.nvars) 
    529    for varid=0,contient.nvars-1 do begin 
    530       varcontient=ncdf_varinq(cdfid,varid) ; que contient la variable 
    531       listename[varid] = varcontient.name 
    532    endfor 
    533    rien= widget_label(base31, value = 'variable') 
    534 ; creation d''un bouton a menu deroulant 
    535    base311=widget_droplist(base31,value=listename, uvalue=2) 
    536    rien = widget_label(base3, value = '') 
    537 ;------------------------------------------------------------ 
    538 ; base 4 bouton done 
    539 ;------------------------------------------------------------ 
    540    base4 = widget_base(base, /row) 
    541    base42=widget_button(base4,value='done', uvalue=3, /align_right) 
    542 ;execution de la fentre de base et des sous-fenetres 
    543    widget_control,base,/realize 
    544 ;------------------------------------------------------------ 
    545    xmanager,'xncdf_lec',base 
    546 ;------------------------------------------------------------ 
    547 ;------------------------------------------------------------ 
    548 ;------------------------------------------------------------ 
    549    return, res 
    550 end 
Note: See TracChangeset for help on using the changeset viewer.