Skip to content

Cokriging#396

Open
n0228a wants to merge 33 commits intoGeoStat-Framework:mainfrom
n0228a:cokriging-backup
Open

Cokriging#396
n0228a wants to merge 33 commits intoGeoStat-Framework:mainfrom
n0228a:cokriging-backup

Conversation

@n0228a
Copy link
Copy Markdown

@n0228a n0228a commented Apr 17, 2026

had to move cokriging to new branch and start pull request again

n0228a added 30 commits August 26, 2025 00:41
- 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
- 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 commit introduces a new Correlogram base class architecture that
makes collocated cokriging future-proof and extensible for different
cross-covariance models (MM1, MM2, etc.).

**New Features:**

- Added Correlogram abstract base class defining the interface for
  cross-covariance models
- Implemented MarkovModel1 as the first concrete correlogram,
  encapsulating Markov Model I assumptions
- Correlogram objects now hold all cross-covariance parameters:
  primary_model, cross_corr, secondary_var, primary_mean, secondary_mean

**API Changes:**

New (recommended) API:
  correlogram = gs.MarkovModel1(
      primary_model=model,
      cross_corr=0.8,
      secondary_var=1.5,
      primary_mean=1.0,
      secondary_mean=0.5
  )
  scck = gs.SimpleCollocated(correlogram, cond_pos, cond_val)

Backward compatibility via from_parameters() classmethod (deprecated):
  scck = gs.SimpleCollocated.from_parameters(
      model, cond_pos, cond_val,
      cross_corr=0.8, secondary_var=1.5,
      mean=1.0, secondary_mean=0.5
  )

**Refactored Classes:**

- CollocatedCokriging: Now accepts correlogram object instead of
  individual parameters (cross_corr, secondary_var, etc.)
- SimpleCollocated: Updated to use new API with backward compatibility
- IntrinsicCollocated: Updated to use new API with backward compatibility
- Both classes delegate covariance computation to correlogram

**Benefits:**

- Separation of concerns: Cross-covariance modeling separated from
  kriging algorithm
- Extensible: Easy to add MM2, Linear Model of Coregionalization, etc.
- Self-documenting: Explicit about which cross-covariance model is used
- Maintainable: Correlogram classes can be tested independently
- Future-proof: Ready for additional correlogram models

**Testing:**

- Added comprehensive test suite (test_correlogram.py)
- All tests pass with numerical equivalence between old and new API
- Updated examples to demonstrate new API

**Documentation:**

- Updated examples/05_kriging/10_simple_collocated_cokriging.py
- Updated examples/05_kriging/11_intrinsic_collocated_cokriging.py
- Added MarkovModel1 to top-level exports
- Comprehensive docstrings with usage examples

**Future Work:**

- Placeholder for MarkovModel2 implementation
- Potential for other correlogram models (intrinsic correlation, etc.)

Closes: #correlogram-architecture
- Explains new Correlogram base class design
- Provides usage examples for MarkovModel1
- Shows how to implement MarkovModel2 (future)
- Includes migration guide from old to new API
- Documents testing and file structure
…ecture

Revert "Feature/correlogram architecture"
…for cokriging

This merge introduces the new Correlogram architecture to replace the
direct-parameter API for collocated cokriging.

Key Changes:
- New Correlogram abstract base class for cross-covariance models
- MarkovModel1 implementation (Markov Model I)
- Refactored SimpleCollocated and IntrinsicCollocated to use Correlogram objects
- Updated API: correlogram parameter replaces model/cross_corr/secondary_var
- Cleaner documentation following GSTools philosophy
- Comprehensive test suite for correlogram models

All conflicts resolved in favor of the new architecture.
All tests passing (14/14).
- Add MarkovModel1 to gstools main __init__.py exports
- Update cokriging __init__.py with proper imports
- Update example files to use new Correlogram API
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