ClimateMARGO / interactive

Interactive Pluto notebooks about ClimateMARGO.jl
https://margo.plutojl.org/
MIT License
8 stars 0 forks source link

Adding a demo notebook to showcase the Energy Balance Model #6

Closed hdrake closed 2 years ago

hdrake commented 2 years ago

For SIO Climate Journal club presentation of the MARGO paper.

hdrake commented 2 years ago

@fonsp, this is awesome! I even was able to understand the javascript well enough to retool some of your functions.

hdrake commented 2 years ago

@fonsp, for some reason the @bind Slider reactivity in ebm.jl is hit-or-miss. It worked last time I ran the notebook but this time the sliders don't do anything and the variables just stay at their default values. Could you look into it? If it works for you than we can ship the notebook as is and I'll present it on Thursday!

hdrake commented 2 years ago

@fonsp, I realized the problem was that I have mistakenly copied the standard Pluto.jl header

using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
    quote
        local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
        local el = $(esc(element))
        global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
        el
    end
end

into a cell within the ebm.jl notebook itself. This understandably broke the bind macro's reactivity.

Everything is now working as expected!