From 6ad5ba5825b97436e1241da9b54cb6731ea9b2fd Mon Sep 17 00:00:00 2001 From: Sylwia Majchrowska Date: Sat, 31 Jul 2021 23:09:49 +0200 Subject: [PATCH] fix relative path for Rawdata and position of arguments for Crim --- gprMax/hash_cmds_multiuse.py | 14 +++++++------- user_libs/DebyeFit/Debye_Fit.py | 8 +++++--- user_models/Rawdata_test.in | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gprMax/hash_cmds_multiuse.py b/gprMax/hash_cmds_multiuse.py index 1a5d140d..e3835461 100644 --- a/gprMax/hash_cmds_multiuse.py +++ b/gprMax/hash_cmds_multiuse.py @@ -217,28 +217,28 @@ def process_multicmds(multicmds): for cmdinstance in multicmds[cmdname]: tmp = cmdinstance.split() - if len(tmp) != 9: + if len(tmp) != 10: logger.exception("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' requires at exactly nine parameters') raise ValueError - if (tmp[5][0] != '[' and tmp[5][-1] != ']') or (tmp[6][0] != '[' and tmp[6][-1] != ']'): + if (tmp[3][0] != '[' and tmp[3][-1] != ']') or (tmp[4][0] != '[' and tmp[4][-1] != ']'): logger.exception("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' requires list at 6th and 7th position') raise ValueError - vol_frac = [float(i) for i in tmp[5].strip('[]').split(',')] - material = [float(i) for i in tmp[6].strip('[]').split(',')] + vol_frac = [float(i) for i in tmp[3].strip('[]').split(',')] + material = [float(i) for i in tmp[4].strip('[]').split(',')] if len(material) % 3 != 0: logger.exception("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' each material requires three parameters: e_inf, de, tau_0') raise ValueError materials = [material[n:n+3] for n in range(0, len(material), 3)] setup = Crim(f_min=float(tmp[0]), f_max=float(tmp[1]), a=float(tmp[2]), - sigma=float(tmp[3]), mu=float(tmp[4]), mu_sigma=float(tmp[5]), volumetric_fractions=vol_frac, materials=materials, - number_of_debye_poles=int(tmp[8], material_name=tmp[9])) + sigma=float(tmp[5]), mu=float(tmp[6]), mu_sigma=float(tmp[7]), + number_of_debye_poles=int(tmp[8]), material_name=tmp[9]) _, properties = setup.run() multicmds['#material'].append(properties[0].split(':')[1].strip(' \t\n')) multicmds['#add_dispersion_debye'].append(properties[1].split(':')[1].strip(' \t\n')) - + cmdname = '#Rawdata' if multicmds[cmdname] is not None: for cmdinstance in multicmds[cmdname]: diff --git a/user_libs/DebyeFit/Debye_Fit.py b/user_libs/DebyeFit/Debye_Fit.py index d3db870a..3522cbc7 100644 --- a/user_libs/DebyeFit/Debye_Fit.py +++ b/user_libs/DebyeFit/Debye_Fit.py @@ -20,6 +20,7 @@ import numpy as np import os from matplotlib import pylab as plt import matplotlib.gridspec as gridspec +from pathlib import Path import sys import scipy.interpolate import warnings @@ -60,7 +61,7 @@ class Relaxation(object): optimizer class (Default: empty dict). :type optimizer_options: dict, optional, default: empty dict """ - + def __init__(self, sigma, mu, mu_sigma, material_name, f_n=50, number_of_debye_poles=-1, @@ -178,7 +179,7 @@ class Relaxation(object): q = self.calculation() # Set the real and the imaginary part of the relaxation function self.rl, self.im = q.real, q.imag - + if self.number_of_debye_poles == -1: print("\n#########", "Try to automaticaly fit number of Debye poles, up to 20!", @@ -609,12 +610,13 @@ class Rawdata(Relaxation): optimizer=optimizer, optimizer_options=optimizer_options) self.delimiter = delimiter - self.filename = filename + self.filename = Path(filename).absolute() self.params = {'filename':self.filename} def check_inputs(self): """ Check the validity of the inputs. """ super(Rawdata, self).check_inputs() + if not os.path.isfile(self.filename): sys.exit("File doesn't exists!") diff --git a/user_models/Rawdata_test.in b/user_models/Rawdata_test.in index 40f50e3e..e06bf366 100644 --- a/user_models/Rawdata_test.in +++ b/user_models/Rawdata_test.in @@ -2,6 +2,6 @@ #dx_dy_dz: 0.004 0.004 0.004 #time_window: 3000 -#Rawdata: ../user_libs/DebyeFit/Test.txt 0.1 1 0.1 3 M4 +#Rawdata: user_libs/DebyeFit/Test.txt 0.1 1 0.1 3 M4 #box: 0 0 0 0.07 0.4 0.004 M4