@@ -147,6 +147,89 @@ def decaying_moving_eddy_dataset(xdim=2, ydim=2):
147147 )
148148
149149
150+ def peninsula_dataset (xdim = 100 , ydim = 50 , mesh = "flat" , grid_type = "A" ):
151+ """Construct a fieldset encapsulating the flow field around an idealised peninsula.
152+
153+ Parameters
154+ ----------
155+ xdim :
156+ Horizontal dimension of the generated fieldset
157+ ydim :
158+ Vertical dimension of the generated fieldset
159+ mesh : str
160+ String indicating the type of mesh coordinates and
161+ units used during velocity interpolation:
162+
163+ 1. spherical: Lat and lon in degree, with a
164+ correction for zonal velocity U near the poles.
165+ 2. flat (default): No conversion, lat/lon are assumed to be in m.
166+ grid_type :
167+ Option whether grid is either Arakawa A (default) or C
168+
169+ The original test description can be found in Fig. 2.2.3 in:
170+ North, E. W., Gallego, A., Petitgas, P. (Eds). 2009. Manual of
171+ recommended practices for modelling physical - biological
172+ interactions during fish early life.
173+ ICES Cooperative Research Report No. 295. 111 pp.
174+ http://archimer.ifremer.fr/doc/00157/26792/24888.pdf
175+ """
176+ domainsizeX , domainsizeY = (1.0e5 , 5.0e4 )
177+ La = np .linspace (1e3 , domainsizeX , xdim , dtype = np .float32 )
178+ Wa = np .linspace (1e3 , domainsizeY , ydim , dtype = np .float32 )
179+
180+ u0 = 1
181+ x0 = domainsizeX / 2
182+ R = 0.32 * domainsizeX / 2
183+
184+ # Create the fields
185+ P = np .zeros ((ydim , xdim ), dtype = np .float32 )
186+ U = np .zeros_like (P )
187+ V = np .zeros_like (P )
188+ x , y = np .meshgrid (La , Wa , sparse = True , indexing = "xy" )
189+ P [:, :] = u0 * R ** 2 * y / ((x - x0 ) ** 2 + y ** 2 ) - u0 * y
190+
191+ # Set land points to zero
192+ landpoints = P >= 0.0
193+ P [landpoints ] = 0.0
194+
195+ if grid_type == "A" :
196+ U [:, :] = u0 - u0 * R ** 2 * ((x - x0 ) ** 2 - y ** 2 ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
197+ V [:, :] = - 2 * u0 * R ** 2 * ((x - x0 ) * y ) / (((x - x0 ) ** 2 + y ** 2 ) ** 2 )
198+ U [landpoints ] = 0.0
199+ V [landpoints ] = 0.0
200+ Udims = ["YC" , "XG" ]
201+ Vdims = ["YG" , "XC" ]
202+ elif grid_type == "C" :
203+ U = np .zeros (P .shape )
204+ V = np .zeros (P .shape )
205+ V [:, 1 :] = (P [:, 1 :] - P [:, :- 1 ]) / (La [1 ] - La [0 ])
206+ U [1 :, :] = - (P [1 :, :] - P [:- 1 , :]) / (Wa [1 ] - Wa [0 ])
207+ Udims = ["YG" , "XG" ]
208+ Vdims = ["YG" , "XG" ]
209+ else :
210+ raise RuntimeError (f"Grid_type { grid_type } is not a valid option" )
211+
212+ # Convert from m to lat/lon for spherical meshes
213+ lon = La / 1852.0 / 60.0 if mesh == "spherical" else La
214+ lat = Wa / 1852.0 / 60.0 if mesh == "spherical" else Wa
215+
216+ return xr .Dataset (
217+ {
218+ "U" : (Udims , U ),
219+ "V" : (Vdims , V ),
220+ "P" : (["YG" , "XG" ], P ),
221+ },
222+ coords = {
223+ "YC" : (["YC" ], np .arange (ydim ) + 0.5 , {"axis" : "Y" }),
224+ "YG" : (["YG" ], np .arange (ydim ), {"axis" : "Y" , "c_grid_axis_shift" : - 0.5 }),
225+ "XC" : (["XC" ], np .arange (xdim ) + 0.5 , {"axis" : "X" }),
226+ "XG" : (["XG" ], np .arange (xdim ), {"axis" : "X" , "c_grid_axis_shift" : - 0.5 }),
227+ "lat" : (["YG" ], lat , {"axis" : "Y" , "c_grid_axis_shift" : 0.5 }),
228+ "lon" : (["XG" ], lon , {"axis" : "X" , "c_grid_axis_shift" : - 0.5 }),
229+ },
230+ )
231+
232+
150233def stommel_gyre_dataset (xdim = 200 , ydim = 200 , grid_type = "A" ):
151234 """Simulate a periodic current along a western boundary, with significantly
152235 larger velocities along the western edge than the rest of the region
0 commit comments