[3621] | 1 | ### =========================================================================== |
---|
| 2 | ### Periodicity of NEMO/ORCA fields |
---|
| 3 | ## |
---|
| 4 | ## Warning, to install, configure, run, use any of Olivier Marti's |
---|
| 5 | ## software or to read the associated documentation you'll need at least |
---|
| 6 | ## one (1) brain in a reasonably working order. Lack of this implement |
---|
| 7 | ## will void any warranties (either express or implied). |
---|
| 8 | ## O. Marti assumes no responsability for errors, omissions, |
---|
| 9 | ## data loss, or any other consequences caused directly or indirectly by |
---|
| 10 | ## the usage of his software by incorrectly or partially configured |
---|
| 11 | ## personal. |
---|
| 12 | ## |
---|
| 13 | ### |
---|
| 14 | ### O. Marti - 2015 |
---|
| 15 | ### |
---|
| 16 | ### =========================================================================== |
---|
| 17 | |
---|
| 18 | def lbc (ptab, npolj=6, cd_type='T', psgn=1.0) : |
---|
| 19 | # npolj : Type of periodicity |
---|
| 20 | # 1, 4, 6 : Cyclic on i dimension (generaly longitudes) |
---|
| 21 | # 2 : Obsolete (was symmetric condition at southern boundary ?) |
---|
| 22 | # 3, 4 : North fold T-point pivot (legacy ORCA2) |
---|
| 23 | # 5, 6 : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) |
---|
| 24 | # ptab : Input array |
---|
| 25 | # rank 2 at least : patb[...., lat, lon] |
---|
| 26 | # cd_type : Grid specification : T, U, V or F |
---|
| 27 | # psgn : For change of sign for vector components |
---|
| 28 | # |
---|
| 29 | # Adapted from NEMO fortran code lbc.F90. |
---|
| 30 | # See NEMO documentation for further details |
---|
| 31 | |
---|
| 32 | jpi = ptab.shape[-1] #> i dimension of NEMO field |
---|
| 33 | |
---|
| 34 | # |
---|
| 35 | #> East-West boundary conditions |
---|
| 36 | # -------------------------------- |
---|
| 37 | |
---|
| 38 | if npolj in [1, 4, 6] : |
---|
| 39 | # ... cyclic |
---|
| 40 | ptab [...,:, 0] = ptab [...,:,-2] |
---|
| 41 | ptab [...,:, -1] = ptab [...,:, 1] |
---|
| 42 | |
---|
| 43 | # |
---|
| 44 | #> North-South boundary conditions |
---|
| 45 | # ---------------------------------- |
---|
| 46 | if npolj in [3, 4] : # North fold T-point pivot |
---|
| 47 | if cd_type in [ 'T', 'W' ] : # T-, W-point |
---|
| 48 | ptab[..., -1, 1: ] = psgn * ptab[..., -3, -1:0:-1] |
---|
| 49 | ptab[..., -1, 0] = psgn * ptab[..., -3, 2] |
---|
| 50 | ptab[..., -2, jpi/2: ] = psgn * ptab[..., -2, jpi/2:0:-1] |
---|
| 51 | |
---|
| 52 | if cd_type == 'U' : |
---|
| 53 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1 ] |
---|
| 54 | ptab[..., -1, 0] = psgn * ptab[..., -3, 1] |
---|
| 55 | ptab[..., -1, -1] = psgn * ptab[..., -3, -2] |
---|
| 56 | ptab[..., -2, jpi/2-1:] = psgn * ptab[..., -2, jpi/2+1:0:-1] |
---|
| 57 | |
---|
| 58 | if cd_type == 'V' : |
---|
| 59 | ptab[..., -2, 1: ] = psgn * ptab[..., -3, jpi-1:0:-1] |
---|
| 60 | ptab[..., -1, 1: ] = psgn * ptab[..., -4, -1:0:-1] |
---|
| 61 | ptab[..., -1, 0] = psgn * ptab[..., -4, 2] |
---|
| 62 | |
---|
| 63 | if cd_type == 'F' : |
---|
| 64 | ptab[..., -2, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1] |
---|
| 65 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -4, -1:0:-1] |
---|
| 66 | ptab[..., -1, 0] = psgn * ptab[..., -4, 1] |
---|
| 67 | ptab[..., -1, -1] = psgn * ptab[..., -4, -2] |
---|
| 68 | |
---|
| 69 | if npolj in [5, 6] : # North fold F-point pivot |
---|
| 70 | if cd_type in ['T', 'W'] : |
---|
| 71 | ptab[..., -1, 0: ] = psgn * ptab[..., -2, -1::-1] |
---|
| 72 | |
---|
| 73 | if cd_type == 'U' : |
---|
| 74 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -2, -2::-1] |
---|
| 75 | ptab[..., -1, -1] = psgn * ptab[..., -2, 0] |
---|
| 76 | |
---|
| 77 | if cd_type == 'V' : |
---|
| 78 | ptab[..., -1, 0: ] = psgn * ptab[..., -3, -1::-1 ] |
---|
| 79 | ptab[..., -2, jpi/2: ] = psgn * ptab[..., -2, jpi/2-1::-1] |
---|
| 80 | |
---|
| 81 | if cd_type == 'F' : |
---|
| 82 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -2::-1] |
---|
| 83 | ptab[..., -1, -1] = psgn * ptab[..., -3, 0] |
---|
| 84 | ptab[..., -2, jpi/2:-1] = psgn * ptab[..., -2, jpi/2-2::-1] |
---|
| 85 | |
---|
| 86 | return ptab |
---|
| 87 | |
---|
| 88 | ### =========================================================================== |
---|
| 89 | ### |
---|
| 90 | ### That's all folk's !!! |
---|
| 91 | ### |
---|
| 92 | ### =========================================================================== |
---|