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) : |
---|
24 | # Set periodicity on input fields |
---|
25 | """ |
---|
26 | ptab : Input array |
---|
27 | rank 2 at least : patb[...., lat, lon] |
---|
28 | nperio : Type of periodicity |
---|
29 | 1, 4, 6 : Cyclic on i dimension (generaly longitudes) |
---|
30 | 2 : Obsolete (was symmetric condition at southern boundary ?) |
---|
31 | 3, 4 : North fold T-point pivot (legacy ORCA2) |
---|
32 | 5, 6 : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) |
---|
33 | cd_type : Grid specification : T, U, V or F |
---|
34 | psgn : For change of sign for vector components |
---|
35 | |
---|
36 | See NEMO documentation for further details |
---|
37 | """ |
---|
38 | |
---|
39 | jpi = ptab.shape[-1] |
---|
40 | |
---|
41 | # |
---|
42 | #> East-West boundary conditions |
---|
43 | # -------------------------------- |
---|
44 | |
---|
45 | if nperio in [1, 4, 6] : |
---|
46 | # ... cyclic |
---|
47 | ptab [...,:, 0] = ptab [...,:,-2] |
---|
48 | ptab [...,:, -1] = ptab [...,:, 1] |
---|
49 | |
---|
50 | # |
---|
51 | #> North-South boundary conditions |
---|
52 | # ---------------------------------- |
---|
53 | if nperio in [3, 4] : # North fold T-point pivot |
---|
54 | if cd_type in [ 'T', 'W' ] : # T-, W-point |
---|
55 | ptab[..., -1, 1: ] = psgn * ptab[..., -3, -1:0:-1 ] |
---|
56 | ptab[..., -1, 0 ] = psgn * ptab[..., -3, 2 ] |
---|
57 | ptab[..., -2, jpi//2: ] = psgn * ptab[..., -2, jpi//2:0:-1 ] |
---|
58 | |
---|
59 | if cd_type == 'U' : |
---|
60 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1 ] |
---|
61 | ptab[..., -1, 0 ] = psgn * ptab[..., -3, 1 ] |
---|
62 | ptab[..., -1, -1 ] = psgn * ptab[..., -3, -2 ] |
---|
63 | ptab[..., -2, jpi//2-1:] = psgn * ptab[..., -2, jpi//2+1:0:-1] |
---|
64 | |
---|
65 | if cd_type == 'V' : |
---|
66 | ptab[..., -2, 1: ] = psgn * ptab[..., -3, jpi-1:0:-1 ] |
---|
67 | ptab[..., -1, 1: ] = psgn * ptab[..., -4, -1:0:-1 ] |
---|
68 | ptab[..., -1, 0 ] = psgn * ptab[..., -4, 2 ] |
---|
69 | |
---|
70 | if cd_type == 'F' : |
---|
71 | ptab[..., -2, 0:-1 ] = psgn * ptab[..., -3, -1:0:-1 ] |
---|
72 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -4, -1:0:-1 ] |
---|
73 | ptab[..., -1, 0 ] = psgn * ptab[..., -4, 1 ] |
---|
74 | ptab[..., -1, -1 ] = psgn * ptab[..., -4, -2 ] |
---|
75 | |
---|
76 | if nperio in [5, 6] : # North fold F-point pivot |
---|
77 | if cd_type in ['T', 'W'] : |
---|
78 | ptab[..., -1, 0: ] = psgn * ptab[..., -2, -1::-1 ] |
---|
79 | |
---|
80 | if cd_type == 'U' : |
---|
81 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -2, -2::-1 ] |
---|
82 | ptab[..., -1, -1 ] = psgn * ptab[..., -2, 0 ] |
---|
83 | |
---|
84 | if cd_type == 'V' : |
---|
85 | ptab[..., -1, 0: ] = psgn * ptab[..., -3, -1::-1 ] |
---|
86 | ptab[..., -2, jpi/2: ] = psgn * ptab[..., -2, jpi/2-1::-1 ] |
---|
87 | |
---|
88 | if cd_type == 'F' : |
---|
89 | ptab[..., -1, 0:-1 ] = psgn * ptab[..., -3, -2::-1 ] |
---|
90 | ptab[..., -1, -1 ] = psgn * ptab[..., -3, 0 ] |
---|
91 | ptab[..., -2, jpi//2:-1] = psgn * ptab[..., -2, jpi//2-2::-1 ] |
---|
92 | |
---|
93 | return ptab |
---|
94 | |
---|
95 | |
---|
96 | def lbc_mask (ptab, nperio=6, cd_type='T', psgn=1.0) : |
---|
97 | # Mask fields on duplicate points |
---|
98 | """ |
---|
99 | ptab : Input array |
---|
100 | rank 2 at least : patb[...., lat, lon] |
---|
101 | nperio : Type of periodicity |
---|
102 | 1, 4, 6 : Cyclic on i dimension (generaly longitudes) |
---|
103 | 2 : Obsolete (was symmetric condition at southern boundary ?) |
---|
104 | 3, 4 : North fold T-point pivot (legacy ORCA2) |
---|
105 | 5, 6 : North fold F-point pivot (ORCA1, ORCA025, ORCA2 with new grid for paleo) |
---|
106 | cd_type : Grid specification : T, U, V or F |
---|
107 | psgn : For change of sign for vector components |
---|
108 | |
---|
109 | See NEMO documentation for further details |
---|
110 | """ |
---|
111 | |
---|
112 | jpi = ptab.shape[-1] |
---|
113 | # |
---|
114 | zero = 0 |
---|
115 | |
---|
116 | # |
---|
117 | #> East-West boundary conditions |
---|
118 | # -------------------------------- |
---|
119 | |
---|
120 | if nperio in [1, 4, 6] : |
---|
121 | # ... cyclic |
---|
122 | ptab [...,:, 0] = zero |
---|
123 | ptab [...,:, -1] = zero |
---|
124 | |
---|
125 | # |
---|
126 | #> North-South boundary conditions |
---|
127 | # ---------------------------------- |
---|
128 | if nperio in [3, 4] : # North fold T-point pivot |
---|
129 | if cd_type in [ 'T', 'W' ] : # T-, W-point |
---|
130 | ptab[..., -1, 1: ] = zero |
---|
131 | ptab[..., -1, 0 ] = zero |
---|
132 | ptab[..., -2, jpi//2: ] = zero |
---|
133 | |
---|
134 | if cd_type == 'U' : |
---|
135 | ptab[..., -1, 0:-1 ] = zero |
---|
136 | ptab[..., -1, 0 ] = zero |
---|
137 | ptab[..., -1, -1 ] = zero |
---|
138 | ptab[..., -2, jpi//2-1:] = zero |
---|
139 | |
---|
140 | if cd_type == 'V' : |
---|
141 | ptab[..., -2, 1: ] = zero |
---|
142 | ptab[..., -1, 1: ] = zero |
---|
143 | ptab[..., -1, 0 ] = zero |
---|
144 | |
---|
145 | if cd_type == 'F' : |
---|
146 | ptab[..., -2, 0:-1 ] = zero |
---|
147 | ptab[..., -1, 0:-1 ] = zero |
---|
148 | ptab[..., -1, 0 ] =zero |
---|
149 | ptab[..., -1, -1 ] = zero |
---|
150 | |
---|
151 | if nperio in [5, 6] : # North fold F-point pivot |
---|
152 | if cd_type in ['T', 'W'] : |
---|
153 | ptab[..., -1, 0: ] = zero |
---|
154 | |
---|
155 | if cd_type == 'U' : |
---|
156 | ptab[..., -1, 0:-1 ] = zero |
---|
157 | ptab[..., -1, -1 ] = zero |
---|
158 | |
---|
159 | if cd_type == 'V' : |
---|
160 | ptab[..., -1, 0: ] = zero |
---|
161 | ptab[..., -2, jpi/2: ] = zero |
---|
162 | |
---|
163 | if cd_type == 'F' : |
---|
164 | ptab[..., -1, 0:-1 ] = zero |
---|
165 | ptab[..., -1, -1 ] = zero |
---|
166 | ptab[..., -2, jpi//2:-1] = zero |
---|
167 | |
---|
168 | return ptab |
---|
169 | ## =========================================================================== |
---|
170 | ## |
---|
171 | ## That's all folk's !!! |
---|
172 | ## |
---|
173 | ## =========================================================================== |
---|