Skip to content

Commit 7bde28e

Browse files
Merge pull request #129 from albert-de-montserrat/adm/sea_level
Sea level curves
2 parents f946bf4 + 2d425a0 commit 7bde28e

16 files changed

+67621
-0
lines changed

src/GeophysicalModelGenerator.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ include("IO.jl")
4747
include("event_counts.jl")
4848
include("surface_functions.jl")
4949
include("movies_from_pics.jl")
50+
include("sea_lvl.jl")
5051

5152
# Add optional routines (only activated when the packages are loaded)
5253

src/sea_level.jl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export sea_level_files, SeaLevel, load_sea_level, curve_name
2+
3+
const sea_level_path = "sea_level_data"
4+
5+
const sea_level_files = Dict(
6+
:Spratt_800ka => "Spratt2016-800ka.txt",
7+
:Spratt_450ka => "Spratt2016-450ka.txt",
8+
:Bintanja_3Ma => "Bintanja-3Ma.txt",
9+
:Grant_153ka => "Grant2012_153ka.txt",
10+
:Rohl_Bint_3Ma => "Rohl-Bint-3Ma.txt",
11+
:Rohling2009_516ka => "Rohling2009-516ka.txt",
12+
:Siddall2003_379ka => "Siddall2003-379ka.txt",
13+
:Waelbroeck2002 => "Waelbroeck2002.txt",
14+
)
15+
16+
struct SeaLevel{T}
17+
elevation::Vector{T}
18+
age::Vector{T}
19+
name::Symbol
20+
21+
function SeaLevel(name::Symbol; flip_elevation = false, flip_age = false)
22+
age, elevation = load_sea_level(
23+
name;
24+
flip_age = flip_age,
25+
flip_elevation = flip_elevation
26+
)
27+
new{eltype(age)}(age, elevation, name)
28+
end
29+
end
30+
31+
Base.getindex(x::SeaLevel, i::Int64) = x.elevation[i]
32+
Base.getindex(x::SeaLevel, i::Int64, j::Int64) = x.elevation[i], x.age[j]
33+
Base.getindex(x::SeaLevel, i::Tuple{Int64}) = x.elevation[i...], x.age[i...]
34+
Base.size(x::SeaLevel) = size(x.elevation)
35+
Base.eachindex(x::SeaLevel) = eachindex(x.elevation)
36+
Base.axes(x::SeaLevel) = axes(x.elevation)
37+
Base.length(x::SeaLevel) = length(x.elevation)
38+
curve_name(x::SeaLevel) = x.name
39+
40+
function load_sea_level(name::Symbol; flip_elevation = false, flip_age = false)
41+
fname = sea_level_files[name]
42+
data = readdlm(joinpath(sea_level_path, fname))
43+
h = data[:, 1]
44+
age = data[:, 2]
45+
flip_elevation && reverse!(h)
46+
flip_age && reverse!(age)
47+
return h, age
48+
end

0 commit comments

Comments
 (0)