source: TOOLS/MOSAIX/nemo.py @ 3740

Last change on this file since 3740 was 3740, checked in by omamce, 6 years ago

O.M. : now usable in Python 3

  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 4.1 KB
RevLine 
[3723]1### ===========================================================================
2###
3### Periodicity of ORCA fields
4###
5### ===========================================================================
6##
7##  Warning, to install, configure, run, use any of Olivier Marti's
8##  software or to read the associated documentation you'll need at least
9##  one (1) brain in a reasonably working order. Lack of this implement
10##  will void any warranties (either express or implied).
11##  O. Marti assumes no responsability for errors, omissions,
12##  data loss, or any other consequences caused directly or indirectly by
13##  the usage of his software by incorrectly or partially configured
14##  personal.
15##
16## SVN information
[3725]17__Author__   = "$Author$"
18__Date__     = "$Date$"
19__Revision__ = "$Revision$"
20__Id__       = "$Id$"
21__HeadURL    = "$HeadURL$"
[3723]22
23def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) :
[3740]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
[3723]34   
[3740]35    See NEMO documentation for further details
36    """
37       
[3723]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
[3740]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  ]
[3723]57                     
58        if cd_type == 'U' :
[3740]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]
[3723]63           
64        if cd_type == 'V' : 
[3740]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            ]
[3723]68           
69        if cd_type == 'F' :
[3740]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           ] 
[3723]74     
75    if nperio in [5, 6] :            #  North fold F-point pivot 
76        if cd_type in ['T', 'W']  :
[3740]77            ptab[..., -1, 0:       ] = psgn * ptab[..., -2, -1::-1       ]
[3723]78               
79        if cd_type == 'U' :
[3740]80            ptab[..., -1, 0:-1     ] = psgn * ptab[..., -2, -2::-1       ]       
81            ptab[..., -1, -1       ] = psgn * ptab[..., -2, 0            ]
[3723]82             
83        if cd_type == 'V' :
[3740]84            ptab[..., -1, 0:       ] = psgn * ptab[..., -3, -1::-1       ]
85            ptab[..., -2, jpi/2:   ] = psgn * ptab[..., -2, jpi/2-1::-1  ]
[3723]86                             
87        if cd_type == 'F' :
[3740]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 ]
[3723]91
92    return ptab
93       
[3740]94## ===========================================================================
95##
96##                               That's all folk's !!!
97##
98## ===========================================================================
Note: See TracBrowser for help on using the repository browser.