Glaciers
Glacier types
Glaciers in ODINN.jl
are represented by a Glacier
type. Each glacier has its related Climate
type. Since ODINN.jl
supports different types of simulations, we offer the possibility to work on 1D (i.e. flowline), 2D (e.g. SIA) or even 3D (not yet implemented, e.g. Full Stokes). For now, all the simulations are workflows are focused on a 2D Shallow Ice Approximation (SIA).
Sleipnir.Glacier2D
— TypeA mutable struct representing a 2D glacier. Notice that all fields can be empty by providing nothing
as the default value.
/!\ WARNING /!\ Glacier
objects should not be constructed manually, but rather through the initialize_glaciers
function.
Glacier2D{F <: AbstractFloat, I <: Integer, CLIM <: Climate2D, THICKDATA <: Union{<: ThicknessData, Nothing}, SURFVELDATA <: Union{<: SurfaceVelocityData, Nothing}}
Fields
rgi_id::String
: The RGI (Randolph Glacier Inventory) identifier for the glacier.name::String
: The name of the glacier if available.climate::CLIM
: The climate data associated with the glacier.H₀::Matrix{F}
: Initial ice thickness matrix.H_glathida::Matrix{F}
: Ice thickness matrix from the GLATHIDA dataset.S::Matrix{F}
: Surface elevation matrix.B::Matrix{F}
: Bedrock elevation matrix.V::Matrix{F}
: Ice velocity magnitude matrix.Vx::Matrix{F}
: Ice velocity in the x-direction matrix.Vy::Matrix{F}
: Ice velocity in the y-direction matrix.A::F
: Flow law parameter.C::F
: Sliding law parameter.n::F
: Flow law exponent.slope::Matrix{F}
: Surface slope matrix.dist_border::Matrix{F}
: Distance to the glacier border matrix.Coords::Dict{String, Vector{Float64}}
: Coordinates dictionary with keys as coordinate names and values as vectors of coordinates.Δx::F
: Grid spacing in the x-direction.Δy::F
: Grid spacing in the y-direction.nx::I
: Number of grid points in the x-direction.ny::I
: Number of grid points in the y-direction.cenlon::F
: Longitude of the glacier center.cenlat::F
: Latitude of the glacier center.params_projection::Dict{String, Float64}
: Projection parameters that allows mapping the regional grid to global WGS84 coordinates.thicknessData::THICKDATA
: Thickness data structure that is used to store the reference values.velocityData::SURFVELDATA
: Surface velocity data structure that is used to store the reference values.
Sleipnir.Glacier2D
— MethodGlacier2D(;
rgi_id::String = "",
name::String = "",
climate::Climate2D = nothing,
H₀::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
H_glathida::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
S::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
B::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
V::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
Vx::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
Vy::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
A::F = 0.0,
C::F = 0.0,
n::F = 0.0,
slope::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
dist_border::Matrix{F} = Matrix{Sleipnir.Float}([;;]),
Coords::Dict{String, Vector{Float64}} = Dict{String, Vector{Float64}}("lon" => [], "lat" => []),
Δx::F = 0.0,
Δy::F = 0.0,
nx::I = 0,
ny::I = 0,
cenlon::F = NaN,
cenlat::F = NaN,
params_projection::Dict{String, Float64} = Dict{String, Float64}(),
thicknessData::THICKDATA = nothing,
velocityData::SURFVELDATA = nothing,
) where {
F <: AbstractFloat,
I <: Integer,
THICKDATA <: Union{<: ThicknessData, Nothing},
SURFVELDATA <: Union{<: SurfaceVelocityData, Nothing},
}
Constructs a Glacier2D
object with the given parameters, including default ones.
Arguments
rgi_id::String
: The RGI identifier for the glacier.name::String
: The name of the glacier if available.climate::Climate2D
: The climate data associated with the glacier.H₀::Matrix{F}
: Initial ice thickness matrix.H_glathida::Matrix{F}
: Ice thickness matrix from GLATHIDA.S::Matrix{F}
: Surface elevation matrix.B::Matrix{F}
: Bed elevation matrix.V::Matrix{F}
: Ice velocity magnitude matrix.Vx::Matrix{F}
: Ice velocity in the x-direction matrix.Vy::Matrix{F}
: Ice velocity in the y-direction matrix.A::F
: Flow law parameter.C::F
: Sliding law parameter.n::F
: Flow law exponent.slope::Matrix{F}
: Slope matrix.dist_border::Matrix{F}
: Distance to border matrix.Coords::Dict{String, Vector{Float64}}
: Coordinates dictionary with keys "lon" and "lat".Δx::F
: Grid spacing in the x-direction.Δy::F
: Grid spacing in the y-direction.nx::I
: Number of grid points in the x-direction.ny::I
: Number of grid points in the y-direction.cenlon::F
: Central longitude of the glacier.cenlat::F
: Central latitude of the glacier.params_projection::Dict{String, Float64}
: Projection parameters that allows mapping the regional grid to global WGS84 coordinates.thicknessData::THICKDATA
: Thickness data structure that is used to store the reference values.velocityData::SURFVELDATA
: Surface velocity data structure that is used to store the reference values.
Returns
- A
Glacier2D
object with the specified parameters.
Climate
Every glacier has its associated climate, following the same spatial representation (e.g. 2D). These are also retrieved using OGGM, and different types of climate can be used. By default we provide W5E5, which is downscaled (for now using very simple methods) to the glacier grid.
Sleipnir.Climate2D
— TypeA mutable struct representing a 2D climate for a glacier with various buffers and datasets.
Climate2D{CLIMRAW <: RasterStack, CLIMRAWSTEP <: RasterStack, CLIMSTEP <: ClimateStep, CLIM2DSTEP <: Climate2Dstep, F <: AbstractFloat}
Fields
raw_climate::CLIMRAW
: Raw climate dataset for the whole simulation.climate_raw_step::CLIMRAWSTEP
: Raw climate trimmed for the current step to avoid memory allocations.climate_step::ClimateStep
: Climate data for the current step.climate_2D_step::Climate2Dstep
: 2D climate data for the current step to feed to the mass balance (MB) model.longterm_temps::Vector{F}
: Long-term temperatures for the ice rheology.avg_temps::F
: Intermediate buffer for computing average temperatures.avg_gradients::F
: Intermediate buffer for computing average gradients.ref_hgt::F
: Reference elevation of the raw climate data.Climate2D( rgi_id, params::Parameters, S::Matrix{<: AbstractFloat}, Coords::Dict, )
Initialize the climate data given a RGI ID, a matrix of surface elevation and glacier coordinates.
Arguments
rgi_id
: The glacier RGI ID.params::Parameters
: The parameters containing simulation settings and paths.S::Matrix{<: AbstractFloat}
: Matrix of surface elevation used to initialize the downscaled climate data.Coords::Dict
: Coordinates of the glacier.
Description
This function initializes the climate data for a glacier by:
Creating a dummy period based on the simulation time span and step.
Loading the raw climate data from a NetCDF file.
Calculating the cumulative climate data for the dummy period.
Downscaling the cumulative climate data to a 2D grid.
Retrieving long-term temperature data for the glacier.
Returning the climate data, including raw climate data, cumulative climate data, downscaled 2D climate data, long-term temperatures, average temperatures, and average gradients.
Climate2D( rawclimate::RasterStack, climaterawstep::RasterStack, climatestep::ClimateStep, climate2Dstep::Climate2Dstep, longtermtemps::Vector{<: AbstractFloat}, avgtemps::AbstractFloat, avggradients::AbstractFloat, refhgt::AbstractFloat, )
Initialize the climate data with the fields provided as arguments. Refer to the list of fields for a complete description of the arguments.
Climate data
In ODINN we can leverage all the climate datasets available through OGGM. For more details, please check the OGGM documentation regarding that.
The main climate data supported include:
- W5E5
- CRU
- ERA5 and CERA-20C
- HISTALP
- Any other climate dataset. It is fairly easy to add climate datasets into OGGM.
Initializing glaciers and their climate
In order to create Glacier
types with information of a given glacier for a simulation, one can initialize a list of glaciers based on RGI (Randolph Glacier Inventory) IDs. Before running this, make sure to have used Gungnir
to download all the necessary data for those glaciers in local. Here you will find a notebook showing how to do so. Even easier, you can just double check that these glaciers are already available on the ODINN server. The list of the already processed glaciers can be obtained with get_rgi_paths()
.
We will soon host all the preprocessed glacier directories in a server so they can be automatically downloaded by users, without having to process them using Gungnir
.
Sleipnir.initialize_glaciers
— Functioninitialize_glaciers(
rgi_ids::Vector{String},
params::Parameters;
velocityDatacubes::Union{Dict{String, String}, Dict{String, RasterStack}}=Dict(),
)
Initialize glaciers based on provided RGI IDs and parameters.
Arguments
rgi_ids::Vector{String}
: A vector of RGI IDs representing the glaciers to be initialized.params::Parameters
: AParameters
object containing simulation parameters.test::Bool
: An optional boolean flag indicating whether to run in test mode. Default isfalse
.velocityDatacubes::Union{Dict{String, String}, Dict{String, RasterStack}}
: A dictionary that provides for each RGI ID either the path to the datacube or theRasterStack
with velocity data.
Returns
glaciers::Vector{Glacier2D}
: A vector of initializedGlacier2D
objects.
Description
This function performs the following steps:
- Generates a file for missing glaciers if it does not already exist.
- Filters out missing glaciers from the provided RGI IDs.
- Generates raw climate data for the glaciers if necessary.
- Initializes the glaciers using the provided RGI IDs and parameters.
- If
use_glathida_data
is enabled in the simulation parameters, assigns GlaThiDa data to the glaciers.
Errors
- Throws an error if none of the provided RGI IDs have GlaThiDa data.
Warnings
- Issues a warning if not all glaciers have GlaThiDa data available.
Example
# We declare a list of glaciers to be initialized with their RGI IDs
rgi_ids = ["RGI60-11.03638", "RGI60-11.01450", "RGI60-11.02346", "RGI60-08.00203"]
# We initialize those glaciers based on the RGI IDs and the parameters we previously specified
glaciers = initialize_glaciers(rgi_ids, params)