Closed rouille closed 1 year ago
@FabianHofmann, can you have a look at this. Thanks!
I believe, this should be ready to be merged.
As discussed with @jenhagg, one potential issue is we only have load zone tag for load buses but not for all buses. I believe it should be fine when running base grid without change table. We might need to revisit this to give all buses load zone tags to make full change table schema work.
My understanding is that the substations bear the same name and coordinates than the load buses and and all buses are connected to a substation. Therefore you get the mapping with:
>>> from powersimdata import Grid
>>> entso = Grid("Europe", source="europe_tub", reduction=128)
Title: PyPSA-Eur: An Open Optimisation Model of the European Transmission System (Dataset)
Publication date: 2022-09-20
Version: v0.6.1
DOI: 10.5281/zenodo.7251657
networks.zip has been downloaded previously
WARNING:pypsa.io:Importing network from PyPSA version v0.20.0 while current version is v0.21.2. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import.
INFO:pypsa.io:Imported network elec_s_128_ec.nc has buses, carriers, generators, lines, links, loads, storage_units, stores
>>> entso.sub
name interconnect_sub_id lat lon interconnect pypsa_y pypsa_x
sub_id
AL1 0 NaN NaN 41.587568 19.897914 NaN 41.587568 19.897914
AT1 0 NaN NaN 47.354096 11.237535 NaN 47.354096 11.237535
AT1 1 NaN NaN 47.671625 15.083487 NaN 47.671625 15.083487
BA1 0 NaN NaN 43.811367 18.122704 NaN 43.811367 18.122704
BE1 0 NaN NaN 51.005779 4.451911 NaN 51.005779 4.451911
... ... ... ... ... ... ... ...
SE2 2 NaN NaN 63.114629 16.174075 NaN 63.114629 16.174075
SE2 3 NaN NaN 67.551535 18.179626 NaN 67.551535 18.179626
SE2 4 NaN NaN 59.851523 16.888635 NaN 59.851523 16.888635
SI1 0 NaN NaN 46.071068 14.693952 NaN 46.071068 14.693952
SK1 0 NaN NaN 48.653333 19.027888 NaN 48.653333 19.027888
[128 rows x 7 columns]
>>> entso.bus2sub
sub_id interconnect
bus_id
AL1 0 AL1 0 NaN
AT1 0 AT1 0 NaN
AT1 1 AT1 1 NaN
BA1 0 BA1 0 NaN
BE1 0 BE1 0 NaN
... ... ...
SE2 2 hydro SE2 2 NaN
SE2 3 hydro SE2 3 NaN
SE2 4 hydro SE2 4 NaN
SI1 0 hydro SI1 0 NaN
SK1 0 hydro SK1 0 NaN
[457 rows x 2 columns]
My understanding is that the substations bear the same name and coordinates than the load buses and and all buses are connected to a substation. Therefore you get the mapping with:
>>> from powersimdata import Grid >>> entso = Grid("Europe", source="europe_tub", reduction=128) Title: PyPSA-Eur: An Open Optimisation Model of the European Transmission System (Dataset) Publication date: 2022-09-20 Version: v0.6.1 DOI: 10.5281/zenodo.7251657 networks.zip has been downloaded previously WARNING:pypsa.io:Importing network from PyPSA version v0.20.0 while current version is v0.21.2. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import. INFO:pypsa.io:Imported network elec_s_128_ec.nc has buses, carriers, generators, lines, links, loads, storage_units, stores >>> entso.sub name interconnect_sub_id lat lon interconnect pypsa_y pypsa_x sub_id AL1 0 NaN NaN 41.587568 19.897914 NaN 41.587568 19.897914 AT1 0 NaN NaN 47.354096 11.237535 NaN 47.354096 11.237535 AT1 1 NaN NaN 47.671625 15.083487 NaN 47.671625 15.083487 BA1 0 NaN NaN 43.811367 18.122704 NaN 43.811367 18.122704 BE1 0 NaN NaN 51.005779 4.451911 NaN 51.005779 4.451911 ... ... ... ... ... ... ... ... SE2 2 NaN NaN 63.114629 16.174075 NaN 63.114629 16.174075 SE2 3 NaN NaN 67.551535 18.179626 NaN 67.551535 18.179626 SE2 4 NaN NaN 59.851523 16.888635 NaN 59.851523 16.888635 SI1 0 NaN NaN 46.071068 14.693952 NaN 46.071068 14.693952 SK1 0 NaN NaN 48.653333 19.027888 NaN 48.653333 19.027888 [128 rows x 7 columns] >>> entso.bus2sub sub_id interconnect bus_id AL1 0 AL1 0 NaN AT1 0 AT1 0 NaN AT1 1 AT1 1 NaN BA1 0 BA1 0 NaN BE1 0 BE1 0 NaN ... ... ... SE2 2 hydro SE2 2 NaN SE2 3 hydro SE2 3 NaN SE2 4 hydro SE2 4 NaN SI1 0 hydro SI1 0 NaN SK1 0 hydro SK1 0 NaN [457 rows x 2 columns]
Exactly.
My understanding is that the substations bear the same name and coordinates than the load buses and and all buses are connected to a substation. Therefore you get the mapping with:
>>> from powersimdata import Grid >>> entso = Grid("Europe", source="europe_tub", reduction=128) Title: PyPSA-Eur: An Open Optimisation Model of the European Transmission System (Dataset) Publication date: 2022-09-20 Version: v0.6.1 DOI: 10.5281/zenodo.7251657 networks.zip has been downloaded previously WARNING:pypsa.io:Importing network from PyPSA version v0.20.0 while current version is v0.21.2. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import. INFO:pypsa.io:Imported network elec_s_128_ec.nc has buses, carriers, generators, lines, links, loads, storage_units, stores >>> entso.sub name interconnect_sub_id lat lon interconnect pypsa_y pypsa_x sub_id AL1 0 NaN NaN 41.587568 19.897914 NaN 41.587568 19.897914 AT1 0 NaN NaN 47.354096 11.237535 NaN 47.354096 11.237535 AT1 1 NaN NaN 47.671625 15.083487 NaN 47.671625 15.083487 BA1 0 NaN NaN 43.811367 18.122704 NaN 43.811367 18.122704 BE1 0 NaN NaN 51.005779 4.451911 NaN 51.005779 4.451911 ... ... ... ... ... ... ... ... SE2 2 NaN NaN 63.114629 16.174075 NaN 63.114629 16.174075 SE2 3 NaN NaN 67.551535 18.179626 NaN 67.551535 18.179626 SE2 4 NaN NaN 59.851523 16.888635 NaN 59.851523 16.888635 SI1 0 NaN NaN 46.071068 14.693952 NaN 46.071068 14.693952 SK1 0 NaN NaN 48.653333 19.027888 NaN 48.653333 19.027888 [128 rows x 7 columns] >>> entso.bus2sub sub_id interconnect bus_id AL1 0 AL1 0 NaN AT1 0 AT1 0 NaN AT1 1 AT1 1 NaN BA1 0 BA1 0 NaN BE1 0 BE1 0 NaN ... ... ... SE2 2 hydro SE2 2 NaN SE2 3 hydro SE2 3 NaN SE2 4 hydro SE2 4 NaN SI1 0 hydro SI1 0 NaN SK1 0 hydro SK1 0 NaN [457 rows x 2 columns]
Exactly.
All the buses belong to one and only one load zone then:
>>> len(set(entso.bus2sub.sub_id))
128
so we should be fine.
@rouille So we already have zone_id
for all buses in the bus table based on the mappings between load buses and substations?
@rouille So we already have
zone_id
for all buses in the bus table based on the mappings between load buses and substations?
Yes, you can do that:
>>> entso.bus
type Pd Qd Gs Bs zone_id ... pypsa_type pypsa_unit pypsa_v_mag_pu_set pypsa_v_mag_pu_min pypsa_v_mag_pu_max pypsa_sub_network
bus_id ...
AL1 0 3 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf
AT1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf
AT1 1 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf
BA1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf
BE1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf
... ... .. .. .. .. ... ... ... ... ... ... ... ...
SE2 2 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN
SE2 3 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN
SE2 4 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN
SI1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN
SK1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN
[457 rows x 32 columns]
>>> entso.model_immutables.zones["loadzone2country"][entso.bus2sub.loc["SK1 0 hydro", "sub_id"]]
'Slovakia'
>>> entso.model_immutables.zones["loadzone2interconnect"][entso.bus2sub.loc["BE1 0", "sub_id"]]
'ContinentalEurope'
@rouille So we already have
zone_id
for all buses in the bus table based on the mappings between load buses and substations?Yes, you can do that:
>>> entso.bus type Pd Qd Gs Bs zone_id ... pypsa_type pypsa_unit pypsa_v_mag_pu_set pypsa_v_mag_pu_min pypsa_v_mag_pu_max pypsa_sub_network bus_id ... AL1 0 3 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 1 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BA1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BE1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf ... ... .. .. .. .. ... ... ... ... ... ... ... ... SE2 2 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 3 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 4 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SI1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SK1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN [457 rows x 32 columns] >>> entso.model_immutables.zones["loadzone2country"][entso.bus2sub.loc["SK1 0 hydro", "sub_id"]] 'Slovakia' >>> entso.model_immutables.zones["loadzone2interconnect"][entso.bus2sub.loc["BE1 0", "sub_id"]] 'ContinentalEurope'
Yes, I understand we have the mappings in model_immutables
set properly via sub_id
. I'm referring to the zone_id
column of the bus table being NaN
. The zone_id
column of other tables, such as plant
relies on the one in the bus table, see here.
@rouille So we already have
zone_id
for all buses in the bus table based on the mappings between load buses and substations?Yes, you can do that:
>>> entso.bus type Pd Qd Gs Bs zone_id ... pypsa_type pypsa_unit pypsa_v_mag_pu_set pypsa_v_mag_pu_min pypsa_v_mag_pu_max pypsa_sub_network bus_id ... AL1 0 3 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 1 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BA1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BE1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf ... ... .. .. .. .. ... ... ... ... ... ... ... ... SE2 2 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 3 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 4 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SI1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SK1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN [457 rows x 32 columns] >>> entso.model_immutables.zones["loadzone2country"][entso.bus2sub.loc["SK1 0 hydro", "sub_id"]] 'Slovakia' >>> entso.model_immutables.zones["loadzone2interconnect"][entso.bus2sub.loc["BE1 0", "sub_id"]] 'ContinentalEurope'
Yes, I understand we have the mappings in
model_immutables
set properly viasub_id
. I'm referring to thezone_id
column of the bus table beingNaN
. Thezone_id
column of other tables, such asplant
relies on the one in the bus table, see here.
Sorry I misunderstood. You are right, we need to add zone_id
to bus
, zone_id
/zone_name
to plant
, from_zone_id
/to_zone_id
/from_zone_name
/to_zone_name
to branch
and from_interconnect
/to_interconnect
to dcline
. It can be done in this PR or in a following one. What do you prefer?
@rouille So we already have
zone_id
for all buses in the bus table based on the mappings between load buses and substations?Yes, you can do that:
>>> entso.bus type Pd Qd Gs Bs zone_id ... pypsa_type pypsa_unit pypsa_v_mag_pu_set pypsa_v_mag_pu_min pypsa_v_mag_pu_max pypsa_sub_network bus_id ... AL1 0 3 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf AT1 1 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BA1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf BE1 0 1 NaN NaN NaN NaN NaN ... None 1.0 0.0 inf ... ... .. .. .. .. ... ... ... ... ... ... ... ... SE2 2 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 3 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SE2 4 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SI1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN SK1 0 hydro 1 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN [457 rows x 32 columns] >>> entso.model_immutables.zones["loadzone2country"][entso.bus2sub.loc["SK1 0 hydro", "sub_id"]] 'Slovakia' >>> entso.model_immutables.zones["loadzone2interconnect"][entso.bus2sub.loc["BE1 0", "sub_id"]] 'ContinentalEurope'
Yes, I understand we have the mappings in
model_immutables
set properly viasub_id
. I'm referring to thezone_id
column of the bus table beingNaN
. Thezone_id
column of other tables, such asplant
relies on the one in the bus table, see here.Sorry I misunderstood. You are right, we need to add
zone_id
tobus
,zone_id
/zone_name
toplant
,from_zone_id
/to_zone_id
/from_zone_name
/to_zone_name
tobranch
andfrom_interconnect
/to_interconnect
todcline
. It can be done in this PR or in a following one. What do you prefer?
🙏 Either way. We can merge this first then.
Pull Request doc
Purpose
Use load buses instead of buses as load zone
What the code is doing
N/A
Testing
Existing unit tests
Where to look
Load buses are used for geographical mappings. The number of load buses now matches the number of nodes of the network as given by the reduction parameter (see below)
Usage Example/Visuals
Time estimate
2min