Changeset 3740 for TOOLS


Ignore:
Timestamp:
04/11/18 17:54:26 (6 years ago)
Author:
omamce
Message:

O.M. : now usable in Python 3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/nemo.py

    r3725 r3740  
    2222 
    2323def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) : 
    24     # nperio    : Type of periodicity 
    25     #   1, 4, 6 : Cyclic on i dimension (generaly longitudes) 
    26     #   2       : Obsolete (was symmetric condition at southern boundary ?) 
    27     #   3, 4    : North fold T-point pivot (legacy ORCA2) 
    28     #   5, 6    : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) 
    29     # ptab     : Input array 
    30     #   rank 2 at least : patb[[...., lat, lon] 
    31     # cd_type  : Grid specification : T, U, V or F 
    32     # psgn     : For change of sign for vector components 
    33     # 
    34     # See NEMO documentation for further details 
     24    """ 
     25    ptab      : Input array 
     26      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 
    3534     
     35    See NEMO documentation for further details 
     36    """ 
     37         
    3638    jpi = ptab.shape[-1] 
    3739     
     
    5052    if nperio in [3, 4] :  # North fold T-point pivot      
    5153        if cd_type in [ 'T', 'W' ] : # T-, W-point 
    52             ptab[..., -1, 1:      ] = psgn * ptab[..., -3, -1:0:-1]       
    53             ptab[..., -1, 0]        = psgn * ptab[..., -3, 2] 
    54             ptab[..., -2, jpi/2:  ] = psgn * ptab[..., -2, jpi/2:0:-1] 
     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  ] 
    5557                       
    5658        if cd_type == 'U' : 
    57             ptab[..., -1, 0:-1    ] = psgn * ptab[..., -3, -1:0:-1  ]        
    58             ptab[..., -1,  0]       = psgn * ptab[..., -3,  1] 
    59             ptab[..., -1, -1]       = psgn * ptab[..., -3, -2]  
    60             ptab[..., -2, jpi/2-1:] = psgn * ptab[..., -2, jpi/2+1:0:-1] 
     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] 
    6163             
    6264        if cd_type == 'V' :  
    63             ptab[..., -2, 1:      ] = psgn * ptab[..., -3, jpi-1:0:-1] 
    64             ptab[..., -1, 1:      ] = psgn * ptab[..., -4, -1:0:-1]    
    65             ptab[..., -1, 0]        = psgn * ptab[..., -4, 2] 
     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            ] 
    6668             
    6769        if cd_type == 'F' : 
    68             ptab[..., -2, 0:-1    ] = psgn * ptab[..., -3, -1:0:-1] 
    69             ptab[..., -1, 0:-1    ] = psgn * ptab[..., -4, -1:0:-1] 
    70             ptab[..., -1,  0]       = psgn * ptab[..., -4,  1] 
    71             ptab[..., -1, -1]       = psgn * ptab[..., -4, -2]  
     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           ]  
    7274       
    7375    if nperio in [5, 6] :            #  North fold F-point pivot   
    7476        if cd_type in ['T', 'W']  : 
    75             ptab[..., -1, 0:      ] = psgn * ptab[..., -2, -1::-1] 
     77            ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ] 
    7678                 
    7779        if cd_type == 'U' : 
    78             ptab[..., -1, 0:-1    ] = psgn * ptab[..., -2, -2::-1]        
    79             ptab[..., -1, -1]       = psgn * ptab[..., -2, 0] 
     80            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]        
     81            ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ] 
    8082              
    8183        if cd_type == 'V' : 
    82             ptab[..., -1, 0:      ] = psgn * ptab[..., -3, -1::-1   ] 
    83             ptab[..., -2, jpi/2:  ] = psgn * ptab[..., -2, jpi/2-1::-1] 
     84            ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ] 
     85            ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ] 
    8486                              
    8587        if cd_type == 'F' : 
    86             ptab[..., -1, 0:-1    ] = psgn * ptab[..., -3, -2::-1] 
    87             ptab[..., -1, -1]       = psgn * ptab[..., -3, 0] 
    88             ptab[..., -2, jpi/2:-1] = psgn * ptab[..., -2, jpi/2-2::-1] 
     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 ] 
    8991 
    9092    return ptab 
    91 ################################ 
    9293         
     94## =========================================================================== 
     95## 
     96##                               That's all folk's !!! 
     97## 
     98## =========================================================================== 
Note: See TracChangeset for help on using the changeset viewer.