Skip to content

Commit

Permalink
fix so2 and nox emissions rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
TNGUYE02 authored and TNGUYE02 committed Sep 22, 2021
1 parent 8580ce2 commit e22f9db
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions app/src/components/EmissionsCalculator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand All @@ -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
),
Expand All @@ -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
),
Expand Down Expand Up @@ -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
),
Expand All @@ -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
),
Expand All @@ -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
),
Expand Down Expand Up @@ -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
),
Expand All @@ -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
),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e22f9db

Please sign in to comment.