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 iamc filter for tabulate/ list runs #54

Merged
merged 2 commits into from
Mar 11, 2024
Merged

Conversation

pmussak
Copy link
Contributor

@pmussak pmussak commented Mar 5, 2024

Added iamc filter similar to mp.backend.models.tabulate and mp.backend.scenarios.tabulate to mp.runs.tabulate (all applies to .list methods as well).

Why was this added?
To be able to filter runs by whether they have IAMC data associated with certain properties, e.g. get all runs that have IAMC data for the Cumulative Emissions|CO2 variable or the World region.

usage:

mp.runs.tabulate(
            iamc={
                "variable": {"name__like": "Cumulative Emissions|CO2*"},
                "unit": {"name": "World"},
            }
        )

@pmussak
Copy link
Contributor Author

pmussak commented Mar 5, 2024

@danielhuppmann please take a look on whether this is sufficient for the needs for filtering runs on IAMC data that you perceived (for ixmp4-ts it is sufficient).

@glatterf42 glatterf42 added the enhancement New feature or request label Mar 5, 2024
Copy link
Member

@glatterf42 glatterf42 left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me :)

@meksor might want to take a look as well.

Copy link
Contributor

@meksor meksor left a comment

Choose a reason for hiding this comment

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

looks good!

Copy link
Member

@danielhuppmann danielhuppmann 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 additional filter (I had thought that this was already implemented)...

One clarifying question: this filter will only return items where a datapoint exists? (not just a measurand linked to the run)

See a possible extension inline.

)

assert sorted(res["model"].tolist()) == ["Model 2"]
assert sorted(res["scenario"].tolist()) == ["Scenario 2"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggest to extend the test in the following way:

  • Remove all datapoints for the run Model 1, Scenario 1 related to Region 3
  • Repeat the assertion form above
             res = test_mp.runs.tabulate(
               default_only=False,
               iamc={
                   "region": {"name": "Region 3"},
               },
           )
  • This should now only return Model 2, Scenario 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danielhuppmann thanks for raising this. I added a test as you proposed and only runs with existing datapoints are returned 👍

Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me!

@pmussak pmussak merged commit ce0b2ff into main Mar 11, 2024
6 checks passed
@pmussak pmussak deleted the feature/run-iamc-filter branch March 11, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants