Problem with PyPSA-EUR-SEC add_base_year

108 views
Skip to first unread message

Erik Rathje

unread,
Dec 8, 2020, 10:06:06 AM12/8/20
to pypsa
Hello everyone,

I'm trying to run PyPSA-Eur-Sec with myopic on a windows machine and the workflow always stops at the rule add_base_year. The error code looks like:

rule add_existing_baseyear:
    input: results/your-run-name/prenetworks/elec_s_3_lv1.0__Co2L0-3H-T-H-B-I-solar3-dist1_2020.nc, D:\Uni Archiv\Masterarbeit\PyPSA Data\pypsa-eur\resources/powerplants.csv, D:\Uni Archiv\Masterarbeit\PyPSA Data\pypsa-eur\resources/busmap_elec_s.csv, D:\Uni Archiv\Masterarbeit\PyPSA Data\pypsa-eur\resources/busmap_elec_s_3.csv, resources/pop_layout_elec_s_3.csv, ../technology-data/outputs/costs_2020.csv, resources/cop_soil_total_elec_s_3.nc, resources/cop_air_total_elec_s_3.nc
    output: results/your-run-name/prenetworks-brownfield/elec_s_3_lv1.0__Co2L0-3H-T-H-B-I-solar3-dist1_2020.nc
    jobid: 2
    wildcards: network=elec, simpl=, clusters=3, lv=1.0, opts=, sector_opts=Co2L0-3H-T-H-B-I-solar3-dist1, planning_horizons=2020
    resources: mem_mb=2000

INFO:pypsa.io:Imported network elec_s_3_lv1.0__Co2L0-3H-T-H-B-I-solar3-dist1_2020.nc has buses, carriers, generators, global_constraints, lines, links, loads, storage_units, stores
adding power capacities installed before baseyear
Traceback (most recent call last):
  File "D:\Uni Archiv\Masterarbeit\PyPSA Data\pypsa-eur-sec\.snakemake\scripts\tmp2uww12ey.add_existing_baseyear.py", line 452, in <module>
    add_power_capacities_installed_before_baseyear(n, grouping_years, costs, baseyear)
  File "D:\Uni Archiv\Masterarbeit\PyPSA Data\pypsa-eur-sec\.snakemake\scripts\tmp2uww12ey.add_existing_baseyear.py", line 188, in add_power_capacities_installed_before_baseyear
    df_agg["grouping_year"] = np.take(grouping_years,
  File "<__array_function__ internals>", line 5, in take
  File "C:\Users\ErikR\anaconda3\envs\pypsa-eur\lib\site-packages\numpy\core\fromnumeric.py", line 191, in take
    return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
  File "C:\Users\ErikR\anaconda3\envs\pypsa-eur\lib\site-packages\numpy\core\fromnumeric.py", line 55, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "C:\Users\ErikR\anaconda3\envs\pypsa-eur\lib\site-packages\numpy\core\fromnumeric.py", line 44, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
IndexError: index 9 is out of bounds for axis 0 with size 9
[Tue Dec  8 15:48:04 2020]
Error in rule add_existing_baseyear:
    jobid: 2
    output: results/your-run-name/prenetworks-brownfield/elec_s_3_lv1.0__Co2L0-3H-T-H-B-I-solar3-dist1_2020.nc

I've tried several versions of PyPSA-Eur and PyPSA-Eur-Sec to assure that the Problem is not Version based and it's reproducible. 

Because of my RAM I'm running PyPSA with only one country (Germany), but I've tested it with three Countries as well and there the Problem still occurs. 

In the Config I've just changed the Planning Horizon, Country Selection and Amount of Clusters.

I'm very grateful for any help.

Best wishes,

Erik

Erik Rathje

unread,
Dec 16, 2020, 7:15:32 AM12/16/20
to pypsa
Hello everyone,

now I've tried to run the myopic workflow with 37 clusters and all countries and the script still stops at line 184 in the add_existing_baseyear script

After some debugging in Spyder I recognize, that for all powerplants with conventional fueltypes (coal, lignite etc.) in the df_agg object the attribute "Year Commissioned" is not set yet (so the value ist NaN). 

The Powerplants with the NaN Years are represented with Index 9 in the digitize method, which is out of Index in the grouping years list (which is 0 to 8). So this is the origin of the error. 

Can someone tell me a solution for this issue? I could code something by myself, but I think this Behaviour of the Code is not intended.

Best wishes, 

Erik

martavict...@gmail.com

unread,
Dec 26, 2020, 2:21:01 PM12/26/20
to pypsa

Hello Erik,

The error is due to a change in the column name of the power plants database. Before the name was “YearCommissioned”, now it is “DataIn”.

I will create a pull request to correct this in the following days when I’m done reviewing other parts of the code. In the meanwhile, you can use the add_existing_baseyear script modified in this commit

cheers,

Marta

Reply all
Reply to author
Forward
0 new messages