PyPSA / pypsa-eur

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System
https://pypsa-eur.readthedocs.io/
341 stars 239 forks source link

Bug in "add_heating_capacities_installed_before_baseyear" #1301

Open cerealice opened 1 month ago

cerealice commented 1 month ago

Describe the Bug

When running a myopic forecast for the year 2050 there is a bug when in the script "add_existing_baseyear.py".

            valid_grouping_years = pd.Series(
                [
                    int(grouping_year)
                    for grouping_year in grouping_years
                    if int(grouping_year) + default_lifetime > int(baseyear)
                    and int(grouping_year) < int(baseyear)
                ]

int(grouping_year) + default_lifetime is lowe than int(baseyear), so the result is an empty pandas series that gives an error in the following lines (see image below). I guess a fix could be a simple check if that variable is empty.
Parameters that changed in my config file (I ran a single nation but I see the same bug in other spatial configurations):

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#foresight
foresight: myopic

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#scenario
# Wildcard docs in https://pypsa-eur.readthedocs.io/en/latest/wildcards.html
scenario:
  ll:
  - vopt
  clusters:
  - 5
  opts:
  - ''
  sector_opts:
  - ''
  planning_horizons:
  # - 2020
  # - 2030
  # - 2040
  - 2050

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#countries
countries: ['IT']

Error Message

image

cerealice commented 1 month ago

@amos-schledorn