integrate-module 0.98.0__tar.gz → 0.99.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {integrate_module-0.98.0/integrate_module.egg-info → integrate_module-0.99.0}/PKG-INFO +2 -1
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/__init__.py +6 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_borehole.py +99 -36
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_io.py +10 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_plot.py +340 -171
- integrate_module-0.99.0/integrate/integrate_query.py +1588 -0
- integrate_module-0.99.0/integrate/integrate_www_cli.py +8 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0/integrate_module.egg-info}/PKG-INFO +2 -1
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate_module.egg-info/SOURCES.txt +1 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate_module.egg-info/entry_points.txt +1 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate_module.egg-info/requires.txt +1 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/pyproject.toml +3 -1
- integrate_module-0.98.0/integrate/integrate_query.py +0 -979
- {integrate_module-0.98.0 → integrate_module-0.99.0}/LICENSE +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/README.md +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/gex.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_hdf5_info_cli.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_rejection.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_rejection_cli.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_rejection_jax.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate/integrate_timing_cli.py +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate_module.egg-info/dependency_links.txt +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/integrate_module.egg-info/top_level.txt +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/setup.cfg +0 -0
- {integrate_module-0.98.0 → integrate_module-0.99.0}/tests/test_likelihood_multinomial.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: integrate_module
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.99.0
|
|
4
4
|
Summary: Localized probabilistic data integration
|
|
5
5
|
Author-email: Thomas Mejer Hansen <tmeha@geo.au.dk>
|
|
6
6
|
License: MIT
|
|
@@ -27,6 +27,7 @@ Requires-Dist: jupytext
|
|
|
27
27
|
Requires-Dist: pandas
|
|
28
28
|
Requires-Dist: pyvista
|
|
29
29
|
Requires-Dist: litellm
|
|
30
|
+
Requires-Dist: streamlit
|
|
30
31
|
Provides-Extra: dev
|
|
31
32
|
Requires-Dist: pytest; extra == "dev"
|
|
32
33
|
Requires-Dist: black; extra == "dev"
|
|
@@ -102,6 +102,7 @@ from integrate.integrate_plot import plot_feature_2d
|
|
|
102
102
|
from integrate.integrate_plot import plot_posterior_cumulative_thickness
|
|
103
103
|
from integrate.integrate_plot import h5_get_clim_cmap
|
|
104
104
|
from integrate.integrate_plot import get_colormap_and_limits
|
|
105
|
+
from integrate.integrate_plot import plot_xy
|
|
105
106
|
from integrate.integrate_plot import find_points_along_line_segments
|
|
106
107
|
from integrate.integrate_plot import plot_boreholes
|
|
107
108
|
|
|
@@ -120,11 +121,16 @@ from integrate.integrate_borehole import save_borehole_data
|
|
|
120
121
|
|
|
121
122
|
# Import query functions
|
|
122
123
|
from integrate.integrate_query import query
|
|
124
|
+
from integrate.integrate_query import query_probability
|
|
125
|
+
from integrate.integrate_query import query_percentile
|
|
123
126
|
from integrate.integrate_query import query_plot
|
|
127
|
+
from integrate.integrate_query import query_percentile_plot
|
|
124
128
|
from integrate.integrate_query import save_query
|
|
125
129
|
from integrate.integrate_query import load_query
|
|
126
130
|
from integrate.integrate_query import get_prior_model_info
|
|
131
|
+
from integrate.integrate_query import prior_describe
|
|
127
132
|
from integrate.integrate_query import query_from_text
|
|
133
|
+
from integrate.integrate_query import title_from_json
|
|
128
134
|
from integrate.integrate_query import query_test_llm
|
|
129
135
|
|
|
130
136
|
# Import gex module functions
|
|
@@ -572,7 +572,8 @@ def rescale_P_obs_temperature(P_obs, T=1.0):
|
|
|
572
572
|
|
|
573
573
|
return P_obs_scaled
|
|
574
574
|
|
|
575
|
-
def Pobs_to_datagrid(P_obs, X, Y, f_data_h5, r_data=10, r_dis=100, doPlot=False
|
|
575
|
+
def Pobs_to_datagrid(P_obs, X, Y, f_data_h5, r_data=10, r_dis=100, doPlot=False,
|
|
576
|
+
nan_freq=0.8, r_data_i_use=None):
|
|
576
577
|
"""
|
|
577
578
|
Convert point-based discrete probability observations to gridded data with distance-based weighting.
|
|
578
579
|
|
|
@@ -602,6 +603,15 @@ def Pobs_to_datagrid(P_obs, X, Y, f_data_h5, r_data=10, r_dis=100, doPlot=False)
|
|
|
602
603
|
doPlot : bool, optional
|
|
603
604
|
If True, creates diagnostic plots showing weight distributions.
|
|
604
605
|
Default is False.
|
|
606
|
+
nan_freq : float, optional
|
|
607
|
+
NaN-frequency threshold for automatic data-gate selection inside
|
|
608
|
+
:func:`get_weight_from_position`. Gates where the fraction of
|
|
609
|
+
non-NaN values is below this threshold are excluded. Default 0.8.
|
|
610
|
+
Ignored when ``r_data_i_use`` is provided.
|
|
611
|
+
r_data_i_use : array-like of int or None, optional
|
|
612
|
+
Explicit gate/channel indices to use for data-distance computation
|
|
613
|
+
inside :func:`get_weight_from_position`. Overrides ``nan_freq`` when
|
|
614
|
+
provided. Default None.
|
|
605
615
|
|
|
606
616
|
Returns
|
|
607
617
|
-------
|
|
@@ -663,7 +673,8 @@ def Pobs_to_datagrid(P_obs, X, Y, f_data_h5, r_data=10, r_dis=100, doPlot=False)
|
|
|
663
673
|
|
|
664
674
|
# Compute distance-based weights for all grid points
|
|
665
675
|
w_combined, w_dis, w_data, i_use_from_func = ig.get_weight_from_position(
|
|
666
|
-
f_data_h5, X, Y, r_data=r_data, r_dis=r_dis, doPlot=doPlot
|
|
676
|
+
f_data_h5, X, Y, r_data=r_data, r_dis=r_dis, doPlot=doPlot,
|
|
677
|
+
nan_freq=nan_freq, r_data_i_use=r_data_i_use
|
|
667
678
|
)
|
|
668
679
|
|
|
669
680
|
# Convert distance weight to temperature
|
|
@@ -692,7 +703,9 @@ def Pobs_to_datagrid(P_obs, X, Y, f_data_h5, r_data=10, r_dis=100, doPlot=False)
|
|
|
692
703
|
|
|
693
704
|
|
|
694
705
|
|
|
695
|
-
def get_weight_from_position(f_data_h5,x_well=0,y_well=0, i_ref=-1, r_dis
|
|
706
|
+
def get_weight_from_position(f_data_h5, x_well=0, y_well=0, i_ref=-1, r_dis=400, r_data=2,
|
|
707
|
+
useLog=True, doPlot=False, plFile=None, showInfo=0,
|
|
708
|
+
nan_freq=0.8, r_data_i_use=None):
|
|
696
709
|
"""Calculate weights based on distance and data similarity to a reference point.
|
|
697
710
|
|
|
698
711
|
This function computes three sets of weights:
|
|
@@ -703,32 +716,53 @@ def get_weight_from_position(f_data_h5,x_well=0,y_well=0, i_ref=-1, r_dis = 400,
|
|
|
703
716
|
Parameters
|
|
704
717
|
----------
|
|
705
718
|
f_data_h5 : str
|
|
706
|
-
Path to HDF5 file containing geometry and observed data
|
|
719
|
+
Path to HDF5 file containing geometry and observed data.
|
|
707
720
|
x_well : float, optional
|
|
708
|
-
X coordinate of reference point (well)
|
|
709
|
-
y_well : float, optional
|
|
710
|
-
Y coordinate of reference point (well)
|
|
721
|
+
X coordinate of reference point (well). Default 0.
|
|
722
|
+
y_well : float, optional
|
|
723
|
+
Y coordinate of reference point (well). Default 0.
|
|
711
724
|
i_ref : int, optional
|
|
712
|
-
Index of reference point
|
|
725
|
+
Index of reference point. Default -1 (auto-calculated as closest to x_well, y_well).
|
|
713
726
|
r_dis : float, optional
|
|
714
|
-
|
|
727
|
+
Geographic XY distance range [m] for spatial weighting. Default 400.
|
|
715
728
|
r_data : float, optional
|
|
716
|
-
Data similarity range parameter for data weighting
|
|
729
|
+
Data-space similarity range parameter for data weighting. Default 2.
|
|
730
|
+
useLog : bool, optional
|
|
731
|
+
Apply log10 transform to data before computing similarity. Default True.
|
|
732
|
+
doPlot : bool, optional
|
|
733
|
+
Create diagnostic weight plots. Default False.
|
|
734
|
+
plFile : str or None, optional
|
|
735
|
+
Output filename for the diagnostic plot. Auto-generated if None.
|
|
736
|
+
showInfo : int, optional
|
|
737
|
+
Verbosity level. Default 0.
|
|
738
|
+
nan_freq : float, optional
|
|
739
|
+
NaN-frequency threshold for automatic gate selection. Gates where the
|
|
740
|
+
fraction of non-NaN values across all soundings is below this threshold
|
|
741
|
+
are excluded from the data-distance computation. Default 0.8.
|
|
742
|
+
Ignored when ``r_data_i_use`` is provided.
|
|
743
|
+
r_data_i_use : array-like of int or None, optional
|
|
744
|
+
Explicit gate/channel indices to use for the data-distance computation.
|
|
745
|
+
When provided, overrides the ``nan_freq`` automatic selection.
|
|
746
|
+
A NaN check at the reference sounding is still applied.
|
|
747
|
+
Default None (use ``nan_freq`` threshold).
|
|
717
748
|
|
|
718
749
|
Returns
|
|
719
750
|
-------
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
751
|
+
w_combined : ndarray (N_data,)
|
|
752
|
+
Combined weights from spatial distance and data similarity.
|
|
753
|
+
w_dis : ndarray (N_data,)
|
|
754
|
+
Geographic distance-based weights.
|
|
755
|
+
w_data : ndarray (N_data,)
|
|
756
|
+
Data similarity-based weights.
|
|
757
|
+
i_ref : int
|
|
758
|
+
Index of the reference sounding used.
|
|
725
759
|
|
|
726
760
|
Notes
|
|
727
761
|
-----
|
|
728
|
-
|
|
729
|
-
- Distance weights
|
|
730
|
-
- Data weights
|
|
731
|
-
where dis is
|
|
762
|
+
Weights are calculated using Gaussian functions:
|
|
763
|
+
- Distance weights: exp(-dis² / r_dis²)
|
|
764
|
+
- Data weights: exp(-sum_dd² / r_data²)
|
|
765
|
+
where dis is geographic distance and sum_dd is cumulative data difference.
|
|
732
766
|
"""
|
|
733
767
|
import integrate as ig
|
|
734
768
|
import numpy as np
|
|
@@ -742,15 +776,16 @@ def get_weight_from_position(f_data_h5,x_well=0,y_well=0, i_ref=-1, r_dis = 400,
|
|
|
742
776
|
if i_ref == -1:
|
|
743
777
|
i_ref = np.argmin((X-x_well)**2 + (Y-y_well)**2)
|
|
744
778
|
|
|
745
|
-
#
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
#
|
|
753
|
-
|
|
779
|
+
# Select gates to use for data-distance computation
|
|
780
|
+
if r_data_i_use is not None:
|
|
781
|
+
gates = np.asarray(r_data_i_use, dtype=int)
|
|
782
|
+
else:
|
|
783
|
+
n_not_nan = np.sum(~np.isnan(d_obs), axis=0)
|
|
784
|
+
n_not_nan_freq = n_not_nan / d_obs.shape[0]
|
|
785
|
+
gates = np.where(n_not_nan_freq > nan_freq)[0]
|
|
786
|
+
# Remove gates that are NaN at the reference sounding
|
|
787
|
+
gates = gates[~np.isnan(d_obs[i_ref, gates])]
|
|
788
|
+
i_use = gates
|
|
754
789
|
# select gates to use, manually
|
|
755
790
|
if useLog:
|
|
756
791
|
d_ref = np.log10(d_obs[i_ref,i_use])
|
|
@@ -990,7 +1025,21 @@ def save_borehole_data(f_prior_h5, f_data_h5, BH, **kwargs):
|
|
|
990
1025
|
Path to the observed-data HDF5 file.
|
|
991
1026
|
BH : dict
|
|
992
1027
|
Borehole dictionary with keys depth_top, depth_bottom, class_obs,
|
|
993
|
-
class_prob, X, Y, name, method.
|
|
1028
|
+
class_prob, X, Y, name, method. Two optional keys control the
|
|
1029
|
+
distance-weighting radii when r_data / r_dis are not passed as
|
|
1030
|
+
explicit kwargs:
|
|
1031
|
+
|
|
1032
|
+
* ``range_data`` (float, optional) — data-space similarity radius.
|
|
1033
|
+
Survey points whose EM data response is similar to the borehole
|
|
1034
|
+
location receive higher weight; points that are more dissimilar are
|
|
1035
|
+
down-weighted. Default: 1,000,000 (effectively no cutoff).
|
|
1036
|
+
* ``range_dis`` (float, optional) — geographic XY distance [m] beyond
|
|
1037
|
+
which the borehole exerts no influence on nearby survey points.
|
|
1038
|
+
Default: 300 m.
|
|
1039
|
+
* ``nan_freq`` (float, optional) — NaN-frequency threshold for automatic
|
|
1040
|
+
data-gate selection. Default: 0.8.
|
|
1041
|
+
* ``r_data_i_use`` (list of int, optional) — explicit gate indices for
|
|
1042
|
+
data-distance computation; overrides ``nan_freq`` when provided.
|
|
994
1043
|
**kwargs
|
|
995
1044
|
im_prior : int, optional
|
|
996
1045
|
Index of the discrete model parameter in f_prior_h5 (e.g. 2 for /M2).
|
|
@@ -998,11 +1047,22 @@ def save_borehole_data(f_prior_h5, f_data_h5, BH, **kwargs):
|
|
|
998
1047
|
parallel : bool, optional
|
|
999
1048
|
Enable parallel mode computation. Default is False.
|
|
1000
1049
|
r_data : float, optional
|
|
1001
|
-
|
|
1002
|
-
|
|
1050
|
+
Data-space similarity radius. Overrides ``BH['range_data']`` when
|
|
1051
|
+
provided. Resolution order: explicit kwarg > BH['range_data'] >
|
|
1052
|
+
1,000,000 (no cutoff).
|
|
1003
1053
|
r_dis : float, optional
|
|
1004
|
-
|
|
1005
|
-
|
|
1054
|
+
Geographic XY fade-out distance [m]. Overrides ``BH['range_dis']``
|
|
1055
|
+
when provided. Resolution order: explicit kwarg > BH['range_dis'] >
|
|
1056
|
+
300 m.
|
|
1057
|
+
nan_freq : float, optional
|
|
1058
|
+
NaN-frequency threshold for automatic data-gate selection. Gates
|
|
1059
|
+
where the fraction of non-NaN soundings is below this threshold are
|
|
1060
|
+
excluded from data-distance computation. Resolution order: explicit
|
|
1061
|
+
kwarg > BH['nan_freq'] > 0.8. Ignored when ``r_data_i_use`` is set.
|
|
1062
|
+
r_data_i_use : list of int or None, optional
|
|
1063
|
+
Explicit gate/channel indices to use for data-distance computation.
|
|
1064
|
+
Overrides ``nan_freq`` when provided. Resolution order: explicit
|
|
1065
|
+
kwarg > BH['r_data_i_use'] > None.
|
|
1006
1066
|
doPlot : bool, optional
|
|
1007
1067
|
Plot distance-weight maps. Default is False.
|
|
1008
1068
|
showInfo : int, optional
|
|
@@ -1034,8 +1094,10 @@ def save_borehole_data(f_prior_h5, f_data_h5, BH, **kwargs):
|
|
|
1034
1094
|
|
|
1035
1095
|
im_prior = kwargs.get('im_prior', 2)
|
|
1036
1096
|
parallel = kwargs.get('parallel', False)
|
|
1037
|
-
r_data
|
|
1038
|
-
r_dis
|
|
1097
|
+
r_data = kwargs.get('r_data', BH.get('range_data', 1_000_000))
|
|
1098
|
+
r_dis = kwargs.get('r_dis', BH.get('range_dis', 300))
|
|
1099
|
+
nan_freq = kwargs.get('nan_freq', BH.get('nan_freq', 0.8))
|
|
1100
|
+
r_data_i_use = kwargs.get('r_data_i_use', BH.get('r_data_i_use', None))
|
|
1039
1101
|
doPlot = kwargs.get('doPlot', False)
|
|
1040
1102
|
showInfo = kwargs.get('showInfo', 1)
|
|
1041
1103
|
|
|
@@ -1047,7 +1109,8 @@ def save_borehole_data(f_prior_h5, f_data_h5, BH, **kwargs):
|
|
|
1047
1109
|
# Step 2: extrapolate point observations to the survey grid
|
|
1048
1110
|
d_obs, i_use, T_use = Pobs_to_datagrid(
|
|
1049
1111
|
P_obs, BH['X'], BH['Y'], f_data_h5,
|
|
1050
|
-
r_data=r_data, r_dis=r_dis, doPlot=doPlot
|
|
1112
|
+
r_data=r_data, r_dis=r_dis, doPlot=doPlot,
|
|
1113
|
+
nan_freq=nan_freq, r_data_i_use=r_data_i_use)
|
|
1051
1114
|
|
|
1052
1115
|
# Step 3: save gridded observations to f_data_h5
|
|
1053
1116
|
id_out, _ = ig.save_data_multinomial(
|
|
@@ -5178,6 +5178,16 @@ def write_borehole(W, filename, **kwargs):
|
|
|
5178
5178
|
* ``elevation`` (float, optional) – ground-surface elevation (m a.s.l.).
|
|
5179
5179
|
Used only by :func:`plot_boreholes` to place the well on a shared
|
|
5180
5180
|
elevation axis. Has no effect on inversion.
|
|
5181
|
+
* ``range_data`` (float, optional) – data-space similarity radius used by
|
|
5182
|
+
:func:`save_borehole_data` when ``r_data`` is not passed explicitly.
|
|
5183
|
+
Default: 1,000,000 (no cutoff).
|
|
5184
|
+
* ``range_dis`` (float, optional) – geographic XY fade-out distance [m]
|
|
5185
|
+
used by :func:`save_borehole_data` when ``r_dis`` is not passed explicitly.
|
|
5186
|
+
Default: 300 m.
|
|
5187
|
+
* ``nan_freq`` (float, optional) – NaN-frequency threshold for automatic
|
|
5188
|
+
data-gate selection in :func:`save_borehole_data`. Default: 0.8.
|
|
5189
|
+
* ``r_data_i_use`` (list of int, optional) – explicit gate/channel indices
|
|
5190
|
+
for data-distance computation; overrides ``nan_freq`` when provided.
|
|
5181
5191
|
|
|
5182
5192
|
numpy arrays and scalars are automatically converted to plain
|
|
5183
5193
|
Python lists/numbers so the file is human-readable JSON.
|