你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
More updates to logging and handling exceptions.
这个提交包含在:
@@ -17,16 +17,18 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import h5py
|
||||
import matplotlib.gridspec as gridspec
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from gprMax.exceptions import CmdInputError
|
||||
from gprMax.receivers import Rx
|
||||
from gprMax.utilities import fft_power
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
|
||||
"""Plots electric and magnetic fields and currents from all receiver points
|
||||
@@ -65,7 +67,8 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
|
||||
|
||||
# Check there are any receivers
|
||||
if not paths:
|
||||
raise CmdInputError(f'No receivers found in {file}')
|
||||
logger.exception(f'No receivers found in {file}')
|
||||
raise ValueError
|
||||
|
||||
# Loop through all grids
|
||||
for path in paths:
|
||||
@@ -77,7 +80,8 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
|
||||
# Check for single output component when doing a FFT
|
||||
if fft:
|
||||
if not len(outputs) == 1:
|
||||
raise CmdInputError('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
|
||||
for rx in range(1, nrx + 1):
|
||||
@@ -98,7 +102,8 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
|
||||
output = outputs[0]
|
||||
|
||||
if output not in availableoutputs:
|
||||
raise CmdInputError(f"{output} output requested to plot, but the available output for receiver 1 is {', '.join(availableoutputs)}")
|
||||
logger.exception(f"{output} output requested to plot, but the available output for receiver 1 is {', '.join(availableoutputs)}")
|
||||
raise ValueError
|
||||
|
||||
outputdata = f[rxpath + output][:] * polarity
|
||||
|
||||
@@ -196,7 +201,8 @@ def mpl_plot(filename, outputs=Rx.defaultoutputs, fft=False):
|
||||
|
||||
# Check if requested output is in file
|
||||
if output not in availableoutputs:
|
||||
raise CmdInputError(f"Output(s) requested to plot: {', '.join(outputs)}, but available output(s) for receiver {rx} in the file: {', '.join(availableoutputs)}")
|
||||
logger.exception(f"Output(s) requested to plot: {', '.join(outputs)}, but available output(s) for receiver {rx} in the file: {', '.join(availableoutputs)}")
|
||||
raise ValueError
|
||||
|
||||
outputdata = f[rxpath + output][:] * polarity
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户