Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Read MT3DMS and MT3DUSGS Budgets from List File fails width ADV-Package activated #1895

Closed
rabbl opened this issue Aug 2, 2023 · 2 comments
Labels

Comments

@rabbl
Copy link
Contributor

rabbl commented Aug 2, 2023

Describe the bug
Reading the MassBudgets from a MT3D-List file fails.

We are seeing two bugs here.

  1. Reading out "CALLS TO GCG PACKAGE" (see attached file line 249) fails, because the expected character span (line[51:58]) does not match with the existing here.

The sourcecode tries to parse, but returns more characters than expected.

line = '     1 CALLS TO GCG PACKAGE FOR TRANSPORT TIME STEP   1 IN FLOW TIME STEP   1 STRESS PERIOD   1'
print(line[51:58])

>>> '   1 IN'
  1. With activated ADV-Package, three additional lines regarding Particle Tracking are created for each Component and Step. Instead of parsing.

The sourcecode expects to parse:

CUMMULATIVE MASS BUDGETS AT END OF TRANSPORT STEP 21, TIME STEP 1, STRESS PERIOD 1

but it gets

TOTAL PARTICLES USED IN THE CURRENT STEP = 4264

To Reproduce
Steps to reproduce the behavior:

Attached goes the mt.list as zip-file.

Additional context

To solve the first bug I propose to use regex instead of static character spans.
This could be something like that, reading a number which in in between known strings.

   def _extract_number_between_strings(input_string, start_string, end_string):
        pattern = rf"{re.escape(start_string)}\s*(\d+)\s*{re.escape(end_string)}"
        match = re.search(pattern, input_string)
        if match:
            return int(match.group(1))
        else:
            raise Exception(
                f"Error extracting number between {start_string} and {end_string} in {input_string}"
            )

To solve the second bug, I propose to add a simple conditional to skip 4 more lines if the string contains part of "TOTAL PARTICLES USED IN THE CURRENT STEP".

We will provide a PR.

mt.list.zip

@rabbl rabbl added the bug label Aug 2, 2023
@rabbl
Copy link
Contributor Author

rabbl commented Aug 3, 2023

I have created #1899 providing a fix with tests.

@wpbonelli
Copy link
Member

presumed closed by #1899, please reopen if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants