Generate bathymetry data for the Mediterranean Sea
This example shows how to configure an Immersed boundary grid with realistic bathymetry using ClimaOcean.jl by generating the bathymetry data for the Mediterranean Sea.
For this example, we need Oceananigans for the LatitudeLongitudeGrid and Field utilities, ClimaOcean to donwload and regrid the bathymetry, and CairoMakie to visualize the grid.
using ClimaOcean
using Oceananigans
using CairoMakie
We start by defining a gridded domain for the Mediterranean Sea using the LatitudeLongitudeGrid
from Oceananigans.
The Mediterranean sea is positioned roughly between 28ᵒ and 48ᵒ latitude and 0ᵒ and 42ᵒ longitude. We define a grid in this region and to have a reasonable resolution, we set a grid resolution to 1/25ᵒ in both latitude and longitude directions.
latitude_range = (28, 48)
longitude_range = (0, 42)
Nφ = 25 * (latitude_range[2] - latitude_range[1])
Nλ = 25 * (longitude_range[2] - longitude_range[1])
grid = LatitudeLongitudeGrid(size = (Nλ, Nφ, 1),
latitude = latitude_range,
longitude = longitude_range,
z = (0, 1),
halo = (7, 7, 1))
1050×500×1 LatitudeLongitudeGrid{Float64, Oceananigans.Grids.Bounded, Oceananigans.Grids.Bounded, Oceananigans.Grids.Bounded} on Oceananigans.Architectures.CPU with 7×7×1 halo and with precomputed metrics
├── longitude: Bounded λ ∈ [0.0, 42.0] regularly spaced with Δλ=0.04
├── latitude: Bounded φ ∈ [28.0, 48.0] regularly spaced with Δφ=0.04
└── z: Bounded z ∈ [0.0, 1.0] regularly spaced with Δz=1.0
Next, we generate the bathymetry data for the Mediterranean Sea using the regrid_bathymetry
function from ClimaOcean. The function downloads the bathymetry data from the ETOPO1 dataset, regrids it to the provided grid, and returns the bathymetry field. The three different regidding procedures below demonstrate the effect of different parameters on the generated bathymetry:
h_rough
shows the output of the function with default parameters, which means only one interpolation passes and no restrictions on connected regions.h_smooth
shows the output of the function with 40 interpolation passes, which results in a smoother bathymetry.h_no_connected_regions
shows the output of the function withconnected_regions_allowed = 0
, which means that the function does not allow connected regions in the bathymetry (e.g., lakes) and fills them with land.
h_rough = regrid_bathymetry(grid)
h_smooth = regrid_bathymetry(grid; interpolation_passes = 40)
h_one_basin = regrid_bathymetry(grid; major_basins = 1)
* WARNING: failed to open cookie file ""
* Couldn't find host www.ngdc.noaa.gov in the .netrc file; using defaults
* Trying 140.172.190.1:443...
* Connected to www.ngdc.noaa.gov (140.172.190.1) port 443
* mbedTLS: Connecting to www.ngdc.noaa.gov:443
* mbedTLS: Set min SSL version to TLS 1.0
* ALPN: curl offers h2,http/1.1
* mbedTLS: Handshake complete, cipher is TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384
* Dumping cert info: * cert. version : 3
* serial number : 08:93:36:84:8D:4B:9D:70:4F:62:9E:21:BF:F6:92:53
* issuer name : C=US, O=DigiCert Inc, CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
* subject name : C=US, ST=North Carolina, L=Asheville, O=National Centers for Environmental Information, CN=www.ngdc.noaa.gov
* issued on : 2024-08-14 00:00:00
* expires on : 2024-11-26 23:59:59
* signed using : RSA with SHA-256
* RSA key size : 2048 bits
* basic constraints : CA=false
* subject alt name :
* dNSName : www.ngdc.noaa.gov
* dNSName : ngdc.noaa.gov
* dNSName : data.ngdc.noaa.gov
* dNSName : maps.ngdc.noaa.gov
* dNSName : gis.ngdc.noaa.gov
* dNSName : ftps.ngdc.noaa.gov
* key usage : Digital Signature, Key Encipherment
* ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
* certificate policies : ???
* ALPN: server did not agree on a protocol. Uses default.
* SSL connected
* using HTTP/1.x
> GET /thredds/fileServer/global/ETOPO2022/60s/60s_surface_elev_netcdf/ETOPO_2022_v1_60s_N90W180_surface.nc HTTP/1.1
Host: www.ngdc.noaa.gov
Accept: */*
User-Agent: curl/8.4.0 julia/1.10
< HTTP/1.1 200 200
< date: Tue, 19 Nov 2024 01:12:40 GMT
< server: Apache
< strict-transport-security: max-age=31536000;
< last-modified: Tue, 04 Oct 2022 21:55:19 GMT
< accept-ranges: bytes
< content-type: application/x-netcdf
< x-frame-options: SAMEORIGIN
< access-control-allow-origin: *
< access-control-allow-headers: X-Requested-With, Content-Type
< transfer-encoding: chunked
< connection: close
<
[ Info: Downloading ...
* Closing connection
Finally, we visualize the generated bathymetry data for the Mediterranean Sea using CairoMakie.
land_smooth = interior(h_smooth) .>= 0
interior(h_smooth)[land_smooth] .= NaN
land_rough = interior(h_rough) .>= 0
interior(h_rough)[land_rough] .= NaN
land_one_basin = interior(h_one_basin) .>= 0
interior(h_one_basin)[land_one_basin] .= NaN
fig = Figure(size=(850, 1150))
ax = Axis(fig[1, 1], title = "Rough bathymetry", xlabel = "Longitude", ylabel = "Latitude")
hm = heatmap!(ax, h_rough, nan_color=:lightgray, colormap = Reverse(:deep))
ax = Axis(fig[2, 1], title = "Smooth bathymetry", xlabel = "Longitude", ylabel = "Latitude")
hm = heatmap!(ax, h_smooth, nan_color=:lightgray, colormap = Reverse(:deep))
ax = Axis(fig[3, 1], title = "Bathymetry with only one basin", xlabel = "Longitude", ylabel = "Latitude")
hm = heatmap!(ax, h_one_basin, nan_color=:lightgray, colormap = Reverse(:deep))
cb = Colorbar(fig[1:3, 2], hm, height = Relative(3/4), label = "Depth (m)")
save("different_bottom_heights.png", fig)
This page was generated using Literate.jl.