From 922a36e900cc3724ecadead12fd7c1562a9df8b8 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 31 Jan 2025 09:34:33 +0100 Subject: [PATCH 1/2] Update Bathymetry.jl --- src/Bathymetry.jl | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Bathymetry.jl b/src/Bathymetry.jl index b9148d06..42f884a1 100644 --- a/src/Bathymetry.jl +++ b/src/Bathymetry.jl @@ -125,25 +125,9 @@ function regrid_bathymetry(target_grid; φ₁, φ₂ = y_domain(target_grid) λ₁, λ₂ = x_domain(target_grid) - if λ₁ < 0 || λ₂ > 360 - throw(ArgumentError("Cannot regrid bathymetry between λ₁ = $(λ₁) and λ₂ = $(λ₂). - Bathymetry data is defined on longitudes spanning λ = (0, 360).")) - end - - # Calculate limiting indices on the bathymetry grid - i₁ = searchsortedfirst(λ_data, λ₁) - i₂ = searchsortedfirst(λ_data, λ₂) - 1 - ii = i₁:i₂ - - j₁ = searchsortedfirst(φ_data, φ₁) - j₂ = searchsortedfirst(φ_data, φ₂) - 1 - jj = j₁:j₂ - - # Restrict bathymetry coordinate_data to region of interest - λ_data = λ_data[ii] |> Array{BigFloat} - φ_data = φ_data[jj] |> Array{BigFloat} - z_data = z_data[ii, jj] - + λ_data = λ_data |> Array{BigFloat} + φ_data = φ_data |> Array{BigFloat} + if !isnothing(height_above_water) # Overwrite the height of cells above water. # This has an impact on reconstruction. Greater height_above_water reduces total @@ -164,7 +148,7 @@ function regrid_bathymetry(target_grid; Nxn = length(λ_data) Nyn = length(φ_data) Nzn = 1 - + native_grid = LatitudeLongitudeGrid(arch; size = (Nxn, Nyn, Nzn), latitude = (φ₁_data, φ₂_data), From cc056e0b02a4d864df6aae1dd6803f209e073ad5 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 13 Feb 2025 10:30:23 +0100 Subject: [PATCH 2/2] add a fill halo --- src/Bathymetry.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bathymetry.jl b/src/Bathymetry.jl index 42f884a1..9b0ecd39 100644 --- a/src/Bathymetry.jl +++ b/src/Bathymetry.jl @@ -158,7 +158,8 @@ function regrid_bathymetry(target_grid; native_z = Field{Center, Center, Nothing}(native_grid) set!(native_z, z_data) - + fill_halo_regions!(native_z) + target_z = interpolate_bathymetry_in_passes(native_z, target_grid; passes = interpolation_passes)