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 facades CommodityGHG and ConversionGHG #180

Merged
merged 19 commits into from
Aug 22, 2024
Merged

Conversation

SabineHaas
Copy link
Member

@SabineHaas SabineHaas commented Aug 9, 2024

Description

Fixes #165 and #177

  • Add new facades ConversionGHG and CommodityGHG which inherit of Conversion and Commodity
  • Parameters like marginal_costs stay associated with the flows they are associated with in Conversion and Commodity
  • Emission buses are defined by starting with 'emission_bus' e.g.: emission_bus_0, emission_bus_1 etc.
  • Emission factors are defined by the following naming convention: emission_factor_<label_of_emission_bus> , e.g.: emission_factor_co2 if the bus the emission flows to is labeled co2.

Type of change

Please tick or delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

Please tick or delete options that are not relevant.

  • New and adjusted code is formatted using the pre-commit hooks
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • If new packages are needed, I added them the setup.py
  • I have added new features/fixes to the CHANGELOG
  • I have added my name to AUTHORS

@SabineHaas SabineHaas self-assigned this Aug 9, 2024
@SabineHaas
Copy link
Member Author

Failing test is tests/test_examples.py::test_examples_datapackages_scripts_infer . I think I won't have the time to improve the infer script. Do you mind if I skip this tests for GHG facades?

Copy link
Collaborator

@Bachibouzouk Bachibouzouk left a comment

Choose a reason for hiding this comment

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

Thanks for adding this feature @SabineHaas

I will try to get the time to see why the test of the infer_metadata method fails

I see that you just added documentation to the new features, which would have been a comment of the review :)

def init_emission_buses(self, kwargs):
"""Adds emissions buses as output flows and drops them from kwargs"""
for key, bus in list(kwargs.items()):
if key.startswith("emission_bus"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If Bus would have a carrier attribute, one could look for emission carriers, but it is not implemented in oemof.solph as long as this naming convention is documented this is fine. Maybe an error or warning if no occurence of emission bus is found in kwargs would make sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you @Bachibouzouk ! I have added warnings in 51bb272.
I also renamed bus to value to avoid missunderstandings in c0f2038 as the value can be of different types (solph.Bus, string) depending on the item.

f"'datapackage_{example_datapackage}.json' \n"
+ open(script_path).read(),
)
if script_path.parts[-3] == "GHG":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for ignoring this test here? Time constraint most probably?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the infer test, that's failing tests/test_examples.py::test_examples_datapackages_scripts_infer .

Copy link
Collaborator

@Bachibouzouk Bachibouzouk left a comment

Choose a reason for hiding this comment

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

I think the implementation following my comments make sense and all test pass, congrats for the nice job :)

@SabineHaas SabineHaas merged commit ba77ec1 into dev Aug 22, 2024
2 checks passed
@SabineHaas SabineHaas deleted the feature/ghg_facades branch August 22, 2024 12:22
from .commodity import Commodity


@dataclasses.dataclass(unsafe_hash=False, frozen=False, eq=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@SabineHaas - Is there a reason why you used this instead of @dataclass_facade?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I opened a new issue for discussion - as I had this in my mind for quite a while:
#184

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.

Add emissions to facades
3 participants