Completes Step 2 in #1 via the following four sub-steps:
Interpolate from specified topography file (_make_raw_topography)
Smooth topography globally to avoid grid-scale instabilities (_smooth_topography_globally)
Fill enclosed basins with land (_fill_enclosed_basins)
Smooth topography locally to satisfy r < rmax (_smooth_topography_locally)
Steps 1, 3, and 4 closely follow the matlab routines. For step 2, we deviate from the matlab implementation and instead use the package GCM-Filters.
The four steps for an example domain:
Saved fields
Following the matlab routines, we save two fields (added as xarray variables to grid.ds):
hraw: topography after step 2
h: topography after step 4
Enhancement of Grid object and default options
As we discussed in #9, the topography (with its four sub-steps) is made as part of the Grid object. The Grid object now takes a few extra kwargs:
topography_source : str, optional
Specifies the data source to use for the topography. Options are "etopo5". The default is "etopo5".
smooth_factor: int
The smoothing factor used in the global Gaussian smoothing of the topography. The default is 2.
hmin: float
The minimum ocean depth (in meters). The default is 5.
rmax: float
The maximum slope parameter (in meters). The default is 0.2.
Smooth factor: python vs. matlab
Choosing smooth_factor = 2 as a default in the python implementation may seem relatively small compared to the matlab default of choosing a smoothing factor / width of 8 (or radius of 4). However, upon comparing the python- and matlab-generated final topographies with their respective default smoothing factors, the python-generated topography is still smoother than the matlab-generated one:
This is due to different smoother implementations. The python implementation uses a smoother with a Gaussian kernel has the same standard deviation as a boxcar filter with a kernel width (not half-width) equal to smooth_factor grid points (see the GCM-Filters convention or Section 2.3.4 in Grooms et al. (2021)), while the matlab implementation does something different. We could consider setting the smooth_factor default to something lower than 2 to get closer to the matlab result, but the GCM-Filter filters get less and less accurate if we approach smooth_factor = 1. To be discussed!
Completes Step 2 in #1 via the following four sub-steps:
_make_raw_topography
)_smooth_topography_globally
)_fill_enclosed_basins
)r < rmax
(_smooth_topography_locally
)Steps 1, 3, and 4 closely follow the matlab routines. For step 2, we deviate from the matlab implementation and instead use the package GCM-Filters.
The four steps for an example domain:
Saved fields
Following the matlab routines, we save two fields (added as xarray variables to
grid.ds
):hraw
: topography after step 2h
: topography after step 4Enhancement of
Grid
object and default optionsAs we discussed in #9, the topography (with its four sub-steps) is made as part of the
Grid
object. TheGrid
object now takes a few extra kwargs:Smooth factor: python vs. matlab
Choosing
smooth_factor
= 2 as a default in the python implementation may seem relatively small compared to the matlab default of choosing a smoothing factor / width of 8 (or radius of 4). However, upon comparing the python- and matlab-generated final topographies with their respective default smoothing factors, the python-generated topography is still smoother than the matlab-generated one:This is due to different smoother implementations. The python implementation uses a smoother with a Gaussian kernel has the same standard deviation as a boxcar filter with a kernel width (not half-width) equal to
smooth_factor
grid points (see the GCM-Filters convention or Section 2.3.4 in Grooms et al. (2021)), while the matlab implementation does something different. We could consider setting thesmooth_factor
default to something lower than 2 to get closer to the matlab result, but the GCM-Filter filters get less and less accurate if we approachsmooth_factor = 1
. To be discussed!