More work on logging exceptions/warnings and coloured logging.

这个提交包含在:
craig-warren
2020-04-09 14:52:04 +01:00
父节点 1e64d493a2
当前提交 2d975a2544
共有 3 个文件被更改,包括 9 次插入10 次删除

查看文件

@@ -187,7 +187,7 @@ class SimulationConfig:
if args.mpi and args.geometry_fixed:
logger.exception('The geometry fixed option cannot be used with MPI.')
raise
raise ValueError
# General settings for the simulation
# inputfilepath: path to inputfile location
@@ -238,7 +238,7 @@ class SimulationConfig:
self.general['precision'] = 'double'
if self.general['cuda']:
logger.exception('The CUDA-based solver cannot currently be used with models that contain sub-grids.')
raise
raise ValueError
except AttributeError:
self.general['subgrid'] = False
@@ -273,7 +273,7 @@ class SimulationConfig:
if not found:
logger.exception(f'GPU with device ID {deviceID} does not exist')
raise
raise ValueError
def _set_precision(self):
"""Data type (precision) for electromagnetic field output.

查看文件

@@ -106,7 +106,7 @@ class ModelBuildRun:
# Write files for any geometry views and geometry object outputs
if not (G.geometryviews or G.geometryobjectswrite) and config.sim_config.args.geometry_only:
logger.warning(Fore.RED + f'\nNo geometry views or geometry objects found.' + Style.RESET_ALL)
logger.warning('\nNo geometry views or geometry objects found.')
for i, geometryview in enumerate(G.geometryviews):
logger.info('')
geometryview.set_filename()
@@ -171,13 +171,13 @@ class ModelBuildRun:
# Check to see if numerical dispersion might be a problem
results = dispersion_analysis(gb.grid)
if results['error']:
logger.warning(Fore.RED + f"\nNumerical dispersion analysis [{gb.grid.name}] not carried out as {results['error']}" + Style.RESET_ALL)
logger.warning(f"\nNumerical dispersion analysis [{gb.grid.name}] not carried out as {results['error']}")
elif results['N'] < config.get_model_config().numdispersion['mingridsampling']:
logger.exception(f"\nNon-physical wave propagation in [{gb.grid.name}] detected. Material '{results['material'].ID}' has wavelength sampled by {results['N']} cells, less than required minimum for physical wave propagation. Maximum significant frequency estimated as {results['maxfreq']:g}Hz")
raise ValueError
elif (results['deltavp'] and np.abs(results['deltavp']) >
config.get_model_config().numdispersion['maxnumericaldisp']):
logger.warning(Fore.RED + f"\n[{gb.grid.name}] has potentially significant numerical dispersion. Estimated largest physical phase-velocity error is {results['deltavp']:.2f}% in material '{results['material'].ID}' whose wavelength sampled by {results['N']} cells. Maximum significant frequency estimated as {results['maxfreq']:g}Hz" + Style.RESET_ALL)
logger.warning(f"\n[{gb.grid.name}] has potentially significant numerical dispersion. Estimated largest physical phase-velocity error is {results['deltavp']:.2f}% in material '{results['material'].ID}' whose wavelength sampled by {results['N']} cells. Maximum significant frequency estimated as {results['maxfreq']:g}Hz")
elif results['deltavp']:
logger.info(f"\nNumerical dispersion analysis [{gb.grid.name}]: estimated largest physical phase-velocity error is {results['deltavp']:.2f}% in material '{results['material'].ID}' whose wavelength sampled by {results['N']} cells. Maximum significant frequency estimated as {results['maxfreq']:g}Hz")
@@ -259,7 +259,7 @@ class ModelBuildRun:
if config.sim_config.general['cpu']:
logger.basic(f'CPU solver using: {config.get_model_config().ompthreads} OpenMP thread(s) on {platform.node()}\n')
if config.get_model_config().ompthreads > config.sim_config.hostinfo['physicalcores']:
logger.warning(Fore.RED + f"You have specified more threads ({config.get_model_config().ompthreads}) than available physical CPU cores ({config.sim_config.hostinfo['physicalcores']}). This may lead to degraded performance." + Style.RESET_ALL)
logger.warning(f"You have specified more threads ({config.get_model_config().ompthreads}) than available physical CPU cores ({config.sim_config.hostinfo['physicalcores']}). This may lead to degraded performance.")
# Print information about any GPU in use
elif config.sim_config.general['cuda']:
logger.basic(f"GPU solver using: {config.get_model_config().cuda['gpu'].deviceID} - {config.get_model_config().cuda['gpu'].name} on {platform.node()}\n")

查看文件

@@ -20,8 +20,7 @@ import logging
import gprMax.config as config
import numpy as np
from colorama import Fore, Style, init
init()
from .subgrids.base import SubGridBase
from .utilities import round_value
@@ -174,5 +173,5 @@ class SubgridUserInput(MainGridUserInput):
# the OS non-working region.
if (np.less(p_t, self.inner_bound).any() or
np.greater(p_t, self.outer_bound).any()):
logger.warning(Fore.RED + f"'{cmd_str}' this object traverses the Outer Surface. This is an advanced feature." + Style.RESET_ALL)
logger.warning(f"'{cmd_str}' this object traverses the Outer Surface. This is an advanced feature.")
return p_t