[x] I am using the current main branch or the latest release. Please indicate.
[x] I am running on an up-to-date pypsa-africa environment. Update via conda env update -f envs/environment.yaml.
Describe the Bug
As soon as we dont have certain data for a country, we run into a ZeroDivision Error. We need to find a way to prevent this.
Error Message
Traceback (most recent call last):
File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpxl0itesf.prepare_sector_network.py", line 2475, in <module>
add_residential(n, costs)
File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/.snakemake/scripts/tmpxl0itesf.prepare_sector_network.py", line 2228, in add_residential
n.loads_t.p_set.filter(like=country)[heat_buses]
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/ops/common.py", line 76, in new_method
return method(self, other)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/arraylike.py", line 210, in __truediv__
return self._arith_method(other, operator.truediv)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/frame.py", line 7644, in _arith_method
new_data = self._dispatch_frame_op(other, op, axis=axis)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/frame.py", line 7676, in _dispatch_frame_op
bm = self._mgr.apply(array_op, right=right)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 352, in apply
applied = b.apply(f, **kwargs)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/internals/blocks.py", line 366, in apply
result = func(self.values, **kwargs)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/ops/array_ops.py", line 285, in arithmetic_op
res_values = _na_arithmetic_op(left, right, op) # type: ignore[arg-type]
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/ops/array_ops.py", line 220, in _na_arithmetic_op
result = func(left, right)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/computation/expressions.py", line 242, in evaluate
return _evaluate(op, op_str, a, b) # type: ignore[misc]
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/computation/expressions.py", line 131, in _evaluate_numexpr
result = _evaluate_standard(op, op_str, a, b)
File "/home/aca39878/anaconda3/envs/pypsa-earth/lib/python3.10/site-packages/pandas/core/computation/expressions.py", line 73, in _evaluate_standard
return op(a, b)
ZeroDivisionError: float division by zero
[Thu Feb 1 13:17:13 2024]
INFO:snakemake.logging:[Thu Feb 1 13:17:13 2024]
Error in rule prepare_sector_network:
jobid: 6
input: results/test_h2_cons_yearly/prenetworks/elec_s_10_ec_lc1.0_Co2L_144H_2030_0.15_DF_presec.nc, data/costs_2030.csv, data/hydrogen_salt_cavern_potentials.csv, resources/demand/heat/nodal_energy_heat_totals_DF_s_10_2030.csv, 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, data/override_component_attrs, resources/population_shares/pop_layout_elec_s_10.csv, resources/demand/industrial_energy_demand_per_node_elec_s_10_2030_DF.csv, data/energy_totals_DF_2030.csv, data/airports.csv, data/ports.csv, resources/demand/heat/heat_demand_DF_s_10_2030.csv, resources/demand/heat/ashp_cop_DF_s_10_2030.csv, resources/demand/heat/gshp_cop_DF_s_10_2030.csv, resources/demand/heat/solar_thermal_DF_s_10_2030.csv, resources/demand/heat/district_heat_share_DF_s_10_2030.csv, data/temp_hard_coded/biomass_transport_costs.csv, /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/pypsa-earth/resources/bus_regions/regions_onshore_elec_s_10.geojson
output: results/test_h2_cons_yearly/prenetworks/elec_s_10_ec_lc1.0_Co2L_144H_2030_0.15_DF.nc
ERROR:snakemake.logging:Error in rule prepare_sector_network:
jobid: 6
input: results/test_h2_cons_yearly/prenetworks/elec_s_10_ec_lc1.0_Co2L_144H_2030_0.15_DF_presec.nc, data/costs_2030.csv, data/hydrogen_salt_cavern_potentials.csv, resources/demand/heat/nodal_energy_heat_totals_DF_s_10_2030.csv, 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, data/override_component_attrs, resources/population_shares/pop_layout_elec_s_10.csv, resources/demand/industrial_energy_demand_per_node_elec_s_10_2030_DF.csv, data/energy_totals_DF_2030.csv, data/airports.csv, data/ports.csv, resources/demand/heat/heat_demand_DF_s_10_2030.csv, resources/demand/heat/ashp_cop_DF_s_10_2030.csv, resources/demand/heat/gshp_cop_DF_s_10_2030.csv, resources/demand/heat/solar_thermal_DF_s_10_2030.csv, resources/demand/heat/district_heat_share_DF_s_10_2030.csv, data/temp_hard_coded/biomass_transport_costs.csv, /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/pypsa-earth/resources/bus_regions/regions_onshore_elec_s_10.geojson
output: results/test_h2_cons_yearly/prenetworks/elec_s_10_ec_lc1.0_Co2L_144H_2030_0.15_DF.nc
RuleException:
CalledProcessError in file /mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile, line 156:
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/tmpxl0itesf.prepare_sector_network.py' returned non-zero exit status 1.
File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile", line 156, in __rule_prepare_sector_network
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 156:
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/tmpxl0itesf.prepare_sector_network.py' returned non-zero exit status 1.
File "/mnt/c/Users/aca39878/Documents/Git/Namibia/pypsa-earth-sec/Snakefile", line 156, in __rule_prepare_sector_network
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```
Checklist
main
branch or the latest release. Please indicate.pypsa-africa
environment. Update viaconda env update -f envs/environment.yaml
.Describe the Bug
As soon as we dont have certain data for a country, we run into a ZeroDivision Error. We need to find a way to prevent this.
Error Message