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

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

Add sum model #364

wants to merge 47 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
    • 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 attribute to Field generators 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)
  • removed usage of scipy.misc.derivative, since it is deprecated
  • doc:
    • replaced m2r2 with myst_parser to include markdown files
    • renamed GeoStatTools to GSTools everywhere
  • CI:
    • build wheels for python 3.13
  • CovModel: added needs_fourier_transform to optimize init in case of analytical spectrum

TODOs

  • testing the sum-model
  • add tutorials about sum-models

@MuellerSeb MuellerSeb marked this pull request as draft August 11, 2024 15:05
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.

1 participant