-
Notifications
You must be signed in to change notification settings - Fork 3
/
generator.py
65 lines (52 loc) · 1.74 KB
/
generator.py
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
60
61
62
63
64
65
import matplotlib
matplotlib.use('agg')
import os
import argparse
from glob import glob
import numpy as np
from tqdm import tqdm
from gprMax.gprMax import api
from tools.outputfiles_merge import merge_files
from tools.plot_Bscan import get_output_data
from utils import save_img
class Generator:
def __init__(self, n_scans, in_dir, out_dir):
self.in_dir = in_dir
self.out_dir = out_dir
self.in_file_paths = glob(in_dir)
self.in_file_paths.sort()
self.rx_number = 1
self.rx_component = 'Ez'
self.n_scans = n_scans
for path in tqdm(self.in_file_paths):
self._create_ascan(path)
self._merge_ascan(path)
outputdata, dt = self._prepare_bscan(path)
save_img(path,
outputdata,
dt,
self.rx_number,
self.rx_component,
self.out_dir)
def _create_ascan(self, path):
api(path,
n=self.n_scans,
geometry_only=False,
gpu=[0])
def _merge_ascan(self, path):
filename, _ = os.path.splitext(path)
merge_files(filename, removefiles=True)
def _prepare_bscan(self, path):
filename, _ = os.path.splitext(path)
filename = filename + '_merged.out'
return get_output_data(filename,
self.rx_number,
self.rx_component)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--in_dir', help='name of the input directory')
parser.add_argument(
'--out_dir', help='name of output directory')
args = parser.parse_args()
Generator(200, args.out_dir, args.in_dir)