Skip to content

Commit

Permalink
Merge pull request #161 from pypsa-meets-earth/carriers_residential
Browse files Browse the repository at this point in the history
Carriers residential
  • Loading branch information
hazemakhalek authored Dec 30, 2022
2 parents d59e30d + 10b4aa3 commit 22dc2ec
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
30 changes: 15 additions & 15 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,21 @@ rule prepare_sector_network:
"scripts/prepare_sector_network.py"


# rule add_export:
# input:
# overrides="data/override_component_attrs",
# ports="data/ports.csv",
# network=RDIR
# + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc",
# shapes_path=pypsaearth(
# "resources/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson"
# ),
# output:
# RDIR
# + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_export.nc",
# # TODO output file name must be adjusted and integrated in workflow
# script:
# "scripts/add_export.py"
rule add_export:
input:
overrides="data/override_component_attrs",
ports="data/ports.csv",
network=RDIR
+ "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc",
shapes_path=pypsaearth(
"resources/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson"
),
output:
RDIR
+ "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_export.nc",
# TODO output file name must be adjusted and integrated in workflow
script:
"scripts/add_export.py"


rule override_respot:
Expand Down
8 changes: 4 additions & 4 deletions data/energy_totals_DF_2030.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
country,total residential space,electricity residential space,total residential water,electricity residential water,total residential cooking,electricity residential cooking,total residential,electricity residential,derived heat residential,thermal uses residential,total services space,electricity services space,total services water,electricity services water,total services cooking,electricity services cooking,total services,electricity services,derived heat services,thermal uses services,total agriculture electricity,total agriculture heat,total agriculture machinery,total agriculture,total road,electricity road,total two-wheel,total passenger cars,electricity passenger cars,total other road passenger,electricity other road passenger,total light duty road freight,electricity light duty road freight,total heavy duty road freight,total rail,electricity rail,total rail passenger,electricity rail passenger,total rail freight,electricity rail freight,total aviation passenger,total aviation freight,total domestic aviation passenger,total international aviation passenger,total domestic aviation freight,total international aviation freight,total domestic aviation,total international aviation,total domestic navigation,district heat share,total international navigation,services electricity,agriculture electricity,agriculture oil
MA,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432
NG,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432
BJ,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432
country,total residential space,electricity residential space,total residential water,electricity residential water,total residential cooking,electricity residential cooking,total residential,electricity residential,derived heat residential,thermal uses residential,total services space,electricity services space,total services water,electricity services water,total services cooking,electricity services cooking,total services,electricity services,derived heat services,thermal uses services,total agriculture electricity,total agriculture heat,total agriculture machinery,total agriculture,total road,electricity road,total two-wheel,total passenger cars,electricity passenger cars,total other road passenger,electricity other road passenger,total light duty road freight,electricity light duty road freight,total heavy duty road freight,total rail,electricity rail,total rail passenger,electricity rail passenger,total rail freight,electricity rail freight,total aviation passenger,total aviation freight,total domestic aviation passenger,total international aviation passenger,total domestic aviation freight,total international aviation freight,total domestic aviation,total international aviation,total domestic navigation,district heat share,total international navigation,services electricity,agriculture electricity,agriculture oil,residential oil,residential biomass
MA,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432,3.6, 2.7
NG,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432,3.6, 2.7
BJ,4.2,0.28,7.3,0.23,4.9,3.3,23.31,8.03,,,,,,,,,15.89,9.13,,,4.91,0,,12.03,64.23,,,,,,,,,,,,,,,,,,,,,,0.39,8.93,10.32,,1.32,3.321242,3.66435234,5.344235432,3.6, 2.7
4 changes: 2 additions & 2 deletions data/energy_totals_NZ_2030.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
country,total residential space,electricity residential space,total residential water,electricity residential water,total residential cooking,electricity residential cooking,total residential,electricity residential,derived heat residential,thermal uses residential,total services space,electricity services space,total services water,electricity services water,total services cooking,electricity services cooking,total services,electricity services,derived heat services,thermal uses services,total agriculture electricity,total agriculture heat,total agriculture machinery,total agriculture,total road,electricity road,total two-wheel,total passenger cars,electricity passenger cars,total other road passenger,electricity other road passenger,total light duty road freight,electricity light duty road freight,total heavy duty road freight,total rail,electricity rail,total rail passenger,electricity rail passenger,total rail freight,electricity rail freight,total aviation passenger,total aviation freight,total domestic aviation passenger,total international aviation passenger,total domestic aviation freight,total international aviation freight,total domestic aviation,total international aviation,total domestic navigation,district heat share,total international navigation,services electricity,agriculture electricity, agriculture oil
MA,5.766916119,0.342850196,8.711837404,0.517929358,6.345549244,3.965968278,26.79420503,22.8,,,,,,,,,18.12963843,10.87778306,,,5.893436668,0,,14.73359167,71.52182725,8.960706721,0.246818419,44.53787907,5.11363105,1.090110939,0.178445734,2.433799832,0.280386662,23.21321899,3.378036398,1.194635708,1.818410082,0.799396967,1.559626316,0.395238741,,,0.507593252,,,,0.507593252,11.2666949,11.83967678,,1.82134562,3.321242,3.66,5.3
country,total residential space,electricity residential space,total residential water,electricity residential water,total residential cooking,electricity residential cooking,total residential,electricity residential,derived heat residential,thermal uses residential,total services space,electricity services space,total services water,electricity services water,total services cooking,electricity services cooking,total services,electricity services,derived heat services,thermal uses services,total agriculture electricity,total agriculture heat,total agriculture machinery,total agriculture,total road,electricity road,total two-wheel,total passenger cars,electricity passenger cars,total other road passenger,electricity other road passenger,total light duty road freight,electricity light duty road freight,total heavy duty road freight,total rail,electricity rail,total rail passenger,electricity rail passenger,total rail freight,electricity rail freight,total aviation passenger,total aviation freight,total domestic aviation passenger,total international aviation passenger,total domestic aviation freight,total international aviation freight,total domestic aviation,total international aviation,total domestic navigation,district heat share,total international navigation,services electricity,agriculture electricity,agriculture oil,residential oil,residential biomass
MA,5.766916119,0.342850196,8.711837404,0.517929358,6.345549244,3.965968278,26.79420503,22.8,,,,,,,,,18.12963843,10.87778306,,,5.893436668,0,,14.73359167,71.52182725,8.960706721,0.246818419,44.53787907,5.11363105,1.090110939,0.178445734,2.433799832,0.280386662,23.21321899,3.378036398,1.194635708,1.818410082,0.799396967,1.559626316,0.395238741,,,0.507593252,,,,0.507593252,11.2666949,11.83967678,,1.82134562,3.321242,3.66,5.3, 3.1, 2.2
39 changes: 39 additions & 0 deletions scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,43 @@ def add_agriculture(n, costs):
)


def add_residential(n, costs):

# TODO make compatible with more counties
profile_residential = n.loads_t.p_set[nodes] / n.loads_t.p_set[nodes].sum().sum()

p_set_oil = (
profile_residential
* energy_totals.loc[countries, "residential oil"].sum()
* 1e6
/ 8760
)
p_set_biomass = (
profile_residential
* energy_totals.loc[countries, "residential biomass"].sum()
* 1e6
/ 8760
)

n.madd(
"Load",
nodes,
suffix=" residential",
bus=spatial.oil.nodes,
carrier="residential oil",
p_set=p_set_oil,
)

n.madd(
"Load",
nodes,
suffix=" residential",
bus=spatial.biomass.nodes,
carrier="residential biomass",
p_set=p_set_oil,
)


if __name__ == "__main__":
if "snakemake" not in globals():
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -2152,6 +2189,8 @@ def add_agriculture(n, costs):

add_agriculture(n, costs)

add_residential(n, costs)

sopts = snakemake.wildcards.sopts.split("-")

for o in sopts:
Expand Down

0 comments on commit 22dc2ec

Please sign in to comment.