To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
begin
import Pkg
Pkg.activate("/home/fons/MargoAPI.jl/")
end
❔
  Activating new project at `/home/fons/MargoAPI.jl`
130 ms
Error message

The package ClimateMARGO.jl could not load because it failed to initialize.

That's not nice! Things you could try:

  • Restart the notebook.
  • Try a different Julia version.
  • Contact the developers of ClimateMARGO.jl about this error.

You might find useful information in the package installation log:

👀 Reading hidden code
begin
ENV["JULIA_MARGO_LOAD_PYPLOT"] = "no thank you"
import ClimateMARGO
using ClimateMARGO.Models
using ClimateMARGO.Optimization
using ClimateMARGO.Diagnostics
Base.range(d::Domain) = d.initial_year:d.dt:d.final_year
end
---
Error message

The package Plots.jl could not load because it failed to initialize.

That's not nice! Things you could try:

  • Restart the notebook.
  • Try a different Julia version.
  • Contact the developers of Plots.jl about this error.

You might find useful information in the package installation log:

Silly computer!
using Plots
👀 Reading hidden code
---
12
dt = 12
👀 Reading hidden code
10.4 μs
setfieldconvert! (generic function with 1 method)

function setfieldconvert!(value, name::Symbol, x)
setfield!(value, name, convert(typeof(getfield(value, name)), x))
end
👀 Reading hidden code
462 μs
Error message

Another cell defining ClimateMARGO contains errors.

model_parameters = let
mp = deepcopy(ClimateMARGO.IO.included_configurations["default"])
mp.domain = Domain(Float64(dt), 2020.0, 2200.0)
mp.economics.baseline_emissions = ramp_emissions(mp.domain)
mp.economics.extra_CO₂ = zeros(size(mp.economics.baseline_emissions))
mp
end
👀 Reading hidden code
---
Error message

Another cell defining M_val, ClimateMARGO and R_val contains errors.

Computers are hard!
controls = Controls(M, R, zeros(size(t)), zeros(size(t)))
👀 Reading hidden code
---
Error message

UndefVarError: ClimateModel not defined

Try asking on Julia Discourse!
model = ClimateModel(model_parameters, controls)
👀 Reading hidden code
---
Error message

Another cell defining M_val, ClimateMARGO, R_val and model_results contains errors.

results = model_results(model)
👀 Reading hidden code
---
[1:2, LinRange(3.0,4.0,6)]
👀 Reading hidden code
18.1 μs
Error message

Another cell defining ClimateMARGO contains errors.

t = model_parameters.domain |> range
👀 Reading hidden code
---

👀 Reading hidden code
71.0 μs
Error message

UndefVarError: Slider not defined

Stack trace

Here is what happened, the most recent locations are first:

  1. macro expansion
  2. Show more...
@bind M_val Slider(LinRange(0,1,1000))
👀 Reading hidden code
---
Error message

UndefVarError: Slider not defined

Stack trace

Here is what happened, the most recent locations are first:

  1. macro expansion
  2. Show more...
@bind R_val Slider(LinRange(0,1,1000))
👀 Reading hidden code
---
Error message

Another cell defining ClimateMARGO, M_val, R_val and model_results contains errors.

let
p = plot(
t, results[:computed][:emissions][:baseline],
lw=4, color=:gray,
label="Baseline",
)
plot!(p,
t, results[:computed][:emissions][:MRGA],
lw=4, color=:red,
label="Emissions",
)
end
👀 Reading hidden code
---

👀 Reading hidden code
71.9 μs
Error message

Another cell defining M_val and ClimateMARGO contains errors.

begin
M = fill(0.0, size(t))
M[6] = M_val
M
end
👀 Reading hidden code
---
Error message

Another cell defining R_val and ClimateMARGO contains errors.

begin
R = fill(0.0, size(t))
R[9] = R_val
R
end
👀 Reading hidden code
---
Error message

The package PlutoUI.jl could not load because it failed to initialize.

That's not nice! Things you could try:

  • Restart the notebook.
  • Try a different Julia version.
  • Contact the developers of PlutoUI.jl about this error.

You might find useful information in the package installation log:

using PlutoUI
👀 Reading hidden code
---
Error message

UndefVarError: ClimateModel not defined

Stack trace

Here is what happened, the most recent locations are first:

  1. model_results(model::ClimateModel) = Dict(    :controls => model.controls,
model_results(model::ClimateModel) = Dict(
:controls => model.controls,
:computed => Dict(
:temperatures => Dict(
:baseline => T(model),
:M => T(model; M=true),
:MR => T(model; M=true, R=true),
:MRG => T(model; M=true, R=true, G=true),
:MRGA => T(model; M=true, R=true, G=true, A=true),
),
:emissions => Dict(
:baseline => effective_emissions(model),
:M => effective_emissions(model; M=true),
:MRGA => effective_emissions(model; M=true, R=true),
),
:concentrations => Dict(
:baseline => c(model),
:M => c(model; M=true),
:MRGA => c(model; M=true, R=true),
),
:damages => Dict(
:baseline => costs_dict(damage(model; discounting=true), model),
:MRGA => costs_dict(damage(model; M=true, R=true, G=true, A=true, discounting=true), model),
),
:costs => Dict(
:M => costs_dict(cost(model; M=true, discounting=true), model),
:R => costs_dict(cost(model; R=true, discounting=true), model),
:G => costs_dict(cost(model; G=true, discounting=true), model),
:A => costs_dict(cost(model; A=true, discounting=true), model),
:MRGA => costs_dict(cost(model; M=true, R=true, G=true, A=true, discounting=true), model),
),
),
)
👀 Reading hidden code
---
costs_dict (generic function with 1 method)
function costs_dict(costs, model)
Dict(
:discounted => costs,
:total_discounted => sum(costs .* model.domain.dt),
)
end
👀 Reading hidden code
527 μs
same_expr_1 (generic function with 1 method)
same_expr_1(a::Any, b::Any) = a === b
👀 Reading hidden code
376 μs
same_expr_1 (generic function with 2 methods)
same_expr_1(a::Expr, b::Expr) =
a.head === b.head &&
length(a.args) == length(b.args) &&
all(p -> same_expr_1(p[1],p[2]), zip(a.args,b.args))
👀 Reading hidden code
1.1 ms
same_expr_2 (generic function with 1 method)
same_expr = same_expr_2
👀 Reading hidden code
12.5 μs
[2.0]
👀 Reading hidden code
12.0 μs
true
same_expr_2(:([]), :([]))
👀 Reading hidden code
27.1 μs
true
same_expr(:([0]), :([0]))
👀 Reading hidden code
30.8 μs
(:([4.0]), :([4])) .|> expr_hash
👀 Reading hidden code
55.4 ms
expr_hash (generic function with 1 method)
expr_hash(e::Expr) = objectid(e.head) + mapreduce(expr_hash, +, e.args; init=UInt(0))
👀 Reading hidden code
575 μs
expr_hash (generic function with 2 methods)
expr_hash(x) = objectid(x)
👀 Reading hidden code
360 μs
same_expr_2 (generic function with 1 method)
same_expr_2(a,b) = expr_hash(a) === expr_hash(b)
👀 Reading hidden code
446 μs