Ignore:
Timestamp:
04/12/18 12:10:00 (6 years ago)
Author:
omamce
Message:

O.M. : improve documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/CPLRESTART/nemo.py

    r3739 r3741  
    2222 
    2323def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) : 
    24     """ 
    25     ptab      : Input array 
     24      """ 
     25      ptab      : Input array 
    2626      rank 2 at least : patb[...., lat, lon] 
    27     nperio    : Type of periodicity 
    28       1, 4, 6 : Cyclic on i dimension (generaly longitudes) 
    29       2       : Obsolete (was symmetric condition at southern boundary ?) 
    30       3, 4    : North fold T-point pivot (legacy ORCA2) 
    31       5, 6    : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) 
    32     cd_type   : Grid specification : T, U, V or F 
    33     psgn      : For change of sign for vector components 
     27      nperio    : Type of periodicity 
     28         1, 4, 6   : Cyclic on i dimension (generaly longitudes) 
     29         2         : Obsolete (was symmetric condition at southern boundary ?) 
     30         3, 4      : North fold T-point pivot (legacy ORCA2) 
     31         5, 6      : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) 
     32      cd_type   : Grid specification : T, U, V or F 
     33      psgn      : For change of sign for vector components 
     34       
     35      See NEMO documentation for further details 
     36      """ 
     37      jpi = ptab.shape[-1] 
    3438     
    35     See NEMO documentation for further details 
    36     """ 
    37          
    38     jpi = ptab.shape[-1] 
    39      
    40     # 
    41     #> East-West boundary conditions 
    42     # -------------------------------- 
    43  
    44     if nperio in [1, 4, 6] : 
    45         # ... cyclic 
    46         ptab [...,:,  0] = ptab [...,:,-2] 
    47         ptab [...,:, -1] = ptab [...,:, 1] 
    48     
    49     # 
    50     #> North-South boundary conditions 
    51     # ---------------------------------- 
    52     if nperio in [3, 4] :  # North fold T-point pivot      
    53         if cd_type in [ 'T', 'W' ] : # T-, W-point 
    54             ptab[..., -1, 1:       ] = psgn * ptab[..., -3, -1:0:-1      ]       
    55             ptab[..., -1, 0        ] = psgn * ptab[..., -3, 2            ] 
    56             ptab[..., -2, jpi//2:  ] = psgn * ptab[..., -2, jpi//2:0:-1  ] 
    57                        
    58         if cd_type == 'U' : 
    59             ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]        
    60             ptab[..., -1,  0       ] = psgn * ptab[..., -3,  1           ] 
    61             ptab[..., -1, -1       ] = psgn * ptab[..., -3, -2           ]  
    62             ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1] 
     39      # 
     40      #> East-West boundary conditions 
     41      # -------------------------------- 
     42       
     43      if nperio in [1, 4, 6] : 
     44            # ... cyclic 
     45            ptab [...,:,  0] = ptab [...,:,-2] 
     46            ptab [...,:, -1] = ptab [...,:, 1] 
     47       
     48      # 
     49      #> North-South boundary conditions 
     50      # ---------------------------------- 
     51      if nperio in [3, 4] :  # North fold T-point pivot      
     52            if cd_type in [ 'T', 'W' ] : # T-, W-point 
     53                  ptab[..., -1, 1:       ] = psgn * ptab[..., -3, -1:0:-1      ]       
     54                  ptab[..., -1, 0        ] = psgn * ptab[..., -3, 2            ] 
     55                  ptab[..., -2, jpi//2:  ] = psgn * ptab[..., -2, jpi//2:0:-1  ] 
     56                   
     57            if cd_type == 'U' : 
     58                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ]        
     59                  ptab[..., -1,  0       ] = psgn * ptab[..., -3,  1           ] 
     60                  ptab[..., -1, -1       ] = psgn * ptab[..., -3, -2           ]  
     61                  ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1] 
     62                   
     63            if cd_type == 'V' :  
     64                  ptab[..., -2, 1:       ] = psgn * ptab[..., -3, jpi-1:0:-1   ] 
     65                  ptab[..., -1, 1:       ] = psgn * ptab[..., -4, -1:0:-1      ]    
     66                  ptab[..., -1, 0        ] = psgn * ptab[..., -4, 2            ] 
     67               
     68            if cd_type == 'F' : 
     69                  ptab[..., -2, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ] 
     70                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -4, -1:0:-1      ] 
     71                  ptab[..., -1,  0       ] = psgn * ptab[..., -4,  1           ] 
     72                  ptab[..., -1, -1       ] = psgn * ptab[..., -4, -2           ]  
     73                   
     74      if nperio in [5, 6] :            #  North fold F-point pivot   
     75            if cd_type in ['T', 'W']  : 
     76                  ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ] 
    6377             
    64         if cd_type == 'V' :  
    65             ptab[..., -2, 1:       ] = psgn * ptab[..., -3, jpi-1:0:-1   ] 
    66             ptab[..., -1, 1:       ] = psgn * ptab[..., -4, -1:0:-1      ]    
    67             ptab[..., -1, 0        ] = psgn * ptab[..., -4, 2            ] 
    68              
    69         if cd_type == 'F' : 
    70             ptab[..., -2, 0:-1     ] = psgn * ptab[..., -3, -1:0:-1      ] 
    71             ptab[..., -1, 0:-1     ] = psgn * ptab[..., -4, -1:0:-1      ] 
    72             ptab[..., -1,  0       ] = psgn * ptab[..., -4,  1           ] 
    73             ptab[..., -1, -1       ] = psgn * ptab[..., -4, -2           ]  
    74        
    75     if nperio in [5, 6] :            #  North fold F-point pivot   
    76         if cd_type in ['T', 'W']  : 
    77             ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ] 
    78                  
    79         if cd_type == 'U' : 
    80             ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]        
    81             ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ] 
    82               
    83         if cd_type == 'V' : 
    84             ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ] 
    85             ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ] 
    86                               
    87         if cd_type == 'F' : 
    88             ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -2::-1       ] 
    89             ptab[..., -1, -1       ] = psgn * ptab[..., -3, 0            ] 
    90             ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ] 
    91  
    92     return ptab 
    93          
     78            if cd_type == 'U' : 
     79                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]        
     80                  ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ] 
     81               
     82            if cd_type == 'V' : 
     83                  ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ] 
     84                  ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ] 
     85               
     86            if cd_type == 'F' : 
     87                  ptab[..., -1, 0:-1     ] = psgn * ptab[..., -3, -2::-1       ] 
     88                  ptab[..., -1, -1       ] = psgn * ptab[..., -3, 0            ] 
     89                  ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ] 
     90               
     91      return ptab 
     92   
    9493## =========================================================================== 
    9594## 
Note: See TracChangeset for help on using the changeset viewer.