Skip to content

Instantly share code, notes, and snippets.

@brenhinkeller
Created August 22, 2022 20:15
Show Gist options
  • Save brenhinkeller/11730d83cb5e8135178a693b73289185 to your computer and use it in GitHub Desktop.
Save brenhinkeller/11730d83cb5e8135178a693b73289185 to your computer and use it in GitHub Desktop.
Reproduce HEFTY-type t-T paths using _only_ the boxes
## --- Reproduce HEFTY-type t-T paths using _only_ the boxes
using Plots, Colors
struct TtBox
Tmin::Float64
Tmax::Float64
tmin::Float64
tmax::Float64
end
import Plots.plot!
function plot!(h::Plots.Plot, box::TtBox; varargs...)
x = [box.tmin, box.tmin, box.tmax, box.tmax, box.tmin, box.tmin,]
y = [box.Tmin, box.Tmax, box.Tmax, box.Tmin, box.Tmin, box.Tmax,]
plot!(h, x, y; varargs...)
end
boxes = [
TtBox(400, 600, 1056, 1076) # "initial cooling" zircon
TtBox(350, 400, 1056, 1076) # "initial cooling" BtAr
TtBox(150, 200, 950, 1050) # "initial cooling" KspAr
TtBox(0, 20, 720, 1000) # "exporation field"
TtBox(0, 20, 720, 720) # arbitrary -- Sturtian
TtBox(0, 30, 510, 717) # arbitrary -- Sturtian to Sawatch
TtBox(0, 20, 497, 509) # Exposure: Sawatch
TtBox(0, 60, 400, 497) # "Paleozoic burial"
TtBox(60, 120, 310, 400) # "Paleozoic burial"
TtBox(0, 20, 300, 310) # Exposure: Fountain fm
TtBox(0, 90, 200, 300) # "Ancestral Rockies burial"
TtBox(90, 180, 80, 200) # "Ancestral Rockies burial"
TtBox(0, 20, 64, 68) # Pikes Peak batholith at surface (clasts in Arapahoe Fm)
TtBox(0, 20, 0, 0) # Surface today
]
function drawfrom(boxes::Array{TtBox})
n = length(boxes)*2 - 1
T = Array{Float64}(undef, n)
t = Array{Float64}(undef, n)
# Nodes
@inbounds for i = 1:length(boxes)
box = boxes[i]
j = 2(i-1) + 1
T[j] = rand() * (box.Tmax-box.Tmin) + box.Tmin
t[j] = rand() * (box.tmax-box.tmin) + box.tmin
end
# Inter-nodes
@inbounds for i = 2:2:n-1
T[i] = rand() * (T[i+1]-T[i-1]) + T[i-1]
t[i] = rand() * (t[i+1]-t[i-1]) + t[i-1]
end
return t,T
end
## -- Plot results
green = parse(Colorant,"#6CB645")
purple = parse(Colorant, "#BE4B96")
yellow = parse(Colorant, "#F0E40A")
blue = parse(Colorant, "#394698")
h = plot(xlims=(0,1100), ylims=(0,200), xflip=true, yflip=true)
plot!(h,xlabel="Time (Ma)", ylabel="Temperature (C)", framestyle=:box)
for _ = 1:500 # Random paths
plot!(h, drawfrom(boxes)..., label="", color=green)
end
for _ = 1:30 # More random "selected" paths
plot!(h, drawfrom(boxes)..., label="", color=purple)
end
savefig(h, "randpaths.pdf")
for i = 1:length(boxes) # Plot the constraint boxes for comparison
color = i==4 ? blue : yellow # Highlight the "exploration field"
plot!(h, boxes[i], label="", color=color, linewidth=3)
end
savefig(h, "randpaths_with_boxes.pdf")
display(h)
## ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment