Ignore:
Timestamp:
03/14/07 18:13:39 (17 years ago)
Author:
pinsard
Message:

improvements of some *.pro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro

    r163 r223  
    44;+ 
    55; 
    6 ; @file_comments   
     6; @file_comments 
    77; averages a 2- or 3-d field over a selected 
    88;           geographical area and along one ore more 
     
    1717; 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 
    1818; 
    19 ; @keyword BOXZOOM   
     19; @keyword BOXZOOM 
    2020; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 
    21 ; boxzoom can have 5 forms:  
     21; boxzoom can have 5 forms: 
    2222;  [vert2], 
    2323;  [vert1, vert2], 
    24 ;  [lon1, lon2, lat1, lat2],   
     24;  [lon1, lon2, lat1, lat2], 
    2525;  [lon1, lon2, lat1, lat2, vert2], 
    2626;  [lon1, lon2, lat1, lat2, vert1,vert2] 
    2727; 
    28 ; @keyword NAN  
     28; @keyword NAN 
    2929; not a number, we activate it if we want to average without considerate some masked values of TAB. 
    3030; If masked values of TAB are values consecrated by IDL(!values.f_nan), we just have to put NAN. 
    3131; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 
    32 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a.  
     32; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 
    3333; Comment: In output, result points which are NAN will be valued a or !values.f_nan. 
    34 ;             
     34; 
    3535; @keyword NODOMDEF 
    36 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom  
     36; We activate it if we do not want to pass in domdef even if the keyword boxzoom 
    3737; is present (like when grossemoyenne is called via checkfield) 
    3838; 
    39 ; @keyword INTEGRATION  
     39; @keyword INTEGRATION 
    4040; To make an integral rather than an average 
    41 ;  
    42 ; @keyword WDEPTH  
    43 ; to specify that the field is at W depth instead of T  
    44 ; depth (automatically activated if vargrid eq 'W')  
    45 ;             
     41; 
     42; @keyword WDEPTH 
     43; to specify that the field is at W depth instead of T 
     44; depth (automatically activated if vargrid eq 'W') 
     45; 
    4646; @returns 
    47 ; An array  
     47; An array 
    4848; 
    4949; @uses 
     
    5151; domdef 
    5252; 
    53 ; @restrictions Put values corresponding to land at 1.e20 
     53; @restrictions 
     54; Put values corresponding to land at 1.e20 
    5455; 
    5556; @history 
     
    112113      if dirx eq 0 and diry eq 0 and dirz eq 0 then return, tab 
    113114    END 
    114     else : return, report('Le tableau d''entree doit etre a 2 ou 3 dimensions s''il contient une dim temporelle utiliser grossemoyenne') 
     115    else : return, report('Array must have 2 or 3 dimensions if there is a time dimension use grossemoyenne') 
    115116  endcase 
    116117;------------------------------------------------------------ 
     
    118119; Redefinition of the domain ajusted at boxzoom (at 6 elements) 
    119120; This will allowed us to calculate only in the domain concerned by the average. 
    120 ; Domdef, followed by grid give us all arrays of the grid on the subdomain  
    121 ;------------------------------------------------------------ 
    122   if keyword_set(boxzoom) then BEGIN  
     121; Domdef, followed by grid give us all arrays of the grid on the subdomain 
     122;------------------------------------------------------------ 
     123  if keyword_set(boxzoom) then BEGIN 
    123124    Case 1 Of 
    124125      N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] 
     
    127128      N_Elements(Boxzoom) Eq 5:bte = [Boxzoom[0:3], 0, Boxzoom[4]] 
    128129      N_Elements(Boxzoom) Eq 6:bte = Boxzoom 
    129       Else: return, report('Mauvaise Definition de Boxzoom') 
     130      Else: return, report('Bad definition of Boxzoom') 
    130131    endcase 
    131     if NOT keyword_set(nodomdef) then BEGIN  
     132    if NOT keyword_set(nodomdef) then BEGIN 
    132133      savedbox = 1b 
    133134      saveboxparam, 'boxparam4moyenne.dat' 
    134135      domdef, bte, GRIDTYPE = vargrid, _extra = ex 
    135     ENDIF  
    136   ENDIF  
     136    ENDIF 
     137  ENDIF 
    137138;--------------------------------------------------------------- 
    138139; attribution of the mask and of longitude and latitude arrays... 
     
    155156          jpk:res = tab[firstz:lastz] 
    156157          nz:res = tab 
    157           ELSE:BEGIN  
     158          ELSE:BEGIN 
    158159            if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    159160            return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') 
    160161          END 
    161162        ENDCASE 
    162         if dirz EQ 1 then BEGIN  
    163           dim = '3d'  
     163        if dirz EQ 1 then BEGIN 
     164          dim = '3d' 
    164165          taille = size(reform(res, nx, ny, nz)) 
    165166        ENDIF ELSE BEGIN 
    166167          if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    167168          return, res 
    168         ENDELSE  
     169        ENDELSE 
    169170      END 
    170171      ny EQ 1:BEGIN             ;vector following x 
     
    172173          jpi:res = tab[firstx:lastx] 
    173174          nx:res = tab 
    174           ELSE:BEGIN  
     175          ELSE:BEGIN 
    175176            if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    176177            return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') 
    177178          END 
    178179        ENDCASE 
    179         if dirx EQ 1 then BEGIN  
    180           dim = '2d'  
     180        if dirx EQ 1 then BEGIN 
     181          dim = '2d' 
    181182          taille = size(reform(res, nx, ny)) 
    182         ENDIF ELSE BEGIN  
     183        ENDIF ELSE BEGIN 
    183184          if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    184185          return, res 
     
    189190          jpj:res = tab[firsty:lasty] 
    190191          ny:res = tab 
    191           ELSE:BEGIN  
     192          ELSE:BEGIN 
    192193            if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    193194            return, report('Probleme d''adequation entre les tailles du domaine et de la boxzoom.') 
     
    197198          dim = '2d' 
    198199          taille = size(reform(res, nx, ny)) 
    199         ENDIF ELSE BEGIN  
     200        ENDIF ELSE BEGIN 
    200201          if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    201202          return, res 
    202         ENDELSE  
     203        ENDELSE 
    203204      END 
    204205    endcase 
     
    213214;   II.1) verification of the coherence of the array's size to average 
    214215; Verification of the coherence between the array's size and the domain defined by domdef 
    215 ; The input array must have either the total domain's size (jpi,jpj) or this  
     216; The input array must have either the total domain's size (jpi,jpj) or this 
    216217; one of the reduced domain (nx,ny) 
    217218;--------------------------------------------------------------- 
     
    220221        res = tab[firstx:lastx, firsty:lasty] 
    221222      taille[1] eq  nx and taille[2] eq  ny:res = tab 
    222       else:BEGIN  
     223      else:BEGIN 
    223224        if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    224225        return, report('Probleme d''adequation entre les tailles du domaine nx*ny '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 
    225226      END 
    226227    ENDCASE 
    227     if keyword_set(nan) NE 0 then BEGIN  
    228       if nan NE 1 then BEGIN    ; If nan is not !values.f_nan  
     228    if keyword_set(nan) NE 0 then BEGIN 
     229      if nan NE 1 then BEGIN    ; If nan is not !values.f_nan 
    229230; we put it at !values.f_nan 
    230231        if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 
     
    234235    ENDIF 
    235236;--------------------------------------------------------------- 
    236 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,  
    237 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN  
     237; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 
     238; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 
    238239; LOOK USELESS AT THE BEGINNING 
    239240;--------------------------------------------------------------- 
    240     if nx EQ 1 OR ny EQ 1 then BEGIN  
     241    if nx EQ 1 OR ny EQ 1 then BEGIN 
    241242      res = reform(res, nx, ny, /over) 
    242243      e1 =  reform(e1, nx, ny, /over) 
     
    254255        e = e1*mask 
    255256        if keyword_set(integration) then divi = 1 $ 
    256         else begin  
     257        else begin 
    257258          divi = e 
    258259          IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan 
     
    272273        e = e2*mask 
    273274        if keyword_set(integration) then divi = 1 $ 
    274         else begin  
     275        else begin 
    275276          divi = e 
    276277          IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan 
     
    288289      end 
    289290      (dirx eq 1) and (diry eq 1) : begin 
    290         if keyword_set(integration) then divi = 1 else BEGIN  
     291        if keyword_set(integration) then divi = 1 else BEGIN 
    291292          IF msknan[0] NE -1 THEN divi = total(e1*e2*mask*msknan) $ 
    292293          ELSE divi = total(e1*e2*mask) 
    293         ENDELSE  
     294        ENDELSE 
    294295        res = total(res*e1*e2*mask, nan = nan)/(divi > 1.) 
    295296        if msknan[0] NE -1 then begin 
     
    307308  if (dim eq '3d') then begin 
    308309;--------------------------------------------------------------- 
    309 ; III.1) Verification of the coherence of the array to average size  
    310 ; Verification of the coherence between the array's size and the domain  
    311 ; defind by domdef  
    312 ; The input array must have either the total domain size (jpi,jpj,jpk)  
     310; III.1) Verification of the coherence of the array to average size 
     311; Verification of the coherence between the array's size and the domain 
     312; defind by domdef 
     313; The input array must have either the total domain size (jpi,jpj,jpk) 
    313314; or this one of the reduced domain (nx,ny,ny) 
    314315;--------------------------------------------------------------- 
     
    321322      taille[1] EQ  nx and taille[2] eq  ny and taille[3] eq jpk : $ 
    322323        res = tab[*, *, firstz:lastz] 
    323       else:BEGIN  
     324      else:BEGIN 
    324325        if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    325326        return, report('Probleme d''adequation entre les tailles du domaine nx*ny*nz '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+'*'+strtrim(nz, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 
    326327      END 
    327328    endcase 
    328     if keyword_set(nan) NE 0 then BEGIN  
    329       if nan NE 1 then BEGIN    ; if nan is not !values.f_nan  
     329    if keyword_set(nan) NE 0 then BEGIN 
     330      if nan NE 1 then BEGIN    ; if nan is not !values.f_nan 
    330331; we put it at !values.f_nan 
    331332        if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 
     
    335336    ENDIF 
    336337;--------------------------------------------------------------- 
    337 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,  
    338 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN  
     338; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 
     339; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 
    339340; LOOK USELESS AT THE BEGINNING 
    340341;--------------------------------------------------------------- 
    341     if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN  
     342    if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN 
    342343      res = reform(res, nx, ny, nz, /over) 
    343344      e1 =  reform(e1, nx, ny, /over) 
     
    349350; the top of the ocean floor is 
    350351      IF vargrid EQ 'T' OR vargrid EQ 'W' THEN bottom = total(mask, 3) $ 
    351       ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3)  
    352 ; we suppress columns with only ocean or land  
     352      ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3) 
     353; we suppress columns with only ocean or land 
    353354      good = where(bottom NE 0 AND bottom NE nz) 
    354355; the bottom of the ocean in 3D index is: 
     
    367368        IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 
    368369          AND nx NE 1 THEN BEGIN 
    369           IF msknan[0] EQ -1 THEN BEGIN  
     370          IF msknan[0] EQ -1 THEN BEGIN 
    370371            msknan = replicate(1b, nx, ny, nz) 
    371372            nan = 1 
     
    395396        IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 
    396397          AND ny NE 1 THEN BEGIN 
    397           IF msknan[0] EQ -1 THEN BEGIN  
     398          IF msknan[0] EQ -1 THEN BEGIN 
    398399            msknan = replicate(1b, nx, ny, nz) 
    399400            nan = 1 
     
    447448        IF keyword_set(key_partialstep) AND bottom[0] NE -1 $ 
    448449          AND nx*ny NE 1 THEN BEGIN 
    449           IF msknan[0] EQ -1 THEN BEGIN  
     450          IF msknan[0] EQ -1 THEN BEGIN 
    450451            msknan = replicate(1b, nx, ny, nz) 
    451452            nan = 1 
     
    454455          res[bottom] = !values.f_nan 
    455456        ENDIF 
    456         if keyword_set(integration) then divi = 1 else BEGIN  
     457        if keyword_set(integration) then divi = 1 else BEGIN 
    457458          divi = e123*mask 
    458459          IF msknan[0] NE -1 THEN divi = temporary(divi)*msknan 
     
    478479          ELSE e133[bottom] = (e1*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 
    479480        ENDIF 
    480         if keyword_set(integration) then divi = 1 else BEGIN  
     481        if keyword_set(integration) then divi = 1 else BEGIN 
    481482          divi = e133*mask 
    482483          if msknan[0] NE -1 then divi = temporary(divi)*msknan 
     
    502503          ELSE e233[bottom] = (e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 
    503504        ENDIF 
    504         if keyword_set(integration) then divi = 1 else BEGIN  
     505        if keyword_set(integration) then divi = 1 else BEGIN 
    505506          divi = e233*mask 
    506507          if msknan[0] NE -1 then divi = temporary(divi)*msknan 
     
    526527          ELSE e1233[bottom] = (e1*e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)] 
    527528        ENDIF 
    528         if keyword_set(integration) then divi = 1 else BEGIN  
     529        if keyword_set(integration) then divi = 1 else BEGIN 
    529530          if msknan[0] NE -1 then divi = total(e1233*mask*msknan) $ 
    530531          ELSE divi = total(e1233*mask) 
     
    550551  IF terre[0] NE -1 THEN BEGIN 
    551552    res[terre] = 1e+20 
    552   ENDIF   
     553  ENDIF 
    553554;------------------------------------------------------------ 
    554555; IV.2) We replace, when nan equal 1, !values.f_nan by nan 
    555556;------------------------------------------------------------ 
    556   if keyword_set(nan) NE 0 then BEGIN  
     557  if keyword_set(nan) NE 0 then BEGIN 
    557558    puttonan = where(testnan EQ 0) 
    558559    if puttonan[0] NE -1 then res[puttonan] = !values.f_nan 
    559     if nan NE 1 then BEGIN  
     560    if nan NE 1 then BEGIN 
    560561      notanumber = where(finite(res) eq 0) 
    561562      if notanumber[0] NE -1 then res[notanumber] = nan 
     
    567568  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
    568569;------------------------------------------------------------ 
    569   if keyword_set(key_performance) THEN print, 'temps moyenne', systime(1)-tempsun  
     570  if keyword_set(key_performance) THEN print, 'temps moyenne', systime(1)-tempsun 
    570571  return, res 
    571572;------------------------------------------------------------ 
Note: See TracChangeset for help on using the changeset viewer.