Skip to main content

flopymetascript

Converts a zip with MODFLOW input files to a zip containing Flopy script in different formats. This Flopy (Python) script can generate the intitial MODFLOW input files.

It should work for all packages of MODFLOW, MT3D, and SEAWAT. For a complete list, see the load supported packages in https://github.com/modflowpy/flopy/blob/develop/docs/supported_packages.md .

No money is to be made by the author with this package. The author has absolutely no convidense in that this script is correct and is not responsible for the content and consequences of malicious scripts. I you find it useful, please consider donating to charity (be creative in choosing which one) and send me a note (or create and close an issue). Thanks! The author is not affiliated with the modflow family nor with Flopy. This converter/generator uses the Flopy load function. Any errors/mistakes in the Flopy load functions propagate to the generated script.

Use cases

  • You are coming from a different modeling environment and want to start using Flopy

  • Clean up your flopy script/notebook

  • Add a description (and default value) to your parameters

  • Check someone else’s MODFLOW input files / Flopy script

  • Check homework assignments

Advantages

  • Returns .ipynb, py, tex, html, markdown, and rst file of your MODFLOW input files

  • Consistent and clean markup is used

  • All the parameters are defined explicitely

  • A description is loaded and interpreted from the flopy package directly. The same description as in the docs (modflowpy.github.io/flopydoc/) is used.

  • Makes use of smart broadcasting to reduce the size of the arrays printed to the script.

Install

Enter in the terminal,

$ pip install https://github.com/bdestombe/flopymetascript/zipball/master

The $-sign should be omitted, and only refers to that the command is to be entered in the bash-commandline. The flopymetascript package added to system’s $PATH and is reachable from any directory. Check if everything works by typing in any directory,

$ flopymetascript --help

Uninstall with,

$ pip uninstall flopymetascript

Please see https://gehrcke.de/2014/02/distributing-a-python-command-line-application/ for more information on the package structure.

Supported

Currently only tested with several MODFLOW and SEAWAT models, on a Mac-platform.

# Known issues

Example usage from the commandline:

With zipfiles

Try this first,

$ flopymetascript --outbytesfile output.zip --inbytesfile input.zip --logfile log.txt

input.zip is a zip-file that contains MODFLOW input files and a single .nam file. Its content is processed and written to output.zip. Some logging is written to log.txt.

Using pipes

$ openssl base64 -in input.zip -out input.zip.b64
$ flopymetascript --outbytesfile output.zip --inbase64file input.zip.b64

input.zip is encoded to base64 and is used as input file for flopymetascript

$ flopymetascript --outbytesfile output.zip --inbase64file - < input.zip.b64

The content of input.zip.b64 is streamed/piped to flopymetascript

$ openssl base64 -in input.zip | flopymetascript --outbytesfile output.zip --inbase64file -

The same as what is done previously, however input.zip is encoded and instead of writing it to a file, it is passed as stdin to the inbase64file argument of flopymetascript.

$ openssl base64 -in input.zip | flopymetascript --outbase64file utput.zip --inbase64file - --logfile -

The log file is printed to stdout.

You cannot send both outbase64file and logfile to stdout. They will be mixed and the resulting output file is not readable.

Example usage in python

This might need somework and is subject to change in the future.

from flopymetascript.flopymetascript import process

# fn = 'input.zip.b64'
# inbase64file = open(fn, 'r')
# fn = 'output.zip.b64'
# outbase64file = open(fn, 'w')
fn = 'input.zip'
inbytesfile = open(fn, 'rb')   # Dont forget the b
fn = 'output.zip'
outbytesfile = open(fn, 'rb')  # Dont forget the b
fn = 'log.txt'
logfile = open(fn, 'w')

process(inbytesfile=inbytesfile, outbytesfile=outbytesfile, logfile=logfile)

inbytesfile.close()
outbytesfile.close()
logfile.close()

Todo:

  • Add additional packages with default values

  • Add a toggle to turn of the parameter description

  • Add line width as parameter

Metadata

Release files for flopymetascript 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flopymetascript 1.0.0
File Size Uploaded
flopymetascript-1.0.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flopymetascript 1.0.0
File Interpreter ABI Platform
flopymetascript-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.8 kB

Release files / flopymetascript-1.0.0.tar.gz

Download URL flopymetascript-1.0.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a2fbfb48bb7ebaf188b908fee1f0d52ffd5fb77473270fb61bf8d636ef820076
BLAKE2b-256 checksum
How to use checksums
21cbef34aa1b998c060d3425c0328c41b2638a7aed9e2591b0900250b76252a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / flopymetascript-1.0.0-py3-none-any.whl

Download URL flopymetascript-1.0.0-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
126174cb2471e6f4daad1d70fc0c7893c48166cc7412cd802279196570ece321
BLAKE2b-256 checksum
How to use checksums
e38a98e1f08173c5bddcbc6109d8b47a8bbbb932b007645b1053b131aadbf318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.1

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page