-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(binaryfile): add head/budget file reversal script (#2383)
Close #2382. Also remove the need for tdis in the reversal methods by inferring period length etc from data headers.
- Loading branch information
Showing
3 changed files
with
86 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
from flopy.utils.binaryfile import CellBudgetFile, HeadFile | ||
|
||
if __name__ == "__main__": | ||
"""Reverse head or budget files.""" | ||
|
||
parser = argparse.ArgumentParser(description="Reverse head or budget files.") | ||
parser.add_argument( | ||
"--infile", | ||
"-i", | ||
type=str, | ||
help="Input file.", | ||
) | ||
parser.add_argument( | ||
"--outfile", | ||
"-o", | ||
type=str, | ||
help="Output file.", | ||
) | ||
args = parser.parse_args() | ||
infile = Path(args.infile) | ||
outfile = Path(args.outfile) | ||
suffix = infile.suffix.lower() | ||
if suffix in [".hds", ".hed"]: | ||
HeadFile(infile).reverse(outfile) | ||
elif suffix in [".bud", ".cbc"]: | ||
CellBudgetFile(infile).reverse(outfile) | ||
else: | ||
raise ValueError(f"Unrecognized file suffix: {suffix}") |