[3739] | 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 |
---|
| 17 | __Author__ = "$Author$" |
---|
| 18 | __Date__ = "$Date$" |
---|
| 19 | __Revision__ = "$Revision$" |
---|
| 20 | __Id__ = "$Id$" |
---|
| 21 | __HeadURL = "$HeadURL$" |
---|
| 22 | |
---|
| 23 | def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) : |
---|
[3741] | 24 | """ |
---|
| 25 | ptab : Input array |
---|
[3739] | 26 | rank 2 at least : patb[...., lat, lon] |
---|
[3741] | 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] |
---|
[3739] | 38 | |
---|
[3741] | 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 ] |
---|
[3739] | 77 | |
---|
[3741] | 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 | |
---|
[3739] | 93 | ## =========================================================================== |
---|
| 94 | ## |
---|
| 95 | ## That's all folk's !!! |
---|
| 96 | ## |
---|
| 97 | ## =========================================================================== |
---|