Skip to content

Update amalgamator for municipal datasets #588

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

Merged
merged 10 commits into from
Jun 27, 2025
Merged

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 199
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?

@@ -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
@kndehaan
Copy link
Contributor

kndehaan commented Apr 7, 2025

This PR is a requirement for solving this issue

@louispt1
Copy link
Contributor

louispt1 commented Apr 7, 2025

This PR is a requirement for solving this issue

Do I need to look at this PR @kndehaan/ @kaskranenburgQ? If so I will add it to the dev sprint

@kndehaan
Copy link
Contributor

Postpone to update of regional datasets to 2023.

@louispt1 louispt1 self-assigned this Jun 5, 2025
@louispt1 louispt1 force-pushed the update-amalgamator branch 2 times, most recently from 6691c44 to 324e8c8 Compare June 5, 2025 09:53
Copy link
Contributor

@louispt1 louispt1 left a comment

Choose a reason for hiding this comment

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

I'm not sure about the modelling changes in this PR, but I've just rebased it and updated the round item values to use a 'smart floor' functionality.

Can you test if this works @kaskranenburgQ? Hopefully the comments are clear enough

@louispt1 louispt1 linked an issue Jun 11, 2025 that may be closed by this pull request
@louispt1 louispt1 force-pushed the update-amalgamator branch from 324e8c8 to 4375a54 Compare June 12, 2025 07:09
@louispt1 louispt1 force-pushed the update-amalgamator branch from b7cc0fa to b85ec4b Compare June 25, 2025 11:41
@louispt1 louispt1 force-pushed the update-amalgamator branch from b85ec4b to 32cbdfa Compare June 25, 2025 11:43
@louispt1 louispt1 merged commit 4edf0c4 into production Jun 27, 2025
1 check passed
@louispt1 louispt1 deleted the update-amalgamator branch June 27, 2025 07:25
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.

Rounding values amalgamator
4 participants