你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Updated with ruff formatter
这个提交包含在:
@@ -100,12 +100,18 @@ if epsr:
|
||||
ax.plot([0, np.deg2rad(180 + thetac)], [min, 0], color="0.7", lw=2)
|
||||
ax.plot([np.deg2rad(270), np.deg2rad(90)], [0, 0], color="0.7", lw=2)
|
||||
ax.annotate("Air", xy=(np.deg2rad(270), 0), xytext=(8, 8), textcoords="offset points")
|
||||
ax.annotate("Ground", xy=(np.deg2rad(270), 0), xytext=(8, -15), textcoords="offset points")
|
||||
ax.annotate(
|
||||
"Ground", xy=(np.deg2rad(270), 0), xytext=(8, -15), textcoords="offset points"
|
||||
)
|
||||
|
||||
# Plot patterns
|
||||
for patt in range(0, len(radii)):
|
||||
pattplot = np.append(patterns[patt, :], patterns[patt, 0]) # Append start value to close circle
|
||||
pattplot = pattplot / np.max(np.max(patterns)) # Normalise, based on set of patterns
|
||||
pattplot = np.append(
|
||||
patterns[patt, :], patterns[patt, 0]
|
||||
) # Append start value to close circle
|
||||
pattplot = pattplot / np.max(
|
||||
np.max(patterns)
|
||||
) # Normalise, based on set of patterns
|
||||
|
||||
# Calculate power (ignore warning from taking a log of any zero values)
|
||||
with np.errstate(divide="ignore"):
|
||||
@@ -140,7 +146,11 @@ ax.set_yticklabels(yticks)
|
||||
ax.grid(True)
|
||||
handles, existlabels = ax.get_legend_handles_labels()
|
||||
leg = ax.legend(
|
||||
[handles[0], handles[-1]], [existlabels[0], existlabels[-1]], ncol=2, loc=(0.27, -0.12), frameon=False
|
||||
[handles[0], handles[-1]],
|
||||
[existlabels[0], existlabels[-1]],
|
||||
ncol=2,
|
||||
loc=(0.27, -0.12),
|
||||
frameon=False,
|
||||
) # Plot just first and last legend entries
|
||||
# leg = ax.legend([handles[0], handles[-3], handles[-2], handles[-1]], [existlabels[0], existlabels[-3], existlabels[-2], existlabels[-1]], ncol=4, loc=(-0.13,-0.12), frameon=False)
|
||||
[legobj.set_linewidth(2) for legobj in leg.legendHandles]
|
||||
|
@@ -9,9 +9,13 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Writes a HDF5 file of AustinMan or AustinWoman head only.", usage="python head_only_hdf5 filename"
|
||||
description="Writes a HDF5 file of AustinMan or AustinWoman head only.",
|
||||
usage="python head_only_hdf5 filename",
|
||||
)
|
||||
parser.add_argument(
|
||||
"filename",
|
||||
help="name and path to (HDF5) file containing AustinMan or AustinWoman model",
|
||||
)
|
||||
parser.add_argument("filename", help="name and path to (HDF5) file containing AustinMan or AustinWoman model")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read full body HDF5 file
|
||||
@@ -22,7 +26,9 @@ data = f["/data"][:, :, :]
|
||||
# Define head as last 1/8 of total body height
|
||||
nzhead = 7 * int(data.shape[2] / 8)
|
||||
|
||||
logger.info(f"Dimensions of head model: {data.shape[0]:g} x {data.shape[1]:g} x {data.shape[2] - nzhead:g} cells")
|
||||
logger.info(
|
||||
f"Dimensions of head model: {data.shape[0]:g} x {data.shape[1]:g} x {data.shape[2] - nzhead:g} cells"
|
||||
)
|
||||
|
||||
# Write HDF5 file
|
||||
headfile = os.path.splitext(args.filename)[0] + "_head.h5"
|
||||
|
@@ -100,7 +100,15 @@ class Relaxation(object):
|
||||
def check_inputs(self):
|
||||
"""Check the validity of the inputs."""
|
||||
try:
|
||||
d = [float(i) for i in [self.number_of_debye_poles, self.sigma, self.mu, self.mu_sigma]]
|
||||
d = [
|
||||
float(i)
|
||||
for i in [
|
||||
self.number_of_debye_poles,
|
||||
self.sigma,
|
||||
self.mu,
|
||||
self.mu_sigma,
|
||||
]
|
||||
]
|
||||
except ValueError:
|
||||
sys.exit("The inputs should be numeric.")
|
||||
if not isinstance(self.number_of_debye_poles, int):
|
||||
@@ -120,7 +128,9 @@ class Relaxation(object):
|
||||
Returns:
|
||||
s (str): Info about chosen function and its parameters.
|
||||
"""
|
||||
print(f"Approximating {self.name}" f" using {self.number_of_debye_poles} Debye poles")
|
||||
print(
|
||||
f"Approximating {self.name} using {self.number_of_debye_poles} Debye poles"
|
||||
)
|
||||
print(f"{self.name} parameters: ")
|
||||
s = "".join(f"{k:10s} = {v}\n" for k, v in self.params.items())
|
||||
print(s)
|
||||
@@ -172,7 +182,12 @@ class Relaxation(object):
|
||||
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!", "##########\n", sep="")
|
||||
print(
|
||||
"\n#########",
|
||||
"Try to automaticaly fit number of Debye poles, up to 20!",
|
||||
"##########\n",
|
||||
sep="",
|
||||
)
|
||||
error = np.infty # artificial best error starting value
|
||||
self.number_of_debye_poles = 1
|
||||
iteration = 1
|
||||
@@ -195,7 +210,11 @@ class Relaxation(object):
|
||||
|
||||
# Print the results in gprMax format style
|
||||
properties = self.print_output(tau, weights, ee)
|
||||
print(f"The average fractional error for:\n" f"- real part: {err_real}\n" f"- imaginary part: {err_imag}\n")
|
||||
print(
|
||||
f"The average fractional error for:\n"
|
||||
f"- real part: {err_real}\n"
|
||||
f"- imaginary part: {err_imag}\n"
|
||||
)
|
||||
if self.save:
|
||||
self.save_result(properties)
|
||||
# Plot the actual and the approximate dielectric properties
|
||||
@@ -220,16 +239,20 @@ class Relaxation(object):
|
||||
print(f" |{'e_inf':^14s}|{'De':^14s}|{'log(tau_0)':^25s}|")
|
||||
print("_" * 65)
|
||||
for i in range(0, len(tau)):
|
||||
print(f"Debye {i + 1}|{ee / len(tau):^14.5f}|{weights[i]:^14.5f}|{tau[i]:^25.5f}|")
|
||||
print(
|
||||
f"Debye {i + 1}|{ee / len(tau):^14.5f}|{weights[i]:^14.5f}|{tau[i]:^25.5f}|"
|
||||
)
|
||||
print("_" * 65)
|
||||
|
||||
# Print the Debye expnasion in a gprMax format
|
||||
material_prop = []
|
||||
material_prop.append(f"#material: {ee} {self.sigma} {self.mu} {self.mu_sigma} {self.material_name}\n")
|
||||
material_prop.append(
|
||||
f"#material: {ee} {self.sigma} {self.mu} {self.mu_sigma} {self.material_name}\n"
|
||||
)
|
||||
print(material_prop[0], end="")
|
||||
dispersion_prop = f"#add_dispersion_debye: {len(tau)}"
|
||||
for i in range(len(tau)):
|
||||
dispersion_prop += f" {weights[i]} {10**tau[i]}"
|
||||
dispersion_prop += f" {weights[i]} {10 ** tau[i]}"
|
||||
dispersion_prop += f" {self.material_name}"
|
||||
print(dispersion_prop)
|
||||
material_prop.append(dispersion_prop + "\n")
|
||||
@@ -251,10 +274,34 @@ class Relaxation(object):
|
||||
gs = gridspec.GridSpec(2, 1)
|
||||
ax = fig.add_subplot(gs[0])
|
||||
ax.grid(b=True, which="major", linewidth=0.2, linestyle="--")
|
||||
ax.semilogx(self.freq * 1e-6, rl_exp, "b-", linewidth=2.0, label="Debye Expansion: Real part")
|
||||
ax.semilogx(self.freq * 1e-6, -im_exp, "k-", linewidth=2.0, label="Debye Expansion: Imaginary part")
|
||||
ax.semilogx(self.freq * 1e-6, self.rl, "r.", linewidth=2.0, label=f"{self.name}: Real part")
|
||||
ax.semilogx(self.freq * 1e-6, -self.im, "g.", linewidth=2.0, label=f"{self.name}: Imaginary part")
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
rl_exp,
|
||||
"b-",
|
||||
linewidth=2.0,
|
||||
label="Debye Expansion: Real part",
|
||||
)
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
-im_exp,
|
||||
"k-",
|
||||
linewidth=2.0,
|
||||
label="Debye Expansion: Imaginary part",
|
||||
)
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
self.rl,
|
||||
"r.",
|
||||
linewidth=2.0,
|
||||
label=f"{self.name}: Real part",
|
||||
)
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
-self.im,
|
||||
"g.",
|
||||
linewidth=2.0,
|
||||
label=f"{self.name}: Imaginary part",
|
||||
)
|
||||
ax.set_ylim([-1, np.max(np.concatenate([self.rl, -self.im])) + 1])
|
||||
ax.legend()
|
||||
ax.set_xlabel("Frequency (MHz)")
|
||||
@@ -262,8 +309,20 @@ class Relaxation(object):
|
||||
|
||||
ax = fig.add_subplot(gs[1])
|
||||
ax.grid(b=True, which="major", linewidth=0.2, linestyle="--")
|
||||
ax.semilogx(self.freq * 1e-6, (rl_exp - self.rl) / (self.rl + 1), "b-", linewidth=2.0, label="Real part")
|
||||
ax.semilogx(self.freq * 1e-6, (-im_exp + self.im) / (self.im + 1), "k-", linewidth=2.0, label="Imaginary part")
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
(rl_exp - self.rl) / (self.rl + 1),
|
||||
"b-",
|
||||
linewidth=2.0,
|
||||
label="Real part",
|
||||
)
|
||||
ax.semilogx(
|
||||
self.freq * 1e-6,
|
||||
(-im_exp + self.im) / (self.im + 1),
|
||||
"k-",
|
||||
linewidth=2.0,
|
||||
label="Imaginary part",
|
||||
)
|
||||
ax.legend()
|
||||
ax.set_xlabel("Frequency (MHz)")
|
||||
ax.set_ylabel("Relative approximation error")
|
||||
@@ -284,8 +343,12 @@ class Relaxation(object):
|
||||
avg_err_imag (float): average fractional error
|
||||
for conductivity (imaginary part)
|
||||
"""
|
||||
avg_err_real = np.sum(np.abs((rl_exp - self.rl) / (self.rl + 1)) * 100) / len(rl_exp)
|
||||
avg_err_imag = np.sum(np.abs((-im_exp + self.im) / (self.im + 1)) * 100) / len(im_exp)
|
||||
avg_err_real = np.sum(np.abs((rl_exp - self.rl) / (self.rl + 1)) * 100) / len(
|
||||
rl_exp
|
||||
)
|
||||
avg_err_imag = np.sum(np.abs((-im_exp + self.im) / (self.im + 1)) * 100) / len(
|
||||
im_exp
|
||||
)
|
||||
return avg_err_real, avg_err_imag
|
||||
|
||||
@staticmethod
|
||||
@@ -306,7 +369,10 @@ class Relaxation(object):
|
||||
elif os.path.isdir("user_libs/materials"):
|
||||
file_path = os.path.join("user_libs", "materials", "my_materials.txt")
|
||||
else:
|
||||
sys.exit("Cannot save material properties " f"in {os.path.join(fdir, 'my_materials.txt')}!")
|
||||
sys.exit(
|
||||
"Cannot save material properties "
|
||||
f"in {os.path.join(fdir, 'my_materials.txt')}!"
|
||||
)
|
||||
with open(file_path, "a") as fileH:
|
||||
fileH.write(f"## {output[0].split(' ')[-1]}")
|
||||
fileH.writelines(output)
|
||||
@@ -382,7 +448,13 @@ class HavriliakNegami(Relaxation):
|
||||
self.f_min, self.f_max = f_min, f_max
|
||||
# Choosing n frequencies logarithmicaly equally spaced between the bounds given
|
||||
self.set_freq(self.f_min, self.f_max, self.f_n)
|
||||
self.e_inf, self.alpha, self.beta, self.de, self.tau_0 = e_inf, alpha, beta, de, tau_0
|
||||
self.e_inf, self.alpha, self.beta, self.de, self.tau_0 = (
|
||||
e_inf,
|
||||
alpha,
|
||||
beta,
|
||||
de,
|
||||
tau_0,
|
||||
)
|
||||
self.params = {
|
||||
"f_min": self.f_min,
|
||||
"f_max": self.f_max,
|
||||
@@ -412,7 +484,11 @@ class HavriliakNegami(Relaxation):
|
||||
def calculation(self):
|
||||
"""Calculates the Havriliak-Negami function for
|
||||
the given parameters."""
|
||||
return self.e_inf + self.de / (1 + (1j * 2 * np.pi * self.freq * self.tau_0) ** self.alpha) ** self.beta
|
||||
return (
|
||||
self.e_inf
|
||||
+ self.de
|
||||
/ (1 + (1j * 2 * np.pi * self.freq * self.tau_0) ** self.alpha) ** self.beta
|
||||
)
|
||||
|
||||
|
||||
class Jonscher(Relaxation):
|
||||
@@ -501,9 +577,9 @@ class Jonscher(Relaxation):
|
||||
|
||||
def calculation(self):
|
||||
"""Calculates the Q function for the given parameters"""
|
||||
return self.e_inf + (self.a_p * (2 * np.pi * self.freq / self.omega_p) ** (self.n_p - 1)) * (
|
||||
1 - 1j / np.tan(self.n_p * np.pi / 2)
|
||||
)
|
||||
return self.e_inf + (
|
||||
self.a_p * (2 * np.pi * self.freq / self.omega_p) ** (self.n_p - 1)
|
||||
) * (1 - 1j / np.tan(self.n_p * np.pi / 2))
|
||||
|
||||
|
||||
class Crim(Relaxation):
|
||||
@@ -583,7 +659,9 @@ class Crim(Relaxation):
|
||||
if (np.array(d) < 0).sum() != 0:
|
||||
sys.exit("The inputs should be positive.")
|
||||
if len(self.volumetric_fractions) != len(self.materials):
|
||||
sys.exit("Number of volumetric volumes does not match the dielectric properties")
|
||||
sys.exit(
|
||||
"Number of volumetric volumes does not match the dielectric properties"
|
||||
)
|
||||
# Check if the materials are at least two
|
||||
if len(self.volumetric_fractions) < 2:
|
||||
sys.exit("The materials should be at least 2")
|
||||
@@ -604,7 +682,10 @@ class Crim(Relaxation):
|
||||
|
||||
def print_info(self):
|
||||
"""Print information about chosen approximation settings"""
|
||||
print(f"Approximating Complex Refractive Index Model (CRIM)" f" using {self.number_of_debye_poles} Debye poles")
|
||||
print(
|
||||
f"Approximating Complex Refractive Index Model (CRIM)"
|
||||
f" using {self.number_of_debye_poles} Debye poles"
|
||||
)
|
||||
print("CRIM parameters: ")
|
||||
for i in range(len(self.volumetric_fractions)):
|
||||
print(f"Material {i + 1}.:")
|
||||
@@ -617,7 +698,9 @@ class Crim(Relaxation):
|
||||
def calculation(self):
|
||||
"""Calculates the Crim function for the given parameters"""
|
||||
return np.sum(
|
||||
np.repeat(self.volumetric_fractions, len(self.freq)).reshape((-1, len(self.materials)))
|
||||
np.repeat(self.volumetric_fractions, len(self.freq)).reshape(
|
||||
(-1, len(self.materials))
|
||||
)
|
||||
* (
|
||||
self.materials[:, 0]
|
||||
+ self.materials[:, 1]
|
||||
@@ -626,7 +709,9 @@ class Crim(Relaxation):
|
||||
+ 1j
|
||||
* 2
|
||||
* np.pi
|
||||
* np.repeat(self.freq, len(self.materials)).reshape((-1, len(self.materials)))
|
||||
* np.repeat(self.freq, len(self.materials)).reshape(
|
||||
(-1, len(self.materials))
|
||||
)
|
||||
* self.materials[:, 2]
|
||||
)
|
||||
)
|
||||
@@ -691,13 +776,19 @@ class Rawdata(Relaxation):
|
||||
# Read the file
|
||||
with open(self.filename) as f:
|
||||
try:
|
||||
array = np.array([[float(x) for x in line.split(self.delimiter)] for line in f])
|
||||
array = np.array(
|
||||
[[float(x) for x in line.split(self.delimiter)] for line in f]
|
||||
)
|
||||
except ValueError:
|
||||
sys.exit("Error: The inputs should be numeric")
|
||||
|
||||
self.set_freq(min(array[:, 0]), max(array[:, 0]), self.f_n)
|
||||
rl_interp = scipy.interpolate.interp1d(array[:, 0], array[:, 1], fill_value="extrapolate")
|
||||
im_interp = scipy.interpolate.interp1d(array[:, 0], array[:, 2], fill_value="extrapolate")
|
||||
rl_interp = scipy.interpolate.interp1d(
|
||||
array[:, 0], array[:, 1], fill_value="extrapolate"
|
||||
)
|
||||
im_interp = scipy.interpolate.interp1d(
|
||||
array[:, 0], array[:, 2], fill_value="extrapolate"
|
||||
)
|
||||
return rl_interp(self.freq) - 1j * im_interp(self.freq)
|
||||
|
||||
|
||||
@@ -774,17 +865,63 @@ if __name__ == "__main__":
|
||||
setup.run()
|
||||
# Testing setup
|
||||
setup = Rawdata(
|
||||
"examples/Test.txt", 0.1, 1, 0.1, "M1", number_of_debye_poles=3, plot=True, optimizer_options={"seed": 111}
|
||||
"examples/Test.txt",
|
||||
0.1,
|
||||
1,
|
||||
0.1,
|
||||
"M1",
|
||||
number_of_debye_poles=3,
|
||||
plot=True,
|
||||
optimizer_options={"seed": 111},
|
||||
)
|
||||
setup.run()
|
||||
np.random.seed(111)
|
||||
setup = HavriliakNegami(1e12, 1e-3, 0.5, 1, 10, 5, 1e-6, 0.1, 1, 0, "M2", number_of_debye_poles=6, plot=True)
|
||||
setup = HavriliakNegami(
|
||||
1e12,
|
||||
1e-3,
|
||||
0.5,
|
||||
1,
|
||||
10,
|
||||
5,
|
||||
1e-6,
|
||||
0.1,
|
||||
1,
|
||||
0,
|
||||
"M2",
|
||||
number_of_debye_poles=6,
|
||||
plot=True,
|
||||
)
|
||||
setup.run()
|
||||
setup = Jonscher(1e6, 1e-5, 50, 1, 1e5, 0.7, 0.1, 1, 0.1, "M3", number_of_debye_poles=4, plot=True)
|
||||
setup = Jonscher(
|
||||
1e6,
|
||||
1e-5,
|
||||
50,
|
||||
1,
|
||||
1e5,
|
||||
0.7,
|
||||
0.1,
|
||||
1,
|
||||
0.1,
|
||||
"M3",
|
||||
number_of_debye_poles=4,
|
||||
plot=True,
|
||||
)
|
||||
setup.run()
|
||||
f = np.array([0.5, 0.5])
|
||||
material1 = [3, 25, 1e6]
|
||||
material2 = [3, 0, 1e3]
|
||||
materials = np.array([material1, material2])
|
||||
setup = Crim(1 * 1e-1, 1e-9, 0.5, f, materials, 0.1, 1, 0, "M4", number_of_debye_poles=2, plot=True)
|
||||
setup = Crim(
|
||||
1 * 1e-1,
|
||||
1e-9,
|
||||
0.5,
|
||||
f,
|
||||
materials,
|
||||
0.1,
|
||||
1,
|
||||
0,
|
||||
"M4",
|
||||
number_of_debye_poles=2,
|
||||
plot=True,
|
||||
)
|
||||
setup.run()
|
||||
|
@@ -121,7 +121,16 @@ class PSO_DLS(Optimizer):
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, swarmsize=40, maxiter=50, omega=0.9, phip=0.9, phig=0.9, minstep=1e-8, minfun=1e-8, pflag=False, seed=None
|
||||
self,
|
||||
swarmsize=40,
|
||||
maxiter=50,
|
||||
omega=0.9,
|
||||
phip=0.9,
|
||||
phig=0.9,
|
||||
minstep=1e-8,
|
||||
minfun=1e-8,
|
||||
pflag=False,
|
||||
seed=None,
|
||||
):
|
||||
super(PSO_DLS, self).__init__(maxiter, seed)
|
||||
self.swarmsize = swarmsize
|
||||
@@ -159,7 +168,9 @@ class PSO_DLS(Optimizer):
|
||||
assert hasattr(func, "__call__"), "Invalid function handle"
|
||||
lb = np.array(lb)
|
||||
ub = np.array(ub)
|
||||
assert np.all(ub > lb), "All upper-bound values must be greater than lower-bound values"
|
||||
assert np.all(ub > lb), (
|
||||
"All upper-bound values must be greater than lower-bound values"
|
||||
)
|
||||
|
||||
vhigh = np.abs(ub - lb)
|
||||
vlow = -vhigh
|
||||
@@ -226,10 +237,16 @@ class PSO_DLS(Optimizer):
|
||||
tmp = x[i, :].copy()
|
||||
stepsize = np.sqrt(np.sum((g - tmp) ** 2))
|
||||
if np.abs(fg - fx) <= self.minfun:
|
||||
print(f"Stopping search: Swarm best objective " f"change less than {self.minfun}")
|
||||
print(
|
||||
f"Stopping search: Swarm best objective "
|
||||
f"change less than {self.minfun}"
|
||||
)
|
||||
return tmp, fx
|
||||
elif stepsize <= self.minstep:
|
||||
print(f"Stopping search: Swarm best position " f"change less than {self.minstep}")
|
||||
print(
|
||||
f"Stopping search: Swarm best position "
|
||||
f"change less than {self.minstep}"
|
||||
)
|
||||
return tmp, fx
|
||||
else:
|
||||
g = tmp.copy()
|
||||
@@ -471,7 +488,10 @@ def DLS(logt, rl, im, freq):
|
||||
# Solving the overdetermined system y=Ax
|
||||
x = np.abs(np.linalg.lstsq(d.imag, im, rcond=None)[0])
|
||||
# x - absolute damped least-squares solution
|
||||
rp, ip = np.matmul(d.real, x[np.newaxis].T).T[0], np.matmul(d.imag, x[np.newaxis].T).T[0]
|
||||
rp, ip = (
|
||||
np.matmul(d.real, x[np.newaxis].T).T[0],
|
||||
np.matmul(d.imag, x[np.newaxis].T).T[0],
|
||||
)
|
||||
cost_i = np.sum(np.abs(ip - im)) / len(im)
|
||||
ee = np.mean(rl - rp)
|
||||
ee = max(ee, 1)
|
||||
|
@@ -64,7 +64,9 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
patchheight = 0.016
|
||||
tx = x + 0.114, y + 0.052, z + skidthickness
|
||||
else:
|
||||
logger.exception("This antenna module can only be used with a spatial discretisation of 1mm or 2mm")
|
||||
logger.exception(
|
||||
"This antenna module can only be used with a spatial discretisation of 1mm or 2mm"
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
# If using parameters from an optimisation
|
||||
@@ -80,8 +82,12 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
hdpesig = kwargs["hdpesig"]
|
||||
sourceresistance = 195
|
||||
rxres = 50
|
||||
absorber1 = gprMax.Material(er=absorber1Er, se=absorber1sig, mr=1, sm=0, id="absorber1")
|
||||
absorber2 = gprMax.Material(er=absorber2Er, se=absorber2sig, mr=1, sm=0, id="absorber2")
|
||||
absorber1 = gprMax.Material(
|
||||
er=absorber1Er, se=absorber1sig, mr=1, sm=0, id="absorber1"
|
||||
)
|
||||
absorber2 = gprMax.Material(
|
||||
er=absorber2Er, se=absorber2sig, mr=1, sm=0, id="absorber2"
|
||||
)
|
||||
pcb = gprMax.Material(er=pcbEr, se=pcbsig, mr=1, sm=0, id="pcb")
|
||||
hdpe = gprMax.Material(er=hdpeEr, se=hdpesig, mr=1, sm=0, id="hdpe")
|
||||
scene_objects.extend((absorber1, absorber2, pcb, hdpe))
|
||||
@@ -95,19 +101,27 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
if optstate == "WarrenThesis":
|
||||
# Original optimised values from http://hdl.handle.net/1842/4074
|
||||
excitationfreq = 1.71e9
|
||||
sourceresistance = 230 # Correction for old (< 123) GprMax3D bug (optimised to 4)
|
||||
sourceresistance = (
|
||||
230 # Correction for old (< 123) GprMax3D bug (optimised to 4)
|
||||
)
|
||||
rxres = 925 # Resistance at Rx bowtie
|
||||
absorber1 = gprMax.Material(er=1.58, se=0.428, mr=1, sm=0, id="absorber1")
|
||||
absorber2 = gprMax.Material(er=3, se=0, mr=1, sm=0, id="absorber2") # Foam modelled as PCB material
|
||||
absorber2 = gprMax.Material(
|
||||
er=3, se=0, mr=1, sm=0, id="absorber2"
|
||||
) # Foam modelled as PCB material
|
||||
pcb = gprMax.Material(er=3, se=0, mr=1, sm=0, id="pcb")
|
||||
hdpe = gprMax.Material(er=2.35, se=0, mr=1, sm=0, id="hdpe")
|
||||
rxres = gprMax.Material(er=3, se=(1 / rxres) * (dy / (dx * dz)), mr=1, sm=0, id="rxres")
|
||||
rxres = gprMax.Material(
|
||||
er=3, se=(1 / rxres) * (dy / (dx * dz)), mr=1, sm=0, id="rxres"
|
||||
)
|
||||
scene_objects.extend((absorber1, absorber2, pcb, hdpe, rxres))
|
||||
|
||||
elif optstate == "DebyeAbsorber":
|
||||
# Same values as WarrenThesis but uses dispersive absorber properties for Eccosorb LS22
|
||||
excitationfreq = 1.71e9
|
||||
sourceresistance = 230 # Correction for old (< 123) GprMax3D bug (optimised to 4)
|
||||
sourceresistance = (
|
||||
230 # Correction for old (< 123) GprMax3D bug (optimised to 4)
|
||||
)
|
||||
rxres = 925 # Resistance at Rx bowtie
|
||||
absorber1 = gprMax.Material(er=1, se=0, mr=1, sm=0, id="absorber1")
|
||||
# Eccosorb LS22 3-pole Debye model (https://bitbucket.org/uoyaeg/aegboxts/wiki/Home)
|
||||
@@ -117,11 +131,17 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
tau=[1.00723e-11, 1.55686e-10, 3.44129e-10],
|
||||
material_ids=["absorber1"],
|
||||
)
|
||||
absorber2 = gprMax.Material(er=3, se=0, mr=1, sm=0, id="absorber2") # Foam modelled as PCB material
|
||||
absorber2 = gprMax.Material(
|
||||
er=3, se=0, mr=1, sm=0, id="absorber2"
|
||||
) # Foam modelled as PCB material
|
||||
pcb = gprMax.Material(er=3, se=0, mr=1, sm=0, id="pcb")
|
||||
hdpe = gprMax.Material(er=2.35, se=0, mr=1, sm=0, id="hdpe")
|
||||
rxres = gprMax.Material(er=3, se=(1 / rxres) * (dy / (dx * dz)), mr=1, sm=0, id="rxres")
|
||||
scene_objects.extend((absorber1, absorber1_disp, absorber2, pcb, hdpe, rxres))
|
||||
rxres = gprMax.Material(
|
||||
er=3, se=(1 / rxres) * (dy / (dx * dz)), mr=1, sm=0, id="rxres"
|
||||
)
|
||||
scene_objects.extend(
|
||||
(absorber1, absorber1_disp, absorber2, pcb, hdpe, rxres)
|
||||
)
|
||||
|
||||
elif optstate == "GiannakisPaper":
|
||||
# Further optimised values from https://doi.org/10.1109/TGRS.2018.2869027
|
||||
@@ -152,13 +172,21 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
# Metallic enclosure
|
||||
b3 = gprMax.Box(
|
||||
p1=(x + 0.025, y + casethickness, z + skidthickness),
|
||||
p2=(x + casesize[0] - 0.025, y + casesize[1] - casethickness, z + skidthickness + 0.027),
|
||||
p2=(
|
||||
x + casesize[0] - 0.025,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + 0.027,
|
||||
),
|
||||
material_id="pec",
|
||||
)
|
||||
|
||||
# Absorber material (absorber1) and foam (absorber2) around edge of absorber
|
||||
b4 = gprMax.Box(
|
||||
p1=(x + 0.025 + shieldthickness, y + casethickness + shieldthickness, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.025 + shieldthickness,
|
||||
y + casethickness + shieldthickness,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.025 + shieldthickness + 0.057,
|
||||
y + casesize[1] - casethickness - shieldthickness,
|
||||
@@ -299,12 +327,24 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
scene_objects.extend((p9, p10))
|
||||
|
||||
# Edges that represent wire between bowtie halves in 1mm model
|
||||
e1 = gprMax.Edge(p1=(tx[0] - 0.059, tx[1] - dy, tx[2]), p2=(tx[0] - 0.059, tx[1], tx[2]), material_id="pec")
|
||||
e2 = gprMax.Edge(
|
||||
p1=(tx[0] - 0.059, tx[1] + dy, tx[2]), p2=(tx[0] - 0.059, tx[1] + 0.002, tx[2]), material_id="pec"
|
||||
e1 = gprMax.Edge(
|
||||
p1=(tx[0] - 0.059, tx[1] - dy, tx[2]),
|
||||
p2=(tx[0] - 0.059, tx[1], tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e2 = gprMax.Edge(
|
||||
p1=(tx[0] - 0.059, tx[1] + dy, tx[2]),
|
||||
p2=(tx[0] - 0.059, tx[1] + 0.002, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e3 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] - dy, tx[2]), p2=(tx[0], tx[1], tx[2]), material_id="pec"
|
||||
)
|
||||
e4 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] + dz, tx[2]),
|
||||
p2=(tx[0], tx[1] + 0.002, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e3 = gprMax.Edge(p1=(tx[0], tx[1] - dy, tx[2]), p2=(tx[0], tx[1], tx[2]), material_id="pec")
|
||||
e4 = gprMax.Edge(p1=(tx[0], tx[1] + dz, tx[2]), p2=(tx[0], tx[1] + 0.002, tx[2]), material_id="pec")
|
||||
scene_objects.extend((e1, e2, e3, e4))
|
||||
|
||||
elif resolution == 0.002:
|
||||
@@ -359,13 +399,21 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
scene_objects.extend((p11, p12))
|
||||
|
||||
# Skid
|
||||
b10 = gprMax.Box(p1=(x, y, z), p2=(x + casesize[0], y + casesize[1], z + skidthickness), material_id="hdpe")
|
||||
b10 = gprMax.Box(
|
||||
p1=(x, y, z),
|
||||
p2=(x + casesize[0], y + casesize[1], z + skidthickness),
|
||||
material_id="hdpe",
|
||||
)
|
||||
scene_objects.append(b10)
|
||||
|
||||
# Geometry views
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(x - dx, y - dy, z - dz),
|
||||
p2=(x + casesize[0] + dx, y + casesize[1] + dy, z + skidthickness + casesize[2] + dz),
|
||||
p2=(
|
||||
x + casesize[0] + dx,
|
||||
y + casesize[1] + dy,
|
||||
z + skidthickness + casesize[2] + dz,
|
||||
),
|
||||
dl=(dx, dy, dz),
|
||||
filename="antenna_like_GSSI_1500",
|
||||
output_type="n",
|
||||
@@ -382,19 +430,29 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
# Excitation
|
||||
if optstate == "WarrenThesis" or optstate == "DebyeAbsorber":
|
||||
# Gaussian pulse
|
||||
w1 = gprMax.Waveform(wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian")
|
||||
w1 = gprMax.Waveform(
|
||||
wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian"
|
||||
)
|
||||
vs1 = gprMax.VoltageSource(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_gaussian"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_gaussian",
|
||||
)
|
||||
scene_objects.extend((w1, vs1))
|
||||
|
||||
elif optstate == "GiannakisPaper":
|
||||
# Optimised custom pulse
|
||||
exc1 = gprMax.ExcitationFile(
|
||||
filepath="toolboxes/GPRAntennaModels/GSSI_1500MHz_pulse.txt", kind="linear", fill_value="extrapolate"
|
||||
filepath="toolboxes/GPRAntennaModels/GSSI_1500MHz_pulse.txt",
|
||||
kind="linear",
|
||||
fill_value="extrapolate",
|
||||
)
|
||||
vs1 = gprMax.VoltageSource(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_pulse"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_pulse",
|
||||
)
|
||||
scene_objects.extend((exc1, vs1))
|
||||
|
||||
@@ -402,7 +460,9 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
if resolution == 0.001:
|
||||
if optstate == "WarrenThesis" or optstate == "DebyeAbsorber":
|
||||
e1 = gprMax.Edge(
|
||||
p1=(tx[0] - 0.059, tx[1], tx[2]), p2=(tx[0] - 0.059, tx[1] + dy, tx[2]), material_id="rxres"
|
||||
p1=(tx[0] - 0.059, tx[1], tx[2]),
|
||||
p2=(tx[0] - 0.059, tx[1] + dy, tx[2]),
|
||||
material_id="rxres",
|
||||
)
|
||||
scene_objects.append(e1)
|
||||
r1 = gprMax.Rx(p1=(tx[0] - 0.059, tx[1], tx[2]), id="rxbowtie", outputs=["Ey"])
|
||||
@@ -411,7 +471,9 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
|
||||
elif resolution == 0.002:
|
||||
if optstate == "WarrenThesis" or optstate == "DebyeAbsorber":
|
||||
e1 = gprMax.Edge(
|
||||
p1=(tx[0] - 0.060, tx[1], tx[2]), p2=(tx[0] - 0.060, tx[1] + dy, tx[2]), material_id="rxres"
|
||||
p1=(tx[0] - 0.060, tx[1], tx[2]),
|
||||
p2=(tx[0] - 0.060, tx[1] + dy, tx[2]),
|
||||
material_id="rxres",
|
||||
)
|
||||
scene_objects.append(e1)
|
||||
r1 = gprMax.Rx(p1=(tx[0] - 0.060, tx[1], tx[2]), id="rxbowtie", outputs=["Ey"])
|
||||
@@ -492,7 +554,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
dz = 0.002
|
||||
foamsurroundthickness = 0.002
|
||||
metalboxheight = 0.088
|
||||
tx = x + 0.01 + 0.004 + 0.056, y + casethickness + 0.005 + 0.143 - 0.002, z + skidthickness - 0.002
|
||||
tx = (
|
||||
x + 0.01 + 0.004 + 0.056,
|
||||
y + casethickness + 0.005 + 0.143 - 0.002,
|
||||
z + skidthickness - 0.002,
|
||||
)
|
||||
|
||||
# Material definitions
|
||||
absorber = gprMax.Material(er=absorberEr, se=absorbersig, mr=1, sm=0, id="absorber")
|
||||
@@ -510,17 +576,28 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
b2 = gprMax.Box(
|
||||
p1=(x + casethickness, y + casethickness, z + skidthickness - 0.002),
|
||||
p2=(x + casesize[0] - casethickness, y + casesize[1] - casethickness, z + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - casethickness,
|
||||
z + casesize[2] - casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
)
|
||||
|
||||
# Metallic enclosure
|
||||
b3 = gprMax.Box(
|
||||
p1=(x + casethickness, y + casethickness, z + skidthickness + (metalmiddleplateheight - metalboxheight)),
|
||||
p1=(
|
||||
x + casethickness,
|
||||
y + casethickness,
|
||||
z + skidthickness + (metalmiddleplateheight - metalboxheight),
|
||||
),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + (metalmiddleplateheight - metalboxheight) + metalboxheight,
|
||||
z
|
||||
+ skidthickness
|
||||
+ (metalmiddleplateheight - metalboxheight)
|
||||
+ metalboxheight,
|
||||
),
|
||||
material_id="pec",
|
||||
)
|
||||
@@ -552,7 +629,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
|
||||
# PCB
|
||||
b6 = gprMax.Box(
|
||||
p1=(x + 0.01 + 0.005 + 0.017, y + casethickness + 0.005 + 0.021, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.017,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.033 + bowtiebase,
|
||||
y + casethickness + 0.006 + 0.202 + patchheight,
|
||||
@@ -561,7 +642,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
material_id="pcb",
|
||||
)
|
||||
b7 = gprMax.Box(
|
||||
p1=(x + 0.01 + 0.005 + 0.179, y + casethickness + 0.005 + 0.021, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.179,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.195 + bowtiebase,
|
||||
y + casethickness + 0.006 + 0.202 + patchheight,
|
||||
@@ -581,18 +666,29 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
b9 = gprMax.Box(
|
||||
p1=(x + casethickness, y + casethickness, z + skidthickness - 0.002),
|
||||
p2=(x + casesize[0] - casethickness, y + casesize[1] - casethickness, z + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - casethickness,
|
||||
z + casesize[2] - casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
averaging="n",
|
||||
)
|
||||
|
||||
# Metallic enclosure
|
||||
b10 = gprMax.Box(
|
||||
p1=(x + casethickness, y + casethickness, z + skidthickness + (metalmiddleplateheight - metalboxheight)),
|
||||
p1=(
|
||||
x + casethickness,
|
||||
y + casethickness,
|
||||
z + skidthickness + (metalmiddleplateheight - metalboxheight),
|
||||
),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + (metalmiddleplateheight - metalboxheight) + metalboxheight,
|
||||
z
|
||||
+ skidthickness
|
||||
+ (metalmiddleplateheight - metalboxheight)
|
||||
+ metalboxheight,
|
||||
),
|
||||
material_id="pec",
|
||||
)
|
||||
@@ -626,7 +722,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
|
||||
# PCB
|
||||
b13 = gprMax.Box(
|
||||
p1=(x + 0.01 + 0.005 + 0.017, y + casethickness + 0.005 + 0.021, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.017,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.033 + bowtiebase,
|
||||
y + casethickness + 0.006 + 0.202 + patchheight,
|
||||
@@ -636,7 +736,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
averaging="n",
|
||||
)
|
||||
b14 = gprMax.Box(
|
||||
p1=(x + 0.01 + 0.005 + 0.179, y + casethickness + 0.005 + 0.021, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.179,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.195 + bowtiebase,
|
||||
y + casethickness + 0.006 + 0.202 + patchheight,
|
||||
@@ -652,7 +756,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
# "left" side
|
||||
# extension plates
|
||||
p1 = gprMax.Plate(
|
||||
p1=(x + 0.01 + 0.005 + 0.025, y + casethickness + 0.005 + 0.021, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.025,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.025 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.021 + patchheight,
|
||||
@@ -661,7 +769,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
p2 = gprMax.Plate(
|
||||
p1=(x + 0.01 + 0.005 + 0.025, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.025,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.025 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.203 + patchheight,
|
||||
@@ -671,8 +783,16 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
# triangles
|
||||
t1 = gprMax.Triangle(
|
||||
p1=(x + 0.01 + 0.005 + 0.025, y + casethickness + 0.005 + 0.081, z + skidthickness - 0.002),
|
||||
p2=(x + 0.01 + 0.005 + 0.025 + bowtiebase, y + casethickness + 0.005 + 0.081, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.025,
|
||||
y + casethickness + 0.005 + 0.081,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.025 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.081,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p3=(
|
||||
x + 0.01 + 0.005 + 0.025 + (bowtiebase / 2),
|
||||
y + casethickness + 0.005 + 0.081 + bowtieheight,
|
||||
@@ -682,8 +802,16 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
t2 = gprMax.Triangle(
|
||||
p1=(x + 0.01 + 0.005 + 0.025, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p2=(x + 0.01 + 0.005 + 0.025 + bowtiebase, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.025,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.025 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p3=(
|
||||
x + 0.01 + 0.005 + 0.025 + (bowtiebase / 2),
|
||||
y + casethickness + 0.005 + 0.203 - bowtieheight,
|
||||
@@ -694,7 +822,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
# "right" side
|
||||
p3 = gprMax.Plate(
|
||||
p1=(x + 0.01 + 0.005 + 0.187, y + casethickness + 0.005 + 0.021, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.187,
|
||||
y + casethickness + 0.005 + 0.021,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.187 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.021 + patchheight,
|
||||
@@ -703,7 +835,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
p4 = gprMax.Plate(
|
||||
p1=(x + 0.01 + 0.005 + 0.187, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.187,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.187 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.203 + patchheight,
|
||||
@@ -713,8 +849,16 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
# triangles
|
||||
t3 = gprMax.Triangle(
|
||||
p1=(x + 0.01 + 0.005 + 0.187, y + casethickness + 0.005 + 0.081, z + skidthickness - 0.002),
|
||||
p2=(x + 0.01 + 0.005 + 0.187 + bowtiebase, y + casethickness + 0.005 + 0.081, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.187,
|
||||
y + casethickness + 0.005 + 0.081,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.187 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.081,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p3=(
|
||||
x + 0.01 + 0.005 + 0.187 + (bowtiebase / 2),
|
||||
y + casethickness + 0.005 + 0.081 + bowtieheight,
|
||||
@@ -724,8 +868,16 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
t4 = gprMax.Triangle(
|
||||
p1=(x + 0.01 + 0.005 + 0.187, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p2=(x + 0.01 + 0.005 + 0.187 + bowtiebase, y + casethickness + 0.005 + 0.203, z + skidthickness - 0.002),
|
||||
p1=(
|
||||
x + 0.01 + 0.005 + 0.187,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p2=(
|
||||
x + 0.01 + 0.005 + 0.187 + bowtiebase,
|
||||
y + casethickness + 0.005 + 0.203,
|
||||
z + skidthickness - 0.002,
|
||||
),
|
||||
p3=(
|
||||
x + 0.01 + 0.005 + 0.187 + (bowtiebase / 2),
|
||||
y + casethickness + 0.005 + 0.203 - bowtieheight,
|
||||
@@ -736,12 +888,24 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
)
|
||||
|
||||
# Edges that represent wire between bowtie halves in 2mm model
|
||||
e1 = gprMax.Edge(p1=(tx[0] + 0.162, tx[1] - dy, tx[2]), p2=(tx[0] + 0.162, tx[1], tx[2]), material_id="pec")
|
||||
e2 = gprMax.Edge(
|
||||
p1=(tx[0] + 0.162, tx[1] + dy, tx[2]), p2=(tx[0] + 0.162, tx[1] + 2 * dy, tx[2]), material_id="pec"
|
||||
e1 = gprMax.Edge(
|
||||
p1=(tx[0] + 0.162, tx[1] - dy, tx[2]),
|
||||
p2=(tx[0] + 0.162, tx[1], tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e2 = gprMax.Edge(
|
||||
p1=(tx[0] + 0.162, tx[1] + dy, tx[2]),
|
||||
p2=(tx[0] + 0.162, tx[1] + 2 * dy, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e3 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] - dy, tx[2]), p2=(tx[0], tx[1], tx[2]), material_id="pec"
|
||||
)
|
||||
e4 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] + dy, tx[2]),
|
||||
p2=(tx[0], tx[1] + 2 * dy, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
e3 = gprMax.Edge(p1=(tx[0], tx[1] - dy, tx[2]), p2=(tx[0], tx[1], tx[2]), material_id="pec")
|
||||
e4 = gprMax.Edge(p1=(tx[0], tx[1] + dy, tx[2]), p2=(tx[0], tx[1] + 2 * dy, tx[2]), material_id="pec")
|
||||
scene_objects.extend((p1, p2, t1, t2, p3, p4, t3, t4, e1, e2, e3, e4))
|
||||
|
||||
# Metallic plate extension
|
||||
@@ -758,7 +922,9 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
# Skid
|
||||
if smooth_dec == "yes":
|
||||
b16 = gprMax.Box(
|
||||
p1=(x, y, z), p2=(x + casesize[0], y + casesize[1], z + skidthickness - 0.002), material_id="hdpe"
|
||||
p1=(x, y, z),
|
||||
p2=(x + casesize[0], y + casesize[1], z + skidthickness - 0.002),
|
||||
material_id="hdpe",
|
||||
)
|
||||
elif smooth_dec == "no":
|
||||
b16 = gprMax.Box(
|
||||
@@ -771,31 +937,48 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
|
||||
# Source
|
||||
if src_type == "voltage_source":
|
||||
w1 = gprMax.Waveform(wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian")
|
||||
w1 = gprMax.Waveform(
|
||||
wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian"
|
||||
)
|
||||
vs1 = gprMax.VoltageSource(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_gaussian"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_gaussian",
|
||||
)
|
||||
scene_objects.extend((w1, vs1))
|
||||
elif src_type == "transmission_line":
|
||||
w1 = gprMax.Waveform(wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian")
|
||||
w1 = gprMax.Waveform(
|
||||
wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian"
|
||||
)
|
||||
tl1 = gprMax.TransmissionLine(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_gaussian"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_gaussian",
|
||||
)
|
||||
scene_objects.extend((w1, tl1))
|
||||
else:
|
||||
# Optimised custom pulse
|
||||
exc1 = gprMax.ExcitationFile(
|
||||
filepath="toolboxes/GPRAntennaModels/GSSI_400MHz_pulse.txt", kind="linear", fill_value="extrapolate"
|
||||
filepath="toolboxes/GPRAntennaModels/GSSI_400MHz_pulse.txt",
|
||||
kind="linear",
|
||||
fill_value="extrapolate",
|
||||
)
|
||||
vs1 = gprMax.VoltageSource(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_pulse"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_pulse",
|
||||
)
|
||||
scene_objects.extend((exc1, vs1))
|
||||
|
||||
# Receiver
|
||||
if src_type == "transmission_line":
|
||||
# Zero waveform to use with transmission line at receiver output
|
||||
w2 = gprMax.Waveform(wave_type="gaussian", amp=0, freq=excitationfreq, id="my_zero_wave")
|
||||
w2 = gprMax.Waveform(
|
||||
wave_type="gaussian", amp=0, freq=excitationfreq, id="my_zero_wave"
|
||||
)
|
||||
tl2 = gprMax.TransmissionLine(
|
||||
polarisation="y",
|
||||
p1=(tx[0] + 0.162, tx[1], tx[2]),
|
||||
@@ -810,7 +993,11 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.002, **kwargs):
|
||||
# Geometry views
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(x - dx, y - dy, z - dz),
|
||||
p2=(x + casesize[0] + dx, y + casesize[1] + dy, z + skidthickness + casesize[2] + dz),
|
||||
p2=(
|
||||
x + casesize[0] + dx,
|
||||
y + casesize[1] + dy,
|
||||
z + skidthickness + casesize[2] + dz,
|
||||
),
|
||||
dl=(dx, dy, dz),
|
||||
filename="antenna_like_GSSI_400",
|
||||
output_type="n",
|
||||
|
@@ -84,20 +84,30 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
bowtieheight = 0.024
|
||||
tx = x + 0.062, y + 0.052, z + skidthickness
|
||||
else:
|
||||
logger.exception("This antenna module can only be used with a spatial resolution of 1mm or 2mm")
|
||||
logger.exception(
|
||||
"This antenna module can only be used with a spatial resolution of 1mm or 2mm"
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
# SMD resistors - 3 on each Tx & Rx bowtie arm
|
||||
txres = 470 # Ohms
|
||||
txrescellupper = txres / 3 # Resistor over 3 cells
|
||||
txsigupper = ((1 / txrescellupper) * (dy / (dx * dz))) / 2 # Divide by number of parallel edges per resistor
|
||||
txsigupper = (
|
||||
(1 / txrescellupper) * (dy / (dx * dz))
|
||||
) / 2 # Divide by number of parallel edges per resistor
|
||||
txrescelllower = txres / 4 # Resistor over 4 cells
|
||||
txsiglower = ((1 / txrescelllower) * (dy / (dx * dz))) / 2 # Divide by number of parallel edges per resistor
|
||||
txsiglower = (
|
||||
(1 / txrescelllower) * (dy / (dx * dz))
|
||||
) / 2 # Divide by number of parallel edges per resistor
|
||||
rxres = 150 # Ohms
|
||||
rxrescellupper = rxres / 3 # Resistor over 3 cells
|
||||
rxsigupper = ((1 / rxrescellupper) * (dy / (dx * dz))) / 2 # Divide by number of parallel edges per resistor
|
||||
rxsigupper = (
|
||||
(1 / rxrescellupper) * (dy / (dx * dz))
|
||||
) / 2 # Divide by number of parallel edges per resistor
|
||||
rxrescelllower = rxres / 4 # Resistor over 4 cells
|
||||
rxsiglower = ((1 / rxrescelllower) * (dy / (dx * dz))) / 2 # Divide by number of parallel edges per resistor
|
||||
rxsiglower = (
|
||||
(1 / rxrescelllower) * (dy / (dx * dz))
|
||||
) / 2 # Divide by number of parallel edges per resistor
|
||||
|
||||
# Material definitions
|
||||
absorber = gprMax.Material(er=absorberEr, se=absorbersig, mr=1, sm=0, id="absorber")
|
||||
@@ -108,7 +118,18 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
txresupper = gprMax.Material(er=3, se=txsigupper, mr=1, sm=0, id="txresupper")
|
||||
rxreslower = gprMax.Material(er=3, se=rxsiglower, mr=1, sm=0, id="rxreslower")
|
||||
rxresupper = gprMax.Material(er=3, se=rxsigupper, mr=1, sm=0, id="rxresupper")
|
||||
scene_objects.extend((absorber, pcb, hdpe, polypropylene, txreslower, txresupper, rxreslower, rxresupper))
|
||||
scene_objects.extend(
|
||||
(
|
||||
absorber,
|
||||
pcb,
|
||||
hdpe,
|
||||
polypropylene,
|
||||
txreslower,
|
||||
txresupper,
|
||||
rxreslower,
|
||||
rxresupper,
|
||||
)
|
||||
)
|
||||
|
||||
# Antenna geometry
|
||||
# Shield - metallic enclosure
|
||||
@@ -119,19 +140,31 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
b2 = gprMax.Box(
|
||||
p1=(x + 0.020, y + casethickness, z + skidthickness),
|
||||
p2=(x + 0.100, y + casesize[1] - casethickness, z + skidthickness + casethickness),
|
||||
p2=(
|
||||
x + 0.100,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
)
|
||||
b3 = gprMax.Box(
|
||||
p1=(x + 0.100, y + casethickness, z + skidthickness),
|
||||
p2=(x + casesize[0] - casethickness, y + casesize[1] - casethickness, z + skidthickness + casethickness),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
)
|
||||
|
||||
# Absorber material
|
||||
b4 = gprMax.Box(
|
||||
p1=(x + 0.020, y + casethickness, z + skidthickness),
|
||||
p2=(x + 0.100, y + casesize[1] - casethickness, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.100,
|
||||
y + casesize[1] - casethickness,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
material_id="absorber",
|
||||
)
|
||||
b5 = gprMax.Box(
|
||||
@@ -148,7 +181,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
# Shield - cylindrical sections
|
||||
c1 = gprMax.Cylinder(
|
||||
p1=(x + 0.055, y + casesize[1] - 0.008, z + skidthickness),
|
||||
p2=(x + 0.055, y + casesize[1] - 0.008, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.055,
|
||||
y + casesize[1] - 0.008,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
r=0.008,
|
||||
material_id="pec",
|
||||
)
|
||||
@@ -160,7 +197,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
c3 = gprMax.Cylinder(
|
||||
p1=(x + 0.147, y + casesize[1] - 0.008, z + skidthickness),
|
||||
p2=(x + 0.147, y + casesize[1] - 0.008, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.147,
|
||||
y + casesize[1] - 0.008,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
r=0.008,
|
||||
material_id="pec",
|
||||
)
|
||||
@@ -172,7 +213,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
c5 = gprMax.Cylinder(
|
||||
p1=(x + 0.055, y + casesize[1] - 0.008, z + skidthickness),
|
||||
p2=(x + 0.055, y + casesize[1] - 0.008, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.055,
|
||||
y + casesize[1] - 0.008,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
r=0.007,
|
||||
material_id="free_space",
|
||||
)
|
||||
@@ -184,7 +229,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
c7 = gprMax.Cylinder(
|
||||
p1=(x + 0.147, y + casesize[1] - 0.008, z + skidthickness),
|
||||
p2=(x + 0.147, y + casesize[1] - 0.008, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.147,
|
||||
y + casesize[1] - 0.008,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
r=0.007,
|
||||
material_id="free_space",
|
||||
)
|
||||
@@ -196,7 +245,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
b6 = gprMax.Box(
|
||||
p1=(x + 0.054, y + casesize[1] - 0.016, z + skidthickness),
|
||||
p2=(x + 0.056, y + casesize[1] - 0.014, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.056,
|
||||
y + casesize[1] - 0.014,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
)
|
||||
b7 = gprMax.Box(
|
||||
@@ -206,7 +259,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
b8 = gprMax.Box(
|
||||
p1=(x + 0.146, y + casesize[1] - 0.016, z + skidthickness),
|
||||
p2=(x + 0.148, y + casesize[1] - 0.014, z + skidthickness + casesize[2] - casethickness),
|
||||
p2=(
|
||||
x + 0.148,
|
||||
y + casesize[1] - 0.014,
|
||||
z + skidthickness + casesize[2] - casethickness,
|
||||
),
|
||||
material_id="free_space",
|
||||
)
|
||||
b9 = gprMax.Box(
|
||||
@@ -219,18 +276,30 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
# PCB
|
||||
b10 = gprMax.Box(
|
||||
p1=(x + 0.020, y + 0.018, z + skidthickness),
|
||||
p2=(x + casesize[0] - casethickness, y + casesize[1] - 0.018, z + skidthickness + pcbthickness),
|
||||
p2=(
|
||||
x + casesize[0] - casethickness,
|
||||
y + casesize[1] - 0.018,
|
||||
z + skidthickness + pcbthickness,
|
||||
),
|
||||
material_id="pcb",
|
||||
)
|
||||
|
||||
# Shield - Tx & Rx cavities
|
||||
b11 = gprMax.Box(
|
||||
p1=(x + 0.032, y + 0.022, z + skidthickness),
|
||||
p2=(x + 0.032 + cavitysize[0], y + 0.022 + cavitysize[1], z + skidthickness + cavitysize[2]),
|
||||
p2=(
|
||||
x + 0.032 + cavitysize[0],
|
||||
y + 0.022 + cavitysize[1],
|
||||
z + skidthickness + cavitysize[2],
|
||||
),
|
||||
material_id="pec",
|
||||
)
|
||||
b12 = gprMax.Box(
|
||||
p1=(x + 0.032 + cavitythickness, y + 0.022 + cavitythickness, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.032 + cavitythickness,
|
||||
y + 0.022 + cavitythickness,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.032 + cavitysize[0] - cavitythickness,
|
||||
y + 0.022 + cavitysize[1] - cavitythickness,
|
||||
@@ -240,11 +309,19 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
)
|
||||
b13 = gprMax.Box(
|
||||
p1=(x + 0.108, y + 0.022, z + skidthickness),
|
||||
p2=(x + 0.108 + cavitysize[0], y + 0.022 + cavitysize[1], z + skidthickness + cavitysize[2]),
|
||||
p2=(
|
||||
x + 0.108 + cavitysize[0],
|
||||
y + 0.022 + cavitysize[1],
|
||||
z + skidthickness + cavitysize[2],
|
||||
),
|
||||
material_id="pec",
|
||||
)
|
||||
b14 = gprMax.Box(
|
||||
p1=(x + 0.108 + cavitythickness, y + 0.022 + cavitythickness, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.108 + cavitythickness,
|
||||
y + 0.022 + cavitythickness,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.108 + cavitysize[0] - cavitythickness,
|
||||
y + 0.022 + cavitysize[1] - cavitythickness,
|
||||
@@ -264,14 +341,22 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
b16 = gprMax.Box(
|
||||
p1=(x + 0.032 + cavitysize[0], y + 0.022, z + skidthickness + cavitysize[2] - casethickness),
|
||||
p1=(
|
||||
x + 0.032 + cavitysize[0],
|
||||
y + 0.022,
|
||||
z + skidthickness + cavitysize[2] - casethickness,
|
||||
),
|
||||
p2=(x + 0.108, y + 0.022 + 0.006, z + skidthickness + cavitysize[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
|
||||
# PCB - replace bits chopped by TX & Rx cavities
|
||||
b17 = gprMax.Box(
|
||||
p1=(x + 0.032 + cavitythickness, y + 0.022 + cavitythickness, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.032 + cavitythickness,
|
||||
y + 0.022 + cavitythickness,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.032 + cavitysize[0] - cavitythickness,
|
||||
y + 0.022 + cavitysize[1] - cavitythickness,
|
||||
@@ -280,7 +365,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
material_id="pcb",
|
||||
)
|
||||
b18 = gprMax.Box(
|
||||
p1=(x + 0.108 + cavitythickness, y + 0.022 + cavitythickness, z + skidthickness),
|
||||
p1=(
|
||||
x + 0.108 + cavitythickness,
|
||||
y + 0.022 + cavitythickness,
|
||||
z + skidthickness,
|
||||
),
|
||||
p2=(
|
||||
x + 0.108 + cavitysize[0] - cavitythickness,
|
||||
y + 0.022 + cavitysize[1] - cavitythickness,
|
||||
@@ -300,7 +389,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
thickness=0,
|
||||
material_id="pec",
|
||||
)
|
||||
e1 = gprMax.Edge(p1=(tx[0], tx[1] - 0.001, tx[2]), p2=(tx[0], tx[1], tx[2]), material_id="pec")
|
||||
e1 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] - 0.001, tx[2]),
|
||||
p2=(tx[0], tx[1], tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
t2 = gprMax.Triangle(
|
||||
p1=(tx[0], tx[1] + 0.002, tx[2]),
|
||||
p2=(tx[0] - 0.026, tx[1] + bowtieheight + 0.002, tx[2]),
|
||||
@@ -308,7 +401,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
thickness=0,
|
||||
material_id="pec",
|
||||
)
|
||||
e2 = gprMax.Edge(p1=(tx[0], tx[1] + 0.001, tx[2]), p2=(tx[0], tx[1] + 0.002, tx[2]), material_id="pec")
|
||||
e2 = gprMax.Edge(
|
||||
p1=(tx[0], tx[1] + 0.001, tx[2]),
|
||||
p2=(tx[0], tx[1] + 0.002, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
scene_objects.extend((t1, t2, e1, e2))
|
||||
elif resolution == 0.002:
|
||||
t1 = gprMax.Triangle(
|
||||
@@ -336,7 +433,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
thickness=0,
|
||||
material_id="pec",
|
||||
)
|
||||
e3 = gprMax.Edge(p1=(tx[0] + 0.076, tx[1] - 0.001, tx[2]), p2=(tx[0] + 0.076, tx[1], tx[2]), material_id="pec")
|
||||
e3 = gprMax.Edge(
|
||||
p1=(tx[0] + 0.076, tx[1] - 0.001, tx[2]),
|
||||
p2=(tx[0] + 0.076, tx[1], tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
t4 = gprMax.Triangle(
|
||||
p1=(tx[0] + 0.076, tx[1] + 0.002, tx[2]),
|
||||
p2=(tx[0] + 0.076 - 0.026, tx[1] + bowtieheight + 0.002, tx[2]),
|
||||
@@ -345,7 +446,9 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
material_id="pec",
|
||||
)
|
||||
e4 = gprMax.Edge(
|
||||
p1=(tx[0] + 0.076, tx[1] + 0.001, tx[2]), p2=(tx[0] + 0.076, tx[1] + 0.002, tx[2]), material_id="pec"
|
||||
p1=(tx[0] + 0.076, tx[1] + 0.001, tx[2]),
|
||||
p2=(tx[0] + 0.076, tx[1] + 0.002, tx[2]),
|
||||
material_id="pec",
|
||||
)
|
||||
scene_objects.extend((t3, e3, t4, e4))
|
||||
elif resolution == 0.002:
|
||||
@@ -631,20 +734,31 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
|
||||
# Skid
|
||||
b19 = gprMax.Box(
|
||||
p1=(x, y, z), p2=(x + casesize[0], y + casesize[1], z + polypropylenethickness), material_id="polypropylene"
|
||||
p1=(x, y, z),
|
||||
p2=(x + casesize[0], y + casesize[1], z + polypropylenethickness),
|
||||
material_id="polypropylene",
|
||||
)
|
||||
b20 = gprMax.Box(
|
||||
p1=(x, y, z + polypropylenethickness),
|
||||
p2=(x + casesize[0], y + casesize[1], z + polypropylenethickness + hdpethickness),
|
||||
p2=(
|
||||
x + casesize[0],
|
||||
y + casesize[1],
|
||||
z + polypropylenethickness + hdpethickness,
|
||||
),
|
||||
material_id="hdpe",
|
||||
)
|
||||
scene_objects.extend((b19, b20))
|
||||
|
||||
# Excitation
|
||||
w2 = gprMax.Waveform(wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian")
|
||||
w2 = gprMax.Waveform(
|
||||
wave_type="gaussian", amp=1, freq=excitationfreq, id="my_gaussian"
|
||||
)
|
||||
scene_objects.append(w2)
|
||||
vs1 = gprMax.VoltageSource(
|
||||
polarisation="y", p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id="my_gaussian"
|
||||
polarisation="y",
|
||||
p1=(tx[0], tx[1], tx[2]),
|
||||
resistance=sourceresistance,
|
||||
waveform_id="my_gaussian",
|
||||
)
|
||||
scene_objects.append(vs1)
|
||||
|
||||
@@ -655,7 +769,11 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
|
||||
# Geometry views
|
||||
gv1 = gprMax.GeometryView(
|
||||
p1=(x - dx, y - dy, z - dz),
|
||||
p2=(x + casesize[0] + dx, y + casesize[1] + dy, z + skidthickness + casesize[2] + dz),
|
||||
p2=(
|
||||
x + casesize[0] + dx,
|
||||
y + casesize[1] + dy,
|
||||
z + skidthickness + casesize[2] + dz,
|
||||
),
|
||||
dl=(dx, dy, dz),
|
||||
filename="antenna_like_MALA_1200",
|
||||
output_type="n",
|
||||
|
@@ -81,7 +81,9 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False, save=False):
|
||||
|
||||
# Check for single output component when doing a FFT
|
||||
if fft and not len(outputs) == 1:
|
||||
logger.exception("A single output must be specified when using " + "the -fft option")
|
||||
logger.exception(
|
||||
"A single output must be specified when using " + "the -fft option"
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
# New plot for each receiver
|
||||
@@ -120,7 +122,11 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False, save=False):
|
||||
# Set plotting range to -60dB from maximum power or 4 times
|
||||
# frequency at maximum power
|
||||
try:
|
||||
pltrange = np.where(power[freqmaxpower:] < -60)[0][0] + freqmaxpower + 1
|
||||
pltrange = (
|
||||
np.where(power[freqmaxpower:] < -60)[0][0]
|
||||
+ freqmaxpower
|
||||
+ 1
|
||||
)
|
||||
except:
|
||||
pltrange = freqmaxpower * 4
|
||||
|
||||
@@ -160,20 +166,27 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False, save=False):
|
||||
plt.setp(line2, color="g")
|
||||
plt.setp(ax1, ylabel=outputtext + " field strength [A/m]")
|
||||
plt.setp(stemlines, "color", "g")
|
||||
plt.setp(markerline, "markerfacecolor", "g", "markeredgecolor", "g")
|
||||
plt.setp(
|
||||
markerline, "markerfacecolor", "g", "markeredgecolor", "g"
|
||||
)
|
||||
elif "I" in outputs[0]:
|
||||
plt.setp(line1, color="b")
|
||||
plt.setp(line2, color="b")
|
||||
plt.setp(ax1, ylabel=outputtext + " current [A]")
|
||||
plt.setp(stemlines, "color", "b")
|
||||
plt.setp(markerline, "markerfacecolor", "b", "markeredgecolor", "b")
|
||||
plt.setp(
|
||||
markerline, "markerfacecolor", "b", "markeredgecolor", "b"
|
||||
)
|
||||
|
||||
plt.show()
|
||||
|
||||
# Plotting if no FFT required
|
||||
else:
|
||||
fig, ax = plt.subplots(
|
||||
subplot_kw=dict(xlabel="Time [s]", ylabel=outputtext + " field strength [V/m]"),
|
||||
subplot_kw=dict(
|
||||
xlabel="Time [s]",
|
||||
ylabel=outputtext + " field strength [V/m]",
|
||||
),
|
||||
num=rxpath + " - " + f[rxpath].attrs["Name"],
|
||||
figsize=(20, 10),
|
||||
facecolor="w",
|
||||
@@ -279,7 +292,13 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False, save=False):
|
||||
|
||||
if save:
|
||||
# Save a PDF of the figure
|
||||
fig.savefig(filename[:-3] + ".pdf", dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
fig.savefig(
|
||||
filename[:-3] + ".pdf",
|
||||
dpi=None,
|
||||
format="pdf",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
# Save a PNG of the figure
|
||||
# fig.savefig(filename[:-3] + '.png', dpi=150, format='png',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
@@ -322,9 +341,17 @@ if __name__ == "__main__":
|
||||
],
|
||||
nargs="+",
|
||||
)
|
||||
parser.add_argument("-fft", action="store_true", default=False, help="plot FFT (single output must be specified)")
|
||||
parser.add_argument(
|
||||
"-save", action="store_true", default=False, help="save plot directly to file, i.e. do not display"
|
||||
"-fft",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="plot FFT (single output must be specified)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-save",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="save plot directly to file, i.e. do not display",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@@ -46,7 +46,12 @@ def mpl_plot(filename, outputdata, dt, rxnumber, rxcomponent, save=False):
|
||||
|
||||
file = Path(filename)
|
||||
|
||||
fig = plt.figure(num=file.stem + " - rx" + str(rxnumber), figsize=(20, 10), facecolor="w", edgecolor="w")
|
||||
fig = plt.figure(
|
||||
num=file.stem + " - rx" + str(rxnumber),
|
||||
figsize=(20, 10),
|
||||
facecolor="w",
|
||||
edgecolor="w",
|
||||
)
|
||||
plt.imshow(
|
||||
outputdata,
|
||||
extent=[0, outputdata.shape[1], outputdata.shape[0] * dt, 0],
|
||||
@@ -73,7 +78,13 @@ def mpl_plot(filename, outputdata, dt, rxnumber, rxcomponent, save=False):
|
||||
|
||||
if save:
|
||||
# Save a PDF of the figure
|
||||
fig.savefig(filename[:-3] + ".pdf", dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
fig.savefig(
|
||||
filename[:-3] + ".pdf",
|
||||
dpi=None,
|
||||
format="pdf",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
# Save a PNG of the figure
|
||||
# fig.savefig(filename[:-3] + '.png', dpi=150, format='png',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
@@ -94,10 +105,16 @@ if __name__ == "__main__":
|
||||
choices=["Ex", "Ey", "Ez", "Hx", "Hy", "Hz", "Ix", "Iy", "Iz"],
|
||||
)
|
||||
parser.add_argument(
|
||||
"-gather", action="store_true", default=False, help="gather together all receiver outputs in file"
|
||||
"-gather",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="gather together all receiver outputs in file",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-save", action="store_true", default=False, help="save plot directly to file, i.e. do not display"
|
||||
"-save",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="save plot directly to file, i.e. do not display",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -118,10 +135,14 @@ if __name__ == "__main__":
|
||||
rxsgather = outputdata
|
||||
rxsgather = np.column_stack((rxsgather, outputdata))
|
||||
else:
|
||||
plthandle = mpl_plot(args.outputfile, outputdata, dt, rx, args.rx_component, save=args.save)
|
||||
plthandle = mpl_plot(
|
||||
args.outputfile, outputdata, dt, rx, args.rx_component, save=args.save
|
||||
)
|
||||
|
||||
# Plot all receivers from single output file together if required
|
||||
if args.gather:
|
||||
plthandle = mpl_plot(args.outputfile, rxsgather, dt, rx, args.rx_component, save=args.save)
|
||||
plthandle = mpl_plot(
|
||||
args.outputfile, rxsgather, dt, rx, args.rx_component, save=args.save
|
||||
)
|
||||
|
||||
plthandle.show()
|
||||
|
@@ -28,7 +28,9 @@ import numpy as np
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def calculate_antenna_params(filename, tltxnumber=1, tlrxnumber=None, rxnumber=None, rxcomponent=None):
|
||||
def calculate_antenna_params(
|
||||
filename, tltxnumber=1, tlrxnumber=None, rxnumber=None, rxcomponent=None
|
||||
):
|
||||
"""Calculates antenna parameters - incident, reflected and total volatges
|
||||
and currents; s11, (s21) and input impedance.
|
||||
|
||||
@@ -160,7 +162,9 @@ def calculate_antenna_params(filename, tltxnumber=1, tlrxnumber=None, rxnumber=N
|
||||
"yin": yin,
|
||||
}
|
||||
if tlrxnumber or rxnumber:
|
||||
with np.errstate(divide="ignore"): # Ignore warning from taking a log of any zero values
|
||||
with np.errstate(
|
||||
divide="ignore"
|
||||
): # Ignore warning from taking a log of any zero values
|
||||
s21 = 20 * np.log10(s21)
|
||||
s21[np.invert(np.isfinite(s21))] = 0
|
||||
antennaparams["s21"] = s21
|
||||
@@ -224,7 +228,10 @@ def mpl_plot(
|
||||
|
||||
# Print some useful values from s11, and input impedance
|
||||
s11minfreq = np.where(s11[pltrange] == np.amin(s11[pltrange]))[0][0]
|
||||
logger.info(f"s11 minimum: {np.amin(s11[pltrange]):g} dB at " + f"{freqs[s11minfreq + pltrangemin]:g} Hz")
|
||||
logger.info(
|
||||
f"s11 minimum: {np.amin(s11[pltrange]):g} dB at "
|
||||
+ f"{freqs[s11minfreq + pltrangemin]:g} Hz"
|
||||
)
|
||||
logger.info(f"At {freqs[s11minfreq + pltrangemin]:g} Hz...")
|
||||
logger.info(
|
||||
f"Input impedance: {np.abs(zin[s11minfreq + pltrangemin]):.1f}"
|
||||
@@ -236,7 +243,10 @@ def mpl_plot(
|
||||
# Figure 1
|
||||
# Plot incident voltage
|
||||
fig1, ax = plt.subplots(
|
||||
num="Transmitter transmission line parameters", figsize=(20, 12), facecolor="w", edgecolor="w"
|
||||
num="Transmitter transmission line parameters",
|
||||
figsize=(20, 12),
|
||||
facecolor="w",
|
||||
edgecolor="w",
|
||||
)
|
||||
gs1 = gridspec.GridSpec(4, 2, hspace=0.7)
|
||||
ax = plt.subplot(gs1[0, 0])
|
||||
@@ -368,7 +378,9 @@ def mpl_plot(
|
||||
|
||||
# Figure 2
|
||||
# Plot frequency spectra of s11
|
||||
fig2, ax = plt.subplots(num="Antenna parameters", figsize=(20, 12), facecolor="w", edgecolor="w")
|
||||
fig2, ax = plt.subplots(
|
||||
num="Antenna parameters", figsize=(20, 12), facecolor="w", edgecolor="w"
|
||||
)
|
||||
gs2 = gridspec.GridSpec(2, 2, hspace=0.3)
|
||||
ax = plt.subplot(gs2[0, 0])
|
||||
markerline, stemlines, baseline = ax.stem(freqs[pltrange], s11[pltrange], "-.")
|
||||
@@ -463,8 +475,20 @@ def mpl_plot(
|
||||
savename2 = filename.stem + "_ant_params"
|
||||
savename2 = filename.parent / savename2
|
||||
# Save a PDF of the figure
|
||||
fig1.savefig(savename1.with_suffix(".pdf"), dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
fig2.savefig(savename2.with_suffix(".pdf"), dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
fig1.savefig(
|
||||
savename1.with_suffix(".pdf"),
|
||||
dpi=None,
|
||||
format="pdf",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
fig2.savefig(
|
||||
savename2.with_suffix(".pdf"),
|
||||
dpi=None,
|
||||
format="pdf",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
# Save a PNG of the figure
|
||||
# fig1.savefig(savename1.with_suffix('.png'), dpi=150, format='png',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
@@ -485,8 +509,15 @@ if __name__ == "__main__":
|
||||
usage="cd gprMax; python -m toolboxes.Plotting.plot_antenna_params outputfile",
|
||||
)
|
||||
parser.add_argument("outputfile", help="name of output file including path")
|
||||
parser.add_argument("--tltx-num", default=1, type=int, help="transmitter antenna - transmission line number")
|
||||
parser.add_argument("--tlrx-num", type=int, help="receiver antenna - transmission line number")
|
||||
parser.add_argument(
|
||||
"--tltx-num",
|
||||
default=1,
|
||||
type=int,
|
||||
help="transmitter antenna - transmission line number",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--tlrx-num", type=int, help="receiver antenna - transmission line number"
|
||||
)
|
||||
parser.add_argument("--rx-num", type=int, help="receiver antenna - output number")
|
||||
parser.add_argument(
|
||||
"--rx-component",
|
||||
@@ -495,7 +526,10 @@ if __name__ == "__main__":
|
||||
choices=["Ex", "Ey", "Ez"],
|
||||
)
|
||||
parser.add_argument(
|
||||
"-save", action="store_true", default=False, help="save plot directly to file, i.e. do not display"
|
||||
"-save",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="save plot directly to file, i.e. do not display",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@@ -90,7 +90,13 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
||||
if w.freq and w.type != "gaussian" and w.type != "impulse":
|
||||
logging.info(f"Centre frequency: {w.freq:g} Hz")
|
||||
|
||||
if w.type in ["gaussian", "gaussiandot", "gaussiandotnorm", "gaussianprime", "gaussiandoubleprime"]:
|
||||
if w.type in [
|
||||
"gaussian",
|
||||
"gaussiandot",
|
||||
"gaussiandotnorm",
|
||||
"gaussianprime",
|
||||
"gaussiandoubleprime",
|
||||
]:
|
||||
delay = 1 / w.freq
|
||||
logging.info(f"Time to centre of pulse: {delay:g} s")
|
||||
elif w.type in ["gaussiandotdot", "gaussiandotdotnorm", "ricker"]:
|
||||
@@ -113,7 +119,9 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
||||
pltrange = np.where(freqs > 4 * w.freq)[0][0]
|
||||
pltrange = np.s_[0:pltrange]
|
||||
|
||||
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, num=w.type, figsize=(20, 10), facecolor="w", edgecolor="w")
|
||||
fig, (ax1, ax2) = plt.subplots(
|
||||
nrows=1, ncols=2, num=w.type, figsize=(20, 10), facecolor="w", edgecolor="w"
|
||||
)
|
||||
|
||||
# Plot waveform
|
||||
ax1.plot(time, waveform, "r", lw=2)
|
||||
@@ -121,7 +129,9 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
||||
ax1.set_ylabel("Amplitude")
|
||||
|
||||
# Plot frequency spectra
|
||||
markerline, stemlines, baseline = ax2.stem(freqs[pltrange], power[pltrange], "-.")
|
||||
markerline, stemlines, baseline = ax2.stem(
|
||||
freqs[pltrange], power[pltrange], "-."
|
||||
)
|
||||
plt.setp(baseline, "linewidth", 0)
|
||||
plt.setp(stemlines, "color", "r")
|
||||
plt.setp(markerline, "markerfacecolor", "r", "markeredgecolor", "r")
|
||||
@@ -130,7 +140,9 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
||||
ax2.set_ylabel("Power [dB]")
|
||||
|
||||
else:
|
||||
fig, ax1 = plt.subplots(num=w.type, figsize=(10, 10), facecolor="w", edgecolor="w")
|
||||
fig, ax1 = plt.subplots(
|
||||
num=w.type, figsize=(10, 10), facecolor="w", edgecolor="w"
|
||||
)
|
||||
|
||||
# Plot waveform
|
||||
ax1.plot(time, waveform, "r", lw=2)
|
||||
@@ -143,9 +155,21 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
||||
if save:
|
||||
savefile = Path(__file__).parent / w.type
|
||||
# Save a PDF of the figure
|
||||
fig.savefig(savefile.with_suffix(".pdf"), dpi=None, format="pdf", bbox_inches="tight", pad_inches=0.1)
|
||||
fig.savefig(
|
||||
savefile.with_suffix(".pdf"),
|
||||
dpi=None,
|
||||
format="pdf",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
# Save a PNG of the figure
|
||||
fig.savefig(savefile.with_suffix(".png"), dpi=150, format="png", bbox_inches="tight", pad_inches=0.1)
|
||||
fig.savefig(
|
||||
savefile.with_suffix(".png"),
|
||||
dpi=150,
|
||||
format="png",
|
||||
bbox_inches="tight",
|
||||
pad_inches=0.1,
|
||||
)
|
||||
|
||||
return plt
|
||||
|
||||
@@ -161,18 +185,27 @@ if __name__ == "__main__":
|
||||
parser.add_argument("freq", type=float, help="centre frequency of waveform")
|
||||
parser.add_argument("timewindow", help="time window to view waveform")
|
||||
parser.add_argument("dt", type=float, help="time step to view waveform")
|
||||
parser.add_argument("-fft", action="store_true", default=False, help="plot FFT of waveform")
|
||||
parser.add_argument(
|
||||
"-save", action="store_true", default=False, help="save plot directly to file, i.e. do not display"
|
||||
"-fft", action="store_true", default=False, help="plot FFT of waveform"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-save",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="save plot directly to file, i.e. do not display",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Check waveform parameters
|
||||
if args.type.lower() not in Waveform.types:
|
||||
logging.exception(f"The waveform must have one of the following types {', '.join(Waveform.types)}")
|
||||
logging.exception(
|
||||
f"The waveform must have one of the following types {', '.join(Waveform.types)}"
|
||||
)
|
||||
raise ValueError
|
||||
if args.freq <= 0:
|
||||
logging.exception("The waveform requires an excitation frequency value of greater than zero")
|
||||
logging.exception(
|
||||
"The waveform requires an excitation frequency value of greater than zero"
|
||||
)
|
||||
raise ValueError
|
||||
|
||||
# Create waveform instance
|
||||
@@ -182,5 +215,7 @@ if __name__ == "__main__":
|
||||
w.freq = args.freq
|
||||
|
||||
timewindow, iterations = check_timewindow(args.timewindow, args.dt)
|
||||
plthandle = mpl_plot(w, timewindow, args.dt, iterations, fft=args.fft, save=args.save)
|
||||
plthandle = mpl_plot(
|
||||
w, timewindow, args.dt, iterations, fft=args.fft, save=args.save
|
||||
)
|
||||
plthandle.show()
|
||||
|
@@ -21,12 +21,20 @@ def convert_file(input_file_path, discretization, pad=1, parallel=False):
|
||||
return convert_files([input_file_path], discretization, pad=pad, parallel=parallel)
|
||||
|
||||
|
||||
def convert_files(input_file_paths, discretization, colors=[(0, 0, 0)], pad=1, parallel=False):
|
||||
def convert_files(
|
||||
input_file_paths, discretization, colors=[(0, 0, 0)], pad=1, parallel=False
|
||||
):
|
||||
meshes = []
|
||||
|
||||
for input_file_path in input_file_paths:
|
||||
mesh_obj = mesh.Mesh.from_file(input_file_path)
|
||||
org_mesh = np.hstack((mesh_obj.v0[:, np.newaxis], mesh_obj.v1[:, np.newaxis], mesh_obj.v2[:, np.newaxis]))
|
||||
org_mesh = np.hstack(
|
||||
(
|
||||
mesh_obj.v0[:, np.newaxis],
|
||||
mesh_obj.v1[:, np.newaxis],
|
||||
mesh_obj.v2[:, np.newaxis],
|
||||
)
|
||||
)
|
||||
meshes.append(org_mesh)
|
||||
vol, scale, shift = convert_meshes(meshes, discretization, parallel)
|
||||
vol = np.transpose(vol)
|
||||
|
@@ -6,7 +6,9 @@ def lines_to_voxels(line_list, pixels):
|
||||
x = 0
|
||||
for event_x, status, line_ind in generate_line_events(line_list):
|
||||
while event_x - x >= 0:
|
||||
lines = reduce(lambda acc, cur: acc + [line_list[cur]], current_line_indices, [])
|
||||
lines = reduce(
|
||||
lambda acc, cur: acc + [line_list[cur]], current_line_indices, []
|
||||
)
|
||||
paint_y_axis(lines, pixels, x)
|
||||
x += 1
|
||||
|
||||
|
@@ -19,7 +19,12 @@ def mesh_to_plane(mesh, bounding_box, parallel):
|
||||
|
||||
current_mesh_indices = set()
|
||||
z = 0
|
||||
with tqdm(total=bounding_box[2], desc="Processing Layers", ncols=get_terminal_width() - 1, file=sys.stdout) as pbar:
|
||||
with tqdm(
|
||||
total=bounding_box[2],
|
||||
desc="Processing Layers",
|
||||
ncols=get_terminal_width() - 1,
|
||||
file=sys.stdout,
|
||||
) as pbar:
|
||||
for event_z, status, tri_ind in generate_tri_events(mesh):
|
||||
while event_z - z >= 0:
|
||||
mesh_subset = [mesh[ind] for ind in current_mesh_indices]
|
||||
|
@@ -17,9 +17,15 @@ if __name__ == "__main__":
|
||||
usage="cd gprMax; python -m toolboxes.STLtoVoxel.stltovoxel stlfilename -matindex -dxdydz",
|
||||
)
|
||||
parser.add_argument(
|
||||
"stlfiles", help="can be the filename of a single STL file, or the path to folder containing multiple STL files"
|
||||
"stlfiles",
|
||||
help="can be the filename of a single STL file, or the path to folder containing multiple STL files",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-dxdydz",
|
||||
type=float,
|
||||
required=True,
|
||||
help="discretisation to use in voxelisation process",
|
||||
)
|
||||
parser.add_argument("-dxdydz", type=float, required=True, help="discretisation to use in voxelisation process")
|
||||
args = parser.parse_args()
|
||||
|
||||
if os.path.isdir(args.stlfiles):
|
||||
@@ -38,7 +44,9 @@ if __name__ == "__main__":
|
||||
newline = "\n\t"
|
||||
logger.info(f"\nConverting STL file(s): {newline.join(files)}")
|
||||
model_array = convert_files(files, dxdydz)
|
||||
logger.info(f"Number of voxels: {model_array.shape[0]} x {model_array.shape[1]} x {model_array.shape[2]}")
|
||||
logger.info(
|
||||
f"Number of voxels: {model_array.shape[0]} x {model_array.shape[1]} x {model_array.shape[2]}"
|
||||
)
|
||||
logger.info(f"Spatial discretisation: {dxdydz[0]} x {dxdydz[1]} x {dxdydz[2]}m")
|
||||
|
||||
# Write HDF5 file for gprMax using voxels
|
||||
|
@@ -55,7 +55,9 @@ class Cursor(object):
|
||||
) # Convert pixel values from float (0-1) to integer (0-255)
|
||||
match = pixel_match(materials, pixel)
|
||||
if match is False:
|
||||
logger.info(f"x, y: {int(x)} {int(y)} px; RGB: {pixel[:-1]}; material ID: {len(self.materials)}")
|
||||
logger.info(
|
||||
f"x, y: {int(x)} {int(y)} px; RGB: {pixel[:-1]}; material ID: {len(self.materials)}"
|
||||
)
|
||||
materials.append(pixel)
|
||||
|
||||
|
||||
@@ -85,10 +87,17 @@ if __name__ == "__main__":
|
||||
)
|
||||
parser.add_argument("imagefile", help="name of image file including path")
|
||||
parser.add_argument(
|
||||
"dxdydz", type=float, action="append", nargs=3, help="spatial resolution of model, e.g. dx dy dz"
|
||||
"dxdydz",
|
||||
type=float,
|
||||
action="append",
|
||||
nargs=3,
|
||||
help="spatial resolution of model, e.g. dx dy dz",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-zcells", default=1, type=int, help="number of cells for domain in z-direction (infinite direction)"
|
||||
"-zcells",
|
||||
default=1,
|
||||
type=int,
|
||||
help="number of cells for domain in z-direction (infinite direction)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -97,7 +106,9 @@ if __name__ == "__main__":
|
||||
|
||||
# Store image data to use for creating geometry
|
||||
imdata = np.rot90(im, k=3) # Rotate 90CW
|
||||
imdata = np.floor(imdata * 255).astype(np.int16) # Convert pixel values from float (0-1) to integer (0-255)
|
||||
imdata = np.floor(imdata * 255).astype(
|
||||
np.int16
|
||||
) # Convert pixel values from float (0-1) to integer (0-255)
|
||||
|
||||
logger.info(f"Reading PNG image file: {os.path.split(args.imagefile)[1]}")
|
||||
logger.info(
|
||||
|
@@ -33,7 +33,11 @@ logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||
|
||||
# Host machine info.
|
||||
hostinfo = get_host_info()
|
||||
hyperthreadingstr = f", {hostinfo['logicalcores']} cores with Hyper-Threading" if hostinfo["hyperthreading"] else ""
|
||||
hyperthreadingstr = (
|
||||
f", {hostinfo['logicalcores']} cores with Hyper-Threading"
|
||||
if hostinfo["hyperthreading"]
|
||||
else ""
|
||||
)
|
||||
hostname = f"\n=== {hostinfo['hostname']}"
|
||||
logging.info(f"{hostname} {'=' * (get_terminal_width() - len(hostname) - 1)}")
|
||||
logging.info(f"\n{'Mfr/model:':<12} {hostinfo['machineID']}")
|
||||
@@ -46,7 +50,8 @@ logging.info(f"{'OS/Version:':<12} {hostinfo['osversion']}")
|
||||
|
||||
# OpenMP
|
||||
logging.info(
|
||||
"\n\n=== OpenMP capabilities (gprMax will not use Hyper-Threading " + "as there is no performance advantage)\n"
|
||||
"\n\n=== OpenMP capabilities (gprMax will not use Hyper-Threading "
|
||||
+ "as there is no performance advantage)\n"
|
||||
)
|
||||
logging.info(f"{'OpenMP threads: '} {hostinfo['physicalcores']}")
|
||||
|
||||
|
@@ -107,7 +107,9 @@ def merge_files(outputfiles, removefiles=False):
|
||||
availableoutputs = list(fin[path].keys())
|
||||
for output in availableoutputs:
|
||||
grp.create_dataset(
|
||||
output, (fout.attrs["Iterations"], len(outputfiles)), dtype=fin[path + "/" + output].dtype
|
||||
output,
|
||||
(fout.attrs["Iterations"], len(outputfiles)),
|
||||
dtype=fin[path + "/" + output].dtype,
|
||||
)
|
||||
|
||||
# For all receivers
|
||||
@@ -134,9 +136,14 @@ if __name__ == "__main__":
|
||||
+ "optionally removes the series of output files.",
|
||||
usage="cd gprMax; python -m tools.outputfiles_merge basefilename",
|
||||
)
|
||||
parser.add_argument("basefilename", help="base name of output file series including path")
|
||||
parser.add_argument(
|
||||
"--remove-files", action="store_true", default=False, help="flag to remove individual output files after merge"
|
||||
"basefilename", help="base name of output file series including path"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--remove-files",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="flag to remove individual output files after merge",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户