Skip to content

Commit 6e9a3cd

Browse files
committed
fix rounding error in exporter
1 parent 61d95a7 commit 6e9a3cd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scripts/pypsa-de/export_ariadne_variables.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def _get_fuel_fractions(n, region, fuel):
227227
else:
228228
raise ValueError(f"Fuel {fuel} not supported")
229229

230-
fuel_fractions = fuel_fractions.divide(domestic_fuel_supply.sum())
230+
fuel_fractions = fuel_fractions.divide(domestic_fuel_supply.sum()).round(9)
231231

232232
assert isclose(fuel_fractions.sum(), 1)
233233

@@ -1233,11 +1233,19 @@ def get_primary_energy(n, region):
12331233

12341234
var["Primary Energy|Gas"] = gas_usage.sum() / primary_gas_factor
12351235

1236+
_gas_primary = (
1237+
n.statistics.withdrawal(
1238+
bus_carrier="gas primary",
1239+
**kwargs,
1240+
)
1241+
.get(("Link", "DE gas compressing"), pd.Series(0))
1242+
.round()
1243+
.item()
1244+
)
1245+
12361246
assert isclose(
12371247
var["Primary Energy|Gas"],
1238-
n.statistics.withdrawal(bus_carrier="gas primary", **kwargs)
1239-
.get(("Link", "DE gas compressing"), pd.Series(0))
1240-
.item(),
1248+
_gas_primary,
12411249
)
12421250

12431251
var["Primary Energy|Gas|Gases"] = (

0 commit comments

Comments
 (0)