MTgeophysics / mtpy

Python toolbox for standard Magnetotelluric (MT) data analysis
GNU General Public License v3.0
147 stars 66 forks source link

Bug reading ModEM .log files #150

Open DGD042 opened 3 years ago

DGD042 commented 3 years ago

Hello,

When reading the .log files, there is a bug when getting the metrics from ModEM inversion results. When the rms values are higher than 10, I get back the following error in the plot_rms_iterations.read(logfile) function

File "mtpy\mtpy\utils\plot_rms_iterations.py", line 77, in read
    metric, value = word.split('=')
ValueError: not enough values to unpack (expected 2, got 1)

Possible Solution

A possible solution is to account for a broader possibilities of rms values by changing line 72 in plot_rms_iterations.py from,

value_lines = [l.strip().replace('   ', '').split() for l in value_lines]

to

value_lines = [
        line.strip().replace('   ', '').replace('  ', '').replace(
            '= ', '=').split()
        for line in value_lines
    ]

Steps to Reproduce (for bugs)

Here is a file (Modular_NLCG.log) that has a series of rms values higher than 10. Download the file and create a python script to run the following code,

wd = 'path_to_log_file_directory'
logfile = plot_rms_iterations.concatenate_log_files(wd)
metrics = plot_rms_iterations.read(logfile)

This should reproduce the error I got.

Your Environment