CWorthy-ocean / roms-tools

Tools for setting up and running ROMS simulations
https://roms-tools.readthedocs.io
GNU General Public License v3.0
7 stars 3 forks source link

Making topography #27

Closed NoraLoose closed 1 month ago

NoraLoose commented 1 month ago

Completes Step 2 in #1 via the following four sub-steps:

  1. Interpolate from specified topography file (_make_raw_topography)
  2. Smooth topography globally to avoid grid-scale instabilities (_smooth_topography_globally)
  3. Fill enclosed basins with land (_fill_enclosed_basins)
  4. 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:

Step1 Step2 Step3 Step4

Saved fields

Following the matlab routines, we save two fields (added as xarray variables to grid.ds):

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:

Screenshot 2024-05-14 at 12 27 16 PM

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!

NoraLoose commented 1 month ago

@TomNicholas @sdbachman if you have feedback, please let me know!

NoraLoose commented 1 month ago

@sdbachman looked over this and gave me a thumbs-up. Scott, I may add some progress reports as part of a later PR, but I am merging this for now.