### =========================================================================== ### ### Periodicity of ORCA fields ### ### =========================================================================== ## ## Warning, to install, configure, run, use any of Olivier Marti's ## software or to read the associated documentation you'll need at least ## one (1) brain in a reasonably working order. Lack of this implement ## will void any warranties (either express or implied). ## O. Marti assumes no responsability for errors, omissions, ## data loss, or any other consequences caused directly or indirectly by ## the usage of his software by incorrectly or partially configured ## personal. ## ## SVN information __Author__ = "$Author$" __Date__ = "$Date$" __Revision__ = "$Revision$" __Id__ = "$Id$" __HeadURL = "$HeadURL$" def lbc (ptab, nperio=6, cd_type='T', psgn=1.0) : # Set periodicity on input fields """ ptab : Input array rank 2 at least : patb[...., lat, lon] nperio : Type of periodicity 1, 4, 6 : Cyclic on i dimension (generaly longitudes) 2 : Obsolete (was symmetric condition at southern boundary ?) 3, 4 : North fold T-point pivot (legacy ORCA2) 5, 6 : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) cd_type : Grid specification : T, U, V or F psgn : For change of sign for vector components See NEMO documentation for further details """ jpi = ptab.shape[-1] # #> East-West boundary conditions # -------------------------------- if nperio in [1, 4, 6] : # ... cyclic ptab [...,:, 0] = ptab [...,:,-2] ptab [...,:, -1] = ptab [...,:, 1] # #> North-South boundary conditions # ---------------------------------- if nperio in [3, 4] : # North fold T-point pivot if cd_type in [ 'T', 'W' ] : # T-, W-point ptab[..., -1, 1: ] = psgn * ptab[..., -3, -1:0:-1 ] ptab[..., -1, 0 ] = psgn * ptab[..., -3, 2 ] ptab[..., -2, jpi//2: ] = psgn * ptab[..., -2, jpi//2:0:-1 ] if cd_type == 'U' : ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1 ] ptab[..., -1, 0 ] = psgn * ptab[..., -3, 1 ] ptab[..., -1, -1 ] = psgn * ptab[..., -3, -2 ] ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1] if cd_type == 'V' : ptab[..., -2, 1: ] = psgn * ptab[..., -3, jpi-1:0:-1 ] ptab[..., -1, 1: ] = psgn * ptab[..., -4, -1:0:-1 ] ptab[..., -1, 0 ] = psgn * ptab[..., -4, 2 ] if cd_type == 'F' : ptab[..., -2, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1 ] ptab[..., -1, 0:-1 ] = psgn * ptab[..., -4, -1:0:-1 ] ptab[..., -1, 0 ] = psgn * ptab[..., -4, 1 ] ptab[..., -1, -1 ] = psgn * ptab[..., -4, -2 ] if nperio in [5, 6] : # North fold F-point pivot if cd_type in ['T', 'W'] : ptab[..., -1, 0: ] = psgn * ptab[..., -2, -1::-1 ] if cd_type == 'U' : ptab[..., -1, 0:-1 ] = psgn * ptab[..., -2, -2::-1 ] ptab[..., -1, -1 ] = psgn * ptab[..., -2, 0 ] if cd_type == 'V' : ptab[..., -1, 0: ] = psgn * ptab[..., -3, -1::-1 ] ptab[..., -2, jpi/2: ] = psgn * ptab[..., -2, jpi/2-1::-1 ] if cd_type == 'F' : ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -2::-1 ] ptab[..., -1, -1 ] = psgn * ptab[..., -3, 0 ] ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ] return ptab def lbc_mask (ptab, nperio=6, cd_type='T', psgn=1.0) : # Mask fields on duplicate points """ ptab : Input array rank 2 at least : patb[...., lat, lon] nperio : Type of periodicity 1, 4, 6 : Cyclic on i dimension (generaly longitudes) 2 : Obsolete (was symmetric condition at southern boundary ?) 3, 4 : North fold T-point pivot (legacy ORCA2) 5, 6 : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) cd_type : Grid specification : T, U, V or F psgn : For change of sign for vector components See NEMO documentation for further details """ jpi = ptab.shape[-1] # zero = 0 # #> East-West boundary conditions # -------------------------------- if nperio in [1, 4, 6] : # ... cyclic ptab [...,:, 0] = zero ptab [...,:, -1] = zero # #> North-South boundary conditions # ---------------------------------- if nperio in [3, 4] : # North fold T-point pivot if cd_type in [ 'T', 'W' ] : # T-, W-point ptab[..., -1, 1: ] = zero ptab[..., -1, 0 ] = zero ptab[..., -2, jpi//2: ] = zero if cd_type == 'U' : ptab[..., -1, 0:-1 ] = zero ptab[..., -1, 0 ] = zero ptab[..., -1, -1 ] = zero ptab[..., -2, jpi//2-1:] = zero if cd_type == 'V' : ptab[..., -2, 1: ] = zero ptab[..., -1, 1: ] = zero ptab[..., -1, 0 ] = zero if cd_type == 'F' : ptab[..., -2, 0:-1 ] = zero ptab[..., -1, 0:-1 ] = zero ptab[..., -1, 0 ] =zero ptab[..., -1, -1 ] = zero if nperio in [5, 6] : # North fold F-point pivot if cd_type in ['T', 'W'] : ptab[..., -1, 0: ] = zero if cd_type == 'U' : ptab[..., -1, 0:-1 ] = zero ptab[..., -1, -1 ] = zero if cd_type == 'V' : ptab[..., -1, 0: ] = zero ptab[..., -2, jpi/2: ] = zero if cd_type == 'F' : ptab[..., -1, 0:-1 ] = zero ptab[..., -1, -1 ] = zero ptab[..., -2, jpi//2:-1] = zero return ptab ## =========================================================================== ## ## That's all folk's !!! ## ## ===========================================================================