Skip to content

Commit

Permalink
update kba path year
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert John committed Oct 18, 2024
1 parent b42f78f commit f56db0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,18 @@ def allocate_evs_numbers():
-------
"""
# Import
kba_data = read_kba_data()
rs7_data = read_rs7_data()

for scenario_name in config.settings()["egon-data"]["--scenarios"]:
if scenario_name.startswith("status"):
year = int(scenario_name.split("status")[1])
year += 1
year = str(year)
else:
year = str(2020) # fallback
# Import
kba_data = read_kba_data(year=year)
rs7_data = read_rs7_data()

# Load scenario params
scenario_parameters = get_sector_parameters(
"mobility", scenario=scenario_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,21 @@
MVGD_MIN_COUNT = 3600 if TESTMODE_OFF else 150


def read_kba_data():
def read_kba_data(year=None):
"""Read KBA data from CSV"""
return pd.read_csv(
WORKING_DIR
/ egon.data.config.datasets()["emobility_mit"]["original_data"][
"sources"
]["KBA"]["file_processed"]
)
p = WORKING_DIR / egon.data.config.datasets()["emobility_mit"]["original_data"][
"sources"]["KBA"]["file_processed"]
if year:
try:
p.replace("YEAR", "2020")
return pd.read_csv(p)
except Exception as E:
print(f"Cannot read_csv for p {p} due to {E}")

# fallback default
p = WORKING_DIR / egon.data.config.datasets()["emobility_mit"]["original_data"][
"sources"]["KBA"]["file_processed"]
return pd.read_csv(p)


def read_rs7_data():
Expand Down

0 comments on commit f56db0d

Please sign in to comment.