你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
updated code in a few files to make it more understandable, also used .join method at a place to increase the speed.
这个提交包含在:
@@ -58,9 +58,9 @@ if epsr:
|
|||||||
wavelength = v1 / f
|
wavelength = v1 / f
|
||||||
|
|
||||||
# Print some useful information
|
# Print some useful information
|
||||||
logger.info('Centre frequency: {} GHz'.format(f / 1e9))
|
logger.info(f'Centre frequency: {f / 1000000000.0} GHz')
|
||||||
if epsr:
|
if epsr:
|
||||||
logger.info('Critical angle for Er {} is {} degrees'.format(epsr, thetac))
|
logger.info(f'Critical angle for Er {epsr} is {thetac} degrees')
|
||||||
logger.info('Wavelength: {:.3f} m'.format(wavelength))
|
logger.info('Wavelength: {:.3f} m'.format(wavelength))
|
||||||
logger.info('Observation distance(s) from {:.3f} m ({:.1f} wavelengths) to {:.3f} m ({:.1f} wavelengths)'.format(radii[0], radii[0] / wavelength, radii[-1], radii[-1] / wavelength))
|
logger.info('Observation distance(s) from {:.3f} m ({:.1f} wavelengths) to {:.3f} m ({:.1f} wavelengths)'.format(radii[0], radii[0] / wavelength, radii[-1], radii[-1] / wavelength))
|
||||||
logger.info('Theoretical boundary between reactive & radiating near-field (0.62*sqrt((D^3/wavelength): {:.3f} m'.format(0.62 * np.sqrt((D**3) / wavelength)))
|
logger.info('Theoretical boundary between reactive & radiating near-field (0.62*sqrt((D^3/wavelength): {:.3f} m'.format(0.62 * np.sqrt((D**3) / wavelength)))
|
||||||
|
@@ -119,9 +119,7 @@ class Relaxation(object):
|
|||||||
print(f"Approximating {self.name}"
|
print(f"Approximating {self.name}"
|
||||||
f" using {self.number_of_debye_poles} Debye poles")
|
f" using {self.number_of_debye_poles} Debye poles")
|
||||||
print(f"{self.name} parameters: ")
|
print(f"{self.name} parameters: ")
|
||||||
s = ''
|
s = ''.join(f"{k:10s} = {v}\n" for k, v in self.params.items())
|
||||||
for k, v in self.params.items():
|
|
||||||
s += f"{k:10s} = {v}\n"
|
|
||||||
print(s)
|
print(s)
|
||||||
return f'{self.name}:\n{s}'
|
return f'{self.name}:\n{s}'
|
||||||
|
|
||||||
@@ -231,16 +229,14 @@ class Relaxation(object):
|
|||||||
print("_" * 65)
|
print("_" * 65)
|
||||||
|
|
||||||
# Print the Debye expnasion in a gprMax format
|
# Print the Debye expnasion in a gprMax format
|
||||||
material_prop = []
|
material_prop = [
|
||||||
material_prop.append("#material: {} {} {} {} {}\n".format(ee, self.sigma,
|
f"#material: {ee} {self.sigma} {self.mu} {self.mu_sigma} {self.material_name}\n"
|
||||||
self.mu,
|
]
|
||||||
self.mu_sigma,
|
|
||||||
self.material_name))
|
|
||||||
print(material_prop[0], end="")
|
print(material_prop[0], end="")
|
||||||
dispersion_prop = "#add_dispersion_debye: {}".format(len(tau))
|
dispersion_prop = f"#add_dispersion_debye: {len(tau)}"
|
||||||
for i in range(len(tau)):
|
for i in range(len(tau)):
|
||||||
dispersion_prop += " {} {}".format(weights[i], 10**tau[i])
|
dispersion_prop += f" {weights[i]} {10**tau[i]}"
|
||||||
dispersion_prop += " {}".format(self.material_name)
|
dispersion_prop += f" {self.material_name}"
|
||||||
print(dispersion_prop)
|
print(dispersion_prop)
|
||||||
material_prop.append(dispersion_prop + '\n')
|
material_prop.append(dispersion_prop + '\n')
|
||||||
return material_prop
|
return material_prop
|
||||||
@@ -327,11 +323,10 @@ class Relaxation(object):
|
|||||||
else:
|
else:
|
||||||
sys.exit("Cannot save material properties "
|
sys.exit("Cannot save material properties "
|
||||||
f"in {os.path.join(fdir, 'my_materials.txt')}!")
|
f"in {os.path.join(fdir, 'my_materials.txt')}!")
|
||||||
fileH = open(file_path, "a")
|
with open(file_path, "a") as fileH:
|
||||||
fileH.write(f"## {output[0].split(' ')[-1]}")
|
fileH.write(f"## {output[0].split(' ')[-1]}")
|
||||||
fileH.writelines(output)
|
fileH.writelines(output)
|
||||||
fileH.write("\n")
|
fileH.write("\n")
|
||||||
fileH.close()
|
|
||||||
print(f"Material properties save at: {file_path}")
|
print(f"Material properties save at: {file_path}")
|
||||||
|
|
||||||
|
|
||||||
@@ -562,7 +557,7 @@ class Crim(Relaxation):
|
|||||||
f" using {self.number_of_debye_poles} Debye poles")
|
f" using {self.number_of_debye_poles} Debye poles")
|
||||||
print("CRIM parameters: ")
|
print("CRIM parameters: ")
|
||||||
for i in range(len(self.volumetric_fractions)):
|
for i in range(len(self.volumetric_fractions)):
|
||||||
print("Material {}.:".format(i+1))
|
print(f"Material {i + 1}.:")
|
||||||
print("---------------------------------")
|
print("---------------------------------")
|
||||||
print(f"{'Vol. fraction':>27s} = {self.volumetric_fractions[i]}")
|
print(f"{'Vol. fraction':>27s} = {self.volumetric_fractions[i]}")
|
||||||
print(f"{'e_inf':>27s} = {self.materials[i][0]}")
|
print(f"{'e_inf':>27s} = {self.materials[i][0]}")
|
||||||
|
@@ -456,7 +456,6 @@ def DLS(logt, rl, im, freq):
|
|||||||
d.imag, x[np.newaxis].T).T[0]
|
d.imag, x[np.newaxis].T).T[0]
|
||||||
cost_i = np.sum(np.abs(ip-im))/len(im)
|
cost_i = np.sum(np.abs(ip-im))/len(im)
|
||||||
ee = np.mean(rl - rp)
|
ee = np.mean(rl - rp)
|
||||||
if ee < 1:
|
ee = max(ee, 1)
|
||||||
ee = 1
|
|
||||||
cost_r = np.sum(np.abs(rp + ee - rl))/len(im)
|
cost_r = np.sum(np.abs(rp + ee - rl))/len(im)
|
||||||
return cost_i, cost_r, x, ee, rp, ip
|
return cost_i, cost_r, x, ee, rp, ip
|
||||||
|
@@ -79,11 +79,10 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False, save=False):
|
|||||||
time = np.linspace(0, (iterations - 1) * dt, num=iterations)
|
time = np.linspace(0, (iterations - 1) * dt, num=iterations)
|
||||||
|
|
||||||
# Check for single output component when doing a FFT
|
# Check for single output component when doing a FFT
|
||||||
if fft:
|
if fft and not len(outputs) == 1:
|
||||||
if not len(outputs) == 1:
|
logger.exception('A single output must be specified when using ' +
|
||||||
logger.exception('A single output must be specified when using ' +
|
'the -fft option')
|
||||||
'the -fft option')
|
raise ValueError
|
||||||
raise ValueError
|
|
||||||
|
|
||||||
# New plot for each receiver
|
# New plot for each receiver
|
||||||
for rx in range(1, nrx + 1):
|
for rx in range(1, nrx + 1):
|
||||||
|
@@ -86,14 +86,14 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False, save=False):
|
|||||||
logging.info(f'Type: {w.type}')
|
logging.info(f'Type: {w.type}')
|
||||||
logging.info(f'Maximum (absolute) amplitude: {np.max(np.abs(waveform)):g}')
|
logging.info(f'Maximum (absolute) amplitude: {np.max(np.abs(waveform)):g}')
|
||||||
|
|
||||||
if w.freq and not w.type == 'gaussian' and not w.type == 'impulse':
|
if w.freq and w.type != 'gaussian' and w.type != 'impulse':
|
||||||
logging.info(f'Centre frequency: {w.freq:g} Hz')
|
logging.info(f'Centre frequency: {w.freq:g} Hz')
|
||||||
|
|
||||||
if (w.type == 'gaussian' or w.type == 'gaussiandot' or w.type == 'gaussiandotnorm'
|
if w.type in ['gaussian', 'gaussiandot', 'gaussiandotnorm',
|
||||||
or w.type == 'gaussianprime' or w.type == 'gaussiandoubleprime'):
|
'gaussianprime', 'gaussiandoubleprime']:
|
||||||
delay = 1 / w.freq
|
delay = 1 / w.freq
|
||||||
logging.info(f'Time to centre of pulse: {delay:g} s')
|
logging.info(f'Time to centre of pulse: {delay:g} s')
|
||||||
elif w.type == 'gaussiandotdot' or w.type == 'gaussiandotdotnorm' or w.type == 'ricker':
|
elif w.type in ['gaussiandotdot', 'gaussiandotdotnorm', 'ricker']:
|
||||||
delay = np.sqrt(2) / w.freq
|
delay = np.sqrt(2) / w.freq
|
||||||
logging.info(f'Time to centre of pulse: {delay:g} s')
|
logging.info(f'Time to centre of pulse: {delay:g} s')
|
||||||
|
|
||||||
|
@@ -36,12 +36,11 @@ def generate_y(p1, p2, x):
|
|||||||
|
|
||||||
def paint_y_axis(lines, pixels, x):
|
def paint_y_axis(lines, pixels, x):
|
||||||
is_black = False
|
is_black = False
|
||||||
target_ys = list(map(lambda line: int(generate_y(line[0], line[1], x)), lines))
|
target_ys = sorted(
|
||||||
target_ys.sort()
|
map(lambda line: int(generate_y(line[0], line[1], x)), lines)
|
||||||
|
)
|
||||||
if len(target_ys) % 2:
|
if len(target_ys) % 2:
|
||||||
distances = []
|
distances = [target_ys[i+1] - target_ys[i] for i in range(len(target_ys) - 1)]
|
||||||
for i in range(len(target_ys) - 1):
|
|
||||||
distances.append(target_ys[i+1] - target_ys[i])
|
|
||||||
# https://stackoverflow.com/a/17952763
|
# https://stackoverflow.com/a/17952763
|
||||||
min_idx = -min((x, -i) for i, x in enumerate(distances))[1]
|
min_idx = -min((x, -i) for i, x in enumerate(distances))[1]
|
||||||
del target_ys[min_idx]
|
del target_ys[min_idx]
|
||||||
@@ -54,7 +53,7 @@ def paint_y_axis(lines, pixels, x):
|
|||||||
pixels[target_y][x] = True
|
pixels[target_y][x] = True
|
||||||
is_black = not is_black
|
is_black = not is_black
|
||||||
yi = target_y
|
yi = target_y
|
||||||
assert is_black is False, 'an error has occured at x%s' % x
|
assert is_black is False, f'an error has occured at x{x}'
|
||||||
|
|
||||||
|
|
||||||
def generate_line_events(line_list):
|
def generate_line_events(line_list):
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import itertools
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -90,10 +91,7 @@ def triangle_to_intersecting_lines(triangle, height, pixels, lines):
|
|||||||
y = int(same[0][1])
|
y = int(same[0][1])
|
||||||
pixels[y][x] = True
|
pixels[y][x] = True
|
||||||
else:
|
else:
|
||||||
cross_lines = []
|
cross_lines = [(b, a) for a, b in itertools.product(above, below)]
|
||||||
for a in above:
|
|
||||||
for b in below:
|
|
||||||
cross_lines.append((b, a))
|
|
||||||
side1 = where_line_crosses_z(cross_lines[0][0], cross_lines[0][1], height)
|
side1 = where_line_crosses_z(cross_lines[0][0], cross_lines[0][1], height)
|
||||||
side2 = where_line_crosses_z(cross_lines[1][0], cross_lines[1][1], height)
|
side2 = where_line_crosses_z(cross_lines[1][0], cross_lines[1][1], height)
|
||||||
lines.append((side1, side2))
|
lines.append((side1, side2))
|
||||||
|
在新工单中引用
屏蔽一个用户