Skip to content

Commit b79de11

Browse files
Always interpolate bathymetry in passes (#496)
* Always interpolate bathymetry in passes * Update test_bathymetry.jl * Update test_ocean_sea_ice_model.jl --------- Co-authored-by: Simone Silvestri <[email protected]>
1 parent 955e464 commit b79de11

File tree

3 files changed

+5
-49
lines changed

3 files changed

+5
-49
lines changed

src/Bathymetry.jl

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -224,38 +224,6 @@ function interpolate_bathymetry_in_passes(native_z, target_grid;
224224
Nλt, Nφt = Nt = size(target_grid)
225225
Nλn, Nφn = Nn = size(native_z)
226226

227-
resxt = minimum_xspacing(target_grid)
228-
resyt = minimum_yspacing(target_grid)
229-
230-
resxn = minimum_xspacing(native_z.grid)
231-
resyn = minimum_yspacing(native_z.grid)
232-
233-
# Check whether we are refining the grid in any directions.
234-
# If so, skip interpolation passes, as they are not needed.
235-
if resxt < resxn || resyt < resyn
236-
target_z = Field{Center, Center, Nothing}(target_grid)
237-
238-
@info "Interpolating bathymetry of size $Nn onto a $gridtype target grid of size $Nt"
239-
interpolate!(target_z, native_z)
240-
241-
if passes > 0
242-
passes_str = passes == 1 ? "1 interpolation pass" : "$passes interpolation passes"
243-
244-
@info string("Skipping extra $passes_str for bathymetry.", '\n',
245-
"Extra interpolation passes may only be used to coarsen bathymetry", '\n',
246-
"and require that the bathymetry is finer than the target grid in", '\n',
247-
"both horizontal directions.", '\n',
248-
"Grid info:", '\n',
249-
"target grid", '\n',
250-
"├── minimum x-spacings ", @sprintf("%.3e", resxt), " m", '\n',
251-
"└── minimum y-spacings ", @sprintf("%.3e", resyt), " m", '\n',
252-
"bathymetry grid", '\n',
253-
"├── minimum x-spacings ", @sprintf("%.3e", resxn), " m", '\n',
254-
"└── minimum y-spacings ", @sprintf("%.3e", resyn), " m")
255-
end
256-
return target_z
257-
end
258-
259227
# Interpolate in passes
260228
latitude = y_domain(native_z.grid)
261229
longitude = x_domain(native_z.grid)
@@ -275,7 +243,7 @@ function interpolate_bathymetry_in_passes(native_z, target_grid;
275243
@info "Interpolation passes of bathymetry size $(size(old_z)) onto a $gridtype target grid of size $Nt:"
276244
for pass = 1:passes - 1
277245
new_size = (Nλ[pass], Nφ[pass], 1)
278-
@info " pass $pass to size $new_size"
246+
@info " Performing pass $pass to size $new_size."
279247

280248
new_grid = LatitudeLongitudeGrid(architecture(target_grid), Float32,
281249
size = new_size,
@@ -469,4 +437,4 @@ end
469437
retrieve_bathymetry(grid, ::Nothing; kw...) = regrid_bathymetry(grid; kw...)
470438
retrieve_bathymetry(grid; kw...) = regrid_bathymetry(grid; kw...)
471439

472-
end # module
440+
end # module

test/test_bathymetry.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ using ClimaOcean
66

77
using ClimaOcean.Bathymetry: remove_minor_basins!
88

9-
@testset "Availability of Bathymetry" begin
10-
@info "Testing Bathymetry utils..."
9+
@testset "Bathymetry construction and smoothing" begin
10+
@info "Testing Bathymetry construction and smoothing..."
1111
for arch in test_architectures
1212

1313
grid = LatitudeLongitudeGrid(arch;
@@ -50,18 +50,6 @@ using ClimaOcean.Bathymetry: remove_minor_basins!
5050
# of -1000 meters
5151
@test mean(view(bottom_height, 51:100, :, 1)) == -1000
5252

53-
grid = LatitudeLongitudeGrid(arch;
54-
size = (200, 200, 10),
55-
longitude = (0, 2),
56-
latitude = (-0.1, 0.1),
57-
z = (-6000, 0))
58-
59-
control_bottom_height = regrid_bathymetry(grid)
60-
interpolated_bottom_height = regrid_bathymetry(grid; interpolation_passes=100)
61-
62-
# Testing that multiple passes do not change the solution when refining the grid
63-
@test parent(control_bottom_height) == parent(interpolated_bottom_height)
64-
6553
grid = LatitudeLongitudeGrid(arch;
6654
size = (200, 200, 10),
6755
longitude = (0, 100),

test/test_ocean_sea_ice_model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ using ClimaSeaIce.Rheologies
5858

5959
bottom_height = regrid_bathymetry(grid;
6060
minimum_depth = 10,
61-
interpolation_passes = 20,
61+
interpolation_passes = 5,
6262
major_basins = 1)
6363

6464
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(bottom_height); active_cells_map=true)

0 commit comments

Comments
 (0)