Docstrings cleaning.

这个提交包含在:
Craig Warren
2022-11-08 12:18:35 +00:00
父节点 1e177dc451
当前提交 1c020ee71a
共有 4 个文件被更改,包括 53 次插入42 次删除

查看文件

@@ -34,11 +34,11 @@ class FractalSurface:
def __init__(self, xs, xf, ys, yf, zs, zf, dimension):
"""
Args:
xs, xf, ys, yf, zs, zf (float): Extent of the fractal surface
(one pair of coordinates must be
equal to correctly define a surface).
dimension (float): Fractal dimension that controls the fractal
distribution.
xs, xf, ys, yf, zs, zf: floats for the extent of the fractal surface
(one pair of coordinates must be equal
to correctly define a surface).
dimension: float for the fractal dimension that controls the fractal
distribution.
"""
self.ID = None
@@ -114,9 +114,9 @@ class FractalVolume:
def __init__(self, xs, xf, ys, yf, zs, zf, dimension):
"""
Args:
xs, xf, ys, yf, zs, zf (float): Extent of the fractal volume.
dimension (float): Fractal dimension that controls the fractal
distribution.
xs, xf, ys, yf, zs, zf: floats for the extent of the fractal volume.
dimension: float for the fractal dimension that controls the fractal
distribution.
"""
self.ID = None
@@ -221,7 +221,7 @@ class Grass:
def __init__(self, numblades):
"""
Args:
numblades (int): Number of blades of grass.
numblades: int for the number of blades of grass.
"""
self.numblades = numblades
@@ -247,11 +247,11 @@ class Grass:
"""Calculates the x and y coordinates for a given height of grass blade.
Args:
blade (int): Numeric ID of grass blade.
height (float): Height of grass blade.
blade: int for the numeric ID of grass blade.
height: float for the height of grass blade.
Returns:
x, y (float): x and y coordinates of grass blade.
x, y: floats for the x and y coordinates of grass blade.
"""
x = (self.geometryparams[blade, 2] * (height / self.geometryparams[blade, 0])
@@ -267,11 +267,11 @@ class Grass:
"""Calculates the x and y coordinates for a given depth of grass root.
Args:
root (int): Numeric ID of grass root.
depth (float): Depth of grass root.
root: int for the umeric ID of grass root.
depth: float for the depth of grass root.
Returns:
x, y (float): x and y coordinates of grass root.
x, y: floats for the x and y coordinates of grass root.
"""
self.geometryparams[root, 4] += -1 + 2 * self.R5.random()

查看文件

@@ -405,8 +405,8 @@ class GeometryObjects:
"""Write a geometry objects file in HDF5 format.
Args:
G (FDTDGrid): Parameters describing a grid in a model.
pbar (class): Progress bar class instance.
G: FDTDGrid class describing a grid in a model.
pbar: Progress bar class instance.
"""
# Write the geometry objects to a HDF5 file

查看文件

@@ -161,7 +161,7 @@ def run_main(args):
"""Called by either run (API) or main (CLI).
Args:
args (Namespace): arguments from either API or CLI.
args: namespace with arguments from either API or CLI.
"""
logging_config(level=args.log_level, log_file=args.log_file)

查看文件

@@ -122,8 +122,8 @@ class FDTDGrid:
def initialise_geometry_arrays(self):
"""Initialise an array for volumetric material IDs (solid);
boolean arrays for specifying whether materials can have dielectric smoothing (rigid);
and an array for cell edge IDs (ID).
boolean arrays for specifying whether materials can have dielectric
smoothing (rigid); and an array for cell edge IDs (ID).
Solid and ID arrays are initialised to free_space (one);
rigid arrays to allow dielectric smoothing (zero).
"""
@@ -158,11 +158,14 @@ class FDTDGrid:
def initialise_dispersive_arrays(self):
"""Initialise field arrays when there are dispersive materials present."""
self.Tx = np.zeros((config.get_model_config().materials['maxpoles'],
self.nx + 1, self.ny + 1, self.nz + 1), dtype=config.get_model_config().materials['dispersivedtype'])
self.nx + 1, self.ny + 1, self.nz + 1),
dtype=config.get_model_config().materials['dispersivedtype'])
self.Ty = np.zeros((config.get_model_config().materials['maxpoles'],
self.nx + 1, self.ny + 1, self.nz + 1), dtype=config.get_model_config().materials['dispersivedtype'])
self.nx + 1, self.ny + 1, self.nz + 1),
dtype=config.get_model_config().materials['dispersivedtype'])
self.Tz = np.zeros((config.get_model_config().materials['maxpoles'],
self.nx + 1, self.ny + 1, self.nz + 1), dtype=config.get_model_config().materials['dispersivedtype'])
self.nx + 1, self.ny + 1, self.nz + 1),
dtype=config.get_model_config().materials['dispersivedtype'])
def initialise_dispersive_update_coeff_array(self):
"""Initialise array for storing update coefficients when there are dispersive
@@ -187,7 +190,7 @@ class FDTDGrid:
"""Estimate the amount of memory (RAM) required for grid arrays.
Returns:
mem_use (int): Memory (bytes).
mem_use: int of memory (bytes).
"""
solidarray = self.nx * self.ny * self.nz * np.dtype(np.uint32).itemsize
@@ -196,7 +199,8 @@ class FDTDGrid:
rigidarrays = (12 + 6) * self.nx * self.ny * self.nz * np.dtype(np.int8).itemsize
# 6 x field arrays + 6 x ID arrays
fieldarrays = (6 + 6) * (self.nx + 1) * (self.ny + 1) * (self.nz + 1) * np.dtype(config.sim_config.dtypes['float_or_double']).itemsize
fieldarrays = ((6 + 6) * (self.nx + 1) * (self.ny + 1) * (self.nz + 1) *
np.dtype(config.sim_config.dtypes['float_or_double']).itemsize)
# PML arrays
pmlarrays = 0
@@ -226,7 +230,7 @@ class FDTDGrid:
"""Estimate the amount of memory (RAM) required for dispersive grid arrays.
Returns:
mem_use (int): Memory (bytes).
mem_use: int of memory (bytes).
"""
mem_use = int(3 * config.get_model_config().materials['maxpoles'] *
@@ -382,10 +386,10 @@ def dispersion_analysis(G):
worse case of maximum frequency and minimum wavelength
Args:
G (class): Grid class instance - holds essential parameters describing the model.
G: FDTDGrid class describing a grid in a model.
Returns:
results (dict): Results from dispersion analysis
results: dict of results from dispersion analysis.
"""
# deltavp: physical phase velocity error (percentage)
@@ -393,7 +397,11 @@ def dispersion_analysis(G):
# material: material with maximum permittivity
# maxfreq: maximum significant frequency
# error: error message
results = {'deltavp': None, 'N': None, 'material': None, 'maxfreq': [], 'error': ''}
results = {'deltavp': None,
'N': None,
'material': None,
'maxfreq': [],
'error': ''}
# Find maximum significant frequency
if G.waveforms:
@@ -437,7 +445,9 @@ def dispersion_analysis(G):
freqthres = np.where(power[freqmaxpower:] < -config.get_model_config().numdispersion['highestfreqthres'])[0][0] + freqmaxpower
results['maxfreq'].append(freqs[freqthres])
except ValueError:
results['error'] = 'unable to calculate maximum power from waveform, most likely due to undersampling.'
results['error'] = ('unable to calculate maximum power ' +
'from waveform, most likely due to ' +
'undersampling.')
# Ignore case where someone is using a waveform with zero amplitude, i.e. on a receiver
elif waveform.amp == 0:
@@ -445,7 +455,8 @@ def dispersion_analysis(G):
# If waveform is truncated don't do any further analysis
else:
results['error'] = 'waveform does not fit within specified time window and is therefore being truncated.'
results['error'] = ('waveform does not fit within specified ' +
'time window and is therefore being truncated.')
else:
results['error'] = 'no waveform detected.'
@@ -458,8 +469,8 @@ def dispersion_analysis(G):
for x in G.materials:
if x.se != float('inf'):
er = x.er
# If there are dispersive materials calculate the complex relative permittivity
# at maximum frequency and take the real part
# If there are dispersive materials calculate the complex
# relative permittivity at maximum frequency and take the real part
if x.__class__.__name__ == 'DispersiveMaterial':
er = x.calculate_er(results['maxfreq'])
er = er.real
@@ -509,9 +520,9 @@ def Ix(x, y, z, Hx, Hy, Hz, G):
"""Calculates the x-component of current at a grid position.
Args:
x, y, z (float): Coordinates of position in grid.
Hx, Hy, Hz (memory view): numpy array of magnetic field values.
G (FDTDGrid): Parameters describing a grid in a model.
x, y, z: floats for coordinates of position in grid.
Hx, Hy, Hz: numpy array of magnetic field values.
G: FDTDGrid class describing a grid in a model.
"""
if y == 0 or z == 0:
@@ -526,9 +537,9 @@ def Iy(x, y, z, Hx, Hy, Hz, G):
"""Calculates the y-component of current at a grid position.
Args:
x, y, z (float): Coordinates of position in grid.
Hx, Hy, Hz (memory view): numpy array of magnetic field values.
G (FDTDGrid): Parameters describing a grid in a model.
x, y, z: floats for coordinates of position in grid.
Hx, Hy, Hz: numpy array of magnetic field values.
G: FDTDGrid class describing a grid in a model.
"""
if x == 0 or z == 0:
@@ -543,9 +554,9 @@ def Iz(x, y, z, Hx, Hy, Hz, G):
"""Calculates the z-component of current at a grid position.
Args:
x, y, z (float): Coordinates of position in grid.
Hx, Hy, Hz (memory view): numpy array of magnetic field values.
G (FDTDGrid): Parameters describing a grid in a model.
x, y, z: floats for coordinates of position in grid.
Hx, Hy, Hz: numpy array of magnetic field values.
G: FDTDGrid class describing a grid in a model.
"""
if x == 0 or y == 0: