modifed the remaining functions to call command and return Coordinate(s)

这个提交包含在:
Øystein Bjørndal
2016-05-20 22:06:35 +02:00
父节点 393d5e38e9
当前提交 3128fbc0d4

查看文件

@@ -112,7 +112,7 @@ def time_window(time_window):
""" """
command('time_window', time_window) command('time_window', time_window)
return time_window return time_window
@@ -138,9 +138,15 @@ def geometry_view(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, type='n'):
dx, dy, dz (float): Spatial discretisation of geometry view. dx, dy, dz (float): Spatial discretisation of geometry view.
filename (str): Filename where geometry file information will be stored. filename (str): Filename where geometry file information will be stored.
type (str): Can be either n (normal) or f (fine) which specifies whether to output the geometry information on a per-cell basis (n) or a per-cell-edge basis (f). type (str): Can be either n (normal) or f (fine) which specifies whether to output the geometry information on a per-cell basis (n) or a per-cell-edge basis (f).
Returns:
s, f, d (tuple): 3 namedtuple Coordinate for the start, finish coordinates and spatial discretisation
""" """
s = Coordinate(xs, ys, zs)
print('#geometry_view: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, type)) f = Coordinate(xf, yf, zf)
d = Coordinate(dx, dy, dz)
command('geometry_view', *s, *f, *d, filename, type)
return s, f, d
def snapshot(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename): def snapshot(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename):
@@ -151,15 +157,20 @@ def snapshot(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename):
dx, dy, dz (float): Spatial discretisation of geometry view. dx, dy, dz (float): Spatial discretisation of geometry view.
time (float): Time in seconds (float) or the iteration number (integer) which denote the point in time at which the snapshot will be taken. time (float): Time in seconds (float) or the iteration number (integer) which denote the point in time at which the snapshot will be taken.
filename (str): Filename where geometry file information will be stored. filename (str): Filename where geometry file information will be stored.
Returns:
s, f, d (tuple): 3 namedtuple Coordinate for the start, finish coordinates and spatial discretisation
""" """
s = Coordinate(xs, ys, zs)
f = Coordinate(xf, yf, zf)
d = Coordinate(dx, dy, dz)
if '.' in str(time) or 'e' in str(time): if '.' in str(time) or 'e' in str(time):
time = float(time) time = '{:g}'.format(float(time))
print('#snapshot: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename))
else: else:
time = int(time) time = '{:d}'.format(int(time))
print('#snapshot: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:d} {}'.format(xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename))
command('snapshot', *s, *f, *d, time, filename)
return s, f, d
def edge(xs, ys, zs, xf, yf, zf, material): def edge(xs, ys, zs, xf, yf, zf, material):
"""Prints the gprMax #edge command. """Prints the gprMax #edge command.
@@ -167,10 +178,15 @@ def edge(xs, ys, zs, xf, yf, zf, material):
Args: Args:
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates. xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
material (str): Material identifier. material (str): Material identifier.
Returns:
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
""" """
s = Coordinate(xs, ys, zs)
print('#edge: {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, material)) f = Coordinate(xf, yf, zf)
command('edge', *s, *f, material)
return s, f
def plate(xs, ys, zs, xf, yf, zf, material): def plate(xs, ys, zs, xf, yf, zf, material):
"""Prints the gprMax #plate command. """Prints the gprMax #plate command.
@@ -178,10 +194,14 @@ def plate(xs, ys, zs, xf, yf, zf, material):
Args: Args:
xs, ys, zs, xf, yf, zf (float): Start and finish coordinates. xs, ys, zs, xf, yf, zf (float): Start and finish coordinates.
material (str): Material identifier(s). material (str): Material identifier(s).
Returns:
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
""" """
s = Coordinate(xs, ys, zs)
print('#plate: {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(xs, ys, zs, xf, yf, zf, material)) f = Coordinate(xf, yf, zf)
command('plate', *s, *f, material)
return s, f
def triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material): def triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material):
"""Prints the gprMax #triangle command. """Prints the gprMax #triangle command.
@@ -190,10 +210,16 @@ def triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material):
x1, y1, z1, x2, y2, z2, x3, y3, z3 (float): Coordinates of the vertices. x1, y1, z1, x2, y2, z2, x3, y3, z3 (float): Coordinates of the vertices.
thickness (float): Thickness for a triangular prism, or zero for a triangular patch. thickness (float): Thickness for a triangular prism, or zero for a triangular patch.
material (str): Material identifier(s). material (str): Material identifier(s).
Returns:
v1, v2, v3 (tuple): 3 namedtuple Coordinate for the vertices
""" """
v1 = Coordinate(x1, y1, z1)
print('#triangle: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {}'.format(x1, y1, z1, x2, y2, z2, x3, y3, z3, thickness, material)) v2 = Coordinate(x2, y2, z2)
v3 = Coordinate(x3, y3, z3)
command('triangle', *v1, *v2, *v3, thickness, material)
return v1, v2, v3
def box(xs, ys, zs, xf, yf, zf, material, averaging=''): def box(xs, ys, zs, xf, yf, zf, material, averaging=''):
"""Prints the gprMax #box command. """Prints the gprMax #box command.
@@ -205,14 +231,14 @@ def box(xs, ys, zs, xf, yf, zf, material, averaging=''):
Returns: Returns:
s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates s, f (tuple): 2 namedtuple Coordinate for the start and finish coordinates
""" """
s = Coordinate(xs, ys, zs) s = Coordinate(xs, ys, zs)
f = Coordinate(xf, yf, zf) f = Coordinate(xf, yf, zf)
print('#box: {} {} {} {}'.format(s, f, material, averaging))
command('box', *s, *f, material, averaging)
return s, f return s, f
def sphere(x, y, z, radius, material, averaging=''): def sphere(x, y, z, radius, material, averaging=''):
"""Prints the gprMax #sphere command. """Prints the gprMax #sphere command.
@@ -222,11 +248,16 @@ def sphere(x, y, z, radius, material, averaging=''):
radius (float): Radius. radius (float): Radius.
material (str): Material identifier(s). material (str): Material identifier(s).
averaging (str): Turn averaging on or off. averaging (str): Turn averaging on or off.
Returns:
c (tuple): namedtuple Coordinate for the center of the sphere
""" """
c = Coordinate(x, y, z)
print('#sphere: {:g} {:g} {:g} {:g} {} {}'.format(x, y, z, radius, material, averaging)) command('sphere', *c, radius, material, averaging)
return c
def cylinder(x1, y1, z1, x2, y2, z2, radius, material, averaging=''): def cylinder(x1, y1, z1, x2, y2, z2, radius, material, averaging=''):
"""Prints the gprMax #cylinder command. """Prints the gprMax #cylinder command.
@@ -235,10 +266,16 @@ def cylinder(x1, y1, z1, x2, y2, z2, radius, material, averaging=''):
radius (float): Radius. radius (float): Radius.
material (str): Material identifier(s). material (str): Material identifier(s).
averaging (str): Turn averaging on or off. averaging (str): Turn averaging on or off.
"""
print('#cylinder: {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(x1, y1, z1, x2, y2, z2, radius, material, averaging)) Returns:
c1, c2 (tuple): 2 namedtuple Coordinate for the centres of the two faces of the cylinder.
"""
c1 = Coordinate(x1, y1, z1)
c2 = Coordinate(x2, y2, z2)
command('cylinder', *c1, *c2, radius, material, averaging)
return c1, c2
def cylindrical_sector(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging=''): def cylindrical_sector(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging=''):
"""Prints the gprMax #cylindrical_sector command. """Prints the gprMax #cylindrical_sector command.
@@ -254,8 +291,8 @@ def cylindrical_sector(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptang
averaging (str): Turn averaging on or off. averaging (str): Turn averaging on or off.
""" """
print('#cylindrical_sector: {} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {} {}'.format(axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging)) command('cylindrical_sector', axis, ctr1, ctr2, t1, t2, radius, startingangle, sweptangle, material, averaging)
def excitation_file(file1): def excitation_file(file1):
"""Prints the #excitation_file: <file1> command. """Prints the #excitation_file: <file1> command.