flopy.utils.optionblock module

class OptionBlock(options_line, package, block=True)[source]

Bases: object

Parent class to for option blocks within Modflow-nwt models. This class contains base information and routines that can be shared throughout all option block classes.

Parameters:
  • options_line (str) – single line based options string

  • package (flopy.pakbase.Package instance) – valid packages include ModflowWel, ModflowSfr2, ModflowUzf1

  • block (bool) – flag to write as single line or block type

dtype = 'dtype'
classmethod load_options(options, package)[source]

Loader for the options class. Reads in an options block and uses context from option util dictionaries to check the validity of the data

Parameters:
  • options (str or file) – string path to a file or file object

  • package (flopy.package type) – valid packages include flopy.modflow.ModflowWel, flopy.modflow.ModflowUzf1, flopy.modflow.ModflowSfr2

Return type:

OptionBlock object

n_nested = 'nvars'
nested = 'nested'
optional = 'optional'
simple_flag = {'dtype': <class 'numpy.bool_'>, 'nested': False, 'optional': False}
simple_float = {'dtype': <class 'float'>, 'nested': False, 'optional': False}
simple_int = {'dtype': <class 'int'>, 'nested': False, 'optional': False}
simple_str = {'dtype': <class 'str'>, 'nested': False, 'optional': False}
simple_tabfile = {'dtype': <class 'numpy.bool_'>, 'nested': True, 'nvars': 2, 'vars': {'maxval': {'dtype': <class 'int'>, 'nested': False, 'optional': False}, 'numtab': {'dtype': <class 'int'>, 'nested': False, 'optional': False}}}
property single_line_options

Method to get the single line representation of the Options Block

Returns:

t

Return type:

(str) single line representation of Options

update_from_package(pak)[source]

Updater method to check the package and update OptionBlock attribute values based on package values.

Parameters:

pak (flopy.package) – valid packages include ModflowWel, ModflowSfr2, and ModflowUzf1 instances

vars = 'vars'
write_options(f)[source]

Method to write the options block or options line to an open file object.

Parameters
ffile, str

open file object, or path to file

class OptionUtil[source]

Bases: object

static isfloat(s)[source]

Simple method to check that a string is a valid floating point variable

Parameters:

s (str) –

Return type:

bool

static isint(s)[source]

Simple data check method to check that a string is a valid integer

Parameters:

s (str) –

Return type:

bool

static isvalid(dtype, val)[source]

Check to see if a dtype is valid before setting as an attribute

Parameters:
  • dtype (type) – int, float, str, bool, etc…

  • val (string) –

Return type:

bool