-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f9ecf4
commit f6f078a
Showing
19 changed files
with
139 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .distance import calc_point_to_point_distance, calc_block_to_block_distance | ||
# from .clusters import ClusterDetector, aggregate_cluster | ||
from .gridding import create_grid, points_to_grid | ||
from .gridding import create_grid, points_to_grid | ||
from .point import point_distance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
""" | ||
Distance calculation functions. | ||
Authors | ||
------- | ||
1. Szymon Moliński | @SimonMolinsky | ||
""" | ||
import numpy as np | ||
from numpy.typing import ArrayLike | ||
from scipy.spatial.distance import cdist | ||
|
||
|
||
# noinspection PyTypeChecker | ||
def point_distance(points: ArrayLike, | ||
other: ArrayLike, | ||
metrics: str = 'euclidean') -> np.ndarray: | ||
""" | ||
Calculates the euclidean distance from one group of points to another | ||
group of points. | ||
Parameters | ||
---------- | ||
points : array | ||
Spatial coordinates. | ||
other : array | ||
Other array with spatial coordinates. | ||
metrics : str, default = 'euclidean' | ||
Metrics used to calculate distance. | ||
See ``scipy.spatial.distance.cdist`` for more details. | ||
Returns | ||
------- | ||
distances : array | ||
Distances matrix. Row index = ``points`` point index, and column | ||
index = ``other`` point index. | ||
Notes | ||
----- | ||
The function creates array of size MxN, where M = number of ``points`` | ||
and N = number of ``other``. Very big coordinates array may cause | ||
memory errors. | ||
Examples | ||
-------- | ||
>> points = [(0, 0), (0, 1), (0, 2)] | ||
>> other = [(2, 2), (3, 3)] | ||
>> distances = point_distance(points=points, other=other) | ||
>> print(distances) | ||
[[2.82842712 4.24264069] | ||
[2.23606798 3.60555128] | ||
[2. 3.16227766]] | ||
""" | ||
|
||
distances = cdist(points, other, metrics) | ||
return distances | ||
|
||
|
||
def select_values_in_range(data: np.ndarray, | ||
current_lag: float, | ||
previous_lag: float): | ||
""" | ||
Function selects set of values which are greater than | ||
(lag - step_size size) and smaller or equal to (lag). | ||
Parameters | ||
---------- | ||
data : numpy array | ||
Distances between points. | ||
current_lag : float | ||
previous_lag : float | ||
Returns | ||
------- | ||
: numpy array | ||
Mask with distances within a specified radius. | ||
""" | ||
|
||
# Check conditions | ||
condition_matrix = np.logical_and( | ||
np.greater(data, previous_lag), | ||
np.less_equal(data, current_lag)) | ||
|
||
# Find positions | ||
position_matrix = np.where(condition_matrix) | ||
return position_matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ prettytable | |
pandas | ||
dask | ||
pyarrow | ||
pylibtiff==0.5.1 | ||
pylibtiff==0.5.1 | ||
deprecation==2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters