-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_synthetic_data_parallel.py
More file actions
59 lines (51 loc) · 1.65 KB
/
create_synthetic_data_parallel.py
File metadata and controls
59 lines (51 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
from datetime import datetime
from pathlib import Path
from src.synthetics import create_synthetic_data
from src.synthetics.create_associations import inventory_to_stations
def run_simulation(i):
DURATION = i[1] # seconds
OUT_DIR = Path(f'data/test_{i[0]}_{i[2]}')
N_CATALOGS = 20
AVG_RATE = i[0]
RANGE = 0.1
NOISE_PICKS = True
PC_NOISE_PICKS = i[2]
NOISE_TT = i[3]
NOISE_GMV = i[4]
MAX_MAGNITUDE = i[5]
OVERWRITE = True
startdate = datetime(2025, 1, 1, 0, 0, 0)
avg_events = DURATION * AVG_RATE
min_events = int(avg_events - (avg_events * RANGE / 2))
max_events = int(avg_events + (avg_events * RANGE / 2))
stations = inventory_to_stations('stations/station_cords_blab_VALTER.csv')
create_synthetic_data(
OUT_DIR,
N_CATALOGS,
min_events,
max_events,
DURATION,
stations,
startdate=startdate,
add_noise_picks=NOISE_PICKS,
pc_noise_picks=PC_NOISE_PICKS,
max_magnitude=MAX_MAGNITUDE,
overwrite=OVERWRITE,
noise_tt=NOISE_TT,
noise_gmv=NOISE_GMV,
id=i[6]
)
if __name__ == '__main__':
# avg_rate, pc_noise_picks, noise_tt, noise_gmv, max_magnitude, id
setting = [
(10, 1, 0.1, 0.1, 0.1, 0.0, 0),
(10, 1, 0.3, 0.1, 0.1, 0.0, 1),
(10, 1, 0.5, 0.1, 0.1, 0.0, 2),
(10, 1, 0.7, 0.1, 0.1, 0.0, 4),
(10, 1, 0.9, 0.1, 0.1, 0.0, 5),
]
ncpu = multiprocessing.cpu_count() - 1
with ProcessPoolExecutor(max_workers=ncpu) as executor:
executor.map(run_simulation, setting)