pypsa-meets-earth / pypsa-earth-sec

GNU General Public License v3.0
24 stars 20 forks source link

IndexError in prepare_gas_network #325

Closed doneachh closed 4 months ago

doneachh commented 5 months ago

Checklist

Describe the Bug

I receive in the following code the IdexError geodf_temp["GADM_ID"] = geodftemp[f"GID{cur_layer_id}"].apply( lambda x: x if x[3] == "." else x[:3] + "." + x[3:] )

geodf_temp is the following dataframe: GID_0 COUNTRY geometry 0 BI Burundi MULTIPOLYGON (((30.04515 -4.25684, 30.04523 -4...

--> GID_0 has no third char --> string index out of range

Error Message


Ausnahme: IndexError
string index out of range
  File "/mnt/l/Git/Africa/pypsa-earth-sec/scripts/prepare_gas_network.py", line 465, in <lambda>
    lambda x: x if x[3] == "." else x[:3] + "." + x[3:]
  File "/mnt/l/Git/Africa/pypsa-earth-sec/scripts/prepare_gas_network.py", line 464, in get_GADM_layer
    geodf_temp["GADM_ID"] = geodf_temp[f"GID_{cur_layer_id}"].apply(
  File "/mnt/l/Git/Africa/pypsa-earth-sec/scripts/prepare_gas_network.py", line 491, in gadm
    df_gadm = get_GADM_layer(countries, layer_id, geo_crs, contended_flag, update)
  File "/mnt/l/Git/Africa/pypsa-earth-sec/scripts/prepare_gas_network.py", line 551, in load_bus_region
    bus_regions_onshore = gadm(
  File "/mnt/l/Git/Africa/pypsa-earth-sec/scripts/prepare_gas_network.py", line 903, in <module>
    bus_regions_onshore = load_bus_region(snakemake.input.regions_onshore, pipelines)[0]
IndexError: string index out of range```
davide-f commented 5 months ago

Thanks for reporting! Can you add more details here? How is that possible?

doneachh commented 5 months ago

@davide-f answered it in the PR - if you need more details, hmu :)