cnchash 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.
cnchash-1.0.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Xingchen He
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cnchash-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: cnchash
3
+ Version: 1.0.0
4
+ Summary: Python implementation of HASH v1.2 for earthquake focal mechanism determination
5
+ Author-email: He XingChen <example@example.com>
6
+ License: BSD 3-Clause
7
+ Project-URL: Homepage, https://github.com/Chuan1937/NCHASH
8
+ Project-URL: Documentation, https://cnchash.readthedocs.io
9
+ Project-URL: Repository, https://github.com/Chuan1937/NCHASH
10
+ Project-URL: Issues, https://github.com/Chuan1937/NCHASH/issues
11
+ Keywords: seismology,earthquake,focal-mechanism,hash,beachball,p-wave,polarity
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: BSD License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.20.0
26
+ Requires-Dist: numba>=0.56.0
27
+ Requires-Dist: scipy>=1.7.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Provides-Extra: docs
32
+ Requires-Dist: sphinx>=5.0; extra == "docs"
33
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
34
+ Requires-Dist: myst-parser>=1.0; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # NCHASH
38
+
39
+ Python implementation of HASH for earthquake focal mechanism determination from P-wave polarities.
40
+
41
+ ![Python](https://img.shields.io/badge/python-3.10+-orange.svg)
42
+ ![License](https://img.shields.io/badge/license-BSD%203--blue.svg)
43
+ ![Numba](https://img.shields.io/badge/numba-0.53+-red.svg)
44
+ ![Numpy](https://img.shields.io/badge/numpy-1.19+-yellow.svg)
45
+ ![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
46
+
47
+ Python uses Numba JIT compilation optimization and vectorization, achieving speed improvements while maintaining complete consistency with the core Fortran algorithm.
48
+
49
+ ![Speed Comparison](docs/images/speed_comparison.png)
50
+
51
+ ## Performance
52
+
53
+ | Metric | Python+Numba | Fortran | Speedup |
54
+ |--------|-------------|---------|---------|
55
+ | 24 events | 0.068s | 0.473s | **6.9x** |
56
+ | Per event | 2.85ms | 19.7ms | **6.9x** |
57
+ | 1000 events | 2.6s | 19.7s | **7.5x** |
58
+
59
+ ### For comprehensive benchmarks and analysis:
60
+
61
+ ![Comprehensive Comparison](docs/images/comprehensive_comparison.png)
62
+
63
+ ## Accuracy Verification
64
+
65
+ ![Accuracy Verification](docs/images/accuracy_verification.png)
66
+
67
+ **Key Results:**
68
+ - Dip error median: < 10°
69
+ - Rake error median: < 15°
70
+ - Core algorithm matches Fortran exactly
71
+
72
+ **Note:** Strike differences (40-80°) are normal - focal mechanisms have two orthogonal nodal planes that both satisfy polarity data.
73
+
74
+ ## Quick Start
75
+
76
+ ```bash
77
+ pip install -r requirements.txt
78
+ ```
79
+
80
+ ### Basic Usage (P-wave polarities only)
81
+
82
+ ```python
83
+ from nchash import run_hash
84
+ import numpy as np
85
+
86
+ # Azimuths, takeoff angles, polarities, quality
87
+ p_azi = np.array([45.0, 135.0, 225.0, 315.0])
88
+ p_the = np.array([30.0, 45.0, 60.0, 75.0])
89
+ p_pol = np.array([1, -1, 1, -1]) # 1=up, -1=down
90
+ p_qual = np.array([0, 0, 0, 0])
91
+
92
+ result = run_hash(p_azi, p_the, p_pol, p_qual)
93
+
94
+ print(f"Strike: {result['strike_avg']:.1f}")
95
+ print(f"Dip: {result['dip_avg']:.1f}")
96
+ print(f"Rake: {result['rake_avg']:.1f}")
97
+ print(f"Quality: {result['quality']}")
98
+ ```
99
+
100
+ ### With S/P Amplitude Ratio
101
+
102
+ ```python
103
+ from nchash import run_hash_with_amp
104
+ import numpy as np
105
+
106
+ # Same inputs as above, plus S/P amplitude ratios (log10 scale)
107
+ # sp_amp = 0.0 means no amplitude data for that station
108
+ sp_amp = np.array([0.3, -0.2, 0.5, 0.0]) # log10(S/P), 0.0 = no data
109
+
110
+ result = run_hash_with_amp(p_azi, p_the, p_pol, sp_amp)
111
+
112
+ print(f"Strike: {result['strike_avg']:.1f}")
113
+ print(f"Dip: {result['dip_avg']:.1f}")
114
+ print(f"Rake: {result['rake_avg']:.1f}")
115
+ print(f"Quality: {result['quality']}")
116
+ print(f"Polarity misfit: {result['mfrac']*100:.1f}%")
117
+ print(f"Amplitude misfit: {result['mavg']:.2f}")
118
+ ```
119
+
120
+ ## Features
121
+
122
+ - Grid search for focal mechanism determination
123
+ - Monte Carlo uncertainty analysis
124
+ - S/P amplitude ratio constraint
125
+ - Quality rating (A-D, E, F)
126
+ - Multiple phase file formats
127
+ - Core algorithm matches Fortran exactly
128
+
129
+ ## Documentation
130
+
131
+ See [docs/README.md](docs/README.md) for full documentation including:
132
+ - API reference
133
+ - Algorithm details
134
+ - File format specifications
135
+ - Performance optimization
136
+
137
+ ## Run Tests
138
+
139
+ ```bash
140
+ jupyter notebook HASH_Tests.ipynb
141
+ ```
142
+
143
+ ## Project Structure
144
+
145
+ ```
146
+ nchash/
147
+ ├── core.py # Grid search algorithm (focalmc)
148
+ ├── amp_subs.py # S/P amplitude ratio (focalamp_mc)
149
+ ├── uncertainty.py # Uncertainty analysis (mech_prob)
150
+ ├── driver.py # Main driver (run_hash, run_hash_with_amp)
151
+ ├── io.py # File I/O
152
+ └── utils.py # Utilities
153
+
154
+ HASH_complete/ # Complete Fortran code with examples
155
+ ```
156
+
157
+ ## Author
158
+
159
+ He XingChen
160
+
161
+ ## License
162
+
163
+ BSD 3-Clause
164
+
165
+ ## References
166
+
167
+ Hardebeck, Jeanne L. and Peter M. Shearer, A new method for determining first-motion
168
+ focal mechanisms, Bulletin of the Seismological Society of America, 92,
169
+ 2264-2276, 2002.
170
+
171
+ Hardebeck, Jeanne L. and Peter M. Shearer, Using S/P Amplitude Ratios to
172
+ Constrain the Focal Mechanisms of Small Earthquakes, Bulletin of the
173
+ Seismological Society of America, 93, 2434-2444, 2003.
@@ -0,0 +1,137 @@
1
+ # NCHASH
2
+
3
+ Python implementation of HASH for earthquake focal mechanism determination from P-wave polarities.
4
+
5
+ ![Python](https://img.shields.io/badge/python-3.10+-orange.svg)
6
+ ![License](https://img.shields.io/badge/license-BSD%203--blue.svg)
7
+ ![Numba](https://img.shields.io/badge/numba-0.53+-red.svg)
8
+ ![Numpy](https://img.shields.io/badge/numpy-1.19+-yellow.svg)
9
+ ![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
10
+
11
+ Python uses Numba JIT compilation optimization and vectorization, achieving speed improvements while maintaining complete consistency with the core Fortran algorithm.
12
+
13
+ ![Speed Comparison](docs/images/speed_comparison.png)
14
+
15
+ ## Performance
16
+
17
+ | Metric | Python+Numba | Fortran | Speedup |
18
+ |--------|-------------|---------|---------|
19
+ | 24 events | 0.068s | 0.473s | **6.9x** |
20
+ | Per event | 2.85ms | 19.7ms | **6.9x** |
21
+ | 1000 events | 2.6s | 19.7s | **7.5x** |
22
+
23
+ ### For comprehensive benchmarks and analysis:
24
+
25
+ ![Comprehensive Comparison](docs/images/comprehensive_comparison.png)
26
+
27
+ ## Accuracy Verification
28
+
29
+ ![Accuracy Verification](docs/images/accuracy_verification.png)
30
+
31
+ **Key Results:**
32
+ - Dip error median: < 10°
33
+ - Rake error median: < 15°
34
+ - Core algorithm matches Fortran exactly
35
+
36
+ **Note:** Strike differences (40-80°) are normal - focal mechanisms have two orthogonal nodal planes that both satisfy polarity data.
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ pip install -r requirements.txt
42
+ ```
43
+
44
+ ### Basic Usage (P-wave polarities only)
45
+
46
+ ```python
47
+ from nchash import run_hash
48
+ import numpy as np
49
+
50
+ # Azimuths, takeoff angles, polarities, quality
51
+ p_azi = np.array([45.0, 135.0, 225.0, 315.0])
52
+ p_the = np.array([30.0, 45.0, 60.0, 75.0])
53
+ p_pol = np.array([1, -1, 1, -1]) # 1=up, -1=down
54
+ p_qual = np.array([0, 0, 0, 0])
55
+
56
+ result = run_hash(p_azi, p_the, p_pol, p_qual)
57
+
58
+ print(f"Strike: {result['strike_avg']:.1f}")
59
+ print(f"Dip: {result['dip_avg']:.1f}")
60
+ print(f"Rake: {result['rake_avg']:.1f}")
61
+ print(f"Quality: {result['quality']}")
62
+ ```
63
+
64
+ ### With S/P Amplitude Ratio
65
+
66
+ ```python
67
+ from nchash import run_hash_with_amp
68
+ import numpy as np
69
+
70
+ # Same inputs as above, plus S/P amplitude ratios (log10 scale)
71
+ # sp_amp = 0.0 means no amplitude data for that station
72
+ sp_amp = np.array([0.3, -0.2, 0.5, 0.0]) # log10(S/P), 0.0 = no data
73
+
74
+ result = run_hash_with_amp(p_azi, p_the, p_pol, sp_amp)
75
+
76
+ print(f"Strike: {result['strike_avg']:.1f}")
77
+ print(f"Dip: {result['dip_avg']:.1f}")
78
+ print(f"Rake: {result['rake_avg']:.1f}")
79
+ print(f"Quality: {result['quality']}")
80
+ print(f"Polarity misfit: {result['mfrac']*100:.1f}%")
81
+ print(f"Amplitude misfit: {result['mavg']:.2f}")
82
+ ```
83
+
84
+ ## Features
85
+
86
+ - Grid search for focal mechanism determination
87
+ - Monte Carlo uncertainty analysis
88
+ - S/P amplitude ratio constraint
89
+ - Quality rating (A-D, E, F)
90
+ - Multiple phase file formats
91
+ - Core algorithm matches Fortran exactly
92
+
93
+ ## Documentation
94
+
95
+ See [docs/README.md](docs/README.md) for full documentation including:
96
+ - API reference
97
+ - Algorithm details
98
+ - File format specifications
99
+ - Performance optimization
100
+
101
+ ## Run Tests
102
+
103
+ ```bash
104
+ jupyter notebook HASH_Tests.ipynb
105
+ ```
106
+
107
+ ## Project Structure
108
+
109
+ ```
110
+ nchash/
111
+ ├── core.py # Grid search algorithm (focalmc)
112
+ ├── amp_subs.py # S/P amplitude ratio (focalamp_mc)
113
+ ├── uncertainty.py # Uncertainty analysis (mech_prob)
114
+ ├── driver.py # Main driver (run_hash, run_hash_with_amp)
115
+ ├── io.py # File I/O
116
+ └── utils.py # Utilities
117
+
118
+ HASH_complete/ # Complete Fortran code with examples
119
+ ```
120
+
121
+ ## Author
122
+
123
+ He XingChen
124
+
125
+ ## License
126
+
127
+ BSD 3-Clause
128
+
129
+ ## References
130
+
131
+ Hardebeck, Jeanne L. and Peter M. Shearer, A new method for determining first-motion
132
+ focal mechanisms, Bulletin of the Seismological Society of America, 92,
133
+ 2264-2276, 2002.
134
+
135
+ Hardebeck, Jeanne L. and Peter M. Shearer, Using S/P Amplitude Ratios to
136
+ Constrain the Focal Mechanisms of Small Earthquakes, Bulletin of the
137
+ Seismological Society of America, 93, 2434-2444, 2003.
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: cnchash
3
+ Version: 1.0.0
4
+ Summary: Python implementation of HASH v1.2 for earthquake focal mechanism determination
5
+ Author-email: He XingChen <example@example.com>
6
+ License: BSD 3-Clause
7
+ Project-URL: Homepage, https://github.com/Chuan1937/NCHASH
8
+ Project-URL: Documentation, https://cnchash.readthedocs.io
9
+ Project-URL: Repository, https://github.com/Chuan1937/NCHASH
10
+ Project-URL: Issues, https://github.com/Chuan1937/NCHASH/issues
11
+ Keywords: seismology,earthquake,focal-mechanism,hash,beachball,p-wave,polarity
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: BSD License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.20.0
26
+ Requires-Dist: numba>=0.56.0
27
+ Requires-Dist: scipy>=1.7.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Provides-Extra: docs
32
+ Requires-Dist: sphinx>=5.0; extra == "docs"
33
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
34
+ Requires-Dist: myst-parser>=1.0; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # NCHASH
38
+
39
+ Python implementation of HASH for earthquake focal mechanism determination from P-wave polarities.
40
+
41
+ ![Python](https://img.shields.io/badge/python-3.10+-orange.svg)
42
+ ![License](https://img.shields.io/badge/license-BSD%203--blue.svg)
43
+ ![Numba](https://img.shields.io/badge/numba-0.53+-red.svg)
44
+ ![Numpy](https://img.shields.io/badge/numpy-1.19+-yellow.svg)
45
+ ![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
46
+
47
+ Python uses Numba JIT compilation optimization and vectorization, achieving speed improvements while maintaining complete consistency with the core Fortran algorithm.
48
+
49
+ ![Speed Comparison](docs/images/speed_comparison.png)
50
+
51
+ ## Performance
52
+
53
+ | Metric | Python+Numba | Fortran | Speedup |
54
+ |--------|-------------|---------|---------|
55
+ | 24 events | 0.068s | 0.473s | **6.9x** |
56
+ | Per event | 2.85ms | 19.7ms | **6.9x** |
57
+ | 1000 events | 2.6s | 19.7s | **7.5x** |
58
+
59
+ ### For comprehensive benchmarks and analysis:
60
+
61
+ ![Comprehensive Comparison](docs/images/comprehensive_comparison.png)
62
+
63
+ ## Accuracy Verification
64
+
65
+ ![Accuracy Verification](docs/images/accuracy_verification.png)
66
+
67
+ **Key Results:**
68
+ - Dip error median: < 10°
69
+ - Rake error median: < 15°
70
+ - Core algorithm matches Fortran exactly
71
+
72
+ **Note:** Strike differences (40-80°) are normal - focal mechanisms have two orthogonal nodal planes that both satisfy polarity data.
73
+
74
+ ## Quick Start
75
+
76
+ ```bash
77
+ pip install -r requirements.txt
78
+ ```
79
+
80
+ ### Basic Usage (P-wave polarities only)
81
+
82
+ ```python
83
+ from nchash import run_hash
84
+ import numpy as np
85
+
86
+ # Azimuths, takeoff angles, polarities, quality
87
+ p_azi = np.array([45.0, 135.0, 225.0, 315.0])
88
+ p_the = np.array([30.0, 45.0, 60.0, 75.0])
89
+ p_pol = np.array([1, -1, 1, -1]) # 1=up, -1=down
90
+ p_qual = np.array([0, 0, 0, 0])
91
+
92
+ result = run_hash(p_azi, p_the, p_pol, p_qual)
93
+
94
+ print(f"Strike: {result['strike_avg']:.1f}")
95
+ print(f"Dip: {result['dip_avg']:.1f}")
96
+ print(f"Rake: {result['rake_avg']:.1f}")
97
+ print(f"Quality: {result['quality']}")
98
+ ```
99
+
100
+ ### With S/P Amplitude Ratio
101
+
102
+ ```python
103
+ from nchash import run_hash_with_amp
104
+ import numpy as np
105
+
106
+ # Same inputs as above, plus S/P amplitude ratios (log10 scale)
107
+ # sp_amp = 0.0 means no amplitude data for that station
108
+ sp_amp = np.array([0.3, -0.2, 0.5, 0.0]) # log10(S/P), 0.0 = no data
109
+
110
+ result = run_hash_with_amp(p_azi, p_the, p_pol, sp_amp)
111
+
112
+ print(f"Strike: {result['strike_avg']:.1f}")
113
+ print(f"Dip: {result['dip_avg']:.1f}")
114
+ print(f"Rake: {result['rake_avg']:.1f}")
115
+ print(f"Quality: {result['quality']}")
116
+ print(f"Polarity misfit: {result['mfrac']*100:.1f}%")
117
+ print(f"Amplitude misfit: {result['mavg']:.2f}")
118
+ ```
119
+
120
+ ## Features
121
+
122
+ - Grid search for focal mechanism determination
123
+ - Monte Carlo uncertainty analysis
124
+ - S/P amplitude ratio constraint
125
+ - Quality rating (A-D, E, F)
126
+ - Multiple phase file formats
127
+ - Core algorithm matches Fortran exactly
128
+
129
+ ## Documentation
130
+
131
+ See [docs/README.md](docs/README.md) for full documentation including:
132
+ - API reference
133
+ - Algorithm details
134
+ - File format specifications
135
+ - Performance optimization
136
+
137
+ ## Run Tests
138
+
139
+ ```bash
140
+ jupyter notebook HASH_Tests.ipynb
141
+ ```
142
+
143
+ ## Project Structure
144
+
145
+ ```
146
+ nchash/
147
+ ├── core.py # Grid search algorithm (focalmc)
148
+ ├── amp_subs.py # S/P amplitude ratio (focalamp_mc)
149
+ ├── uncertainty.py # Uncertainty analysis (mech_prob)
150
+ ├── driver.py # Main driver (run_hash, run_hash_with_amp)
151
+ ├── io.py # File I/O
152
+ └── utils.py # Utilities
153
+
154
+ HASH_complete/ # Complete Fortran code with examples
155
+ ```
156
+
157
+ ## Author
158
+
159
+ He XingChen
160
+
161
+ ## License
162
+
163
+ BSD 3-Clause
164
+
165
+ ## References
166
+
167
+ Hardebeck, Jeanne L. and Peter M. Shearer, A new method for determining first-motion
168
+ focal mechanisms, Bulletin of the Seismological Society of America, 92,
169
+ 2264-2276, 2002.
170
+
171
+ Hardebeck, Jeanne L. and Peter M. Shearer, Using S/P Amplitude Ratios to
172
+ Constrain the Focal Mechanisms of Small Earthquakes, Bulletin of the
173
+ Seismological Society of America, 93, 2434-2444, 2003.
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ cnchash.egg-info/PKG-INFO
5
+ cnchash.egg-info/SOURCES.txt
6
+ cnchash.egg-info/dependency_links.txt
7
+ cnchash.egg-info/entry_points.txt
8
+ cnchash.egg-info/requires.txt
9
+ cnchash.egg-info/top_level.txt
10
+ nchash/__init__.py
11
+ nchash/amp_subs.py
12
+ nchash/cli.py
13
+ nchash/core.py
14
+ nchash/driver.py
15
+ nchash/io.py
16
+ nchash/uncertainty.py
17
+ nchash/utils.py
18
+ nchash/velocity.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nchash = nchash.cli:main
@@ -0,0 +1,12 @@
1
+ numpy>=1.20.0
2
+ numba>=0.56.0
3
+ scipy>=1.7.0
4
+
5
+ [dev]
6
+ ruff>=0.1.0
7
+ pytest>=7.0.0
8
+
9
+ [docs]
10
+ sphinx>=5.0
11
+ sphinx-rtd-theme>=1.0
12
+ myst-parser>=1.0
@@ -0,0 +1 @@
1
+ nchash
@@ -0,0 +1,81 @@
1
+ """
2
+ NCHASH - Python implementation of HASH v1.2 for earthquake focal mechanism inversion.
3
+
4
+ This package provides a pure Python implementation of the HASH algorithm for
5
+ determining earthquake focal mechanisms from polarities, with performance
6
+ optimizations using numba and numpy.
7
+
8
+ Author: He XingChen
9
+ License: BSD 3-Clause
10
+ """
11
+
12
+ __version__ = "1.0.0"
13
+ __author__ = "He XingChen"
14
+
15
+ from .amp_subs import (
16
+ focalamp_mc,
17
+ get_misf_amp,
18
+ )
19
+ from .core import (
20
+ focalmc,
21
+ get_gap,
22
+ get_misfit,
23
+ )
24
+ from .driver import (
25
+ run_hash,
26
+ run_hash_with_amp,
27
+ run_hash_from_file,
28
+ )
29
+ from .io import (
30
+ read_phase_file,
31
+ read_station_file,
32
+ read_velocity_model,
33
+ write_mechanism_output,
34
+ )
35
+ from .uncertainty import (
36
+ mech_avg,
37
+ mech_prob,
38
+ mech_rot,
39
+ )
40
+ from .utils import (
41
+ cross_product,
42
+ fp_coord,
43
+ normal_distribution_random,
44
+ strike_dip_rake_to_vectors,
45
+ to_cartesian,
46
+ vectors_to_strike_dip_rake,
47
+ )
48
+ from .velocity import (
49
+ get_tts,
50
+ make_table,
51
+ )
52
+
53
+ __all__ = [
54
+ # Main functions
55
+ "run_hash",
56
+ "run_hash_with_amp",
57
+ "run_hash_from_file",
58
+ # Core algorithms
59
+ "focalmc",
60
+ "focalamp_mc",
61
+ "mech_prob",
62
+ "mech_avg",
63
+ "mech_rot",
64
+ # Utilities
65
+ "get_misfit",
66
+ "get_misf_amp",
67
+ "get_gap",
68
+ "make_table",
69
+ "get_tts",
70
+ "cross_product",
71
+ "to_cartesian",
72
+ "fp_coord",
73
+ "normal_distribution_random",
74
+ "strike_dip_rake_to_vectors",
75
+ "vectors_to_strike_dip_rake",
76
+ # I/O
77
+ "read_phase_file",
78
+ "read_station_file",
79
+ "read_velocity_model",
80
+ "write_mechanism_output",
81
+ ]