From e22f9db7f78ad1fc685af7fe395294cc91c9f37a Mon Sep 17 00:00:00 2001 From: TNGUYE02 Date: Wed, 22 Sep 2021 11:37:42 -0400 Subject: [PATCH] fix so2 and nox emissions rounding --- app/src/components/EmissionsCalculator.vue | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/src/components/EmissionsCalculator.vue b/app/src/components/EmissionsCalculator.vue index ad57c4d..1e7328d 100644 --- a/app/src/components/EmissionsCalculator.vue +++ b/app/src/components/EmissionsCalculator.vue @@ -396,7 +396,7 @@ export default { this.userEmissions = { co2: this.calculateEmissionsAll( - this.emissionFactors.co2EmissionRate.value, + Math.round(this.emissionFactors.co2EmissionRate.value*10)/10, this.gridLoss.value, userTotal ), @@ -414,7 +414,7 @@ export default { this.subregionEmissions = { co2: this.calculateEmissionsAll( - this.emissionFactors.co2EmissionRate.value, + Math.round(this.emissionFactors.co2EmissionRate.value*10)/10, this.gridLoss.value, this.nationalTotal ), @@ -432,8 +432,8 @@ export default { this.nationalEmissions = { co2: this.calculateEmissionsAll( - this.nationalFeature[0].properties.emissionFactor.co2EmissionRate - .value, + Math.round(this.nationalFeature[0].properties.emissionFactor.co2EmissionRate + .value*10)/10, this.natGridloss.value, this.nationalTotal ), @@ -548,7 +548,7 @@ export default { this.userEmissions = { co2: this.calculateEmissionsAll( - this.emissionFactors.co2EmissionRate.value, + Math.round(this.emissionFactors.co2EmissionRate.value*10)/10, this.gridLoss.value, total ), @@ -566,7 +566,7 @@ export default { this.subregionEmissions = { co2: this.calculateEmissionsAll( - this.emissionFactors.co2EmissionRate.value, + Math.round(this.emissionFactors.co2EmissionRate.value*10)/10, this.gridLoss.value, this.nationalTotal ), @@ -584,8 +584,8 @@ export default { this.nationalEmissions = { co2: this.calculateEmissionsAll( - this.nationalFeature[0].properties.emissionFactor.co2EmissionRate - .value, + Math.round(this.nationalFeature[0].properties.emissionFactor.co2EmissionRate + .value*10)/10, this.natGridloss.value, this.nationalTotal ), @@ -691,8 +691,8 @@ export default { this.nationalEmissions = { co2: this.calculateEmissionsAll( - this.nationalFeature[0].properties.emissionFactor.co2EmissionRate - .value, + Math.round(this.nationalFeature[0].properties.emissionFactor.co2EmissionRate + .value*10)/10, this.natGridloss.value, this.nationalTotal ), @@ -714,7 +714,7 @@ export default { this.userEmissions = { co2: this.calculateEmissionsAll( - this.emissionFactors.co2EmissionRate.value, + Math.round(this.emissionFactors.co2EmissionRate.value*10)/10, this.gridLoss.value, this.nationalTotal ), @@ -1001,8 +1001,7 @@ export default { } }, calculateEmissionsAll: function(emissionFactorValue, gridLoss, total) { - var emFactor = Math.round(emissionFactorValue*10)/10; - var emissionsAttr = total * emFactor * 0.001; + var emissionsAttr = total * emissionFactorValue * 0.001; var totEm = emissionsAttr + ((gridLoss * emissionsAttr) / (1 - gridLoss)); var res = totEm.toFixed(1); return res;