Generators¶
The generators module provides three levels of synthetic InSAR data creation: single interferograms, time series, and batch generation for ML training.
Single Interferogram¶
generate_synthetic_insar ¶
generate_synthetic_insar(Mw: Optional[float] = None, M0: Optional[float] = None, strike_deg: float = 0.0, dip_deg: float = 45.0, rake_deg: float = 90.0, xcen_km: float = 0.0, ycen_km: float = 0.0, depth_km: float = 10.0, grid_size: Optional[int] = None, grid_extent_km: float = 50.0, grid_spacing_km: Optional[float] = None, nu: float = DEFAULT_POISSON_RATIO, mu: float = DEFAULT_SHEAR_MODULUS_PA, satellite: Optional[str] = None, orbit: str = 'ascending', incidence_deg: Optional[float] = None, heading_deg: Optional[float] = None, wavelength_m: Optional[float] = None, add_noise: bool = True, noise_amplitude_m: float = 0.005, add_orbital_ramp: bool = False, wrap: bool = True, seed: Optional[int] = None) -> Dict
Generate synthetic InSAR data for earthquake deformation.
This is the main generator function that creates a complete synthetic interferogram including displacement field, phase, and noise. Uses the Davis (1986) point source model.
| PARAMETER | DESCRIPTION |
|---|---|
Mw
|
Moment magnitude (provide either Mw or M0)
TYPE:
|
M0
|
Scalar seismic moment in N·m
TYPE:
|
strike_deg
|
Fault strike in degrees (0-360, clockwise from North)
TYPE:
|
dip_deg
|
Fault dip in degrees (0-90, from horizontal)
TYPE:
|
rake_deg
|
Slip rake in degrees (-180 to 180) - 0°: left-lateral strike-slip - 90°: thrust/reverse - ±180°: right-lateral strike-slip - -90°: normal fault
TYPE:
|
xcen_km
|
Epicenter location in km
TYPE:
|
ycen_km
|
Epicenter location in km
TYPE:
|
depth_km
|
Source depth in km (positive downward)
TYPE:
|
grid_size
|
Number of pixels for the grid (e.g., 128 for 128x128). If provided, grid_spacing_km is calculated automatically.
TYPE:
|
grid_extent_km
|
Half-width of the grid in km (default: 50 km, so 100 km total)
TYPE:
|
grid_spacing_km
|
Grid spacing in km. If not provided and grid_size is given, calculated as: 2 * grid_extent_km / (grid_size - 1)
TYPE:
|
nu
|
Poisson's ratio (default: 0.25)
TYPE:
|
mu
|
Shear modulus in Pa (default: 30 GPa)
TYPE:
|
satellite
|
Satellite name for automatic geometry. Options: 'sentinel1', 'alos2', 'terrasar', 'cosmo', 'radarsat2', 'nisar', etc. If provided, overrides incidence_deg, heading_deg, wavelength_m
TYPE:
|
orbit
|
Orbit direction: 'ascending' or 'descending' (used with satellite)
TYPE:
|
incidence_deg
|
Radar incidence angle in degrees (manual specification)
TYPE:
|
heading_deg
|
Satellite heading in degrees (manual specification)
TYPE:
|
wavelength_m
|
Radar wavelength in meters (manual specification)
TYPE:
|
add_noise
|
Whether to add random noise
TYPE:
|
noise_amplitude_m
|
Noise standard deviation in meters (default: 5 mm)
TYPE:
|
add_orbital_ramp
|
Whether to add orbital ramp artifact
TYPE:
|
wrap
|
Whether to wrap phase to [-π, π]
TYPE:
|
seed
|
Random seed for reproducibility
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
result
|
Dictionary containing: - X_km, Y_km: coordinate grids (km) - Ue, Un, Uz: displacement components (m) - los_displacement: LOS displacement (m) - phase_unwrapped: unwrapped phase (rad) - phase_wrapped: wrapped phase (rad) - phase_noisy: wrapped phase with noise (rad) - metadata: source and processing parameters
TYPE:
|
Examples:
>>> result = generate_synthetic_insar(
... Mw=6.0,
... strike_deg=45,
... dip_deg=30,
... rake_deg=90,
... depth_km=10,
... satellite='sentinel1',
... orbit='ascending'
... )
Source code in src/eq_insar/generators/single.py
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 195 196 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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
Time Series¶
generate_timeseries ¶
generate_timeseries(Mw: Optional[float] = None, M0: Optional[float] = None, strike_deg: float = 0.0, dip_deg: float = 45.0, rake_deg: float = 90.0, xcen_km: float = 0.0, ycen_km: float = 0.0, depth_km: float = 10.0, grid_size: Optional[int] = None, grid_extent_km: float = 50.0, grid_spacing_km: Optional[float] = None, nu: float = DEFAULT_POISSON_RATIO, mu: float = DEFAULT_SHEAR_MODULUS_PA, satellite: Optional[str] = None, orbit: str = 'ascending', incidence_deg: Optional[float] = None, heading_deg: Optional[float] = None, wavelength_m: Optional[float] = None, n_pre: int = 5, n_event: int = 1, n_post: int = 5, noise_amplitude_m: float = 0.005, wrap: bool = True, output_type: str = 'phase', deformation_threshold_m: float = 0.005, seed: Optional[int] = None) -> Dict
Generate time series of synthetic InSAR data.
Creates a sequence with: - Pre-event frames: noise only (no deformation signal) - Event frames: deformation signal + noise - Post-event frames: noise only
This format is designed for training ML models to detect and segment earthquake deformation signals.
| PARAMETER | DESCRIPTION |
|---|---|
Mw
|
Moment magnitude
TYPE:
|
M0
|
Seismic moment in N·m
TYPE:
|
strike_deg
|
Fault geometry parameters
TYPE:
|
dip_deg
|
Fault geometry parameters
TYPE:
|
rake_deg
|
Fault geometry parameters
TYPE:
|
xcen_km
|
Epicenter location in km
TYPE:
|
ycen_km
|
Epicenter location in km
TYPE:
|
depth_km
|
Source depth in km
TYPE:
|
grid_size
|
Number of pixels for the grid (e.g., 128 for 128x128). If provided, grid_spacing_km is calculated automatically.
TYPE:
|
grid_extent_km
|
Half-width of the grid in km (default: 50 km)
TYPE:
|
grid_spacing_km
|
Grid spacing in km. If not provided and grid_size is given, calculated as: 2 * grid_extent_km / (grid_size - 1)
TYPE:
|
satellite
|
Satellite configuration ('sentinel1', 'alos2', etc.)
TYPE:
|
orbit
|
'ascending' or 'descending'
TYPE:
|
n_pre
|
Number of pre-event frames (noise only)
TYPE:
|
n_event
|
Number of event frames (signal + noise)
TYPE:
|
n_post
|
Number of post-event frames (noise only)
TYPE:
|
noise_amplitude_m
|
Noise standard deviation in meters
TYPE:
|
wrap
|
Wrap phase to [-π, π]
TYPE:
|
output_type
|
'phase' (default), 'displacement', or 'both'
TYPE:
|
deformation_threshold_m
|
Threshold for creating binary deformation labels
TYPE:
|
seed
|
Random seed for reproducibility
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
result
|
Dictionary containing: - All fields from generate_synthetic_insar (static deformation) - timeseries: (n_total, ny, nx) array of frames - labels: (n_total, ny, nx) binary segmentation masks - metadata: includes n_pre, n_event, n_post
TYPE:
|
Examples:
>>> result = generate_timeseries(
... Mw=6.0,
... satellite='sentinel1',
... n_pre=5,
... n_event=1,
... n_post=5
... )
>>> X = result['timeseries'] # Shape: (11, ny, nx)
>>> y = result['labels'] # Binary masks
Source code in src/eq_insar/generators/timeseries.py
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 63 64 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 195 196 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 223 | |
Batch Generation¶
generate_training_batch ¶
generate_training_batch(n_samples: int, grid_size: Optional[int] = None, grid_extent_km: float = 50.0, grid_spacing_km: Optional[float] = None, mw_range: Tuple[float, float] = (4.5, 7.0), depth_range_km: Tuple[float, float] = (5.0, 20.0), fault_type: Optional[str] = None, satellite: str = 'sentinel1', orbit: str = 'ascending', n_pre: int = 3, n_event: int = 1, n_post: int = 3, noise_range_m: Tuple[float, float] = (0.002, 0.008), wrap: bool = True, output_type: str = 'phase', seed: Optional[int] = None, verbose: bool = True) -> List[Dict]
Generate a batch of training samples with random parameters.
Creates multiple synthetic InSAR time series with varied earthquake parameters, suitable for training ML models.
| PARAMETER | DESCRIPTION |
|---|---|
n_samples
|
Number of samples to generate
TYPE:
|
grid_size
|
Number of pixels for the grid (e.g., 128 for 128x128). If provided, grid_spacing_km is calculated automatically.
TYPE:
|
grid_extent_km
|
Half-width of the grid in km (default: 50 km)
TYPE:
|
grid_spacing_km
|
Grid spacing in km. If not provided and grid_size is given, calculated as: 2 * grid_extent_km / (grid_size - 1)
TYPE:
|
mw_range
|
Range of moment magnitudes
TYPE:
|
depth_range_km
|
Range of depths in km
TYPE:
|
fault_type
|
Constrain fault type: 'strike-slip', 'thrust', 'normal', or None
TYPE:
|
satellite
|
Satellite configuration name
TYPE:
|
orbit
|
'ascending' or 'descending'
TYPE:
|
n_pre
|
Time series structure
TYPE:
|
n_event
|
Time series structure
TYPE:
|
n_post
|
Time series structure
TYPE:
|
noise_range_m
|
Range of noise amplitudes
TYPE:
|
wrap
|
Whether to wrap phase
TYPE:
|
output_type
|
'phase' or 'displacement'
TYPE:
|
seed
|
Random seed for reproducibility
TYPE:
|
verbose
|
Print progress messages
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
samples
|
List of sample dictionaries from generate_timeseries
TYPE:
|
Examples:
>>> batch = generate_training_batch(
... n_samples=100,
... mw_range=(5.0, 6.5),
... satellite='sentinel1'
... )
>>> X = np.stack([s['timeseries'] for s in batch]) # (100, T, H, W)
>>> y = np.stack([s['labels'] for s in batch]) # (100, T, H, W)
Source code in src/eq_insar/generators/batch.py
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 195 196 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 223 | |
batch_to_arrays ¶
Convert batch of samples to stacked numpy arrays for ML training.
| PARAMETER | DESCRIPTION |
|---|---|
batch
|
Output from generate_training_batch
TYPE:
|
include_metadata
|
Include metadata as a list
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
data
|
Dictionary containing: - X: (N, T, H, W) timeseries array - y: (N, T, H, W) labels array - los: (N, H, W) static LOS displacement - metadata: list of metadata dicts (if include_metadata=True)
TYPE:
|
Source code in src/eq_insar/generators/batch.py
Parameter Sampling¶
sample_earthquake_parameters ¶
sample_earthquake_parameters(mw_range: Tuple[float, float] = (4.5, 7.0), depth_range_km: Tuple[float, float] = (5.0, 20.0), location_range_km: float = 30.0, fault_type: Optional[str] = None, seed: Optional[int] = None) -> Dict
Sample random earthquake source parameters.
Generates physically reasonable earthquake parameters with optional constraints on fault type.
| PARAMETER | DESCRIPTION |
|---|---|
mw_range
|
Range of moment magnitudes to sample from
TYPE:
|
depth_range_km
|
Range of depths in km to sample from
TYPE:
|
location_range_km
|
Maximum offset from center for epicenter location
TYPE:
|
fault_type
|
Constrain fault type: 'strike-slip', 'thrust', 'normal', or None (random)
TYPE:
|
seed
|
Random seed for reproducibility
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
params
|
Dictionary with keys: Mw, strike_deg, dip_deg, rake_deg, xcen_km, ycen_km, depth_km
TYPE:
|