pypsa-meets-earth / pypsa-earth-sec

GNU General Public License v3.0
19 stars 16 forks source link

KeyError 'Total rail' for namibia #271

Closed doneachh closed 4 months ago

doneachh commented 5 months ago

Checklist

Describe the Bug

There is no "Electricity - Consumption by rail" data in the UN Dataset for Namibia. We need to find a workaround for countries without the data in build_base_energy_totals.py

Error Message


Traceback (most recent call last):
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3791, in get_loc
    return self._engine.get_loc(casted_key)
  File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'total rail'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpt15_6wat.prepare_transport_data.py", line 242, in <module>
    ) = prepare_transport_data(n)
  File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpt15_6wat.prepare_transport_data.py", line 154, in prepare_transport_data
    + nodal_energy_totals["total rail"]
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/frame.py", line 3893, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3798, in get_loc
    raise KeyError(key) from err
KeyError: 'total rail'
[Tue Jan 30 15:38:25 2024]
INFO:snakemake.logging:[Tue Jan 30 15:38:25 2024]
Error in rule prepare_transport_data:
    jobid: 16
    input: /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/pypsa-earth/networks/elec_s_10.nc, data/energy_totals_DF_2030.csv, data/emobility/KFZ__count, data/emobility/Pkw__count, resources/transport_data.csv, resources/population_shares/pop_layout_elec_s_10.csv, resources/temperatures/temp_air_total_elec_s_10.nc
    output: resources/demand/transport_DF_s_10_2030.csv, resources/pattern_profiles/avail_profile_DF_s_10_2030.csv, resources/pattern_profiles/dsm_profile_DF_s_10_2030.csv, resources/demand/nodal_transport_data_DF_s_10_2030.csv

ERROR:snakemake.logging:Error in rule prepare_transport_data:
    jobid: 16
    input: /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/pypsa-earth/networks/elec_s_10.nc, data/energy_totals_DF_2030.csv, data/emobility/KFZ__count, data/emobility/Pkw__count, resources/transport_data.csv, resources/population_shares/pop_layout_elec_s_10.csv, resources/temperatures/temp_air_total_elec_s_10.nc
    output: resources/demand/transport_DF_s_10_2030.csv, resources/pattern_profiles/avail_profile_DF_s_10_2030.csv, resources/pattern_profiles/dsm_profile_DF_s_10_2030.csv, resources/demand/nodal_transport_data_DF_s_10_2030.csv

RuleException:
CalledProcessError in file /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile, line 225:
Command 'set -euo pipefail;  /home/aca39878/anaconda3/envs/pypsa-earth/bin/python3.10 /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpt15_6wat.prepare_transport_data.py' returned non-zero exit status 1.
  File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile", line 225, in __rule_prepare_transport_data
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/concurrent/futures/thread.py", line 58, in run
ERROR:snakemake.logging:RuleException:
CalledProcessError in file /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile, line 225:
Command 'set -euo pipefail;  /home/aca39878/anaconda3/envs/pypsa-earth/bin/python3.10 /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpt15_6wat.prepare_transport_data.py' returned non-zero exit status 1.
  File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile", line 225, in __rule_prepare_transport_data
  File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/concurrent/futures/thread.py", line 58, in run
Shutting down, this might take some time.
WARNING:snakemake.logging:Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message```