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

Update setup configurations #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@ ENV/
./stmetrics/spatial.py

# Vs Code
.vscode/
.vscode/

# Poetry
poetry.lock

# others
TODO
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[tool.poetry]
name = "stmetrics"
version = "0.1.8"
description = "A package to compute features from Satellite Image Time Series (SITS)."
authors = ["Brazil Data Cube Team <[email protected]>"]
readme = "README.rst"

[tool.poetry.dependencies]
python = "^3.10"
dtaidistance = "==2.3.11"
pandas = "==2.1.4"
matplotlib = "==3.8.2"
numba = "==0.58.1"
numpy = "==1.26.2"
xarray = "==2023.12.0"
rasterio = "==1.3.9"
shapely = "==2.0.2"
affine = "==2.4.0"
descartes = "==1.1.0"
connected-components-3d = "==3.12.4"
rasterstats = "==0.19.0"
pointpats = "==2.4.0"
geopandas = "==0.14.1"
nolds = "==0.5.2"
urllib3 = "~1"
fastremap = "==1.14.0"
scikit-learn = "==1.3.2"



[tool.poetry.group.dev.dependencies]
pytest = "==7.4.3"
flake8 = "==6.1.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

14 changes: 8 additions & 6 deletions stmetrics/basics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy
from .utils import fixseries, truncate
from stmetrics.utils import fixseries, truncate


def ts_basics(timeseries, funcs=["all"], nodata=-9999):
"""This function compute all basic metrics in a single call, returning a dictionary:
"""This function compute all basic metrics in a single call, returning a
dictionary:

- "Max" - Maximum value of the time series.

- "Min" - Minimum value of the time series.
Expand Down Expand Up @@ -31,7 +33,7 @@ def ts_basics(timeseries, funcs=["all"], nodata=-9999):
- "IQR" - Interquaritle range (IQR) of the time series.

- "FQR" - First quartile of the time series.

- "SQR" - Second quartile of the time series.

- "TQR" - Third quaritle of the time series.
Expand All @@ -47,7 +49,7 @@ def ts_basics(timeseries, funcs=["all"], nodata=-9999):

out_metrics = dict()

metrics_count = 15
# metrics_count = 15

if "all" in funcs:
funcs = [
Expand Down Expand Up @@ -78,8 +80,8 @@ def ts_basics(timeseries, funcs=["all"], nodata=-9999):


def mean_ts(timeseries, nodata=-9999):
"""Average value (mean) of the time series, considering only valid \
values. When nodata is found, it is not included in N value (for all functions).
"""Average value (mean) of the time series, considering only valid values.
When nodata is found, it is not included in N value (for all functions).

:param timeseries: Time series.
:type timeseries: numpy.ndarray
Expand Down
22 changes: 11 additions & 11 deletions stmetrics/fractal.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import numpy
from .utils import fixseries, truncate
from stmetrics.utils import fixseries, truncate


def ts_fractal(timeseries, funcs=['all'], nodata=-9999):
"""This function computes 4 fractal dimensions and the hurst exponential.

- DFA: measures the Hurst parameter H, which is similar to the \
- DFA: measures the Hurst parameter H, which is similar to the
Hurst exponent.

- HE: self-similarity measure that assess long-range dependence in a \
- HE: self-similarity measure that assess long-range dependence in a
time series.

- KFD: This algorirhm computes the FD using Katz algorithm.

:param timeseries: Time series.
Expand Down Expand Up @@ -65,11 +65,11 @@ def dfa_fd(timeseries, nvals=None, overlap=True, order=1, nodata=-9999):

.. Note::

This function uses the Detrended Fluctuation Analysis (DFA) \
implementation from the Nolds package. Due to time series \
characteristcs we use by default the 'RANSAC' \
This function uses the Detrended Fluctuation Analysis (DFA)
implementation from the Nolds package. Due to time series
characteristcs we use by default the 'RANSAC'
fitting method as it is more robust to outliers.
For more details regarding the hurst implementation, check Nolds \
For more details regarding the hurst implementation, check Nolds
documentation page.

"""
Expand All @@ -90,10 +90,10 @@ def hurst_exp(timeseries, nvals=None, nodata=-9999):

:param timeseries: Time series.
:type timeseries: numpy.ndarray

:param nvals: Sizes of subseries to use.
:type nvals: int

:param nodata: nodata of the time series. Default is -9999.
:type nodata: int

Expand Down Expand Up @@ -125,7 +125,7 @@ def katz_fd(timeseries, nodata=-9999):

:param timeseries: Time series.
:type timeseries: numpy.ndarray

:param nodata: nodata of the time series. Default is -9999.
:type nodata: int

Expand Down
8 changes: 4 additions & 4 deletions stmetrics/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def ts_polar(timeseries, funcs=["all"], nodata=-9999, show=False):

- CSI - This is a dimensionless quantitative measure of morphology, \
that characterize the standard deviation of an object from a circle.

To visualize the time series on polar space use: ts_polar(timeseries,\
show=True)

Expand All @@ -56,7 +56,7 @@ def ts_polar(timeseries, funcs=["all"], nodata=-9999, show=False):
"""
out_metrics = dict()

metrics_count = 9
# metrics_count = 9

if "all" in funcs:
funcs = [
Expand Down Expand Up @@ -161,7 +161,7 @@ def polar_plot(timeseries, nodata=-9999):
"""
import matplotlib.pyplot as plt
from descartes import PolygonPatch
from matplotlib.ticker import FormatStrFormatter
# from matplotlib.ticker import FormatStrFormatter

# filter time series
ts = fixseries(timeseries, nodata)
Expand All @@ -175,7 +175,7 @@ def polar_plot(timeseries, nodata=-9999):
maxY = numpy.max(numpy.abs(y))

# get season rings
ringTopLeft, ringTopRight,\
ringTopLeft, ringTopRight, \
ringBottomLeft, ringBottomRight = get_seasons(x, y)

# setup plot
Expand Down
Loading