예제 #1
0
def generate_files(start=s, count=2, gpu=False):
    for i in range(start, start + count):
        seed = randint(1, 9999999)
        cylinders = ''.join(get_cylinders(0.5, 0.45, 0.02, 3, 0.05, 0.03))

        with open('in_file.in', 'w') as in_file:
            in_file.write(
                in_file_content.format(cylinders=cylinders, seed=seed))

        api('in_file.in', geometry_only=True)
        reader = pyvista.read('in_geometry.vti')
        shape = np.array([reader.dimensions[1], reader.dimensions[0]]) - 1
        material = reader['Material']
        in_img = material.reshape(shape)
        in_img = np.flip(in_img, axis=0)
        in_img = in_img + abs(np.min(in_img))
        in_img = in_img / np.max(in_img) * 255
        in_img[in_img < 15] = 0
        in_img[in_img >= 15] = 255
        in_img = Image.fromarray(in_img)

        with open('in_file.in', 'w') as in_file:
            in_file.write(
                in_file_content.format(cylinders=cylinders, seed=seed).replace(
                    '#geometry_view', 'geometry_view'))

        if gpu:
            api('in_file.in', 105, gpu=[0])
        else:
            api('in_file.in', 105)
        merge_files('in_file', removefiles=True)
        data, dt = get_output_data('in_file_merged.out', 1, 'Ez')

        # Усиливаем границы фильтром лапласа
        data = laplace(data)
        # Гауссово размытие
        data = gaussian_filter(data, sigma=5)
        # Нормируем значения матрицы
        data += abs(np.min(data))
        data = data / np.max(data) * 255

        out_img = Image.fromarray(data)
        out_img = out_img.resize(in_img.size)
        in_img.convert('RGB').save('y/in_{}.png'.format(i), 'PNG')
        out_img.convert('RGB').save('x/out_{}.png'.format(i), 'PNG')
예제 #2
0
# Select a specific model if desired
# testmodels = testmodels[:-1]
testmodels = [testmodels[6]]
testresults = dict.fromkeys(testmodels)
path = '/rxs/rx1/'

# Minimum value of difference to plot (dB)
plotmin = -160

for i, model in enumerate(testmodels):

    testresults[model] = {}

    # Run model
    inputfile = os.path.join(basepath, model + os.path.sep + model + '.in')
    api(inputfile, gpu=[None])

    # Special case for analytical comparison
    if model == 'hertzian_dipole_fs_analytical':
        # Get output for model file
        filetest = h5py.File(
            os.path.join(basepath, model + os.path.sep + model + '.out'), 'r')
        testresults[model]['Test version'] = filetest.attrs['gprMax']

        # Get available field output component names
        outputstest = list(filetest[path].keys())

        # Arrays for storing time
        floattype = filetest[path + outputstest[0]].dtype
        timetest = np.linspace(
            0, (filetest.attrs['Iterations'] - 1) * filetest.attrs['dt'],
예제 #3
0
# Select a specific model if desired
testmodels = testmodels[:-1]
# testmodels = [testmodels[0]]
testresults = dict.fromkeys(testmodels)
path = '/rxs/rx1/'

# Minimum value of difference to plot (dB)
plotmin = -160

for i, model in enumerate(testmodels):

    testresults[model] = {}

    # Run model
    api(os.path.join(basepath, model + os.path.sep + model + '.in'), gpu=None)

    # Special case for analytical comparison
    if model == 'hertzian_dipole_fs_analytical':
        # Get output for model file
        filetest = h5py.File(os.path.join(basepath, model + os.path.sep + model + '.out'), 'r')
        testresults[model]['Test version'] = filetest.attrs['gprMax']

        # Get available field output component names
        outputstest = list(filetest[path].keys())

        # Arrays for storing time
        floattype = filetest[path + outputstest[0]].dtype
        timetest = np.zeros((filetest.attrs['Iterations']), dtype=floattype)
        timetest = np.arange(0, filetest.attrs['dt'] * filetest.attrs['Iterations'], filetest.attrs['dt']) / 1e-9
        timeref = timetest
예제 #4
0
 def _create_ascan(self, path):
     api(path, n=self.n_scans, geometry_only=False, gpu=[0])
예제 #5
0
from gprMax.gprMax import api

import glob

for files in glob.glob("Documents/*.txt"):
    api(files, n=60, geometry_only=False)
예제 #6
0
파일: test_models.py 프로젝트: lij0e/gprMax
# Select a specific model if desired
# testmodels = [testmodels[0], testmodels[5], testmodels[7]]
# testmodels = [testmodels[5]]
testresults = dict.fromkeys(testmodels)
path = '/rxs/rx1/'

# Minimum value of difference to plot (dB)
plotmin = -160

for i, model in enumerate(testmodels):

    testresults[model] = {}

    # Run model
    api(os.path.join(basepath, model + os.path.sep + model + '.in'))

    # Special case for analytical comparison
    if model == 'hertzian_dipole_fs_analytical':
        # Get output for model file
        filetest = h5py.File(
            os.path.join(basepath, model + os.path.sep + model + '.out'), 'r')
        testresults[model]['Test version'] = filetest.attrs['gprMax']

        # Get available field output component names
        outputstest = list(filetest[path].keys())

        # Arrays for storing time
        floattype = filetest[path + outputstest[0]].dtype
        timetest = np.zeros((filetest.attrs['Iterations']), dtype=floattype)
        timetest = np.arange(
예제 #7
0
# Testing

import os
from gprMax.gprMax import api

sims_to_run = [37, 38, 39, 40]

for item in sims_to_run:
    filename_input = os.path.join('simulator_2.2', 'sim' + str(item) + '.in')
    print(filename_input)
    api(filename_input, n=500, geometry_only=False, gpu=[True])

    filename_output = os.path.join('simulator_2.2', 'sim' + str(item))
    print(filename_output)

    filename_merge = 'python -m tools.outputfiles_merge_no_prompt ' + filename_output
    print(filename_merge)
    os.system(filename_merge)