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

Revision locate bus #1195

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

davide-f
Copy link
Member

@davide-f davide-f commented Nov 14, 2024

Closes # (if applicable).

Changes proposed in this Pull Request

This PR proposes a revision of the procedure used in locate_bus and adopt geospatial comparisons of geopandas. This methodology is heavier and has deep code implications; therefore, I quickly merged a fix to solve the CI first.

A similar approach can be also included into build_powerplants and cluster_network.
Currently, it is adopted in the sector scripts where more outliers have been founded

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.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • 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.

@davide-f davide-f marked this pull request as ready for review November 14, 2024 19:29
Copy link
Member

@ekatef ekatef left a comment

Choose a reason for hiding this comment

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

Brilliant work @davide-f!!

Have gone trough the changes and added some comments which are mainly quite minor. The only potentially crucial point is changing arguments of mock_snakemake, but I assume there has been a reason for that. All the other points can be also addressed in future PRs if you feel that improvements would take too much time for now.

Thanks a lot for investigating that, and looking forward to see CI running! 😄

scripts/_helpers.py Show resolved Hide resolved
Comment on lines +1206 to +1213
col = "name"
if not gadm_clustering:
gdf_shapes = gpd.read_file(path_to_gadm)
else:
if path_to_gadm:
gdf_shapes = gpd.read_file(path_to_gadm)
if "GADM_ID" in gdf_shapes.columns:
col = "GADM_ID"
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it's really easy this part with four nested if-conditions. Agree that it's not the point to be addressed now, as the fix is quite urgent, but could we probably add a TODO for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Completely agree; this is to maintain the features of the previous code.
To revise this I believe there is the need to revise this together with the revision of the alternative clustering procedure.
Good to add a TODO

Comment on lines +1259 to +1262
df = df[df.country.isin(countries)]
df[col_out] = None
for co in countries:
gdf_shape, col = _get_shape_col_gdf(
Copy link
Member

Choose a reason for hiding this comment

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

I recognise that it may be opening Pandora box, but wouldn't it be possible to replace naming for df and col with something a bit more specific? To my perception, it could probably facilitate a bit reading of the code. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll try :)

Comment on lines 30 to 32
Only cement not steel - proof of concept.
Change hotmaps to more descriptive name, etc.
"""
Copy link
Member

Choose a reason for hiding this comment

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

A docstring of map_industry_to_buses( ) seems to be a bit outdated. May it be a good idea to fix it?

scripts/build_industrial_distribution_key.py Outdated Show resolved Hide resolved
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.

2 participants