sdatip 1.0.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.
sdatip-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 He Xingchen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
sdatip-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: sdatip
3
+ Version: 1.0.0
4
+ Summary: Fast stochastic determination of arrival time and initial polarity of seismic waveforms
5
+ Author: Chuan1937
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Chuan1937/SDATIP-Fast
8
+ Project-URL: Documentation, https://github.com/Chuan1937/SDATIP-Fast#readme
9
+ Project-URL: Repository, https://github.com/Chuan1937/SDATIP-Fast
10
+ Keywords: seismic,waveform,arrival-time,polarity,geophysics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.20.0
24
+ Requires-Dist: scipy>=1.7.0
25
+ Requires-Dist: numba>=0.55.0
26
+ Requires-Dist: obspy>=1.3.0
27
+ Requires-Dist: matplotlib>=3.5.0
28
+ Requires-Dist: tqdm>=4.60.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # SDATIP
35
+
36
+ [![PyPI version](https://badge.fury.io/py/sdatip.svg)](https://badge.fury.io/py/sdatip)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
38
+
39
+ **Fast Stochastic Determination of Arrival Time and Initial Polarity of Seismic Waveforms**
40
+
41
+ A high-performance Python package for seismic waveform analysis that determines arrival time and initial polarity using Markov chain-based stochastic methods.
42
+
43
+ ## Performance
44
+
45
+ | Metric | Original | SDATIP |
46
+ |--------|----------|--------|
47
+ | 100Hz, 10s waveform | ~30 minutes | ~55 seconds |
48
+ | Speedup | - | **30x faster** |
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install sdatip
54
+ ```
55
+
56
+ Or install from source:
57
+
58
+ ```bash
59
+ git clone https://github.com/Chuan1937/SDATIP-Fast.git
60
+ cd SDATIP-Fast
61
+ pip install -e .
62
+ ```
63
+
64
+ ## Quick Start
65
+
66
+ ### Process a Single Waveform
67
+
68
+ ```python
69
+ import numpy as np
70
+ import sdatip
71
+
72
+ # Your waveform data (1D numpy array)
73
+ data = np.random.randn(1000)
74
+
75
+ # Process the waveform
76
+ result = sdatip.process_waveform(
77
+ name="STATION_A",
78
+ data=data,
79
+ output_dir="./output/"
80
+ )
81
+
82
+ # Get results
83
+ print(f"Arrival time: {result['results'][0]['arrival_time']:.3f}s")
84
+ print(f"Polarity (up): {result['results'][0]['polarity_up']:.3f}")
85
+ ```
86
+
87
+ ### Process Multiple Waveforms
88
+
89
+ ```python
90
+ import sdatip
91
+
92
+ # Batch process all SAC files in a directory
93
+ results = sdatip.process_batch(
94
+ input_dir="./data/",
95
+ output_dir="./output/",
96
+ num_workers=4, # Use 4 CPU cores
97
+ plot_enabled=False
98
+ )
99
+ ```
100
+
101
+ ### Step-by-Step Processing
102
+
103
+ ```python
104
+ import sdatip
105
+
106
+ # Create waveform object
107
+ wf = sdatip.Waveform("station")
108
+ wf.importdata(data, delta=0.01)
109
+ wf.analyzedata()
110
+ wf.rmmean()
111
+ wf.interpolate(1)
112
+ wf.denseunique()
113
+ wf.denselong(hvcoefficient=2.5, mininsertco=200)
114
+ wf.extremearr()
115
+ wf.densebin()
116
+
117
+ # Build state model
118
+ state = wf.constructstate()
119
+ timeprobs, num_solutions = state.markovmatrix()
120
+ ampprob = state.ampprobcalculate()
121
+
122
+ # Estimate results
123
+ state.estimation(0)
124
+ print(f"Arrival: {state.arrivalestimate:.3f}s")
125
+ print(f"Polarity up: {state.polarityup:.3f}")
126
+ ```
127
+
128
+ ## API Reference
129
+
130
+ ### `process_waveform(name, data, output_dir, ...)`
131
+
132
+ Process a single seismic waveform.
133
+
134
+ | Parameter | Type | Default | Description |
135
+ |-----------|------|---------|-------------|
136
+ | `name` | str | required | Station name |
137
+ | `data` | np.ndarray | required | 1D amplitude array |
138
+ | `output_dir` | str | required | Output directory |
139
+ | `delta` | float | 0.01 | Sampling interval (s) |
140
+ | `plot_enabled` | bool | True | Generate plots |
141
+
142
+ ### `process_batch(input_dir, output_dir, ...)`
143
+
144
+ Process multiple waveforms in parallel.
145
+
146
+ | Parameter | Type | Default | Description |
147
+ |-----------|------|---------|-------------|
148
+ | `input_dir` | str | required | Input directory with SAC files |
149
+ | `output_dir` | str | required | Output directory |
150
+ | `num_workers` | int | -1 | CPU cores (-1 = all) |
151
+ | `plot_enabled` | bool | False | Generate plots |
152
+
153
+ ### Classes
154
+
155
+ - `Waveform(name)` - Waveform preprocessing container
156
+ - `State(name)` - Markov state model
157
+
158
+ ## Output Files
159
+
160
+ | File | Description |
161
+ |------|-------------|
162
+ | `{station}.txt` | Text summary with arrival time and polarity |
163
+ | `{station}.npz` | Main results (matrix, probabilities, thresholds) |
164
+ | `{station}_timeprob_{i}.npz` | Time probability distribution |
165
+ | `{station}_{i}.pdf` | Probability plot (if enabled) |
166
+ | `{station}.eps` | Publication-ready plot (if enabled) |
167
+
168
+ ## Algorithm
169
+
170
+ Based on: Pei, W., Zhuang, J. & Zhou, S. "Stochastic determination of arrival time and initial polarity of seismic waveform." *Earth Planets Space* 77, 36 (2025). https://doi.org/10.1186/s40623-025-02161-5
171
+
172
+ ## Validation
173
+
174
+ ```bash
175
+ python benchmark_validate.py check
176
+ ```
177
+
178
+ ## Citation
179
+
180
+ ```bibtex
181
+ @article{pei2025stochastic,
182
+ title={Stochastic determination of arrival time and initial polarity of seismic waveform},
183
+ author={Pei, W. and Zhuang, J. and Zhou, S.},
184
+ journal={Earth, Planets and Space},
185
+ volume={77},
186
+ pages={36},
187
+ year={2025},
188
+ doi={10.1186/s40623-025-02161-5}
189
+ }
190
+ ```
191
+
192
+ ## License
193
+
194
+ MIT License
195
+
196
+ ## Star History
197
+
198
+ [![Star History Chart](https://api.star-history.com/svg?repos=Chuan1937/SDATIP-Fast&type=Date)](https://star-history.com/#Chuan1937/SDATIP-Fast&Date)
sdatip-1.0.0/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # SDATIP
2
+
3
+ [![PyPI version](https://badge.fury.io/py/sdatip.svg)](https://badge.fury.io/py/sdatip)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ **Fast Stochastic Determination of Arrival Time and Initial Polarity of Seismic Waveforms**
7
+
8
+ A high-performance Python package for seismic waveform analysis that determines arrival time and initial polarity using Markov chain-based stochastic methods.
9
+
10
+ ## Performance
11
+
12
+ | Metric | Original | SDATIP |
13
+ |--------|----------|--------|
14
+ | 100Hz, 10s waveform | ~30 minutes | ~55 seconds |
15
+ | Speedup | - | **30x faster** |
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install sdatip
21
+ ```
22
+
23
+ Or install from source:
24
+
25
+ ```bash
26
+ git clone https://github.com/Chuan1937/SDATIP-Fast.git
27
+ cd SDATIP-Fast
28
+ pip install -e .
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### Process a Single Waveform
34
+
35
+ ```python
36
+ import numpy as np
37
+ import sdatip
38
+
39
+ # Your waveform data (1D numpy array)
40
+ data = np.random.randn(1000)
41
+
42
+ # Process the waveform
43
+ result = sdatip.process_waveform(
44
+ name="STATION_A",
45
+ data=data,
46
+ output_dir="./output/"
47
+ )
48
+
49
+ # Get results
50
+ print(f"Arrival time: {result['results'][0]['arrival_time']:.3f}s")
51
+ print(f"Polarity (up): {result['results'][0]['polarity_up']:.3f}")
52
+ ```
53
+
54
+ ### Process Multiple Waveforms
55
+
56
+ ```python
57
+ import sdatip
58
+
59
+ # Batch process all SAC files in a directory
60
+ results = sdatip.process_batch(
61
+ input_dir="./data/",
62
+ output_dir="./output/",
63
+ num_workers=4, # Use 4 CPU cores
64
+ plot_enabled=False
65
+ )
66
+ ```
67
+
68
+ ### Step-by-Step Processing
69
+
70
+ ```python
71
+ import sdatip
72
+
73
+ # Create waveform object
74
+ wf = sdatip.Waveform("station")
75
+ wf.importdata(data, delta=0.01)
76
+ wf.analyzedata()
77
+ wf.rmmean()
78
+ wf.interpolate(1)
79
+ wf.denseunique()
80
+ wf.denselong(hvcoefficient=2.5, mininsertco=200)
81
+ wf.extremearr()
82
+ wf.densebin()
83
+
84
+ # Build state model
85
+ state = wf.constructstate()
86
+ timeprobs, num_solutions = state.markovmatrix()
87
+ ampprob = state.ampprobcalculate()
88
+
89
+ # Estimate results
90
+ state.estimation(0)
91
+ print(f"Arrival: {state.arrivalestimate:.3f}s")
92
+ print(f"Polarity up: {state.polarityup:.3f}")
93
+ ```
94
+
95
+ ## API Reference
96
+
97
+ ### `process_waveform(name, data, output_dir, ...)`
98
+
99
+ Process a single seismic waveform.
100
+
101
+ | Parameter | Type | Default | Description |
102
+ |-----------|------|---------|-------------|
103
+ | `name` | str | required | Station name |
104
+ | `data` | np.ndarray | required | 1D amplitude array |
105
+ | `output_dir` | str | required | Output directory |
106
+ | `delta` | float | 0.01 | Sampling interval (s) |
107
+ | `plot_enabled` | bool | True | Generate plots |
108
+
109
+ ### `process_batch(input_dir, output_dir, ...)`
110
+
111
+ Process multiple waveforms in parallel.
112
+
113
+ | Parameter | Type | Default | Description |
114
+ |-----------|------|---------|-------------|
115
+ | `input_dir` | str | required | Input directory with SAC files |
116
+ | `output_dir` | str | required | Output directory |
117
+ | `num_workers` | int | -1 | CPU cores (-1 = all) |
118
+ | `plot_enabled` | bool | False | Generate plots |
119
+
120
+ ### Classes
121
+
122
+ - `Waveform(name)` - Waveform preprocessing container
123
+ - `State(name)` - Markov state model
124
+
125
+ ## Output Files
126
+
127
+ | File | Description |
128
+ |------|-------------|
129
+ | `{station}.txt` | Text summary with arrival time and polarity |
130
+ | `{station}.npz` | Main results (matrix, probabilities, thresholds) |
131
+ | `{station}_timeprob_{i}.npz` | Time probability distribution |
132
+ | `{station}_{i}.pdf` | Probability plot (if enabled) |
133
+ | `{station}.eps` | Publication-ready plot (if enabled) |
134
+
135
+ ## Algorithm
136
+
137
+ Based on: Pei, W., Zhuang, J. & Zhou, S. "Stochastic determination of arrival time and initial polarity of seismic waveform." *Earth Planets Space* 77, 36 (2025). https://doi.org/10.1186/s40623-025-02161-5
138
+
139
+ ## Validation
140
+
141
+ ```bash
142
+ python benchmark_validate.py check
143
+ ```
144
+
145
+ ## Citation
146
+
147
+ ```bibtex
148
+ @article{pei2025stochastic,
149
+ title={Stochastic determination of arrival time and initial polarity of seismic waveform},
150
+ author={Pei, W. and Zhuang, J. and Zhou, S.},
151
+ journal={Earth, Planets and Space},
152
+ volume={77},
153
+ pages={36},
154
+ year={2025},
155
+ doi={10.1186/s40623-025-02161-5}
156
+ }
157
+ ```
158
+
159
+ ## License
160
+
161
+ MIT License
162
+
163
+ ## Star History
164
+
165
+ [![Star History Chart](https://api.star-history.com/svg?repos=Chuan1937/SDATIP-Fast&type=Date)](https://star-history.com/#Chuan1937/SDATIP-Fast&Date)
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sdatip"
7
+ version = "1.0.0"
8
+ description = "Fast stochastic determination of arrival time and initial polarity of seismic waveforms"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ {name = "Chuan1937"}
14
+ ]
15
+ keywords = ["seismic", "waveform", "arrival-time", "polarity", "geophysics"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Science/Research",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Topic :: Scientific/Engineering",
26
+ ]
27
+ dependencies = [
28
+ "numpy>=1.20.0",
29
+ "scipy>=1.7.0",
30
+ "numba>=0.55.0",
31
+ "obspy>=1.3.0",
32
+ "matplotlib>=3.5.0",
33
+ "tqdm>=4.60.0",
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=7.0",
39
+ "ruff>=0.1.0",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/Chuan1937/SDATIP-Fast"
44
+ Documentation = "https://github.com/Chuan1937/SDATIP-Fast#readme"
45
+ Repository = "https://github.com/Chuan1937/SDATIP-Fast"
46
+
47
+ [tool.setuptools.packages.find]
48
+ where = ["."]
49
+ include = ["sdatip*"]
50
+
51
+ [tool.ruff]
52
+ line-length = 120
53
+ target-version = "py38"
@@ -0,0 +1,46 @@
1
+ """SDATIP: Fast Stochastic Determination of Arrival Time and Initial Polarity.
2
+
3
+ A high-performance Python package for seismic waveform analysis that determines
4
+ arrival time and initial polarity using Markov chain-based stochastic methods.
5
+
6
+ Example usage:
7
+ >>> import sdatip
8
+ >>>
9
+ >>> # Quick processing
10
+ >>> result = sdatip.process_waveform(
11
+ ... name="station_A",
12
+ ... data=waveform_array,
13
+ ... output_dir="./output/"
14
+ ... )
15
+ >>> print(f"Arrival time: {result['arrival_time']:.3f}s")
16
+ >>> print(f"Polarity: {result['polarity_up']:.3f}")
17
+ >>>
18
+ >>> # Step-by-step processing
19
+ >>> wf = sdatip.Waveform("station_A")
20
+ >>> wf.importdata(data, delta=0.01)
21
+ >>> wf.analyzedata()
22
+ >>> # ... continue with other steps
23
+ """
24
+
25
+ from sdatip.waveform import Waveform, findnoise
26
+ from sdatip.state import State
27
+ from sdatip.pmi import entropy, pmi, maxpmi, calculate_general
28
+ from sdatip.processor import process_waveform, process_batch
29
+
30
+ __version__ = "1.0.0"
31
+ __author__ = "Chuan1937"
32
+
33
+ __all__ = [
34
+ # Main classes
35
+ "Waveform",
36
+ "State",
37
+ # High-level API
38
+ "process_waveform",
39
+ "process_batch",
40
+ # Utility functions
41
+ "findnoise",
42
+ "entropy",
43
+ "pmi",
44
+ "maxpmi",
45
+ "calculate_general",
46
+ ]