Simon Danisch / Sep 25 2019
Reactive Mimi Demo
Without running this Notebook in the cloud, you won't be able to interact with the Parameters, since the simulation can't run in the browser. For this we will need to cache the results of the simulation. Here is a preview of how it looks when running this notebook:
You can remix this notebook and press run-all, to interact with the below model visualization:
3.1s
Julia
using Mimi, MimiDICE2013 # Makie & Visualization libraries using AbstractPlotting, WGLMakie, Markdown # Javascript & Compute graph libraries using Observables, Hyperscript, JSServe # Import needed functionality using JSServe: with_session, Slider using JSServe.DOM # Set Plotting Theme set_theme!( markersize = 5, font = "Dejavu Sans", resolution = (500, 400) ) # Create model instances baseline = MimiDICE2013.get_model() run(baseline) # run baseline one time interacted = MimiDICE2013.get_model() function run_model(control) set_param!(interacted, :emissions, :MIU, fill(control, 60)) run(interacted) return something.(interacted[:climatedynamics, :TATM], 0.0) end # Create visualization with_session() do session time_tatm = getdataframe(baseline, :climatedynamics, :TATM) time = time_tatm.time control_rate_s = JSServe.Slider(LinRange(0, 1, 100)) control_rate = map(control_rate_s) do r round(r, digits = 3) end year = JSServe.Slider(1:length(time)) data = map(run_model, control_rate) scene = scatter(time, something.(time_tatm.TATM, 0.0)) scatter!(time, data, color = :red) scene[Axis].names.axisnames = ("Year", "Temperature Increase") scene[Axis].names.textsize = (8, 8) dmg_estimated = map(year, control_rate) do year_idx, _ round(interacted[:damages, :DAMAGES][year_idx], digits = 4) end selected_year = map(year) do i time[i] end b = DOM.font("● baseline", color = :black) ec = DOM.font("● with emission control", color = :red) return md""" # Explore Climate Set amount of emission control: $(control_rate_s) $(control_rate) # Temperature Increase $b | $ec $(scene) # Estimated damage in year $(selected_year) $(year) $(dmg_estimated) trillion USD per year. """ end