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

Improved CSG filling strategies #288

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft

Improved CSG filling strategies #288

wants to merge 23 commits into from

Conversation

JGuetschow
Copy link
Contributor

@JGuetschow JGuetschow commented Nov 5, 2024

Pull request

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

Add more filling strategies for the csg

  • local trend based filling: similar to primap1 method
  • local least squares filling: improvement over global least squares with configurable matching area

Important

Merge #286 first

@JGuetschow JGuetschow self-assigned this Nov 5, 2024
@JGuetschow JGuetschow added the enhancement New feature or request label Nov 5, 2024
@JGuetschow JGuetschow added this to the Composite Source Generator milestone Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 99.19355% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.94%. Comparing base (09060da) to head (2bcbcec).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
primap2/csg/_strategies/gaps.py 97.72% 3 Missing ⚠️
primap2/csg/_wrapper.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #288      +/-   ##
==========================================
+ Coverage   96.70%   96.94%   +0.23%     
==========================================
  Files          49       54       +5     
  Lines        4710     5205     +495     
==========================================
+ Hits         4555     5046     +491     
- Misses        155      159       +4     

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

@JGuetschow JGuetschow changed the title Imrpoved CSG filling strategies Improved CSG filling strategies Nov 12, 2024
docs/source/usage/csg.md Outdated Show resolved Hide resolved
docs/source/usage/csg.md Outdated Show resolved Hide resolved
primap2/csg/_wrapper.py Outdated Show resolved Hide resolved
@JGuetschow
Copy link
Contributor Author

Ready for review. Docs still to come, but that should be quick as the class docstring is quite detailed.

fill_ts: xr.DataArray,
gap: Gap,
factor: np.array,
) -> xr.DataArray:
Copy link
Member

@mikapfl mikapfl Nov 29, 2024

Choose a reason for hiding this comment

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

Suggested change
) -> xr.DataArray:
) -> xr.DataArray:
"""Fill a gap in a timeseries using data from another timeseries and factors.
Parameters
----------
ts: xr.DataArray
Timeseries with a gap to be filled.
fill_ts: xr.DataArray
Timeseries from which to take the data to fill in the gap in ts.
gap: Gap
The gap that should be filled.
factor: np.array
Numpy array containing two floats, the scaling factor to use at the left side of the gap
and the scaling factor to use at the right side of the gap. The data from fill_ts will be
multiplied with the factor before filling the gap in ts. If the factors differ, a linear
interpolation of the scaling factor between both values will be performed.
Returns
-----------
result
DataArray with the same size and shape as ts, but with the given gap filled from fill_ts.
"""

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.

2 participants