Looking for a API to merge and move data to directory

102 views
Skip to first unread message

Anadyr

unread,
Sep 25, 2020, 4:47:37 PM9/25/20
to gprMax-users
Hi guys,

I have the following problem like many others: I'd like to automate the process of running simulations.
So ideally I would write a .in file using the #python: directive, importing tools like pandas and then I would start more simulations from the same file.
I mean something like:

#python:

from gprMax.input_cmd_funcs import *
import pandas as pd

df
= pd.read_csv("list_parameters.csv")    # parameter for the simulation


for i in range(6):

     dx
= dy = dz = df.iloc[0,1]
     time_window_var
= df.iloc[0, 2]
     domain
= domain(df.iloc[0, 3:5])

     dx_dy_dz
= dx_dy_dz(dx, dy, dz)
     time_window
= time_window(time_window_var)

      material
(df.iloc[i, 6], 0, df.iloc[i, 7], 0, "half_space")

      box1    
= box(0, 0,  0, 0.480, 0.148, 0.170, "half_space", "n")

     
from user_libs.antennas.GSSI import antenna_like_GSSI_1500

      antenna_like_GSSI_1500
( 0.105 + current_model_run * 0.005, 0.074, 0.170, 0.001 )

#end_python:

But in this case i miss an output function, which let me to move the results to another directory at the end of every for loop.
I mean a function like:

#python:
dir_a
= 'results/test_a'
...
output_dir
(dir_a)            # This should be the equivalent of "#output_dir:"
#end_python:

but looking to this list of function I couldn't find any suitable function to do that.


On the other side I found this post from Craig which suggests to use those APIs:

from gprMax.gprMax import api as gprMax
from tools.outputfiles_merge import merge_files

gprMax can then be run by calling:

gprMax(box_Bscan_2d.in, n=228)
merge_files(box_Bscan_2d, removefiles=True)

This is a good idea but in this case I cannot load the variables from a list like above and passing them as argument to any of the functions

gprMax(<file>, n)
merge_files
(<file_name>, removefiles)

Can you suggest me a better way to solve this problem?
Thanks


Craig Warren

unread,
Oct 9, 2020, 10:55:18 AM10/9/20
to gprMax-users
Dear Anadyr,

I'd suggest you write a top level pure Python scripts that imports gprMax as I described previously. This can then be used to run your input file which itself can contain a #python #end_python block with your input parameters. The control of the input and output file names etc... can happen in the top level script.

Kind regards,

Craig
Reply all
Reply to author
Forward
0 new messages