Skip to content

Commit 3874017

Browse files
committed
Merge branch 'main' into feature/234-site-design-updates
2 parents 5546e96 + 9f1d398 commit 3874017

19 files changed

Lines changed: 2071 additions & 34741 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typings/
7070

7171
# Nuxt generate
7272
dist
73+
dist2
7374

7475
# vuepress build output
7576
.vuepress/dist

components/Charts/PowerEnergyChart.vue

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ import * as SI from '@/constants/si.js'
214214
import { RANGE_ALL_12MTH_ROLLING } from '@/constants/ranges.js'
215215
import { LOAD } from '@/constants/energy-fuel-techs/group-detailed.js'
216216
import EnergyToAveragePower from '@/data/transform/energy-to-average-power.js'
217-
import transformToGrowthTimeSeries from '~/data/transform/growth-series.js'
217+
import transformToGrowthTimeSeries from '@/data/transform/growth-series.js'
218+
import { dataFilterByPeriod } from '@/data/parse/region-energy'
218219
import DateDisplay from '@/services/DateDisplay.js'
219220
import MultiLine from '@/components/Vis/MultiLine'
220221
import DateBrush from '@/components/Vis/DateBrush'
@@ -411,7 +412,8 @@ export default {
411412
isTypeLine: 'chartOptionsPowerEnergy/isTypeLine',
412413
isTypeChangeSinceLine: 'chartOptionsPowerEnergy/isTypeChangeSinceLine',
413414
isTypeGrowthStackedArea: 'chartOptionsPowerEnergy/isTypeGrowthStackedArea',
414-
allowResize: 'regionEnergy/allowResize'
415+
allowResize: 'regionEnergy/allowResize',
416+
_rolledUpDataset: 'regionEnergy/_rolledUpDataset'
415417
}),
416418
417419
showDateAxis: {
@@ -1235,7 +1237,8 @@ export default {
12351237
12361238
getGrowthDataset() {
12371239
let compareIndex = 1
1238-
1240+
let dataset
1241+
12391242
if (this.isRollingSumRange) {
12401243
if (this.interval === 'Season' || this.interval === 'Quarter') {
12411244
compareIndex = 4
@@ -1246,21 +1249,34 @@ export default {
12461249
}
12471250
}
12481251
1249-
const ds = this.isYAxisAbsolute
1250-
? this.powerEnergyDataset
1251-
: this.averagePowerDataset
1252+
if (this.filterPeriod === 'All') {
1253+
const ds = this.isYAxisAbsolute
1254+
? this.powerEnergyDataset
1255+
: this.averagePowerDataset
12521256
1253-
const dataset = transformToGrowthTimeSeries(ds, this.domains, compareIndex)
1257+
dataset = transformToGrowthTimeSeries(ds, this.domains, compareIndex)
1258+
} else {
1259+
const ds = this.isYAxisAbsolute
1260+
? this._rolledUpDataset
1261+
: EnergyToAveragePower({
1262+
data: this._rolledUpDataset,
1263+
domains: this.domains,
1264+
range: this.range,
1265+
interval: this.interval,
1266+
exponent: this.chartEnergyUnitPrefix,
1267+
isRollingSum: this.isRollingSumRange
1268+
})
1269+
const transformedToGrowth = transformToGrowthTimeSeries(ds, this.domains, compareIndex)
1270+
const { filteredDatasetFlat } = dataFilterByPeriod({
1271+
currentDataset: transformedToGrowth,
1272+
interval: this.interval,
1273+
period: this.filterPeriod
1274+
})
1275+
dataset = filteredDatasetFlat
1276+
}
12541277
12551278
this.handleTypeClick()
12561279
1257-
if (this.isRollingSumRange) {
1258-
// only return the data where there are values
1259-
return dataset.slice(compareIndex, dataset.length - 1)
1260-
}
1261-
1262-
// remove first null period
1263-
dataset.shift()
12641280
return dataset
12651281
},
12661282

components/layout/AppFooter.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@
4444
class="sources">
4545
<a
4646
target="_blank"
47-
href="https://zenodo.org/record/7179775#.Y5WC4OxxU0E"
48-
title="Link to dataset used by this visualisation">Gütschow, J.; Pflüger, M. (2022): The PRIMAP-hist national
49-
historical emissions time series v2.4 (1750-2021).</a>
47+
href="https://zenodo.org/records/10705513"
48+
title="Link to dataset used by this visualisation">Gütschow, J.; Pflüger, M.; Busch, D. (2023): The PRIMAP-hist national historical emissions time series v2.5.1 (1750-2022). zenodo. doi:10.5281/zenodo.10705513.</a>
5049
</div>
5150

5251
<div

constants/facilities/map-styles.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ export const MAP_STYLE_LIGHT = 'light'
33
export const MAP_STYLE_SATELLITE = 'satellite'
44

55
export const MAP_STYLE_URLS = {}
6+
// MAP_STYLE_URLS[MAP_STYLE_LIGHT] =
7+
// 'mapbox://styles/steventan/ckoji70651l9j18p5uefuskvt'
8+
// MAP_STYLE_URLS[MAP_STYLE_SATELLITE] =
9+
// 'mapbox://styles/steventan/ckomkdzo11qcw17qljpcd1wki'
10+
611
MAP_STYLE_URLS[MAP_STYLE_LIGHT] =
7-
'mapbox://styles/steventan/ckoji70651l9j18p5uefuskvt'
12+
'mapbox://styles/mapbox/light-v11'
813
MAP_STYLE_URLS[MAP_STYLE_SATELLITE] =
9-
'mapbox://styles/steventan/ckomkdzo11qcw17qljpcd1wki'
14+
'mapbox://styles/mapbox/satellite-v9'
1015

1116
export const mapStyleSelections = [
1217
{

data/calculate-carbon-intensity.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ function calAverage(isEnergyType, isWemOrAu, dataset) {
1919

2020
if (isWemOrAu) {
2121
ei = ei * 2
22-
} else {
23-
ei = ei * 12
2422
}
2523
}
2624

@@ -35,7 +33,8 @@ export default function({
3533
domainPowerEnergy,
3634
isEnergyType,
3735
isWemOrAu,
38-
regionId
36+
regionId,
37+
interval
3938
}) {
4039

4140
/**
@@ -70,7 +69,14 @@ export default function({
7069
}
7170

7271
const getPowerEnergy = (data, domain) => {
73-
return data[domain.id] || 0
72+
if (isEnergyType) {
73+
return data[domain.id] || 0
74+
} else {
75+
if (data[`${domain.id}_to_energy`]) {
76+
return data[`${domain.id}_to_energy`] || 0
77+
}
78+
return data[domain.id] || 0
79+
}
7480
}
7581

7682
const batteryDischarging = domainPowerEnergy.find(
@@ -109,7 +115,7 @@ export default function({
109115
}
110116
})
111117

112-
powerEnergyDomains.forEach((domain) => {
118+
powerEnergyDomains.forEach((domain) => {
113119
totalPowerEnergy += getPowerEnergy(d, domain)
114120
})
115121

@@ -129,9 +135,7 @@ export default function({
129135

130136
if (isWemOrAu) {
131137
ei = ei * 2
132-
} else {
133-
ei = ei * 12
134-
}
138+
}
135139
}
136140

137141
const isValidEI = Number.isFinite(ei)

data/parse/region-energy/group/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ export default function ({
2424
Object.keys(groups).forEach((key) => {
2525
if (key !== GROUP_DETAILED) {
2626
const groupDomains = groups[key]
27+
2728
groupDomains.forEach((g) => {
2829
let groupValue = 0,
29-
allNulls = true
30+
allNulls = true,
31+
groupPowerToEnergy = 0
32+
3033
g.domainIds.forEach((dId) => {
3134
groupValue += d[dId]
35+
groupPowerToEnergy += d[`${dId}_to_energy`] || 0
36+
3237
if (d[dId] || d[dId] === 0) {
3338
allNulls = false
3439
}
3540
})
41+
42+
if (g.type === 'power') {
43+
d[`${g.id}_to_energy`] = groupPowerToEnergy
44+
}
45+
3646
d[g.id] = allNulls ? null : groupValue
3747
})
3848
}

data/parse/region-energy/process/flattenAndInterpolate.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import eachDayOfInterval from 'date-fns/eachDayOfInterval'
44
import eachMonthOfInterval from 'date-fns/eachMonthOfInterval'
55
import addMinutes from 'date-fns/addMinutes'
66
import { mutateDate } from '@/services/datetime-helpers.js'
7+
import { isLoad } from '@/constants/energy-fuel-techs/group-detailed.js'
78
import * as DT from '@/constants/data-types.js'
89
import interpolateDataset from './interpolateDataset.js'
910

@@ -225,8 +226,28 @@ export default function (isPowerData, dataInterval, dataAll, displayTz) {
225226
})
226227

227228
// interpolate and create pos/neg price props
229+
// convert power to energy
228230
if (isPowerData) {
229231
interpolateDataset(dataAll, allArr)
232+
const powerData = dataAll.filter((d) => d.type === 'power')
233+
const powerIds = powerData.map((d) => { return {
234+
id: d.id,
235+
fuelTech: d.fuel_tech
236+
}})
237+
238+
allArr.forEach((d) => {
239+
let totalEnergy = 0
240+
powerIds.forEach(({id, fuelTech}) => {
241+
d[`${id}_to_energy`] = d[id] * 5 / 60
242+
243+
if (isLoad(fuelTech)) {
244+
d[`${id}_to_energy`] = -d[`${id}_to_energy`]
245+
}
246+
247+
totalEnergy += d[`${id}_to_energy`]
248+
})
249+
d._totalPowerToEnergy = totalEnergy
250+
})
230251

231252
const priceObj = dataAll.find((d) => d.type === 'price')
232253
if (priceObj) {

data/parse/region-energy/rollUp/powerRollUp.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { mean, rollups } from 'd3-array'
1+
import { sum, mean, rollups } from 'd3-array'
22
import * as DT from '@/constants/data-types.js'
33

44
function reducer(a, domains) {
55
let obj = {}
66
let priceId = null
77

88
domains.forEach((domain) => {
9+
let allNulls = true
910
const id = domain.id
11+
const toEnergyId = `${id}_to_energy`
1012
const type = domain.type
1113
const isPowerOrEnergy = DT.isPowerOrEnergy(type)
1214
const isTemperature = DT.isTemperature(type)
@@ -19,17 +21,40 @@ function reducer(a, domains) {
1921
id !== '_volWeightedPriceAbove300' &&
2022
id !== '_volWeightedPriceBelow0'
2123

22-
if (isPowerOrEnergy || isPrice || isEmissionsType) {
24+
if (isPowerOrEnergy) {
25+
// calculate mean power values
2326
obj[id] = mean(a, (d) => d[id] || 0)
2427

25-
if (type === DT.PRICE) {
26-
// use the first 30min data for period
27-
obj[id] = a[0][id]
28-
}
28+
// calculate energy and total energy values
29+
let totalEnergy = 0
30+
a.forEach((point) => {
31+
point[toEnergyId] = point[id] * 5 / 60
32+
if (domain.category === 'load') {
33+
point[toEnergyId] = -point[toEnergyId]
34+
}
35+
totalEnergy += point[toEnergyId]
36+
})
37+
38+
obj[toEnergyId] = sum(a, (d) => d[toEnergyId] || 0)
39+
obj._totalPowerToEnergy = totalEnergy
2940

41+
} else if (isPrice) {
42+
// use the first price value for the rest of the period
43+
obj[id] = a[0][id]
3044
if (isOriginalPrice) {
3145
priceId = id
3246
}
47+
} else if (isEmissionsType) {
48+
const total = sum(a, (d) => {
49+
let value = d[id]
50+
51+
if (value || value === 0) {
52+
allNulls = false
53+
}
54+
return value
55+
})
56+
57+
obj[id] = allNulls ? null : total
3358
} else if (isTemperature) {
3459
obj[id] = mean(a, (d) => d[id])
3560
}

nuxt.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ module.exports = {
171171
}
172172
],
173173
script: [
174-
{ src: 'https://cdn.polyfill.io/v2/polyfill.min.js?features=default' },
175174
{ async: true, src: 'https://www.googletagmanager.com/gtag/js?id=G-FYYXTDCEND"' },
176175
{ src: '/scripts/ga.js' }
177176
]
@@ -269,7 +268,7 @@ module.exports = {
269268
/*
270269
** You can extend webpack config here
271270
*/
272-
// publicPath: `/_nuxt_${timestamp}/`,
271+
// publicPath: `/nuxt_${timestamp}/`,
273272
publicPath: `/js/`,
274273
plugins: [
275274
new webpack.IgnorePlugin({

0 commit comments

Comments
 (0)