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

sdba - Grouped detrending #467

Merged
merged 15 commits into from
Jun 4, 2020
Merged

sdba - Grouped detrending #467

merged 15 commits into from
Jun 4, 2020

Conversation

aulemahal
Copy link
Collaborator

@aulemahal aulemahal commented May 28, 2020

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • HISTORY.rst has been updated (with summary of main changes)
  • bumpversion (minor / major / patch) has been called on this branch
  • Tags have been pushed (git push --tags)
  • What kind of change does this PR introduce?
    All detrending is now made using the Grouper class of sdba. The BaseDetrend exposed methods call group.apply() with the _fit and _get_trend methods of the subclasses.

Performance could be lower for simple detrendings. To code it as elegantly as I could, I didn't code shortcuts. When calling fit, the _fit(da) method returns a grouped dataset. This dataset is broadcasted back along the 'time' coordinate of the dataarray to detrend and then grouped again for the trend computation (which is a non-grouping grouped operation). For something as simple as MeanDetrend it's a lot of overhead...

  • Does this PR introduce a breaking change?
    Yes, in order to achieve this as elegantly as I could, I removed the resampling possibility of PolyDetrend. It could be put back, but it's slightly more complicated. Watcha think @huard?

Results of DQM might be different between this new method and the previous one.

EDIT: Comment on the performance

@aulemahal aulemahal requested a review from huard May 28, 2020 19:00
xclim/sdba/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@huard huard left a comment

Choose a reason for hiding this comment

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

I suggest adding tests. Otherwise it looks fine.

xclim/sdba/detrending.py Show resolved Hide resolved
@aulemahal aulemahal requested a review from huard May 28, 2020 21:28
@coveralls
Copy link

coveralls commented May 28, 2020

Pull Request Test Coverage Report for Build 1974

  • 1 of 49 (2.04%) changed or added relevant lines in 4 files are covered.
  • 6 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.1%) to 77.286%

Changes Missing Coverage Covered Lines Changed/Added Lines %
xclim/sdba/adjustment.py 0 4 0.0%
xclim/sdba/base.py 0 10 0.0%
xclim/sdba/detrending.py 0 34 0.0%
Files with Coverage Reduction New Missed Lines %
xclim/sdba/adjustment.py 1 0%
xclim/sdba/base.py 2 0%
xclim/sdba/detrending.py 3 0%
Totals Coverage Status
Change from base Build 1972: -0.1%
Covered Lines: 2654
Relevant Lines: 3434

💛 - Coveralls

@aulemahal aulemahal merged commit e0bd5d2 into master Jun 4, 2020
@aulemahal aulemahal deleted the grouped-detrending branch June 4, 2020 17:24
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.

sdba - Grouped Detrending
3 participants