---
title: "Margo Playground"
order: 2
author:
- name: "Declan Naughton ๐งฎ๐จโ๐ป๐ง"
url: "https://calcwithdec.dev/about.html"
description: "some visuals for 'main' model"
format:
html:
resources:
- '../../models/climate-simple/*.js'
- '../../models/climate-simple/*.js.map'
- '../../models/climate-simple/*.json'
---
# WIP
Do not use.
```{ojs}
viewof emissions_rate_in = Inputs.range([0,20], {value: 7.5*main.ppm_to_GtC({ppm_to_GtC_in})/**//*ucar 10.5 GtC*/, step:0.001, label: 'emissions rate Gt Carbon'})
viewof ppm_to_GtC_in = Inputs.select([2.3,2.13], {value: 2.13, label: 'ppmv to GtC'})
viewof ฮบ_in = Inputs.range([0,1], {value:0.73,step:0.01, label:'heat exchange coeff'}) // /*heat exchange coeff*/
viewof B_in = Inputs.range([0,2],{value:1.13,step:0.01, 'label': 'feedback param'}) /*feedback param*/
viewof Cd_in = Inputs.range([0,200],{value:106,step:1, 'label': 'Deep ocean heat capacity'}) //"Deep ocean heat capacity" [J m^-2 K^-1] (from default_configuration.jl)
climate_formulae = ['drawdown','temperature','CO2_concentration','concentration_factor','temperature_delta','T_fast','T_slow','ฯd','area','darea','T']
embed(
calcuvizspec({
models: [main],
input_cursors: [{emissions_rate_in, ppm_to_GtC_in, ฮบ_in, B_in, Cd_in}],
mark: 'line',
encodings: {
x: {name: 'year_in', type:'quantitative', domain: _.range(2015,2505.1,5)},
color: {name: 'climate_sensitivity_in', type: 'nominal', domain: [3.45], independent:true}, //
y: {name: 'value', type: 'quantitative', zero: false, independent:true},
row: {name: 'formula', type:'nominal', domain: ['CO2_concentration','T','T_fast','T_slow']},
//color: {name: 'formula', type:'nominal', domain: climate_formulae, legend: true},
},
width: 400, height:200
}))
embed(
calcuvizspec({
models: [main],
input_cursors: [{emissions_rate_in, ppm_to_GtC_in, ฮบ_in, B_in, Cd_in}],
mark: 'text',
encodings: {
x: {name: 'year_in', type:'nominal', domain: [2015,2016,2017,2020,2025,2030,2060,2090,2100,2200,2205]},
y: {name: 'climate_sensitivity_in', type: 'nominal', domain: [3.45/*2,3,3.45,4*/]},
text: {name: 'value', type: 'quantitative', format:',.4f'},
row: {name: 'formula', type:'nominal', domain: climate_formulae},
color: {name: 'formula', type:'nominal', domain: climate_formulae, legend: false},
},
width: 500, height:50
}))
```
Diff emissions rates:
```{ojs}
viewof f = Inputs.select(['temperature_delta','CO2_concentration'])
embed(
calcuvizspec({
models: [main],
input_cursors: [{emissions_rate_in, ppm_to_GtC_in}],
mark: 'line',
encodings: {
x: {name: 'year_in', type:'quantitative', domain: _.range(2015,2100,3), grid:false},
column: {name: 'climate_sensitivity_in', type: 'nominal', domain: [2,3,4], independent:'shared'}, //
y: {name: f, type: 'quantitative', zero: false, independent:false, grid:false},
color: {name: 'emissions_rate_in', type:'quantitative', domain: _.range(10,3-0.1,-1), scale:{'scheme':'reds'}},
//color: {name: 'formula', type:'nominal', domain: climate_formulae, legend: true},
},
spec_post_process: s => {
s.encoding.color.title = 'emissions_rate_in (GtC)';
s.encoding.column.title = 'climate_sensitivity_in (ฮT per ppmv doubling)';
s.encoding.x.axis = {"grid": false, "tickCount":1, "format": "k"};
return s },
width: 90, height:140
}))
```
# Appendix
```{ojs}
import { calcuvizspec } from "@declann/little-calcu-helpers"
embed = require('vega-embed');
viewof entrypoint = Inputs.select(['models/climate-simple/climate-simple-margo.cul.js'], {label:'entrypoint'})
entrypoint_no_cul_js = entrypoint.slice(0,-7)
main = require(`../../${entrypoint_no_cul_js}.js`);
introspection_fetch = await fetch(`../../${entrypoint_no_cul_js}.introspection.json`)
introspection = introspection_fetch.json({typed:true})
inputs = Object.values(introspection.cul_functions).filter(d => d.reason == 'input definition').map(d => d.name).sort()
formulae = Object.values(introspection.cul_functions).filter(d => d.reason == 'definition').map(d => d.name)
// formulae excluding pure inputs
formulae_not_inputs = Object.values(introspection.cul_functions).filter(d => d.reason == 'definition' && inputs.indexOf(d.name+'_in') == -1).map(d => d.name) // not good when memo on?
```