Ignore:
Timestamp:
07/21/06 14:47:49 (18 years ago)
Author:
navarro
Message:

english and nicer header (2a)

File:
1 edited

Legend:

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

    r134 r142  
    33;------------------------------------------------------------ 
    44;+ 
    5 ; NAME: moyenne 
    6 ; 
    7 ; PURPOSE:  averages a 2- or 3-d field over a selected 
     5; 
     6; @file_comments   
     7; averages a 2- or 3-d field over a selected 
    88;           geographical area and along one ore more 
    99;           selected axes (x, y or z) 
    1010; 
    11 ; CATEGORY: 
    12 ; 
    13 ; CALLING SEQUENCE: result = moyenne(tab,'direc',BOXZOOM=boxzoom) 
    14 ; 
    15 ; INPUTS:       tab = 2 or 3d field 
    16 ;               direc = 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 
    17 ; 
    18 ; KEYWORD PARAMETERS: 
    19 ; 
    20 ;               BOXZOOM = [xmin,xmax,ymin,ymax (,(zmin,)zmax)] pour plus 
    21 ;               de detail cf domdef. 
    22 ;               boxzoom peut prendre 5 formes:  
    23 ;               [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2],   
    24 ;               [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, 
    25 ;               lat2, vert1,vert2] 
    26 ; 
    27 ;               NAN: not a number, a activer si l''on peut faire veut 
    28 ;               faire une moyenne sans tenir compte de certaines 
    29 ;               valeurs masques de tab. 
    30 ;               si les valeurs masques de tab sont la valeur consacree 
    31 ;               par IDL (!values.f_nan), il suffit de mettre /NAN. 
    32 ;               si les valeurs masques de tab on pour valeur a (a doit 
    33 ;               etre differente de 1 (correspond a nan = 
    34 ;               !values.f_nan) et de 0 (qui desactive nan) 
    35 ;               il faut mettre NAN=a.  
    36 ;               Rq: en sorties les points de result qui sont NAN 
    37 ;               auront pour valeur a ou !values.f_nan. 
    38 ; 
    39 ;               NODOMDEF: activer si l''on ne veut pas passer ds 
    40 ;               domdef bien que le mot cle boxzoom soit present (comme 
    41 ;               c''est le cas qd moyenne est appelee via checkfield)  
     11; @categories 
     12; 
     13; @param        TAB {in}{required} 
     14; 2 or 3d field 
     15; 
     16; @param DIREC {in}{required} 
     17; 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 
     18; 
     19; @keyword BOXZOOM   
     20; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 
     21; boxzoom can have 5 forms:  
     22; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2],   
     23; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, lat2, vert1,vert2] 
     24; 
     25; @keyword NAN  
     26; not a number, we activate it if we want to average without considerate some masked values of TAB. 
     27; If masked values of TAB are values consecrated by IDL(!values.f_nan), wr just have to put NAN. 
     28; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 
     29; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a.  
     30; Comment: In output, rsult points which are NAN will be valued a or !values.f_nan. 
    4231;             
    43 ;               INTEGRATION: pour faire une integrale plutot qu''une moyenne 
     32; @keyword NODOMDEF 
     33; We activate it if we do not want to pass in domdef even if the keyword boxzoom  
     34; is present (like when grossemoyenne is called via checkfield) 
     35; 
     36; @keyword INTEGRATION  
     37; To make an integral rather than an average 
    4438;  
    45 ;         /WDEPTH: to specify that the field is at W depth instad of T  
    46 ;         depth (automatically activated if vargrid eq 'W') 
     39; @keyword WDEPTH  
     40; to specify that the field is at W depth instad of T  
     41; depth (automatically activated if vargrid eq 'W')  
    4742;             
    48 ; OUTPUTS:  result:un tableau  
    49 ; 
    50 ; COMMON BLOCKS: 
    51 ;       common   domdef 
    52 ; 
    53 ; SIDE EFFECTS:met les valeurs correspondants a la terre a 1e20 
    54 ; 
    55 ; RESTRICTIONS: 
    56 ; 
    57 ; EXAMPLE: 
    58 ; 
    59 ; MODIFICATION HISTORY: Jerome Vialard (jv@lodyc.jussieu.fr) 
     43; @returns 
     44; An array  
     45; 
     46; @uses 
     47; common 
     48; domdef 
     49; 
     50; @restrictions Put values corresponding to land at 1.e20 
     51; 
     52; @history 
     53;  Jerome Vialard (jv@lodyc.jussieu.fr) 
    6054;                       2/7/98 
    6155;                       Sebastien Masson (smasson@lodyc.jussieu.fr) 
    62 ;                       mise au propre de certains truc (les terres...) 
    6356;                       14/8/98 
    6457;                       15/1/98 
    65 ;                       11/3/99 adaptation pour NAN 
    66 ;                       28/7/99 moyennes tableaux 1d 
     58;                       11/3/99 adaptation for NAN 
     59;                       28/7/99 Averages 1d arrays 
     60; 
     61; @version 
     62; $Id$ 
     63; 
    6764;- 
    68 ;------------------------------------------------------------ 
    69 ;------------------------------------------------------------ 
    70 ; PLAN DU PROGRAMME: 
    71 ;------------------------------------------------------------ 
    72 ;------------------------------------------------------------ 
    73 ;I) preliminaires 
    74 ;   I.1) determination des directions de moyennes d''apres direc 
    75 ;   I.2) verification de la taille du tableau d''entree 
    76 ;   I.3) obtention des facteurs d''echelles et du masque sur le sous 
    77 ;   domaine concerne par la moyenne  
    78 ;  ) moyennes pour les tableaux 1d (x,y) 
    79 ;II) moyennes pour les tableaux 2d (x,y) 
    80 ;   II.1) verification de la coherence de la taille du tableau a 
    81 ;   moyenner  
    82 ;   II.2) differents types de moyennes possibles 
    83 ;III) moyennes pour les tableaux 3d (x,y,z) 
    84 ;   III.1) verification de la coherence de la taille du tableau a 
    85 ;   moyenner  
    86 ;   III.2) differents types de moyennes possibles 
    87 ;IV ) finitions 
    88 ;   IV.1) on masque les terres par une valeur a 1e+20 
    89 ;   IV.2) on remplace, quand nan ne 1, !values.f_nan par nan 
    90 ;   IV.3) on revient au sous domaine initial. 
    91 ;------------------------------------------------------------ 
    92 ;------------------------------------------------------------ 
     65 
    9366function moyenne, tab, direc, BOXZOOM = boxzoom, INTEGRATION = integration $ 
    9467                  , NAN = nan, NODOMDEF = nodomdef, WDEPTH = wdepth $ 
     
    10679  ENDIF 
    10780;--------------------------------------------------------- 
    108   tempsun = systime(1)          ; pour key_performance 
    109 ;------------------------------------------------------------ 
    110 ;I) preliminaires 
     81  tempsun = systime(1)          ; To key_performance 
     82;------------------------------------------------------------ 
     83;I) preliminaries 
    11184;------------------------------------------------------------ 
    11285  dirt = 0 
     
    11588  dirz = 0 
    11689;------------------------------------------------------------ 
    117 ; I.1) direction(s) suivants lesquelles on integre 
     90; I.1) Directions(s) we follow to integrate 
    11891;------------------------------------------------------------ 
    11992  if ( strpos(direc, 't') ge 0 ) then dirt = 1 
     
    12396  if (dirx eq 0 and diry eq 0 and dirz eq 0) then return, tab 
    12497;------------------------------------------------------------ 
    125 ; I.2) verification de la taille du tableau d'entree 
     98; I.2) verification of the input array's size 
    12699;------------------------------------------------------------ 
    127100  taille = size(tab) 
     
    139112  endcase 
    140113;------------------------------------------------------------ 
    141 ;   I.3) obtention des facteurs d''echelles et du masque sur le sous 
    142 ;   domaine concerne par la moyenne  
    143 ; redefinition du domaine ajuste a boxzoom (a 6 elements) 
    144 ; ceci va nous permetre de faire les calcules que sur le sous domaine 
    145 ; comcerne par la moyenne. domdef, suivit de grille nous donne tous 
    146 ; les tableaux de la grille sur le sous domaine  
     114;   I.3) Obtainment of scale's factors and of the mask on the subdomain concernedby the average. 
     115; Redefinition of the domain ajusted at boxzoom (at 6 elements) 
     116; This will allowed us to calculate only in the domain concerned by the average. 
     117; Domdef, followed by grid give us all arrays of the grid on the subdomain  
    147118;------------------------------------------------------------ 
    148119  if keyword_set(boxzoom) then BEGIN  
     
    162133  ENDIF  
    163134;--------------------------------------------------------------- 
    164 ; attribution du mask et des tableaux de longitude et latitude... 
     135; attribution of the mask and of longitude and latitude arrays... 
    165136;--------------------------------------------------------------- 
    166137  IF vargrid EQ 'W' THEN wdepth = 1 
     
    168139;------------------------------------------------------------ 
    169140;------------------------------------------------------------ 
    170 ; II) Cas du tableau 1d 
     141; II) Case of the 1d array 
    171142;------------------------------------------------------------ 
    172143;------------------------------------------------------------ 
     
    177148    ENDIF 
    178149    case 1 of 
    179       nx EQ 1 AND ny EQ 1:BEGIN ;vecteur suivant z 
     150      nx EQ 1 AND ny EQ 1:BEGIN ;vector following z 
    180151        case n_elements(tab) of 
    181152          jpk:res = tab[firstz:lastz] 
     
    194165        ENDELSE  
    195166      END 
    196       ny EQ 1:BEGIN             ;vecteur suivant x 
     167      ny EQ 1:BEGIN             ;vector following x 
    197168        case n_elements(tab) of 
    198169          jpi:res = tab[firstx:lastx] 
     
    211182        ENDELSE 
    212183      END 
    213       nx EQ 1:BEGIN             ;vecteur suivant y 
     184      nx EQ 1:BEGIN             ;vector following y 
    214185        case n_elements(tab) of 
    215186          jpj:res = tab[firsty:lasty] 
     
    232203;------------------------------------------------------------ 
    233204;------------------------------------------------------------ 
    234 ; II) Cas du tableau 2d 
     205; II) Case of the 2d array 
    235206;------------------------------------------------------------ 
    236207;------------------------------------------------------------ 
    237208  if (dim eq '2d') then begin 
    238209;--------------------------------------------------------------- 
    239 ;   II.1) verification de la coherence de la taille du tableau a 
    240 ;   moyenner  
    241 ; verification de la coherence entre la taille du tableau et le 
    242 ; domaine definit par domdef 
    243 ; le tableau en entree doit avoir soit la taille du domaine total 
    244 ; (jpi,jpj) soit celle du domaine reduit (nx,ny) 
     210;   II.1) verification of the coherence of the array's size to average 
     211; Verification of the coherence between the array's size and the domain defined by domdef 
     212; The input array must have either the total domain's size (jpi,jpj) or this  
     213; one of the reduced domain (nx,ny) 
    245214;--------------------------------------------------------------- 
    246215    case 1 of 
     
    254223    ENDCASE 
    255224    if keyword_set(nan) NE 0 then BEGIN  
    256       if nan NE 1 then BEGIN    ; si nan n''est pas !values.f_nan  
    257 ; on le met a !values.f_nan 
     225      if nan NE 1 then BEGIN    ; If nan is not !values.f_nan  
     226; we put it at !values.f_nan 
    258227        if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 
    259228        ELSE notanumber = where(abs(res) GT abs(nan)/10.) 
     
    262231    ENDIF 
    263232;--------------------------------------------------------------- 
    264 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET 
    265 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI 
    266 ; PEUVENT SEMBLER INUTILE AU DEPART 
     233; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,  
     234; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN  
     235; LOOK USELESS AT THE BEGINNING 
    267236;--------------------------------------------------------------- 
    268237    if nx EQ 1 OR ny EQ 1 then BEGIN  
     
    274243      mask =  reform(mask, nx, ny, nz, /over) 
    275244;--------------------------------------------------------------- 
    276 ; II.3) differents types de moyennes 
     245; II.3) Different types of average 
    277246;--------------------------------------------------------------- 
    278247    mask = mask[*, *, 0] 
     
    330299;------------------------------------------------------------ 
    331300;------------------------------------------------------------ 
    332 ; III) Cas du tableau 3d 
     301; III) Case 3d arrays series (tab4d) 
    333302;------------------------------------------------------------ 
    334303;------------------------------------------------------------ 
    335304  if (dim eq '3d') then begin 
    336305;--------------------------------------------------------------- 
    337 ; III.1) verification de la coherence de la taille du tableau a 
    338 ; moyenner  
    339 ; verification de la coherence entre la taille du tableau et le 
    340 ; domaine definit par domdef  
    341 ; le tableau en entree doit avoir soit la taille du domaine total 
    342 ; (jpi,jpj,jpk) soit celle du domaine reduit (nx,ny,ny) 
     306; III.1) Verification of the coherence of the array to average size  
     307; Verification of the coherence between the array's size and the domain  
     308; defind by domdef  
     309; The input array must have either the total domain size (jpi,jpj,jpk)  
     310; or this one of the reduced domain (nx,ny,ny) 
    343311;--------------------------------------------------------------- 
    344312    case 1 of 
     
    356324    endcase 
    357325    if keyword_set(nan) NE 0 then BEGIN  
    358       if nan NE 1 then BEGIN    ; si nan n''est pas !values.f_nan  
    359 ; on le met a !values.f_nan 
     326      if nan NE 1 then BEGIN    ; if nan is not !values.f_nan  
     327; we put it at !values.f_nan 
    360328        if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 
    361329        ELSE notanumber = where(abs(res) GT abs(nan)/10.) 
     
    364332    ENDIF 
    365333;--------------------------------------------------------------- 
    366 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET 
    367 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI 
    368 ; PEUVENT SEMBLER INUTILE AU DEPART 
     334; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1,  
     335; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN  
     336; LOOK USELESS AT THE BEGINNING 
    369337;--------------------------------------------------------------- 
    370338    if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN  
     
    387355    ENDIF ELSE bottom = -1 
    388356;--------------------------------------------------------------- 
    389 ; III.2) differents types de moyennes 
     357; III.2) different average types 
    390358;--------------------------------------------------------------- 
    391359    if keyword_set(nan) NE 0 then msknan = finite(res) ELSE msknan = -1 
     
    570538;------------------------------------------------------------ 
    571539;------------------------------------------------------------ 
    572 ;IV ) finitions 
    573 ;------------------------------------------------------------ 
    574 ;------------------------------------------------------------ 
    575 ; IV.1) on masque les terres par une valeur a 1e+20 
     540;IV ) finishing 
     541;------------------------------------------------------------ 
     542;------------------------------------------------------------ 
     543; IV.1) We mask land by a value equal to 1.e+20 
    576544;------------------------------------------------------------ 
    577545  valmask = 1e+20 
     
    581549  ENDIF   
    582550;------------------------------------------------------------ 
    583 ; IV.2) on remplace, quand nan ne 1, !values.f_nan par nan 
     551; IV.2) We replace, when nan equal 1, !values.f_nan by nan 
    584552;------------------------------------------------------------ 
    585553  if keyword_set(nan) NE 0 then BEGIN  
     
    592560  ENDIF 
    593561;------------------------------------------------------------ 
    594 ; IV.3) on se remplace ds le sous domaine qui etait definit a l''entree de 
    595 ; moyenne  
     562; IV.3) We replace in the domain whch was defined at the entry of average 
    596563;------------------------------------------------------------ 
    597564  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' 
Note: See TracChangeset for help on using the changeset viewer.