Changeset 219 for trunk


Ignore:
Timestamp:
03/14/07 16:44:26 (17 years ago)
Author:
smasson
Message:

get back to changeset:217

Location:
trunk/SRC
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Postscript/printps.pro

    r218 r219  
    105105; call the viewers 
    106106      CASE event.value OF 
    107         'GNU Ghostview':cmd = '\gv --media='+papsize+' --orientation='+ori+' '+uval.nameps 
    108         'Gnome Ghostview':cmd = '\ggv '+uval.nameps 
    109         'Ghostview':cmd = '\ghostview -'+papsize+' -quiet -'+ori+' '+uval.nameps 
    110         'Ghostscript':cmd = '\gs -sPAPERSIZE='+papsize+' -q '+uval.nameps 
    111         'Kghostview':cmd = '\kghostview '+uval.nameps 
     107        'Ghostview':spawn, '\ghostview -'+papsize+' -quiet -'+ori+' '+uval.nameps 
     108        'Ghostscript':spawn, '\gs -sPAPERSIZE='+papsize+' -q '+uval.nameps 
     109        'Kghostview':spawn, '\kghostview '+uval.nameps 
    112110      ENDCASE 
    113       spawn, cmd 
    114111      return 
    115112    END 
     
    279276; ps viewers grouped button 
    280277  psviewers = ['no psviewers found'] 
    281   IF file_which(getenv('PATH'), 'gv') NE '' THEN $ 
    282     psviewers = [psviewers, 'GNU Ghostview'] 
    283   IF file_which(getenv('PATH'), 'ggv') NE '' THEN $ 
    284     psviewers = [psviewers, 'Gnome Ghostview'] 
    285278  IF file_which(getenv('PATH'), 'ghostview') NE '' THEN $ 
    286279    psviewers = [psviewers, 'Ghostview'] 
  • trunk/SRC/ToBeReviewed/INIT/initncdf.pro

    r218 r219  
    2828; @keyword START1 {default=0}{type=scalar: 0 or 1} 
    2929; Index the axis from 1 instead of 0 when using 
    30 ; /xyindex and/or /zindex 
     30; /xyindex and/or zindex 
    3131; 
    3232; @keyword USEASMASK {type=scalar string} 
     
    3939;    3 NaN values if existing 
    4040; 
     41; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string} 
     42; A string giving the name of the variable in the file  
     43; that contains the [xyz]axis.  
     44;       
     45; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string} 
     46; A string giving the name of the variable in the file  
     47; that contains the [xyz]axis.  
     48; 
    4149; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=scalar string} 
    4250; A string giving the name of the variable in the file  
     
    5563;  
    5664; @keyword _EXTRA 
    57 ; Used to pass keywords to computegrid and ncdf_getaxis 
     65; Used to pass keywords to computegrid 
    5866; 
    5967; @uses 
     
    8088;------------------------------------------------------------ 
    8189;------------------------------------------------------------ 
    82 PRO initncdf, ncfilein $ 
     90PRO initncdf, ncfilein, XAXISNAME = xaxisname, YAXISNAME = yaxisname $ 
    8391              , ZAXISNAME = zaxisname, MASKNAME = maskname $ 
    8492              , INVMASK = invmask, USEASMASK = useasmask $ 
     
    105113; what is inside the file 
    106114  inside = ncdf_inquire(cdfid) 
    107 ;------------------------------------------------------------ 
    108 ; name of all dimensions 
    109   namedim = strarr(inside.ndims) 
    110   for dimiq = 0, inside.ndims-1 do begin 
    111     ncdf_diminq, cdfid, dimiq, tmpname, value  
    112     namedim[dimiq] = strlowcase(tmpname) 
    113   ENDFOR 
    114115;---------------------------------------------------------- 
    115116; name of the variables 
     
    120121  ENDFOR 
    121122;---------------------------------------------------------- 
    122 ; find the x/yaxis 
    123  ncdf_getaxis, cdfid, dimidx, dimidy, xaxis, yaxis $ 
    124                , START1 = start1, XYINDEX = xyindex, ROMSGRID = romsgrid, _extra = ex 
     123; find the xaxis 
     124  if keyword_set(xaxisname) then xaxisname = strlowcase(xaxisname) ELSE xaxisname = 'x' 
     125  xvarid = (where(namevar EQ xaxisname OR namevar EQ 'longitude' $ 
     126                  OR namevar EQ 'nav_lon' OR namevar EQ 'lon' $ 
     127                  OR namevar EQ 'lon_rho' OR namevar EQ 'nblongitudes'))[0] 
     128  if xvarid EQ -1 then begin 
     129    print, 'the xaxis was not found, check the use of XAXISNAME keyword' 
     130    stop 
     131  endif 
     132  romsgrid = strmid(namevar[xvarid], 0, 4) EQ 'lon_' 
     133; get the size of xaxis 
     134  xinq = ncdf_varinq(cdfid, xvarid) 
     135  ncdf_diminq, cdfid, xinq.dim[0], blabla, jpifromx 
     136; should we read or compute the xaxis? 
     137  IF NOT keyword_set(xyindex) THEN BEGIN 
     138; read the xaxis 
     139    ncdf_varget, cdfid, xvarid, xaxis 
     140; make sure of the shape of xaxis 
     141    IF xinq.ndims GE 2 THEN BEGIN 
     142      ncdf_diminq, cdfid, xinq.dim[1], blabla, jpjfromx 
     143      xaxis = reform(xaxis, jpifromx, jpjfromx, /over) 
     144    ENDIF 
     145  ENDIF ELSE xaxis = keyword_set(start1) + findgen(jpifromx) 
     146;---------------------------------------------------------- 
     147; find the yaxis 
     148  if keyword_set(yaxisname) then yaxisname = strlowcase(yaxisname) ELSE yaxisname = 'y' 
     149  yvarid = (where(namevar EQ yaxisname OR namevar EQ 'latitude' $ 
     150                  OR namevar EQ 'nav_lat' OR namevar EQ 'lat' $ 
     151                  OR namevar EQ 'lat_rho' OR namevar EQ 'nblatitudes'))[0] 
     152  yvarid = yvarid[0] 
     153  if yvarid EQ -1 then begin 
     154    print, 'the yaxis was not found, check the use of YAXISNAME keyword' 
     155    stop 
     156  endif 
     157; get the size of yaxis and check it is ok with the values found for x 
     158  yinq = ncdf_varinq(cdfid, yvarid) 
     159  IF xinq.ndims GE 2 THEN BEGIN 
     160    ncdf_diminq, cdfid, yinq.dim[0], blabla, jpifromy 
     161    ncdf_diminq, cdfid, yinq.dim[1], blabla, jpjfromy 
     162    IF jpifromy NE jpifromx THEN BEGIN  
     163      print, 'xaxis and y axis do not have the same x dimension...' 
     164    ENDIF 
     165  ENDIF ELSE ncdf_diminq, cdfid, yinq.dim[0], blabla, jpjfromy 
     166  IF n_elements(jpjfromx) NE 0 THEN BEGIN 
     167    IF jpjfromy NE jpjfromx THEN BEGIN  
     168      print, 'xaxis and y axis do not have the same y dimension...' 
     169    ENDIF     
     170  ENDIF 
     171; should we read or compute the xaxis? 
     172  IF NOT keyword_set(xyindex) THEN BEGIN 
     173; read the yaxis 
     174    ncdf_varget, cdfid, yvarid, yaxis 
     175; make sure of the shape of xaxis 
     176    IF xinq.ndims GE 2 THEN yaxis = reform(yaxis, jpifromy, jpjfromy, /over) 
     177  ENDIF ELSE yaxis = keyword_set(start1) + findgen(jpjfromy) 
    125178;---------------------------------------------------------- 
    126179; find the zaxis 
  • trunk/SRC/ToBeReviewed/POSTSCRIPT/calibre.pro

    r218 r219  
    9898;------------------------------------------------------------ 
    9999   tempsun = systime(1)         ; For key_performance 
    100 ; 
    101100;------------------------------------------------------------- 
    102101   if keyword_set(portrait) then key_portrait=1 
     
    121120; If smalldraw is count like in matlab 
    122121;------------------------------------------------------------- 
    123    if n_elements(smalldraw) EQ 3  then BEGIN 
    124      IF smalldraw[2] LT 1 OR smalldraw[2] GT smalldraw[0]*smalldraw[1] THEN BEGIN 
    125        dummy = report('wrong definition of the small keyword, we stop') 
    126        stop 
    127      ENDIF 
     122   if n_elements(smalldraw) EQ 3  then begin 
    128123      if n_elements(page_margins) EQ 0 then page_margins = [1, 1, 1, 1] 
    129124      smalldraw = long(smalldraw) 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/scanfile.pro

    r218 r219  
    99; 
    1010;  
    11 ; @keyword GRID {default='T'}{type=scalar string} 
    12 ; Used to specify on which grid type are located the data 
     11; @keyword GRID 
     12; 
    1313; 
    1414; @keyword _EXTRA 
    15 ; Used to pass your keywords to isafile and ncdf_getaxis 
     15; Used to pass your keywords 
    1616;  
    1717; @returns 
     
    7676@common 
    7777;------------------------------------------------------------ 
     78  res = -1 
     79;------------------------------------------------------------ 
    7880; filename 
    7981;------------------------------------------------------------ 
    8082  fullname = isafile(filename = namefile, IODIRECTORY = iodir, _extra = ex) 
    81   IF size(fullname, /type) NE 7 THEN return, -1 
    8283;------------------------------------------------------------ 
    8384; open file 
     
    8788; What contains the file? 
    8889;------------------------------------------------------------ 
    89   inside = ncdf_inquire(cdfid)  ; 
     90  infile = ncdf_inquire(cdfid)  ; 
    9091;------------------------------------------------------------ 
    9192; name of all dimensions 
    9293;------------------------------------------------------------ 
    93   namedim = strarr(inside.ndims) 
    94   for dimiq = 0, inside.ndims-1 do begin 
     94  namedim = strarr(infile.ndims) 
     95  for dimiq = 0, infile.ndims-1 do begin 
    9596    ncdf_diminq, cdfid, dimiq, tmpname, value  
    9697    namedim[dimiq] = strlowcase(tmpname) 
    9798  ENDFOR 
    98 ;------------------------------------------------------------ 
    99 ; x/y dimensions id 
    100 ;------------------------------------------------------------ 
    101   ncdf_getaxis, cdfid, dimidx, dimidy, _extra = ex 
     99; roms file? 
     100  dimidx = where(namedim EQ 'xi_rho' OR namedim EQ 'xi_u' OR namedim EQ 'xi_v' OR namedim EQ 'xi_psi') 
     101  IF dimidx[0] EQ -1 THEN BEGIN 
     102; we are looking for a x dimension with a name matching one of the following regular expression: 
     103    testname = ['longitude', 'lon', 'x', 'longitude*', 'lon*', 'x*', '*longitude*', '*lon*', '*x*'] 
     104    cnt = -1 
     105    ii = 0 
     106    WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
     107      dimidx = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
     108      ii = ii+1 
     109    ENDWHILE 
     110    CASE cnt OF 
     111      0:begin 
     112        dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
     113                        , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
     114                        , ' => we cannot find the x dimension']) 
     115        stop 
     116      END 
     117      1:dimidx = dimidx[0] 
     118      ELSE:begin 
     119        dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
     120                        , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
     121                        , ' => we cannot find the x dimension']) 
     122        stop 
     123      ENDELSE 
     124    ENDCASE 
     125  ENDIF 
     126; roms file? 
     127  dimidy = where(namedim EQ 'eta_rho' OR namedim EQ 'eta_u' OR namedim EQ 'eta_v' OR namedim EQ 'eta_psi') 
     128  IF dimidy[0] EQ -1 THEN BEGIN 
     129; we are looking for a y dimension with a name matching one of the following regular expression: 
     130    testname = ['latitude', 'lat', 'y', 'latitude*', 'lat*', 'y*', 'eta_*', '*latitude*', '*lat*', '*y*'] 
     131    cnt = -1 
     132    ii = 0 
     133    WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
     134      dimidy = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
     135      ii = ii+1 
     136    ENDWHILE 
     137    CASE cnt OF 
     138      0:begin 
     139        dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
     140                        , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
     141                        , ' => we cannot find the y dimension']) 
     142        stop 
     143      END 
     144      1:dimidy = dimidy[0] 
     145      ELSE:begin 
     146        dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
     147                        , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
     148                        , ' => we cannot find the x dimension']) 
     149        stop 
     150      ENDELSE 
     151    ENDCASE 
     152  ENDIF 
    102153;------------------------------------------------------------ 
    103154; name of all variables 
    104155;------------------------------------------------------------ 
    105156; we keep only the variables containing at least x, y and time dimension (if existing...) 
    106   namevar = strarr(inside.nvars) 
    107   for varid = 0, inside.nvars-1 do begin 
     157  namevar = strarr(infile.nvars) 
     158  for varid = 0, infile.nvars-1 do begin 
    108159    invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
    109160    if (inter(invar.dim, dimidx))[0] NE -1 AND $ 
    110161       (inter(invar.dim, dimidy))[0] NE -1 AND $ 
    111        ((where(invar.dim EQ inside.recdim))[0] NE -1 OR inside.recdim EQ -1) $ 
     162       ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
    112163    THEN namevar[varid] = invar.name  
    113164  ENDFOR 
     
    159210;------------------------------------------------------------ 
    160211  date0fk = date2jul(19000101) 
    161   IF inside.recdim EQ -1 THEN BEGIN  
     212  IF infile.recdim EQ -1 THEN BEGIN  
    162213    jpt = 1 
    163214    time = date0fk 
    164215    fakecal = 1 
    165216  ENDIF ELSE BEGIN 
    166     ncdf_diminq, cdfid, inside.recdim, timedimname, jpt 
     217    ncdf_diminq, cdfid, infile.recdim, timedimname, jpt 
    167218; we look for the variable containing the time axis 
    168 ; we look for the first variable having for only dimension inside.recdim 
     219; we look for the first variable having for only dimension infile.recdim 
    169220    varid = 0 
    170221    repeat BEGIN 
    171       IF varid LT inside.nvars THEN BEGIN 
     222      IF varid LT infile.nvars THEN BEGIN 
    172223        invar = ncdf_varinq(cdfid, varid)  
    173224        varid = varid+1         
    174225      ENDIF ELSE varid = 0 
    175     endrep until (n_elements(invar.dim) EQ 1 AND invar.dim[0] EQ inside.recdim) OR (varid EQ 0) 
     226    endrep until (n_elements(invar.dim) EQ 1 AND invar.dim[0] EQ infile.recdim) OR (varid EQ 0) 
    176227    varid = varid-1 
    177228; 
Note: See TracChangeset for help on using the changeset viewer.