Changeset 172 for trunk/SRC/ToBeReviewed


Ignore:
Timestamp:
09/11/06 09:11:26 (18 years ago)
Author:
smasson
Message:

bugfix + manage roms outputs

Location:
trunk/SRC/ToBeReviewed
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/GRILLE/grille.pro

    r163 r172  
    111111;------------------------------------------------------------ 
    112112;------------------------------------------------------------ 
    113 pro grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, e1, e2, e3, TRI = tri, NOTRI = notri, TOUT = tout, FORPLT = forplt, IFPLTZ = ifpltz, WDEPTH = wdepth, _EXTRA = ex 
     113pro grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, e1, e2, e3, TRI = tri, NOTRI = notri, TOUT = tout, FORPLT = forplt, TYPE = type, WDEPTH = wdepth, _EXTRA = ex 
    114114;------------------------------------------------------------ 
    115115; include commons 
     
    119119@cm_4mesh 
    120120@cm_4data 
     121@cm_4cal ; for jpt 
    121122  IF NOT keyword_set(key_forgetold) THEN BEGIN 
    122123@updatenew 
     
    354355  ENDELSE 
    355356; for the vertical sections with partial steps 
    356   IF keyword_set(ifpltz) AND keyword_set(key_partialstep) THEN BEGIN 
     357  IF keyword_set(type) AND keyword_set(key_partialstep) THEN BEGIN 
    357358    CASE 1 OF 
    358       ifpltz EQ 'xz' AND ny EQ 1:BEGIN 
     359      type EQ 'xz' AND ny EQ 1:BEGIN 
    359360        bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 
    360361        good = where(bottom NE 0 AND bottom NE nz+keyword_set(wdepth)) 
     
    370371        ENDIF 
    371372      END 
    372       ifpltz EQ 'yz' AND nx EQ 1:BEGIN 
     373      type EQ 'yz' AND nx EQ 1:BEGIN 
    373374        bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 
    374375        good = where(bottom NE 0 AND bottom NE nz+keyword_set(wdepth)) 
     
    387388    ENDCASE 
    388389  ENDIF 
     390; for the vertical sections with roms 
     391  IF keyword_set(type) AND n_elements(romszinfos) NE 0 THEN BEGIN 
     392    romsdp = romsdepth() 
     393    IF romsdp[0] NE -1 THEN BEGIN  
     394      IF jpt EQ 1 THEN BEGIN 
     395        CASE type OF 
     396          'z':gdep = moyenne(temporary(romsdp), 'xy') 
     397          'xz':gdep = moyenne(temporary(romsdp), 'y') 
     398          'yz':gdep = moyenne(temporary(romsdp), 'x') 
     399          'zt':gdep = moyenne(temporary(romsdp), 'xy') 
     400          ELSE: 
     401        ENDCASE 
     402      ENDIF ELSE BEGIN  
     403        CASE type OF 
     404          'z':gdep = moyenne(temporary(romsdp), 'xyt') 
     405          'xz':gdep = grossemoyenne(temporary(romsdp), 'yt') 
     406          'yz':gdep = grossemoyenne(temporary(romsdp), 'xt') 
     407          'zt':gdep = grossemoyenne(temporary(romsdp), 'xy') 
     408          ELSE: 
     409        ENDCASE 
     410      ENDELSE 
     411      IF size(gdep, /n_dimensions) EQ 2 THEN $ 
     412         gdep = remplit(gdep, niter = 32000, mask = gdep LT 1.E19, /basique, /fillxdir) 
     413    ENDIF 
     414  ENDIF 
     415; 
    389416  IF testvar(var = key_performance) EQ 2 THEN $ 
    390417    print, 'temps grille: Variables se rapportant a la dimension verticale ', systime(1)-tempdeux 
  • trunk/SRC/ToBeReviewed/INIT/initncdf.pro

    r167 r172  
    55; 
    66; @file_comments 
    7 ; Initfile for Netcdf file. define all the grid parameters 
     7; Initfile for Netcdf file. define all the grid parameters through 
     8; an appropriate call to computegid 
    89; 
    910; @categories 
    10 ; 
     11; Grid 
    1112;  
    12 ; @param NCFILEIN {in}{required}{type=string} 
     13; @param NCFILEIN {in}{required}{type=scalar string} 
    1314; A string giving the name of the NetCdf file 
    1415; 
    15 ; @keyword INVMASK 
    16 ; To inverse the mask: mask = 1-mask 
     16; @keyword INVMASK {default=0}{type=scalar: 0 or 1} 
     17; Inverse the land/sea mask (that should have 0/1 values for land/sea): mask = 1-mask 
    1718; 
    1819; @keyword MASKNAME {type=string} 
     
    2021; that contains the land/sea mask 
    2122; 
    22 ; @keyword MISSING_VALUE 
     23; @keyword MISSING_VALUE {type=scalar} 
    2324; To define (or redefine if the attribute is 
    2425; already existing) the missing values used with USEASMASK 
    2526; keyword 
    2627; 
    27 ; @keyword START1 
     28; @keyword START1 {default=0}{type=scalar: 0 or 1} 
    2829; Index the axis from 1 instead of 0 when using 
    2930; /xyindex and/or zindex 
    3031; 
    31 ; @keyword USEASMASK {type=string} 
     32; @keyword USEASMASK {type=scalar string} 
    3233; A string giving the name of the variable in the file  
    3334; that will be used to build the land/sea mask. In this case the 
     
    3839;    3 NaN values if existing 
    3940; 
    40 ; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon' or 'lon'}{type=string} 
     41; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string} 
    4142; A string giving the name of the variable in the file  
    4243; that contains the [xyz]axis.  
    4344;       
    44 ; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat' or 'lat'}{type=string} 
     45; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string} 
    4546; A string giving the name of the variable in the file  
    4647; that contains the [xyz]axis.  
    4748; 
    48 ; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=string} 
     49; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=scalar string} 
    4950; A string giving the name of the variable in the file  
    5051; that contains the [xyz]axis.  
    5152; 
    52 ; @keyword XYINDEX 
     53; @keyword XYINDEX {default=0}{type=scalar: 0 or 1} 
    5354; To define the x/y axis with index instead of using 
    5455; the values contained in X/YAXISNAME.  
     
    5657; this forces key_onearth = 0 
    5758; 
    58 ; @keyword ZINDEX 
     59; @keyword ZINDEX {default=0}{type=scalar: 0 or 1} 
    5960; To define the z axis with index instead of using 
    6061; the values contained in ZAXISNAME.  
     
    6263;  
    6364; @keyword _EXTRA 
    64 ; Used to pass your keywords/ 
     65; Used to pass keywords to computegrid 
    6566; 
    6667; @uses 
     
    6869; 
    6970; @restrictions 
    70 ; Change the grid parameters of the common.pro 
     71; Change the grid parameters (see computegrid) 
    7172; 
    7273; @restrictions 
     
    122123; find the xaxis 
    123124  if keyword_set(xaxisname) then xaxisname = strlowcase(xaxisname) ELSE xaxisname = 'x' 
    124   xvarid = where(namevar EQ xaxisname OR namevar EQ 'longitude' $ 
    125                  OR namevar EQ 'nav_lon' OR namevar EQ 'lon' $ 
    126                  OR namevar EQ 'NbLongitudes') 
    127   xvarid = xvarid[0] 
     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  romsgrid = strmid(namevar[xvarid], 0, 4) EQ 'lon_' 
    128129  if xvarid EQ -1 then begin 
    129130    print, 'the xaxis was not found, check the use of XAXISNAME keyword' 
     
    146147; find the yaxis 
    147148  if keyword_set(yaxisname) then yaxisname = strlowcase(yaxisname) ELSE yaxisname = 'y' 
    148   yvarid = where(namevar EQ yaxisname OR namevar EQ 'latitude' $ 
    149                  OR namevar EQ 'nav_lat' OR namevar EQ 'lat' $ 
    150                  OR namevar EQ 'NbLatitudes') 
     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] 
    151152  yvarid = yvarid[0] 
    152153  if yvarid EQ -1 then begin 
     
    177178;---------------------------------------------------------- 
    178179; find the zaxis 
    179   if keyword_set(zaxisname) then zaxisname = strlowcase(zaxisname) ELSE zaxisname = 'z' 
    180   zvarid = where(namevar EQ 'nav_lev' or namevar EQ zaxisname OR namevar EQ 'level' OR namevar EQ 'lev' OR strmid(namevar, 0, 5) EQ 'depth') 
    181   zvarid = zvarid[0] 
    182   if zvarid EQ -1 AND inside.ndims GT 3 then begin 
    183     print, 'initncdf: the zaxis was not found..., check the the use of ZAXISNAME keyword if you whant to find one...' 
     180  IF keyword_set(romsgrid) THEN BEGIN 
     181    FOR i = 0, inside.ndims-1 DO BEGIN  
     182      ncdf_diminq, cdfid, i, name, size 
     183      CASE strlowcase(name) OF 
     184        's_rho':zaxis = reverse(indgen(size)) 
     185        's_u':zaxis = reverse(indgen(size)) 
     186        's_v':zaxis = reverse(indgen(size)) 
     187        's_psi':zaxis = reverse(indgen(size)) 
     188        's_w':zaxis = reverse(indgen(size-1)) 
     189        ELSE: 
     190      ENDCASE 
     191    ENDFOR  
     192    IF (where(namevar EQ 'h'))[0] NE -1 THEN BEGIN 
     193      ncdf_varget, cdfid, 'h', romsh 
     194    ENDIF ELSE romsh = -1 
     195  ENDIF ELSE BEGIN  
     196    if keyword_set(zaxisname) then zaxisname = strlowcase(zaxisname) ELSE zaxisname = 'z' 
     197    zvarid = (where(namevar EQ 'nav_lev' or namevar EQ zaxisname OR namevar EQ 'level' OR namevar EQ 'lev' OR strmid(namevar, 0, 5) EQ 'depth'))[0] 
     198    if zvarid EQ -1 AND inside.ndims GT 3 then begin 
     199      print, 'initncdf: the zaxis was not found..., check the the use of ZAXISNAME keyword if you whant to find one...' 
    184200;     stop 
    185   endif 
     201    endif 
    186202; read the zaxis 
    187   if zvarid NE -1 THEN ncdf_varget, cdfid, zvarid, zaxis 
    188   IF keyword_set(zindex) THEN $ 
    189     zaxis = keyword_set(start1) + findgen(n_elements(zaxis)) 
     203    if zvarid NE -1 THEN ncdf_varget, cdfid, zvarid, zaxis 
     204  ENDELSE  
     205  IF keyword_set(zindex) AND keyword_set(zaxis) THEN $ 
     206     zaxis = keyword_set(start1) + findgen(n_elements(zaxis)) 
    190207;---------------------------------------------------------- 
    191208; mask 
     209  IF NOT (keyword_set(maskname) OR keyword_set(useasmask)) AND keyword_set(romsgrid) THEN maskname = 'mask_rho' 
    192210  CASE 1 OF 
    193211    keyword_set(maskname):BEGIN 
     
    252270            'scale_factor':ncdf_attget, cdfid, mskid, attname, scale_factor 
    253271            'missing_value':IF n_elements(missing_value) EQ 0 THEN $ 
    254               ncdf_attget, cdfid, mskid, attname, missing_value 
     272               ncdf_attget, cdfid, mskid, attname, missing_value 
    255273            ELSE: 
    256274          ENDCASE 
     
    279297    ELSE:tmask  = -1 
    280298  ENDCASE 
     299; 
    281300  ncdf_close, cdfid 
    282301; 
    283302; compute the grid 
    284   if zvarid EQ -1 then BEGIN  
     303  if NOT keyword_set(zaxis) then BEGIN  
    285304    computegrid, xaxis = xaxis, yaxis = yaxis $ 
    286       , mask = tmask, onearth = 1b - keyword_set(xyindex), _EXTRA = ex  
     305                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex  
    287306  ENDIF ELSE BEGIN  
    288307    computegrid, xaxis = xaxis, yaxis = yaxis, zaxis = zaxis $ 
    289       , mask = tmask, onearth = 1b - keyword_set(xyindex), _EXTRA = ex 
     308                 , mask = tmask, onearth = 1b - keyword_set(xyindex), ROMSH = romsh, _EXTRA = ex 
    290309  ENDELSE  
    291310  IF n_elements(time) EQ 0 THEN time = 0 
  • trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro

    r163 r172  
    9191                    , PARENTIN = parentin, TIMESTEP = timestep, TIMEVAR = timevar $ 
    9292                    , TOUT = tout, NOSTRUCT = nostruct, CONT_NOFILL = CONT_NOFILL, INIT = init $ 
    93                     , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex 
     93                    , GRID = grid, FBASE2TBASE = fbase2tbase, _EXTRA = ex, CALLITSELF = callitself 
    9494;--------------------------------------------------------- 
    9595; 
     
    129129  ENDIF 
    130130  varcontient = ncdf_varinq(cdfid, name) 
     131  IF varcontient.ndims LT 2 THEN return, report('read_ncdf cannot read scalar or 1D data') 
     132; look for the dimension names 
     133  dimnames = strarr(varcontient.ndims) 
     134  FOR i = 0, varcontient.ndims-1 DO BEGIN 
     135    ncdf_diminq, cdfid, varcontient.dim[i], tmp, dimsize 
     136    dimnames[i] = tmp 
     137  ENDFOR  
    131138;------------------------------------------------------------ 
    132139; shall we redefine the grid parameters 
     
    144151    if n_elements(ending) NE 0 then lasttps = ending[0] ELSE lasttps = firsttps 
    145152    jpt = lasttps-firsttps+1 
    146     time = julday(1, 1, 1) + lindgen(jpt) 
     153    IF NOT keyword_set(callitself) then time = julday(1, 1, 1) + lindgen(jpt) 
    147154  ENDIF ELSE BEGIN 
    148155    if keyword_set(parent) then BEGIN 
     
    236243      mots = str_sep(value, ' ') 
    237244      unite = mots[0] 
     245      IF unite NE 'seconds' AND unite NE 'hours' AND unite NE 'days' $ 
     246         AND unite NE 'months' AND unite NE 'years' THEN BEGIN 
     247        ncdf_close, cdfid 
     248        return, report('time units does not start with seconds/hours/days/months/years') 
     249      ENDIF 
     250      IF stregex(value, '[^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*', /boolean) EQ 0 THEN BEGIN 
     251        ncdf_close, cdfid 
     252        return, report('attribut units of time has not the good format: [^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*') 
     253      ENDIF 
    238254      depart = str_sep(mots[2], '-') 
    239255      ncdf_varget, cdfid, timeid, time 
     
    260276        ELSE:BEGIN 
    261277          ncdf_close, cdfid 
    262           return, report('The "units" attribu of the time axis must be something like: !C "seconds since 0001-01-01 ..." !C "days since 1979-01-01 ..." !C "months since 1979-01-01 ..." !C "years since 1979-01-01 ..."') 
     278          return, report('The "units" attribute of the time axis must be something like: !C "seconds since 0001-01-01 ..." !C "days since 1979-01-01 ..." !C "months since 1979-01-01 ..." !C "years since 1979-01-01 ..."') 
    263279        end 
    264280      ENDCASE 
     
    291307    vargrid = 'T'               ; default definition 
    292308    IF finite(glamu[0]) EQ 1 THEN BEGIN 
    293       pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
    294       gdtype = ['T', 'U', 'V', 'W', 'F'] 
    295       fnametest = strupcase(filename) 
    296       FOR i = 0, n_elements(pattern)-1 DO BEGIN 
    297         FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
    298           substr = pattern[i]+gdtype[j] 
    299           pos = strpos(fnametest, substr) 
    300           IF pos NE -1 THEN $ 
    301              vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
    302         ENDFOR 
    303       ENDFOR 
    304     ENDIF 
     309; are we in one of the case corresponding to ROMS conventions? 
     310      CASE 1 OF 
     311        dimnames[2 <(varcontient.ndims-1)] EQ 's_w':vargrid = 'W' 
     312        dimnames[0] EQ 'xi_rho' AND dimnames[1] EQ 'eta_rho':vargrid = 'T' 
     313        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_u'  :vargrid = 'U' 
     314        dimnames[0] EQ 'xi_v'   AND dimnames[1] EQ 'eta_v'  :vargrid = 'V' 
     315        dimnames[0] EQ 'xi_psi' AND dimnames[1] EQ 'eta_psi':vargrid = 'F' 
     316        dimnames[0] EQ 'xi_rho' AND dimnames[1] EQ 'eta_v'  :vargrid = 'V' 
     317        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_rho':vargrid = 'U' 
     318        dimnames[0] EQ 'xi_u'   AND dimnames[1] EQ 'eta_v'  :vargrid = 'F' 
     319        ELSE:BEGIN  
     320; could we define the grid type from the file name?? 
     321          pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
     322          gdtype = ['T', 'U', 'V', 'W', 'F'] 
     323          fnametest = strupcase(filename) 
     324          FOR i = 0, n_elements(pattern)-1 DO BEGIN 
     325            FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
     326              substr = pattern[i]+gdtype[j] 
     327              pos = strpos(fnametest, substr) 
     328              IF pos NE -1 THEN $ 
     329                 vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
     330            ENDFOR 
     331          ENDFOR 
     332        END 
     333      ENDCASE 
     334     ENDIF 
    305335  ENDELSE 
    306336;--------------------------------------------------------------- 
     
    380410  ENDIF 
    381411; 
     412  IF n_elements(key_zreverse) EQ 0 THEN key_zreverse = 0 
     413  IF keyword_set(key_zreverse) THEN BEGIN 
     414    tmp = jpk-1-firstz 
     415    firstz = jpk-1-lastz 
     416    lastz = tmp 
     417  ENDIF 
     418; 
    382419  IF keyword_set(fbase2tbase) THEN BEGIN 
    383420    case strupcase(vargrid) of 
     
    419456;--------------------------------------------------------------------- 
    420457; varname 
    421   varname = name 
     458  IF NOT keyword_set(callitself) THEN varname = name 
    422459; varunit 
    423460  if varcontient.natts NE 0 then begin 
     
    428465    found = (where(lowattnames EQ 'units'))[0] 
    429466    IF found NE -1 then ncdf_attget, cdfid, name, attnames[found], value ELSE value = '' 
    430     varunit = strtrim(string(value), 2) 
     467    IF NOT keyword_set(callitself) THEN varunit = strtrim(string(value), 2) 
    431468; 
    432469    found = (where(lowattnames EQ 'add_offset'))[0] 
     
    443480; 
    444481  ENDIF ELSE BEGIN  
    445     varunit = '' 
     482    IF NOT keyword_set(callitself) THEN varunit = '' 
    446483    add_offset = 0. 
    447484    scale_factor = 1. 
     
    457494 
    458495; we apply reverse 
    459   if keyword_set(key_yreverse) then res = reverse(temporary(res),  2) 
    460   if keyword_set(key_zreverse) AND (size(res))[0] EQ 3 AND jpt EQ 1 then res = reverse(temporary(res), 3) 
    461   if keyword_set(key_zreverse) AND (size(res))[0] EQ 4 THEN res = reverse(temporary(res), 3) 
    462  
     496  if keyword_set(key_yreverse) AND ny NE 1 THEN $ 
     497     res = reverse(reform(res, nx, ny, nz, jpt, /overwrite),  2) 
     498  if keyword_set(key_zreverse) AND nz NE 1 $ 
     499     AND varcontient.ndims - ((where(varcontient.dim EQ contient.recdim))[0] NE -1) EQ 3 THEN $ 
     500        res = reverse(reform(res, nx, ny, nz, jpt, /overwrite),  3) 
    463501; We apply the value valmask on land points. 
    464502  if NOT keyword_set(cont_nofill) then begin 
     
    501539  if add_offset NE 0 then res = temporary(res)+add_offset 
    502540  if missing[0] NE -1 then res[temporary(missing)] = !values.f_nan 
    503   if earth[0] NE -1 then res[temporary(earth)] = 1e20 
     541  if earth[0] NE -1 then res[temporary(earth)] = 1.e20 
     542;--------------------------------------------------------------------- 
     543; if it is roms outputs, we need to get additionals infos... 
     544  IF NOT keyword_set(callitself) THEN BEGIN 
     545    IF strmid(dimnames[0], 0, 3) EQ 'xi_' AND strmid(dimnames[1], 0, 4) EQ 'eta_' THEN BEGIN 
     546      ncdf_attget, cdfid, 'theta_s', theta_s, /global 
     547      ncdf_attget, cdfid, 'theta_b', theta_b, /global 
     548      ncdf_attget, cdfid, 'hc', hc, /global 
     549; +++ binder l'exsitance de h et zeta... 
     550; +++ mettre zeta a 0 par defaut 
     551      hroms = read_ncdf('h', 0, 0, FILENAME = filename $ 
     552                        , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     553                        , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     554      zeta = read_ncdf('zeta', firsttps, lasttps, FILENAME = filename $ 
     555                       , /TIMESTEP, /NOSTRUCT, CONT_NOFILL = CONT_NOFILL $ 
     556                       , GRID = vargrid, /CALLITSELF, _EXTRA = ex) 
     557      romszinfos = {h:temporary(hroms), zeta:temporary(zeta), theta_s:theta_s, theta_b:theta_b, hc:hc} 
     558    ENDIF ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 
     559  ENDIF 
    504560;--------------------------------------------------------------------- 
    505561  ncdf_close, cdfid 
    506 ;--------------------------------------------------------------------- 
    507   if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4rdncdf.dat' 
    508   if keyword_set(nostruct) then return, res $ 
    509   ELSE BEGIN  
    510     IF keyword_set(key_forgetold) THEN BEGIN 
    511       return, {arr:res, grid:vargrid, unit:varunit, experiment:varexp, name:varname}  
    512     ENDIF ELSE BEGIN  
    513       return, {tab:res, grille:vargrid, unite:varunit, experience:varexp, nom:varname} 
    514     ENDELSE  
    515   ENDELSE  
     562 
     563  IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4rdncdf.dat' 
     564 
     565  IF keyword_set(nostruct) THEN return, res 
     566  IF keyword_set(key_forgetold) THEN BEGIN 
     567    return, {arr:temporary(res), grid:vargrid, unit:varunit, experiment:varexp, name:varname}  
     568  ENDIF ELSE BEGIN  
     569    return, {tab:temporary(res), grille:vargrid, unite:varunit, experience:varexp, nom:varname} 
     570  ENDELSE 
     571 
    516572END 
    517573 
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/plt1d.pro

    r163 r172  
    180180    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $ 
    181181                     , direc = direc, _extra = ex) 
    182     grille, mask, glam, gphi, gdep, nx, ny, nz 
     182    grille, mask, glam, gphi, gdep, nx, ny, nz, type = type 
    183183  ENDELSE 
    184184  if z1d[0] EQ -1 then BEGIN  
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltt.pro

    r163 r172  
    267267        return 
    268268      endif 
    269       grille, mask, glam, gphi, gdep, nx, ny,nz 
     269      grille, mask, glam, gphi, gdep, nx, ny, nz, type = type 
    270270   ENDELSE 
    271271;--------------------------------------------------------------- 
     
    412412            end 
    413413            type eq 'zt' : begin 
    414                yy =  gdep 
     414               IF size(gdep, /n_dimensions) EQ 2 THEN $ 
     415                  yy = transpose(gdep) ELSE yy = gdep 
    415416               xx = temps-tempsmin 
    416417               z2d = transpose(z2d) 
     
    463464      z2d = remplit(z2d,nite=2+keyword_set(nan), mask = mask, /basique, _extra=ex) 
    464465      if NOT keyword_set(strictfill) then z2d = min > z2d <  max 
    465       if keyword_set(nan) then $ 
    466        triangulation = triangule(mask,/basic,coinmonte=coinmontemask $ 
    467                                  ,coindescend=coindescendmask) $ 
    468        ELSE triangulation = -1  
     466      if keyword_set(nan) then BEGIN 
     467        triangulation = triangule(mask, /basic, coinmonte = coinmontemask $ 
     468                                  , coindescend = coindescendmask) 
     469        usetri = 1 
     470      ENDIF ELSE triangulation = -1  
     471       
     472      IF size(gdep, /n_dimensions) EQ 2 THEN BEGIN 
     473        usetri = 2 
     474        IF triangulation[0] EQ -1 THEN $ 
     475           triangulation = triangule(mask, /basic, coinmonte = coinmontemask $ 
     476                                     , coindescend = coindescendmask) 
     477      ENDIF   
    469478;---------------------------------------------------------------------- 
    470       pltbase,z2d, xx, yy, mask,xx, yy, level_z2d,colnumb, contour = contour,/noerase $ 
     479      pltbase, z2d, xx, yy, mask, xx, yy, level_z2d, colnumb, contour = contour, /noerase $ 
    471480       , c_linestyle=linestyle,c_labels=1-(indgen(n_elements(level_z2d)) MOD 2) $ 
    472481       , trichamp = triangulation, trimsk = triangulation, overplot = overplot $ 
    473        , c_thick=thick, performance = key_performance, usetri = keyword_set(nan) $ 
     482       , c_thick=thick, performance = key_performance, usetri = usetri $ 
    474483       , coinmontemask=coinmontemask, coindescendmask=coindescendmask, _extra = ex 
    475484;------------------------------------------------------------ 
  • trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltz.pro

    r171 r172  
    244244      return 
    245245    ENDIF 
    246     IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, ifpltz = type, WDEPTH = wdepth $ 
     246    IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, type = type, WDEPTH = wdepth $ 
    247247    ELSE grille, mask, glam, gphi, gdep, nx, ny, nz, WDEPTH = wdepth 
    248248  ENDELSE 
    249 ; stop 
     249  IF size(gdep, /n_dimensions) EQ 2 THEN usetri = 2 
    250250;--------------------------------------------------------------- 
    251251  profmax = !y.range[0] 
     
    357357; dessin en lui meme 
    358358;------------------------------------------------------------ 
     359  IF n_elements(romszinfos) EQ 1 THEN BEGIN 
     360; add one line at bottom to have nicer plot (colors go until the ocean bottom) 
     361    IF n_elements(romszinfos.h) NE 1 THEN BEGIN 
     362      CASE type OF 
     363        'xz':romsh = moyenne(romszinfos.h, 'y') 
     364        'yz':romsh = moyenne(romszinfos.h, 'x') 
     365      ENDCASE 
     366      IF nzt EQ jpk THEN BEGIN 
     367        z2d = [[z2d], [z2d[*, jpk-1]]] 
     368        zzaxis = [[zzaxis], [romsh]] 
     369      ENDIF 
     370    ENDIF 
     371  ENDIF 
    359372  pltbase, z2d, xxaxis, zzaxis, mask, xmask, zmask $ 
    360373    , level_z2d, colnumb, overplot = overplot $ 
  • trunk/SRC/ToBeReviewed/PLOTS/DIVERS/axis4pltz.pro

    r163 r172  
    9090    ENDELSE 
    9191    if keyword_set(sin) then xxaxis = sin(!pi/180.*xxaxis) 
    92     if (size(z))[0] EQ 1 THEN zzaxis = z ELSE zzaxis = z 
    9392  ENDIF ELSE BEGIN 
    9493    xxaxis = glam[*, 0] 
    95     if (size(z))[0] EQ 1 then zzaxis = z ELSE zzaxis = z 
    9694  ENDELSE  
     95  zzaxis = z 
    9796;---------------------------------------------------------- 
    9897; We project the z axis in [0,1] 
     
    102101  if zoom LT profmax then begin 
    103102    mp = projsegment([profmin, zoom], [0, zratio], /mp) 
    104     zzaxis[where(zzaxis LE zoom)] = mp[0]*zzaxis[where(zzaxis LE zoom)]+mp[1] 
     103    small = where(zzaxis LE zoom) 
     104    IF small[0] NE -1 THEN zzaxis[small] = mp[0]*zzaxis[small]+mp[1] 
    105105    mp = projsegment([zoom, profmax], [zratio, 1], /mp) 
    106     zzaxis[where(zzaxis GE zoom)] = mp[0]*zzaxis[where(zzaxis GE zoom)]+mp[1] 
     106    big = where(zzaxis GE zoom) 
     107    IF big[0] NE -1 THEN zzaxis[big] = mp[0]*zzaxis[big]+mp[1] 
    107108  ENDIF ELSE BEGIN 
    108109    mp = projsegment([profmin, profmax], [0, 1], /mp) 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcmd.pro

    r157 r172  
    184184      if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    185185      exextra = cw_specifie_get_value(base) 
     186      tgnm = strlowcase(tag_names(exextra)) 
     187      indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt) 
     188      IF cnt EQ 1 THEN BEGIN  
     189        boxextra = exextra.(indtmp[0]) 
     190        exextra = extractstru(exextra, ['box', 'boxzoom']) 
     191      ENDIF  
    186192      extra =  mixstru(exextra, extra) 
    187193      sextra = struct2string(extra) 
     
    342348; determination of the boxzoom's name. 
    343349  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     350  CASE n_elements(boxextra) OF 
     351    0: 
     352    1:boxzoom[5] = boxextra 
     353    2:boxzoom[4:5] = boxextra 
     354    4:boxzoom[0:3] = boxextra 
     355    5:boxzoom = [boxextra[0:3], 0, boxextra[4]] 
     356    6:boxzoom = boxextra 
     357  ENDCASE 
    344358; Writting of this one as a string 
    345359  box = '['+strtrim(boxzoom[0], 1) 
     
    358372      if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $ 
    359373      ELSE pmax = 200 
    360       box = box+',0,'+strtrim(pmax, 1) 
     374      box = box+',0,'+strtrim(boxzoom[5] > pmax, 1) 
    361375    ENDELSE 
    362376  endif 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro

    r157 r172  
    8787  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    8888  exextra = cw_specifie_get_value(base) 
    89   exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) 
     89  tgnm = strlowcase(tag_names(exextra)) 
     90  indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt) 
     91  IF cnt EQ 1 THEN boxextra = exextra.(indtmp[0]) 
     92  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct', 'box', 'boxzoom']) 
    9093  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra) 
    9194  sextra = struct2string(extra) 
     
    116119;--------------- 
    117120  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     121  CASE n_elements(boxextra) OF 
     122    0: 
     123    1:boxzoom[5] = boxextra 
     124    2:boxzoom[4:5] = boxextra 
     125    4:boxzoom[0:3] = boxextra 
     126    5:boxzoom = [boxextra[0:3], 0, boxextra[4]] 
     127    6:boxzoom = boxextra 
     128  ENDCASE 
    118129; put boxzoom into a string 
    119130  box = '['+strtrim(boxzoom[0], 1) 
     
    121132     box = box+', '+strtrim(boxzoom[i], 1) 
    122133  if strpos(type, 'z') NE -1 then BEGIN 
    123       @common 
    124       min = min([gdept, gdepw], max = max) 
     134      @cm_4mesh 
     135      min = min([gdept, gdepw, boxzoom[4:5]], max = max) 
    125136      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) 
    126137    endif 
  • trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/scanfile.pro

    r167 r172  
    8989;------------------------------------------------------------ 
    9090  infile = ncdf_inquire(cdfid)  ; 
    91 ; find vargrid ... 
    92   IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE BEGIN 
    93     vargrid = 'T'               ; default definition 
    94     IF finite(glamu[0]) EQ 1 THEN BEGIN 
     91;------------------------------------------------------------ 
     92; name of all dimensions 
     93;------------------------------------------------------------ 
     94  namedim = strarr(infile.ndims) 
     95  for dimiq = 0, infile.ndims-1 do begin 
     96    ncdf_diminq, cdfid, dimiq, tmpname, value  
     97    namedim[dimiq] = strlowcase(tmpname) 
     98  ENDFOR 
     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 
     153;------------------------------------------------------------ 
     154; name of all variables 
     155;------------------------------------------------------------ 
     156; we keep only the variables containing at least x, y and time dimension (if existing...) 
     157  namevar = strarr(infile.nvars) 
     158  for varid = 0, infile.nvars-1 do begin 
     159    invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
     160    if (inter(invar.dim, dimidx))[0] NE -1 AND $ 
     161       (inter(invar.dim, dimidy))[0] NE -1 AND $ 
     162       ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
     163    THEN namevar[varid] = invar.name  
     164  ENDFOR 
     165  namevar = namevar[where(namevar NE '')] 
     166;------------------------------------------------------------ 
     167; find vargrid for each selected variable... 
     168;------------------------------------------------------------ 
     169  listgrid = strarr(n_elements(namevar)) 
     170; default definitions 
     171  IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE vargrid = 'T' 
     172; look for values of vargrid for each variable 
     173  IF finite(glamu[0]) EQ 1 AND NOT keyword_set(grid) THEN BEGIN 
     174; for each variable, look if we in one of the case corresponding to ROMS conventions? 
     175    FOR i = 0, n_elements(namevar)-1 do begin 
     176      invar = ncdf_varinq(cdfid, namevar[i]) 
     177      tmpnm = namedim[invar.dim] 
     178; are we in one of the case corresponding to ROMS conventions? 
     179      CASE 1 OF 
     180        tmpnm[2 <(invar.ndims-1)] EQ 's_w':vargrid = 'W' 
     181        tmpnm[0] EQ 'xi_rho' AND tmpnm[1] EQ 'eta_rho':listgrid[i] = 'T' 
     182        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_u'  :listgrid[i] = 'U' 
     183        tmpnm[0] EQ 'xi_v'   AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'V' 
     184        tmpnm[0] EQ 'xi_psi' AND tmpnm[1] EQ 'eta_psi':listgrid[i] = 'F' 
     185        tmpnm[0] EQ 'xi_rho' AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'V' 
     186        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_rho':listgrid[i] = 'U' 
     187        tmpnm[0] EQ 'xi_u'   AND tmpnm[1] EQ 'eta_v'  :listgrid[i] = 'F' 
     188        ELSE:  
     189      ENDCASE  
     190    ENDFOR 
     191    empty = where(listgrid EQ '') 
     192    IF empty[0] NE -1 THEN BEGIN    
     193; could we define the grid type from the file name?? 
    95194      pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
    96195      gdtype = ['T', 'U', 'V', 'W', 'F'] 
     
    104203        ENDFOR 
    105204      ENDFOR 
    106     ENDIF 
    107   ENDELSE 
    108 ;------------------------------------------------------------ 
    109 ; name of all dimensions 
    110 ;------------------------------------------------------------ 
    111   namedim = strarr(infile.ndims) 
    112   for dimiq = 0, infile.ndims-1 do begin 
    113     ncdf_diminq, cdfid, dimiq, tmpname, value  
    114     namedim[dimiq] = strlowcase(tmpname) 
    115   ENDFOR 
    116 ; we are looking for a x dimension with a name matching one of the following regular expression: 
    117   testname = ['longitude', 'lon', 'x', 'longitude*', 'lon*', 'x*', '*longitude*', '*lon*', '*x*'] 
    118   cnt = -1 
    119   ii = 0 
    120   WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
    121     dimidx = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
    122     ii = ii+1 
    123   ENDWHILE 
    124   CASE cnt OF 
    125     0:begin 
    126       dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
    127                       , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
    128                       , ' => we cannot find the x dimension']) 
    129       stop 
    130     END 
    131     1:dimidx = dimidx[0] 
    132     ELSE:begin 
    133       dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
    134                       , '''longitude'', ''lon'', ''x'', ''longitude*'', ''lon*'', ''x*'', ''*longitude*'', ''*lon*'', ''*x*''' $ 
    135                       , ' => we cannot find the x dimension']) 
    136       stop 
    137     END 
    138   ENDCASE 
    139 ; we are looking for a y dimension with a name matching one of the following regular expression: 
    140   testname = ['latitude', 'lat', 'y', 'latitude*', 'lat*', 'y*', 'eta_*', '*latitude*', '*lat*', '*y*'] 
    141   cnt = -1 
    142   ii = 0 
    143   WHILE cnt NE 1 AND ii LT n_elements(testname) DO BEGIN 
    144     dimidy = where(strmatch(namedim, testname[ii]) EQ 1, cnt) 
    145     ii = ii+1 
    146   ENDWHILE 
    147   CASE cnt OF 
    148     0:begin 
    149       dummy = report(['none of the dimensions name matches one of the following regular expression:' $ 
    150                       , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
    151                       , ' => we cannot find the y dimension']) 
    152       stop 
    153     END 
    154     1:dimidy = dimidy[0] 
    155     ELSE:begin 
    156       dummy = report(['several (and not one unique) dimensions name matches the following regular expression:' $ 
    157                       , '''latitude'', ''lat'', ''y'', ''latitude*'', ''lat*'', ''y*'', ''eta_*'', ''*latitude*'', ''*lat*'', ''*y*''' $ 
    158                       , ' => we cannot find the x dimension']) 
    159       stop 
    160     END 
    161   ENDCASE 
    162 ;------------------------------------------------------------ 
    163 ; name of all variables 
    164 ;------------------------------------------------------------ 
    165 ; we keep only the variables containing at least x, y and time dimension (if existing...) 
    166   namevar = strarr(infile.nvars) 
    167   for varid = 0, infile.nvars-1 do begin 
    168     invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
    169     if (where(invar.dim EQ dimidx))[0] NE -1 AND $ 
    170        (where(invar.dim EQ dimidy))[0] NE -1 AND $ 
    171        ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
    172     THEN namevar[varid] = invar.name  
    173   ENDFOR 
    174   namevar = namevar[where(namevar NE '')] 
    175   listgrid = replicate(vargrid, n_elements(namevar)) 
     205      listgrid[empty] = vargrid 
     206    ENDIF  
     207  ENDIF ELSE listgrid[*] = vargrid 
    176208;------------------------------------------------------------ 
    177209; time axis 
     
    229261          mots = str_sep(value, ' ') 
    230262          unite = mots[0] 
    231           debut = str_sep(mots[2], '-') 
     263          err = 0 
     264          IF unite NE 'seconds' AND unite NE 'hours' AND unite NE 'days' $ 
     265             AND unite NE 'months' AND unite NE 'years' THEN BEGIN 
     266            dummy = report('time units does not start with seconds/hours/days/months/years') 
     267            err = 1 
     268          ENDIF 
     269          err = err + 1 - stregex(value, '[^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*', /boolean) 
     270          IF err GT 0 THEN BEGIN  
     271            dummy = report('attribut units of time has not the good format: [^ ]* since ([0-9]){4}-([0-9]){2}-([0-9]){2}.*') 
     272            fakecal = 1 
     273            time = date0fk + lindgen(jpt) 
     274          ENDIF ELSE BEGIN  
     275            debut = str_sep(mots[2], '-') 
    232276; 
    233277; now we try to find the attribut called calendar... 
     
    235279; If no, we suppose that the calendar is gregorian calendar 
    236280; 
    237           if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
    238             ncdf_attget, cdfid, varid, 'calendar', value 
    239             value = string(value) 
    240             CASE value OF 
    241               'noleap':key_caltype = 'noleap' 
    242               '360d':key_caltype = '360d' 
    243               'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
    244               ELSE:BEGIN 
     281            if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
     282              ncdf_attget, cdfid, varid, 'calendar', value 
     283              value = string(value) 
     284              CASE value OF 
     285                'noleap':key_caltype = 'noleap' 
     286                '360d':key_caltype = '360d' 
     287                'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     288                ELSE:BEGIN 
    245289;            notused = report('Unknown calendar: '+value+', we use greg calendar.')  
    246                 key_caltype = 'greg' 
     290                  key_caltype = 'greg' 
     291                END 
     292              ENDCASE 
     293            ENDIF ELSE BEGIN 
     294;        notused = report('Unknown calendar, we use '+key_caltype+' calendar.')  
     295              IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     296            ENDELSE 
     297; 
     298; BEWARE we have to get back the calendar attribute and ajust time by consequence... 
     299; 
     300; 
     301; We pass time in IDL julian days 
     302; 
     303            unite = strlowcase(unite) 
     304            IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
     305            IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
     306            case unite of 
     307              'second':time = julday(debut[1], debut[2], debut[0])+time/86400.d 
     308              'hour':time = julday(debut[1], debut[2], debut[0])+time/24.d 
     309              'day':time = julday(debut[1], debut[2], debut[0])+time 
     310              'month':BEGIN  
     311                if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
     312                   time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
     313                ELSE for t = 0, n_elements(time)-1 DO $ 
     314                   time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
     315              END 
     316              'year':BEGIN 
     317                if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
     318                   time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
     319                ELSE for t = 0, n_elements(time)-1 do $ 
     320                   time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
    247321              END 
    248322            ENDCASE 
    249           ENDIF ELSE BEGIN 
    250 ;        notused = report('Unknown calendar, we use '+key_caltype+' calendar.')  
    251             IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     323; 
     324; high frequency calendar: more than one element per day 
     325            IF max(histogram([long(time-time[0])])) GT 1 THEN fakecal = 1 ELSE fakecal = 0 
     326            date0fk = date2jul(19000101) 
     327            IF keyword_set(fakecal) THEN time = date0fk+lindgen(jpt) $ 
     328            ELSE time = long(time) 
     329; 
    252330          ENDELSE 
    253 ; 
    254 ; BEWARE we have to get back the calendar attribute and ajust time by consequence... 
    255 ; 
    256 ; 
    257 ; We pass time in IDL julian days 
    258 ; 
    259           unite = strlowcase(unite) 
    260           IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
    261           IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
    262           case unite of 
    263             'second':time = julday(debut[1], debut[2], debut[0])+time/86400.d 
    264             'hour':time = julday(debut[1], debut[2], debut[0])+time/24.d 
    265             'day':time = julday(debut[1], debut[2], debut[0])+time 
    266             'month':BEGIN  
    267               if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
    268                  time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
    269               ELSE for t = 0, n_elements(time)-1 DO $ 
    270                  time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
    271             END 
    272             'year':BEGIN 
    273               if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
    274                  time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
    275               ELSE for t = 0, n_elements(time)-1 do $ 
    276                  time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
    277             END 
    278           ENDCASE 
    279 ; 
    280 ; high frequency calendar: more than one element per day 
    281           IF max(histogram([long(time-time[0])])) GT 1 THEN fakecal = 1 ELSE fakecal = 0 
    282           date0fk = date2jul(19000101) 
    283           IF keyword_set(fakecal) THEN time = date0fk+lindgen(jpt) $ 
    284           ELSE time = long(time) 
    285 ; 
    286331        ENDELSE 
    287332      END 
  • trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_domain.pro

    r167 r172  
    245245      gdep1 = floor(gdep) 
    246246      gdep2 = ceil(gdep) 
    247       same = where(gdep2-gdep1 EQ 0) 
    248       if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
     247;;       same = where(gdep2-gdep1 EQ 0) 
     248;;       if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
    249249      widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} 
    250250      widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} 
     
    321321  compile_opt idl2, strictarrsubs 
    322322; 
    323    box = lonarr(6) 
     323   box = fltarr(6) 
    324324   possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] 
    325325   for i = 0, 5 do begin 
     
    327327       , get_value = value 
    328328      box[i] = value.value 
    329    endfor 
     329    ENDFOR 
    330330   return, box 
    331331end 
     
    636636  gdep1 = floor(gdep) 
    637637  gdep2 = ceil(gdep) 
    638   same = where(gdep2-gdep1 EQ 0) 
    639   if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
     638;;   same = where(gdep2-gdep1 EQ 0) 
     639;;   if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
    640640  sgdep1 = strtrim(gdep1, 1) 
    641641  sgdep2 = strtrim(gdep2, 1) 
Note: See TracChangeset for help on using the changeset viewer.