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

Updated variance error calculations in area-to-point poisson kriging #430

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Pyinterpolate

**version 0.5.2** - *Mykolaiv*
**version 0.5.3** - *Mykolaiv*

---

Expand Down
6 changes: 6 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Pyinterpolate is the Python library for **geostatistics** and **spatial statisti
Changes by date
===============

2024-10-26
----------
**version 0.5.3**

* (logic) debugged variance error calculations for Area-to-Point Poisson Kriging

2024-06-26
----------
**version 0.5.2**
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
project = 'Pyinterpolate'
copyright = '2024, Szymon Moliński'
author = 'Szymon Moliński'
release = '0.5.2'
release = '0.5.3'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Pyinterpolate
=============

**version 0.5.2** - *Mykolaiv*
**version 0.5.3** - *Mykolaiv*
------------------------------------

.. image:: imgs/pyinterpolate-banner.png
Expand Down
2 changes: 1 addition & 1 deletion pyinterpolate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
from pyinterpolate.viz import interpolate_raster


__version__ = "0.5.1"
__version__ = "0.5.3"
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pyinterpolate.kriging.utils.kwarnings import ExperimentalFeatureWarning
from pyinterpolate.processing.preprocessing.blocks import Blocks, PointSupport
from pyinterpolate.processing.select_values import select_poisson_kriging_data, prepare_pk_known_areas, \
get_aggregated_point_support_values
get_aggregated_point_support_values, get_distances_within_unknown
from pyinterpolate.processing.transform.transform import transform_ps_to_dict, get_areal_values_from_agg, sem_to_cov
from pyinterpolate.variogram import TheoreticalVariogram

Expand Down Expand Up @@ -194,6 +194,18 @@ def area_to_point_pk(semivariogram_model: TheoreticalVariogram,
transposed = avg_b2p_covariances.T
logging.info("POISSON KRIGING: AREA-TO-POINT | Kriging system weights has been prepared")

if isinstance(unknown_block[0], np.ndarray):
u_idx = unknown_block[0][0]
else:
u_idx = unknown_block[0]

distances_within_unknown_block = get_distances_within_unknown(unknown_block_point_support)
semivariance_within_unknown = b2b_semivariance.calculate_average_semivariance({
u_idx: distances_within_unknown_block
})[u_idx]

covariance_within_unknown = sem_to_cov([semivariance_within_unknown], sill)[0]

predicted_points = []

for idx, point in enumerate(transposed):
Expand Down Expand Up @@ -225,6 +237,8 @@ def area_to_point_pk(semivariogram_model: TheoreticalVariogram,

# Calculate error
sigmasq = np.matmul(w.T, point)
sigmasq = covariance_within_unknown - sigmasq

if sigmasq < 0:
if raise_when_negative_error:
logging.info(f"POISSON KRIGING: AREA-TO-POINT | Negative variance error for point {point}")
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = pyinterpolate
description = Spatial Interpolation in Python
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
version = 0.5.2
version = 0.5.3
url = https://github.com/DataverseLabs/pyinterpolate
download_url = https://github.com/DataverseLabs/pyinterpolate/archive/
author = Szymon Moliński
Expand Down
70 changes: 52 additions & 18 deletions tutorials/C15-Poisson-Kriging-Area-to-Point.ipynb

Large diffs are not rendered by default.

Loading