Published
Edited
Apr 17, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
myenergy = {
let energy = new my.Energy();

// use the test energy source
energy._token = 'resource_test';
await energy.load();

// this is annual energy in that the time range has been set
return energy.range({from: '2020-02-01T00:00:00.000+00:00', to: '2021-02-01T00:00:00.000+00:00' , interval: 1800000 });
}
Insert cell
myci = {
let myci = new my.CarbonIntensity();
// if using a token the GSP is automatically looked up, hard setting here for illustration
myci.gsp = 'J';
await myci.load();
return myci;
}
Insert cell
Insert cell
myenergycarbon = {
let energycarbon = new my.Carbon();
energycarbon.carbonintensity = myci;
energycarbon.energy = myenergy;
energycarbon.calc();
return energycarbon;
}
Insert cell
Insert cell
hh = {

let lochh = myenergycarbon.byHHSlotDOW({ aggregate: my.Timeseries.AGG_MEAN});
let out = [];
let j = 0;
let slotLabel;
lochh.forEach((day) => {
let daylabel;
let dayarray = [];
let i = 0;
let hour = 0;
if(j == 0) daylabel = 'Monday';
if(j == 1) daylabel = 'Tuesday';
if(j == 2) daylabel = 'Wednesday';
if(j == 3) daylabel = 'Thursday';
if(j == 4) daylabel = 'Friday';
if(j == 5) daylabel = 'Saturday';
if(j == 6) daylabel = 'Sunday';
day.forEach((item) => {
if(i%2) {
slotLabel = ":30";
} else {
slotLabel = ":00";
}
dayarray.push({hh: i, label: Math.floor(i/2) + slotLabel, day: j, daylabel: daylabel, value: item});
i++;

});
out.push(dayarray);
j++;
});

return out;
}
Insert cell
Insert cell
mycarbonhh = {
return myenergycarbon.byHHSlotDOW({});
}
Insert cell
my = require('https://bundle.run/stsc-tsc@1.0.13');
Insert cell
Table = Inputs.Table
Insert cell
Inputs = require("@observablehq/inputs@0.7.17/dist/inputs.umd.min.js")
Insert cell
luxon = require("luxon/build/amd/luxon.js")
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
d3 = require("d3@6")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more