Dynamic Time Warping based Hierarchical Agglomerative Clustering
Codes to perform Dynamic Time Warping Based Hierarchical Agglomerative Clustering of GPS data
Documentation
Installation and usage information can be obtained from the documentation: dtwhaclustering.pdf
Complete documentation at: dtwhaclustering-docs
Details
This package include codes for processing the GPS displacement data including least-square modelling for trend, co-seismic jumps, seasonal and tidal signals. Finally, it can be used to cluster the GPS displacements based on the similarity of the waveforms. The similarity among the waveforms will be obtained using the DTW distance.
Usage
Least-squares modeling
from dtwhaclustering.leastSquareModeling import lsqmodeling
final_dU, final_dN, final_dE = lsqmodeling(dUU, dNN, dEE,stnlocfile="helper_files/stn_loc.txt", plot_results=True, remove_trend=False, remove_seasonality=True, remove_jumps=False)
Plot station map
from dtwhaclustering import plot_stations
plot_stations.plot_station_map(station_data = 'helper_files/selected_stations_info.txt', outfig=f'{outloc}/station_map.pdf')
Plot linear trend
slopeFile=f'stn_slope_res_U.txt'
df = pd.read_csv(slopeFile, names=['stn','lon','lat','slope'], delimiter='\s+')
plot_linear_trend_on_map(df, outfig=f"Maps/slope-plot_U.pdf")
Note: slopeFile is obtained from lsqmodeling.
Dynamic Time Warping Analysis
from dtwhaclustering.dtw_analysis import dtw_signal_pairs, dtw_clustering
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
np.random.seed(0)
# sampling parameters
fs = 100 # sampling rate, in Hz
T = 1 # duration, in seconds
N = T * fs # duration, in samples
# time variable
t = np.linspace(0, T, N)
SNR = 0.2 #noise
XX0 = np.sin(2 * np.pi * t * 7+np.pi/2) #+ np.random.randn(1, N) * SNR
XX1 = signal.sawtooth(2 * np.pi * t * 5+np.pi/2) #+ np.random.randn(1, N) * SNR
# XX1 = np.abs(np.cos(2 * np.pi * t * 3)) - 0.5
s1, s2 = XX0, XX1
dtwsig = dtw_signal_pairs(s1, s2, labels=['S1', 'S2'])
dtwsig.plot_signals()
plt.show()
dtwsig.plot_matrix(windowfrac=0.6, psi=None) #Only allow for shifts up to 60% of the minimum signal length away from the two diagonals.
plt.show()
References
- Kumar, U., Chao, B.F., Chang, E.T.-Y.Y., 2020. What Causes the Common‐Mode Error in Array GPS Displacement Fields: Case Study for Taiwan in Relation to Atmospheric Mass Loading. Earth Sp. Sci. 0–2. https://doi.org/10.1029/2020ea001159
License
© 2021 Utpal Kumar
Licensed under the Apache License, Version 2.0
Metadata
Release files for dtwhaclustering 1.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dtwhaclustering-1.0.15.tar.gz | 26.8 kB | Without provenance | Details for dtwhaclustering-1.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dtwhaclustering-1.0.15-py3-none-any.whl | Python 3 | none | any | Details for dtwhaclustering-1.0.15-py3-none-any.whl |
Total release size: 55.0 kB
Release files / dtwhaclustering-1.0.15.tar.gz
| Download URL | dtwhaclustering-1.0.15.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf47d788620b97fe1dd997f9698004bac4abd53def2581597ef6f3b630f3b14d
|
|
BLAKE2b-256 checksum How to use checksums |
27fbf3f74ba67b2027b648a7acfdf6ea9ac839b4a2768e0f6944d7954cc6473d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / dtwhaclustering-1.0.15-py3-none-any.whl
| Download URL | dtwhaclustering-1.0.15-py3-none-any.whl |
|---|---|
| Size | 28.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
986dbad37b18367e7b1ae841184ab84ebdb91e449ff78d6dffec0e27e01e522b
|
|
BLAKE2b-256 checksum How to use checksums |
dcf794224e0db0cbc619d567eecfcbf0d3e757aed984deac7a0b60c474e4d92f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for dtwhaclustering 1.0.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.