Public
Edited
Apr 9
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
temperature_reference = 2700
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bb_table = FileAttachment("bb@1.csv").csv({typed: true})
Insert cell
Insert cell
Insert cell
Insert cell
// power at 293K, i.e. 20°C or 68°F. This represents the power we receive from and radiate to the environment
// The exact choise here doesn’t matter, for any reasonable room temperature this power level is really low.
power_0 = Math.pow(293 / temperature_reference, 4) * last_power
Insert cell
function power_to_temperature(p) {
return Math.pow(p / last_power + power_0, 0.25) * temperature_reference;
}
Insert cell
calculated_data = measured_u_i.map(o => {
var p = o.u * o.i;
var t = power_to_temperature(p);
var lm_w = 0;
var css = "black";
if (t > bb_table[0].temp && t < bb_table.at(-1).temp)
{
var ix = Math.floor((t - 200) / dt);
var bb1 = bb_table[ix]
var bb2 = bb_table[ix + 1]
var mix = (t - bb1.temp) / (bb2.temp - bb1.temp);
lm_w = (1 - mix) * bb1.lm_w + mix * bb2.lm_w;
css = bb1.css;
}
return {...o, p: p, r: o.u / o.i, t: t, lm_w: lm_w, css_bb: css};
})

Insert cell
last_power = measured_u_i.at(-1).u * measured_u_i.at(-1).i
Insert cell
dt = bb_table[1].temp - bb_table[0].temp
Insert cell
Insert cell
function sRGB([r, g, b])
{
// both sRGB and Display-P3 use this transfer function.
var a = 0.055;
r = r < .0031308 ? r / 12.92 : (1 + a) * Math.pow(r, 1/2.4) - a;
g = g < .0031308 ? g / 12.92 : (1 + a) * Math.pow(g, 1/2.4) - a;
b = b < .0031308 ? b / 12.92 : (1 + a) * Math.pow(b, 1/2.4) - a;
return [r, g, b]
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more