Published
Edited
Sep 18, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
illu = (date) => {
let angle = getSunPosition(date)
if (angle <= 0) {
return 0
} else if (angle < 10) {
return angle*8.5
} else if (angle <= 40) {
return 85 + Math.log(angle-9)*4.3
} else {
return 100
}
}
Insert cell
Insert cell
Insert cell
Insert cell
plotFunc(illuCap)
Insert cell
Insert cell
illuNeg = (date) => {
let angle = getSunPosition(date)
let res = 100
if (angle <= -5) {
res = 100
} else if (angle < 10) {
res = 100-(5+angle)*15
} else {
res = 0
}
return Math.max(res, 0)
}
Insert cell
plotFunc(illuNeg)
Insert cell
Insert cell
Insert cell
illu60 = (d) => {
return 60+illu(d)*0.4
}
Insert cell
Insert cell
Insert cell
illu40 = (d) => {
return 40+illu(d)*0.6
}
Insert cell
plotFunc(illu40)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
darkday = timeperiod([
{t: 0, v: 0},
{t: 6, v: 0},
{t: 9, v: 100},
{t: 17, v: 100},
{t: 22.5, v: 15},
{t: 24, v: 0}
])
Insert cell
Insert cell
Insert cell
weekday = timeperiod([
{t: 0, v: 1},
{t: 6, v: 1},
{t: 6.5, v: 20},
{t: 7.25, v: 80},
{t: 9, v: 100},
{t: 17, v: 100},
{t: 18, v: 70},
{t: 20.5, v: 30},
{t: 24, v: 1}
])
Insert cell
Insert cell
Insert cell
weekend = timeperiod([
{t: 0, v: 1},
{t: 7, v: 1},
{t: 8, v: 20},
{t: 11.5, v: 100},
{t: 17, v: 100},
{t: 18, v: 70},
{t: 21.5, v: 20},
{t: 24, v: 1}
])
Insert cell
Insert cell
Insert cell
Insert cell
dim0 = (d) => {
let day = isWeekend(d) ? weekend : weekday
return darkday(d)*illuNeg(d)/100
}
Insert cell
plotFunc(dim0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
plotFunc(dim2)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
work in progress
Insert cell
dim4 = (d) => {
let day = isWeekend(d) ? weekend : weekday
return day(d)*illuCap(d)/100
}
Insert cell
Insert cell
Insert cell
isWeekend = (d) => {
let dayOfWeek = d.getDay()
return true
return (dayOfWeek === 6) || (dayOfWeek === 0)
}
Insert cell
timeperiod = (slots) => {

return (d) => {
let time = d.getHours() + d.getMinutes()/60
let v = slots[0].v
for (let i = 0; i < slots.length-1; i++) {
if (time > slots[i].t && time <= slots[i+1].t) {
v = slots[i].v + (slots[i+1].v-slots[i].v) * ((time-slots[i].t)/(slots[i+1].t-slots[i].t))
//v = 100*((time-slots[i].t)/(slots[i+1].t-slots[i].t))
}
}
return v
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lat = 63.448668
Insert cell
lng = 10.464586
Insert cell
tf = d3.timeFormat("%H:%M")
Insert cell
Insert cell
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