Skip to content

Commit

Permalink
updated direction parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMolinsky committed Aug 28, 2023
1 parent 0c6c4e7 commit 4a8a909
Show file tree
Hide file tree
Showing 22 changed files with 848 additions and 841 deletions.
4 changes: 3 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Changes by date
* (dependencies) fixed dependencies (`hdbscan` and `scikit-learn`),
* (enhancement) updated tutorials, we slightly changed their structure,
* (dependencies) End of support for Python 3.7,
* (invalid) Warning when user tries to use `.plot()` method of the `ExperimentalVariogram` class.
* (invalid) Warning when user tries to use `.plot()` method of the `ExperimentalVariogram` class,
* (invalid) Default `direction` and `tolerance` are `None` instead of floats,
* (invalid) Removed unnecessary warning from the `.autofit()` method.

2023-05-03
----------
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 = '2023, Szymon Moliński'
author = 'Szymon Moliński'
release = '0.5'
release = '0.5.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
15 changes: 10 additions & 5 deletions pyinterpolate/variogram/empirical/experimental_variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class DirectionalVariogram:
Plot all variograms on a single plot.
"""

def __init__(self, input_array: np.array, step_size: float, max_range: float, weights=None, tolerance: float = 0.2,
def __init__(self,
input_array: np.ndarray,
step_size: float,
max_range: float,
weights=None,
tolerance: float = 0.2,
method='t'):

self.ds = input_array
Expand Down Expand Up @@ -203,15 +208,15 @@ class ExperimentalVariogram:
weights : numpy array, default=None
Weights assigned to points, index of weight must be the same as index of point.
direction : float (in range [0, 360]), default=None
direction : float (in range [0, 360]), optional
Direction of semivariogram, values from 0 to 360 degrees:
- 0 or 180: is E-W,
- 90 or 270 is N-S,
- 45 or 225 is NE-SW,
- 135 or 315 is NW-SE.
tolerance : float (in range [0, 1]), default=1
tolerance : float (in range [0, 1]), default = 1
If ``tolerance`` is 0 then points must be placed at a single line with the beginning in the origin of
the coordinate system and the direction given by y axis and direction parameter. If ``tolerance`` is ``> 0``
then the bin is selected as an elliptical area with major axis pointed in the same direction as the line
Expand Down Expand Up @@ -551,15 +556,15 @@ def build_experimental_variogram(input_array: np.array,
weights : numpy array or None, optional, default=None
Weights assigned to points, index of weight must be the same as index of point.
direction : float (in range [0, 360]), default = None
direction : float (in range [0, 360]), optional
Direction of semivariogram, values from 0 to 360 degrees:
- 0 or 180: is E-W,
- 90 or 270 is N-S,
- 45 or 225 is NE-SW,
- 135 or 315 is NW-SE.
tolerance : float (in range [0, 1]), optional, default=1
tolerance : float (in range [0, 1]), default = 1
If ``tolerance`` is 0 then points must be placed at a single line with the beginning in the origin of
the coordinate system and the direction given by y axis and direction parameter. If ``tolerance`` is ``> 0``
then the bin is selected as an elliptical area with major axis pointed in the same direction as the line
Expand Down
5 changes: 0 additions & 5 deletions pyinterpolate/variogram/theoretical/semivariogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,6 @@ def autofit(self,
elif isinstance(experimental_variogram, np.ndarray):
self.experimental_array = experimental_variogram
self.lags = experimental_variogram[:, 0]
if direction is None:
msg = 'If you provide experimental variogram as a numpy array you must remember that the direction' \
' parameter must be set if it is a directional variogram. Otherwise, algorithm assumes that' \
' variogram is isotropic.'
warnings.warn(msg)
self.direction = direction

# Check model type and set models
Expand Down
8 changes: 4 additions & 4 deletions pyinterpolate/viz/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def interpolate_raster(data,
dim=1000,
number_of_neighbors=4,
semivariogram_model=None,
direction=0,
tolerance=1) -> Dict:
direction=None,
tolerance=None) -> Dict:
"""
Function interpolates raster from data points using ordinary kriging.
Expand All @@ -85,15 +85,15 @@ def interpolate_raster(data,
semivariogram_model : TheoreticalVariogram, default=None
Variogram model, if not provided then it is estimated from a given dataset.
direction : float (in range [0, 360]), default = 0
direction : float (in range [0, 360]), optional
Direction of semivariogram, values from 0 to 360 degrees:
- 0 or 180: is E-W,
- 90 or 270 is N-S,
- 45 or 225 is NE-SW,
- 135 or 315 is NW-SE.
tolerance : float (in range [0, 1]), optional, default=1
tolerance : float (in range [0, 1]), optional
If ``tolerance`` is 0 then points must be placed at a single line with the beginning in the origin of
the coordinate system and the direction given by y-axis and direction parameter. If ``tolerance`` is ``> 0``
then the bin is selected as an elliptical area with major axis pointed in the same direction as the line
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
descartes
geopandas
matplotlib
hdbscan~=0.8.26
scikit-learn<1.3.0
hdbscan
scikit-learn
numpy
tqdm
pyproj
Expand All @@ -16,4 +16,4 @@ prettytable
pandas
dask
pyarrow
pylibtiff~=0.5.1
pylibtiff==0.5.1
Loading

0 comments on commit 4a8a909

Please sign in to comment.