Merge branch 'yerbol-akhmetov-fix_biomass_transport'

This commit is contained in:
Fabian Neumann 2024-05-20 22:40:29 +02:00
commit 8b303d93e9
2 changed files with 12 additions and 1 deletions

View File

@ -316,6 +316,8 @@ Upcoming Release
* Mark downloaded files as ``ancient`` rather than ``protected``.
* Fix file name enconding in optional rule :mod:`build_biomass_transport_costs` depending on the operating system.
PyPSA-Eur 0.10.0 (19th February 2024)
=====================================

View File

@ -17,20 +17,27 @@ assuming as an approximation energy content of wood pellets
@author: bw0928
"""
import platform
import pandas as pd
import tabula as tbl
ENERGY_CONTENT = 4.8 # unit MWh/t (wood pellets)
system = platform.system()
encoding = "cp1252" if system == "Windows" else None
def get_countries():
pandas_options = dict(skiprows=range(6), header=None, index_col=0)
pandas_options = dict(
skiprows=range(6), header=None, index_col=0, encoding=encoding
)
return tbl.read_pdf(
str(snakemake.input.transport_cost_data),
pages="145",
multiple_tables=False,
pandas_options=pandas_options,
encoding=encoding,
)[0].index
@ -41,6 +48,7 @@ def get_cost_per_tkm(page, countries):
sep=" |,",
engine="python",
index_col=False,
encoding=encoding,
)
sc = tbl.read_pdf(
@ -48,6 +56,7 @@ def get_cost_per_tkm(page, countries):
pages=page,
multiple_tables=False,
pandas_options=pandas_options,
encoding=encoding,
)[0]
sc.index = countries
sc.columns = sc.columns.str.replace("", "EUR")