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

Drop non string entries in country column of CO2_emissions data in prepare_transport_data_input #1166

Merged
merged 7 commits into from
Nov 12, 2024

Conversation

yerbol-akhmetov
Copy link
Collaborator

@yerbol-akhmetov yerbol-akhmetov commented Nov 4, 2024

Changes proposed in this Pull Request

Good day. Here I propose to update download_co2_emissions function in prepare_transport_data_input.py script to drop entries where country column contains not string. This issue appeared very recently, as I have noticed it in the CI check. Great thanks for @finozzifa, who pointed out the error location and proposed the solution.

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.
  • 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.

@yerbol-akhmetov yerbol-akhmetov marked this pull request as ready for review November 5, 2024 10:21
@yerbol-akhmetov
Copy link
Collaborator Author

Hi, @hazemakhalek. Can you please review the bug fix provided in this PR? Currently CI fails due to that too.

@hazemakhalek
Copy link
Collaborator

Hi Yerbol, this part I believe is legacy code that is not used anymore. Can you please confirm that in prepare_sector_network.py (this should be the only script we use this output file) and then we can omit the part of the emissions here altogether?

@yerbol-akhmetov
Copy link
Collaborator Author

Hi Yerbol, this part I believe is legacy code that is not used anymore. Can you please confirm that in prepare_sector_network.py (this should be the only script we use this output file) and then we can omit the part of the emissions here altogether?

Hi, @hazemakhalek. I have checked the prepare_transport_data_input rule. Its output is used in prepare_transport_data. This rule has an output of transport data (resources/demand/transport_...), which is used in prepare_sector_network rule to define the demand for land transport (using add_land_transport). I think it is not redundant, no?

@hazemakhalek
Copy link
Collaborator

Hi Yerbol, thanks for taking the time to check it. I meant only the CO2 emission part, not the whole file. Is it still being used in prepare_sector_network?

@yerbol-akhmetov
Copy link
Collaborator Author

yerbol-akhmetov commented Nov 6, 2024

Hi Yerbol, thanks for taking the time to check it. I meant only the CO2 emission part, not the whole file. Is it still being used in prepare_sector_network?

Sorry @hazemakhalek for not mentioning, CO2_emissions_csv data have average_fuel_efficiency column, which is used in further rule prepare_transport_data:

transport_data = pd.read_csv(
snakemake.input.transport_name, index_col=0, keep_default_na=False
)
nodal_transport_data = transport_data.reindex(pop_layout.ct, fill_value=0.0)
nodal_transport_data.index = pop_layout.index
nodal_transport_data["number cars"] = (
pop_layout["fraction"] * nodal_transport_data["number cars"]
)
nodal_transport_data.loc[
nodal_transport_data["average fuel efficiency"] == 0.0,
"average fuel efficiency",
] = transport_data["average fuel efficiency"].mean()

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.

Added a comment; what do you think?

scripts/prepare_transport_data_input.py Show resolved Hide resolved
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 @yerbol-akhmetov and thanks for the clarification.
A minor stylistic comment, ready to merge right after

scripts/prepare_transport_data_input.py Outdated Show resolved Hide resolved
@davide-f davide-f merged commit 2c7cbdb into pypsa-meets-earth:main Nov 12, 2024
2 of 4 checks passed
@davide-f
Copy link
Member

Many thanks :D merged :)

@yerbol-akhmetov yerbol-akhmetov deleted the fix_co2_emissions branch November 12, 2024 18:52
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