-
Notifications
You must be signed in to change notification settings - Fork 76
Collocated Cokriging #394
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
base: main
Are you sure you want to change the base?
Collocated Cokriging #394
Conversation
- Implement Simple Collocated Cokriging (SCCK) extending Krige class - Implement Intrinsic Collocated Cokriging (ICCK) with flexible secondary models - Add comprehensive test suite with 14 test cases covering: - Matrix construction and dimensions - Cross-correlation validation - RHS vector structure - Integration with drift functions - Edge cases (zero/perfect correlation) - Follow gstools patterns: property validation, error handling, documentation - Matrix structure: (n+1) x (n+1) for n conditioning points + 1 secondary variable - Uses Markov model assumption: C_zy(h) = ρ * √(C_zz(h) * C_yy(h)) - All tests passing with proper position handling via pre_pos method
- Clean minimal implementation extending Krige base class - Follows existing gstools design patterns exactly - Only adds cross_corr parameter and secondary_data requirement - Uses (n+1)×(n+1) matrix system solved per estimation point - Full API compatibility: return_var, chunk_size, only_mean, etc. - Proper integration with gstools post-processing and chunking - Zero cross-correlation equals Simple Kriging (verified) - Located in separate cokriging module as requested
Feature/collocated cokriging
- Create CollocatedCokriging base class following kriging module pattern - Refactor SCCK and ICCK as thin wrappers (algorithm='MM1' vs 'intrinsic') - Eliminate ~400 lines of duplicated code - Maintain full backward compatibility - All tests passing (14/14) - Cleaner architecture for future extensibility
This is great! I love it. I wanted this for a long time but never found the time to work on it. I have some general questions/remarks:
import gstools as gs
correlo_model = gs.MarkovModel1(
model=gs.Gaussian(dim=1, var=0.5, len_scale=2),
cross_corr=0.8,
secondary_var=1.5,
)
scck = gs.SimpleCollocated(
correlo_model, cond_pos, cond_val,
mean=1.0, secondary_mean=0.5
) Maybe the means could be combined in a list then, or we could also move them into the MarkovModel1 (not sure what makes more sense here), or keep them as is.
|
1: I'm not sure if this will work very well with the approach I chose. As you maybe have seen, after some linear algebra reformulations of the problem, SCCK and ICCK can be shown as an extension to simple Kriging, making it not necessary to construct new matrices, that would need to be solved for every estimation point in collocated cokriging. That is also where the normalizer goes currently., it applies in the way it would apply for Simple Kriging. |
This PR adds collocated cokriging methods to GSTools for multivariate geostatistical estimation, allowing users to improve sparse primary variable estimates by leveraging densely-sampled secondary variable data.
Collocated Cokriging Features
Krige
base class for full API compatibilityC_YZ(h) = ρ_YZ(0)·√(C_Z(h)·C_Y(h))
gstools.cokriging
submodule or top-level:from gstools import SimpleCollocated, IntrinsicCollocated
return_var=True
cross_corr ∈ [-1, 1]
,secondary_var > 0
ρ=0
recovers Simple Kriging,ρ=±1
gives zero ICCK varianceSimple Collocated Cokriging
Uses only collocated secondary data at the estimation point:
Intrinsic Collocated Cokriging
Uses collocated secondary data plus secondary values at all primary locations for more stable variance:
Implementation Details
gstools.cokriging
submodule with base class and methodsCollocatedCokriging
base class handles MM1 formulation and variance computationSimpleCollocated
implements SCCK estimator:Z*_SCCK = Z*_SK·(1-k·λ_Y0) + λ_Y0·(Y(u0)-m_Y) + k·λ_Y0·m_Z
IntrinsicCollocated
implements ICCK estimator using secondary weightssecondary_data
parameter on callC_YZ(0) = ρ_YZ(0)·√(C_Z(0)·C_Y(0))
Krige
functionality: grids, models, dimensions, anisotropy, drift, normalizersTests
11 tests in
test_cokriging.py
testing only cokriging logic:All tests passing with no warnings.
Examples
Two minimal examples following GSTools conventions (76 & 78 lines):
10_simple_collocated_cokriging.py
- SCCK demonstration11_intrinsic_collocated_cokriging.py
- ICCK demonstrationReferences