Fitting the Data API Documentation
fault_fitting.py
This module contains functions to process the merged seismicity and fit the fault surfaces using Support Vector Regression (SVR), calculate fault orientations, and prepare data for further analysis and visualization.
Author: Travis Alongi (talongi@usgs.gov)
fit_fault_surface(file, n_iter, xstrap_fraction, grid_spacing, svr_cross_validation_distribution={'C': uniform(1, 100), 'epsilon': uniform(50, 600)}, max_subsurface_depth_meters=-15000)
Fit a surface from fault data using Support Vector Regression (SVR).
This function reads fault data from a CSV file, calculates the fault's strike and dip, fits a surface using SVR, and extrapolates the surface beyond the observed data. It returns the gridded surface coordinates and fault orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str or path - like
|
The file containing fault data with x, y, depth_m columns. x and y are assumed to be in UTM coordinates |
required |
n_iter
|
int
|
The number of iterations for cross-validation to determine the best SVR parameters. |
required |
xstrap_fraction
|
float
|
The fraction of the fault's dimensions to extrapolate beyond. |
required |
grid_spacing
|
float or int
|
The desired spacing between points in the output grid. |
required |
svr_cross_validation_distribution
|
dict
|
A dictionary of C and epsilon values for SVR cross-validation. |
{'C': uniform(1, 100), 'epsilon': uniform(50, 600)}
|
max_subsurface_depth_meters
|
float or in
|
The maximum depth in meters to build faults too (default: -15,000 meters or -15 km) |
-15000
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Example
svr_params = {"C": [1, 10, 100], "epsilon": [0.01, 0.1, 1]}
result = fit_fault_surface(
"fault_data.csv", svr_params, n_iter=10, xstrap_fraction=0.2, grid_spacing=100
)
grid_data, strike, dip, best_params = result
print(f"Strike: {strike:.2f}, Dip: {dip:.2f}")
print(f"Best SVR Params: {best_params}")
Source code in fault_fitting.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
stdip_from_norm(array)
Calculates strike and dip from a normal vector (array).
The function calculates the strike and dip based on the normal vector, following the right-hand rule. The strike is measured from the positive x-axis, and the dip is the angle between the surface and the horizontal plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
A 3D vector representing the normal vector (x, y, z). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Example:
python
import numpy as np
normal_vector = np.array([0.5, 0.5, -1])
strike, dip = stdip_from_norm(normal_vector)
print(f"Strike: {strike:.2f}, Dip: {dip:.2f}")
Source code in fault_fitting.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
wrapper_fit_fault_surface(args)
Wrapper for fit_fault_surface used for parallel processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
tuple
|
A tuple containing the arguments for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
The same output as |
Example
from multiprocessing import Pool
fault_files = ["fault1.csv", "fault2.csv"]
svr_params = {"C": [1, 10, 100], "epsilon": [0.01, 0.1, 1]}
args_list = [(f, svr_params, 10, 0.2, 100) for f in fault_files]
with Pool() as pool:
results = pool.map(wrapper_process_single_fault, args_list)
for res in results:
print(f"Strike: {res[1]:.2f}, Dip: {res[2]:.2f}")
Source code in fault_fitting.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |