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 wrapper for csg #286

Merged
merged 28 commits into from
Mar 27, 2025
Merged

Add wrapper for csg #286

merged 28 commits into from
Mar 27, 2025

Conversation

JGuetschow
Copy link
Contributor

@JGuetschow JGuetschow commented Nov 4, 2024

Pull request

This PR adds a wrapper around the primap2.csg.compose() function that prepares input data (e.g. remove unnecessary data) and postprocesses the output (add coordinates that were used in the process with new values).

A larger test for the compose function as well a small test for a subfunction are added as well.

Docs will be extended.

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Description in a {pr}.thing.md file in the directory changelog added - see changelog/README.md for details

Description

Please provide a short description what your pull request does.

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 8 lines in your changes missing coverage. Please review.

Project coverage is 97.07%. Comparing base (129ba1b) to head (bd02ecf).
Report is 36 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
primap2/pm2io/_data_reading.py 28.57% 5 Missing ⚠️
primap2/csg/_wrapper.py 94.73% 2 Missing ⚠️
primap2/pm2io/_GHG_inventory_reading.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #286      +/-   ##
==========================================
- Coverage   97.15%   97.07%   -0.09%     
==========================================
  Files          49       51       +2     
  Lines        4748     4848     +100     
==========================================
+ Hits         4613     4706      +93     
- Misses        135      142       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JGuetschow JGuetschow requested a review from mikapfl November 5, 2024 09:09
@JGuetschow JGuetschow self-assigned this Nov 5, 2024
@JGuetschow JGuetschow added this to the Composite Source Generator milestone Nov 5, 2024
@JGuetschow JGuetschow marked this pull request as ready for review November 5, 2024 09:10
@JGuetschow JGuetschow mentioned this pull request Nov 5, 2024
3 tasks
Copy link
Member

@mikapfl mikapfl left a comment

Choose a reason for hiding this comment

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

I found some typos in the docs

The {py:func}`primap2.csg.compose` function creates a composite time series according to
the given priorities and strategies, but it does not take care of pre- and postprocessing
of the data. It will carry along unnecessary data and the resulting dataset will miss the
priority coordinates. The {py:func}`primap2.csg.create_composite_source` function takes acre
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
priority coordinates. The {py:func}`primap2.csg.create_composite_source` function takes acre
priority coordinates. The {py:func}`primap2.csg.create_composite_source` function takes care

define pre- and postprocessing:

* **result_prio_coords** Defines the vales for the priority coordinates in the output dataset. As the
priority coordinates differ for all input sources there is no canonical vale
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
priority coordinates differ for all input sources there is no canonical vale
priority coordinates differ for all input sources there is no canonical value


```

* **limit_coords** Optional parameter to remove data for coordinate vales not needed for the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* **limit_coords** Optional parameter to remove data for coordinate vales not needed for the
* **limit_coords** Optional parameter to remove data for coordinate values not needed for the


* **limit_coords** Optional parameter to remove data for coordinate vales not needed for the
composition from the input data. The time coordinate is treated separately.
* **time_range** Optional parameter to limit the time coverage of the input data. The input can either be pandas `DatetimeIndex` or a tuple of `str` or datetime-like in the form (year_from, year_to) where both boundaries are included in the range. Only the overlap of the supplied index or index created from the tuple with the time coordinate of the input dataset will be used.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* **time_range** Optional parameter to limit the time coverage of the input data. The input can either be pandas `DatetimeIndex` or a tuple of `str` or datetime-like in the form (year_from, year_to) where both boundaries are included in the range. Only the overlap of the supplied index or index created from the tuple with the time coordinate of the input dataset will be used.
* **time_range** Optional parameter to limit the time coverage of the input data. The input can either be a pandas `DatetimeIndex` or a tuple of `str` or datetime-like in the form (year_from, year_to) where both boundaries are included in the range. Only the overlap of the supplied index or index created from the tuple with the time coordinate of the input dataset will be used.

Comment on lines 26 to 27
"create_time_index",
"set_priority_coords",
Copy link
Member

Choose a reason for hiding this comment

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

Do we need create_time_index and set_priority_coords in the public API? I'd think users only need to know about create_composite_source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe there was an issue with imports when importing directly from the files but I'm not sure. I'll try if it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was no problem to change the import in the tests.

@JGuetschow
Copy link
Contributor Author

All suggestions accepted now

@JGuetschow JGuetschow merged commit 8d7a7b9 into main Mar 27, 2025
18 checks passed
@JGuetschow JGuetschow deleted the csg_regression_test branch March 27, 2025 07:55
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