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 sum model #364

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open

Add sum model #364

wants to merge 57 commits into from

Conversation

MuellerSeb
Copy link
Member

@MuellerSeb MuellerSeb commented Aug 11, 2024

This PR adds a SumModel class to represent sums of Covariance models.

Sum-Model

  • added SumModel class
    • represents sum of covariance models
    • behaves just as a normal covariance model with kriging and field generation
    • covariance models can be added with overloaded + operator: model = m1 + m2
    • class is subscriptable to access sub-models by index: m1 = model[0]
    • included models will get a nugget of 0 and the nugget is stored separately in the sum-model
    • model variance is the sum of the sub-model variances
    • model length-scale is weighted sum of sub-model len-scales, where the weights are the ratios of the sub-models variance to the sum variance (motivated by the integral scale, which satisfies this relation)
    • anisotropy and rotation need to be the same for all included sub-models
    • parameters of the sub-models can be accessed by name with added index suffix: model[0].nu == model.nu_0
    • fitting: if len_scale is fixed, none of the len_scale_<i> can be fixed since len_scale is calculated from variance ratios
  • added Nugget class (empty SumModel)
    • allow len scale of 0 in CovModel to enable a pure nugget model
    • added zero_var and model attributes to Generator ABC to shortcut field generation for pure nugget models
import gstools as gs
m1 = gs.Gaussian(dim=2, var=1.0, len_scale=2.0)
m2 = gs.Gaussian(dim=2, var=2.0, len_scale=20.0)
model = m1 + m2
model.plot()

Other changes

  • removed var_raw attribute from CovModel (was rarely used and only relevant for the truncated power law models)
    • BREAKING CHANGE (but not to many should be affected)
    • TPLCovModel now has a intensity attribute which calculates what var_raw was before
  • simplified variogram fitting (var_raw was a bad idea in the first place)
  • variogram plotting now handles a len-scale of 0 (to properly plot nugget models)
  • fitting: when sill is given and var and nugget are deselected from fitting, an error is raised if given var+nugget is not equal to sill (before, they were reset under the hood in a strange way)

@MuellerSeb MuellerSeb marked this pull request as draft August 11, 2024 15:05
@MuellerSeb MuellerSeb added this to the 1.7 milestone Feb 3, 2025
@MuellerSeb MuellerSeb added enhancement New feature or request Refactoring Code-Refactoring needed here labels Feb 3, 2025
@MuellerSeb MuellerSeb self-assigned this Feb 3, 2025
@MuellerSeb MuellerSeb marked this pull request as ready for review February 8, 2025 13:11
@MuellerSeb MuellerSeb requested a review from LSchueler February 8, 2025 13:11
@MuellerSeb
Copy link
Member Author

@LSchueler this is ready for review.

@LSchueler
Copy link
Member

Awesome, I'll need some time to thoroughly go throw your changes.
But I already saw that you claimed example number 11 for the sum model after I did the same for the plurigaussian fields :-D Do we just keep adding new examples in an ascending order according to the time a PR is merged?

@MuellerSeb
Copy link
Member Author

First come, first serve :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Refactoring Code-Refactoring needed here
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants