Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update amalgamator for municipal datasets #588

Open
wants to merge 4 commits into
base: production
Choose a base branch
from

Conversation

kaskranenburgQ
Copy link
Contributor

@kaskranenburgQ kaskranenburgQ commented Mar 17, 2025

While updating the RES-regions to 2019 we encountered the following issues :

The Eemsdelta dataset had incorrect share values for useful demand per housing and period.

  1. The Eemsdelta dataset had incorrect share values for useful demand per housing and period.
  2. The combination method weighted_average doesn't work as desired when calculating with shares (example: all keys of parent group share_useful_demand_houses, since the resulting shares add up to >1.0.
  3. Excel rounding issue where summed value of group shares are for instance 1.0000000001 (this is for instance the case for parent group transport_road_electricity_distribution).

The first issue was fixed by updating the household shares in the Eemsdelta municipality and migrating this change on etlocal. --> This will be fixed in the data-update of the RES-regions

The second issue was fixed by altering the variable on which the combination method was called. For the combination method weighted_average to function correctly for shares, we need to specify one variable for the whole share group. We changed it to the sum of al households in the dataset for the households_heat share_in_useful_demand group.

The third issue was caused due to the rounding of the keys to 8 digits. We changed the round method to a floor method. With the floor method, when the total sum of the share group will become lower than 1.0, instead of higher. The difference will be attributed to the flexible share in the share group. This way, rounding to 8 digits will no longer lead to errors.

This PR fixes the last 2 issues and in addition I made an alteration on how the interconnector capacity is calculated, for the European datasets it makes sense to use the sum method, since we use the actual interconnector data for this capacity.
For Municipal datasets this value is set to 60 GW per municipality, to ensure the connection to the rest of the Dutch grid.
If we use the sum method for local datasets, the RES regions would end up with 100+ GW connections, which have a huge influence on the cost of the scenario.

Comment on lines 175 to 197
combination_method:
weighted_average:
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a comment concerning the combination method be useful here: explaining how we use the total number of residences?

@@ -47,7 +47,7 @@ def adjust_flexible_shares(dataset_c_values)

# Rounds values to 8 decimals and replaces nil with 0.0
Copy link
Member

@mabijkerk mabijkerk Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have changed the method from round to floor, shouldn't we update the comment as well?

@@ -39,7 +39,7 @@

it 'rounds values to 8 decimals and replaces nil with 0.0' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have changed the method from round to floor, shouldn't we update the comment as well?

@mabijkerk
Copy link
Member

With the floor method, when the total sum of the share group will become lower than 1.0, instead of higher. The difference will be attributed to the flexible share in the share group. This way, rounding to 8 digits will no longer lead to errors.

This I don't really get. Does this mean that there will be something like a 0.000000001 share attributed to the flexible share?

@mabijkerk
Copy link
Member

For Municipal datasets this value is set to 60 GW per municipality, to ensure the connection to the rest of the Dutch grid.
If we use the sum method for local datasets, the RES regions would end up with 100+ GW connections, which have a huge influence on the cost of the scenario.

Sure. I think in the future we should reconsider the 60 GW interconnector capacity per municipality value, but that's something for future improvement. It is also not really relevant for EU countries now, since we do not use the amalgamator for those. @louispt1 would this be relevant for the "subtracting" amalgamator - so the one for UK, GB and NI?

@kaskranenburgQ
Copy link
Contributor Author

This I don't really get. Does this mean that there will be something like a 0.000000001 share attributed to the flexible share?

Yes you are right!
An example with rounding on 2 decimals instead of 8:
Share_1: 0.425 --> 0.43
Share_2: 0.225 --> 0.23
Share_3: 0.350 --> 0.35
Share_4 (flexible_share): 0.0 --> 0.0
The sum becomes: 0.43+0.23+0.35= 1.01

Same example with floor rounding on 2 decimals:
Share_1: 0.425 --> 0.42
Share_2: 0.225 --> 0.22
Share_3: 0.350 --> 0.35
Share_4 (flexible_share): 0.0
The sum becomes: 0.43+0.23+0.35= 0.99
Due to flexible share balancing the distribution becomes:

Share_1: 0.42
Share_2: 0.22
Share_3: 0.35
Share_4 0.01

@kaskranenburgQ kaskranenburgQ marked this pull request as ready for review March 18, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants