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

Add option to adjust load scale for each individual countries #1006

Merged
merged 8 commits into from
Apr 30, 2024

Conversation

virio-andreyana
Copy link
Contributor

@virio-andreyana virio-andreyana commented Apr 19, 2024

Closes # (if applicable).

Changes proposed in this Pull Request

Add option to individually adjust load scale for each country. The code format in the config is the same as focus_weights.

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

logger.info(f"Load data scaled with scaling factor {scale}.")
gegis_load["Electricity demand"] *= scale

if scale is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Great that you have thought about edge cases! However, not sure this particular check makes sense, as if scale is not defined it would cause an error earlier, at

scale = snakemake.params.load_options["scale"]
So, I'd remove this check which would also make the code easier to read. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I agree

@ekatef
Copy link
Member

ekatef commented Apr 21, 2024

Hello @virio-andreyana! An amazing idea and very nice implementation. I have only one comment on it. Otherwise, looks perfect 🙂

Copy link
Member

@davide-f davide-f left a comment

Choose a reason for hiding this comment

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

Great contributions @virio-andreyana :D and very interesting indeed!
I've added few comments.
It would be great to have your opinion on this little changes :)

logger.info(f"Load data scaled with scaling factor {scale}.")
gegis_load["Electricity demand"] *= scale

if scale is not None:
Copy link
Member

Choose a reason for hiding this comment

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

I agree

gegis_load["Electricity demand"] *= scale

if scale is not None:
if isinstance(scale, dict):
Copy link
Member

Choose a reason for hiding this comment

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

It may be useful to have a "DEFAULT" code, as in some cases, we may like only to describe a subset of users.
In the case it is a dict, I'd read a "DEFAULT" code (with .get("DEFAULT", 1.0)) and use this value for all countries that are not in the list.
What do you think?

@@ -246,7 +257,7 @@ def upsample(cntry, group):
load_paths = snakemake.input["load"]
countries = snakemake.params.countries
admin_shapes = snakemake.input.gadm_shapes
scale = snakemake.params.load_options["scale"]
scale = snakemake.params.load_options.get("scale")
Copy link
Member

Choose a reason for hiding this comment

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

We could do .get("scale", 1.0) to avoid the None case

virio-andreyana and others added 3 commits April 29, 2024 14:28
@pz-max
Copy link
Member

pz-max commented Apr 30, 2024

@virio-andreyana is next me. PR is ready to merge.

@davide-f davide-f merged commit a4fe0ea into pypsa-meets-earth:main Apr 30, 2024
5 checks passed
@virio-andreyana virio-andreyana deleted the custom-scale-factor branch June 24, 2024 16:14
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.

4 participants