flopy.mf6.data.mfstructure module

mfstructure module. Contains classes related to package structure

class BlockType(value)[source]

Bases: enum.Enum

Types of blocks that can be found in a package file

multiple = 2
single = 1
transient = 3
class DataType(value)[source]

Bases: enum.Enum

Types of data that can be found in a package file

array = 3
array_transient = 4
list = 5
list_multiple = 7
list_transient = 6
scalar = 2
scalar_keyword = 1
scalar_keyword_transient = 9
scalar_transient = 8
class DatumType(value)[source]

Bases: enum.Enum

Types of individual pieces of data

constant = 5
double_precision = 3
integer = 2
keystring = 7
keyword = 1
list_defined = 6
recarray = 10
record = 8
repeating_record = 9
string = 4
class Dfn[source]

Bases: object

Base class for package file definitions

dfndir

folder containing package definition files (dfn)

Type

path

common

file containing common information

Type

path

get_file_list : () : list

returns all of the dfn files found in dfndir. files are returned in a specified order defined in the local variable file_order

Notes

Examples

get_file_list()[source]
class DfnFile(file)[source]

Bases: flopy.mf6.data.mfstructure.Dfn

Dfn child class that loads dfn information from a package definition (dfn) file

file

name of the file to be loaded

Type

str

dict_by_name : {} : dict

returns a dictionary of data item descriptions from the dfn file with the data item name as the dictionary key

get_block_structure_dict : (path : tuple, common : bool, model_file :

bool) : dict

returns a dictionary of block structure information for the package

Notes

Examples

dict_by_name()[source]
get_block_structure_dict(path, common, model_file)[source]
class DfnPackage(package)[source]

Bases: flopy.mf6.data.mfstructure.Dfn

Dfn child class that loads dfn information from a list structure stored in the auto-built package classes

package

MFPackage subclass that contains dfn information

Type

MFPackage

get_block_structure_dict : (path : tuple, common : bool, model_file :

bool) : dict

returns a dictionary of block structure information for the package

Notes

Examples

get_block_structure_dict(path, common, model_file)[source]
class DfnType(value)[source]

Bases: enum.Enum

An enumeration.

common = 1
exch_file = 5
gnc_file = 8
ims_file = 4
model_file = 7
model_name_file = 6
mvr_file = 9
mvt_file = 11
sim_name_file = 2
sim_tdis_file = 3
unknown = 999
utl = 10
class MFBlockStructure(name, path, model_block)[source]

Bases: object

Defines the structure of a MF6 block.

Parameters
  • name (string) – block name

  • path (tuple) – tuple that describes location of block within simulation (<model>, <package>, <block>)

  • model_block (bool) – true if this block is part of a model

name

block name

Type

string

path

tuple that describes location of block within simulation (<model>, <package>, <block>)

Type

tuple

model_block

true if this block is part of a model

Type

bool

data_structures

dictionary of data items in this block, with the data item name as the key

Type

dict

block_header_structure

list of data items that are part of this block’s “header”

Type

list

repeating() : bool

Returns true if more than one instance of this block can appear in a MF6 package file

add_dataset(dataset: MFDataStructure, block_header_dataset: bool)[source]

Adds dataset to this block, as a header dataset of block_header_dataset is true

number_non_optional_data() : int

Returns the number of non-optional non-header data structures in this block

number_non_optional_block_header_data() : int

Returns the number of non-optional block header data structures in this block

get_data_structure(path : tuple) : MFDataStructure

Returns the data structure in this block with name defined by path[0]. If name does not exist, returns None.

get_all_recarrays() : list

Returns all data non-header data structures in this block that are of type recarray

Notes

Examples

add_dataset(dataset)[source]
get_all_recarrays()[source]
get_data_structure(path)[source]
number_non_optional_block_header_data()[source]
number_non_optional_data()[source]
repeating()[source]
class MFDataItemStructure[source]

Bases: object

Defines the structure of a single MF6 data item in a dfn file

block_name

name of block that data item is in

Type

str

name

name of data item

Type

str

name_list

list of alternate names for the data item, includes data item’s main name “name”

Type

list

python_name

name of data item referenced in python, with illegal python characters removed

Type

str

type

type of the data item as it appears in the dfn file

Type

str

type_obj

type of the data item as a python type

Type

python type

valid_values

list of valid values for the data item. if empty, this constraint does not apply

Type

list

data_items

list of data items contained in this data_item, including itself

Type

list

in_record

in_record attribute as appears in dfn file

Type

bool

tagged

whether data item is tagged. if the data item is tagged its name is included in the MF6 input file

Type

bool

just_data

when just_data is true only data appears in the MF6 input file. otherwise, name information appears

Type

bool

shape

describes the shape of the data

Type

list

layer_dims

which dimensions in the shape function as layers, if None defaults to “layer”

Type

list

reader

reader that MF6 uses to read the data

Type

basestring

optional

whether data item is optional or required as part of the MFData in the MF6 input file

Type

bool

longname

long name of the data item

Type

str

description

description of the data item

Type

str

path

a tuple describing the data item’s location within the simulation (<model>,<package>,<block>,<data>)

Type

tuple

repeating

whether or not the data item can repeat in the MF6 input file

Type

bool

block_variable

if true, this data item is part of the block header

Type

bool

block_type

whether the block containing this item is a single non-repeating block, a multiple repeating block, or a transient repeating block

Type

BlockType

keystring_dict

dictionary containing acceptable keystrings if this data item is of type keystring

Type

dict

is_cellid

true if this data item is definitely of type cellid

Type

bool

possible_cellid

true if this data item may be of type cellid

Type

bool

ucase

this data item must be displayed in upper case in the MF6 input file

Type

bool

remove_cellid : (resolved_shape : list, cellid_size : int)

removes the cellid size from the shape of a data item

set_path : (path : tuple)

sets the path to this data item to path

get_rec_type : () : object type

gets the type of object of this data item to be used in a numpy recarray

Notes

Examples

file_nam_in_nam_file()[source]
get_description(line_size, initial_indent, level_indent)[source]
get_doc_string(line_size, initial_indent, level_indent)[source]
get_keystring_desc(line_size, initial_indent, level_indent)[source]
get_rec_type()[source]
get_type_string()[source]
indicates_file_name()[source]
is_file_name()[source]
static remove_cellid(resolved_shape, cellid_size)[source]
set_path(path)[source]
set_value(line, common)[source]
class MFDataStructure(data_item, model_data, package_type, dfn_list)[source]

Bases: object

Defines the structure of a single MF6 data item in a dfn file

Parameters
  • data_item (MFDataItemStructure) – base data item associated with this data structure

  • model_data (bool) – whether or not this is part of a model

  • package_type (str) – abbreviated package type

type

type of the data as it appears in the dfn file

Type

str

path

a tuple describing the data’s location within the simulation (<model>,<package>,<block>,<data>)

Type

tuple

optional

whether data is optional or required as part of the MFBlock in the MF6 input file

Type

bool

name

name of data item

Type

str

name_list

list of alternate names for the data, includes data item’s main name “name”

Type

list

python_name

name of data referenced in python, with illegal python characters removed

Type

str

longname

long name of the data

Type

str

repeating

whether or not the data can repeat in the MF6 input file

Type

bool

layered

whether this data can appear by layer

Type

bool

num_data_items

number of data item structures contained in this MFDataStructure, including itself

Type

int

record_within_record

true if this MFDataStructure is a record within a container MFDataStructure

Type

bool

file_data

true if data points to a file

Type

bool

block_type

whether the block containing this data is a single non-repeating block, a multiple repeating block, or a transient repeating block

Type

BlockType

block_variable

if true, this data is part of the block header

Type

bool

model_data

if true, data is part of a model

Type

bool

num_optional

number of optional data items

Type

int

parent_block

parent block structure object

Type

MFBlockStructure

data_item_structures

list of data item structures contained in this MFDataStructure

Type

list

expected_data_items

dictionary of expected data item names for quick lookup

Type

dict

shape

shape of first data item

Type

tuple

get_keywords : () : list

returns a list of all keywords associated with this data

supports_aux : () : bool

returns true of this data supports aux variables

add_item : (item : MFDataItemStructure, record : bool)

adds a data item to this MFDataStructure

set_path : (path : tuple)

sets the path describing the data’s location within the simulation (<model>,<package>,<block>,<data>)

get_datatype : () : DataType

returns the DataType of this data (array, list, scalar, …)

get_min_record_entries : () : int

gets the minimum number of entries, as entered in a package file, for a single record. excludes optional data items

get_record_size : () : int

gets the number of data items, excluding keyword data items, in this MFDataStructure

all_keywords : () : bool

returns true of all data items are keywords

get_type_string : () : str

returns descriptive string of the data types in this MFDataStructure

get_description : () : str

returns a description of the data

get_type_array : (type_array : list):

builds an array of data type information in type_array

get_datum_type : (numpy_type : bool):

returns the object type of the first data item in this MFDataStructure with a standard type. if numpy_type is true returns the type as a numpy type

get_data_item_types: () : list

returns a list of object type for every data item in this MFDataStructure

first_non_keyword_index : () : int

return the index of the first data item in this MFDataStructure that is not a keyword

Notes

Examples

add_item(item, record=False, dfn_list=None)[source]
all_keywords()[source]
display_item(item_num)[source]
first_non_keyword_index()[source]
get_data_item_types()[source]
get_datatype()[source]
get_datum_type(numpy_type=False, return_enum_type=False)[source]
get_description(line_size=79, initial_indent='        ', level_indent='    ')[source]
get_doc_string(line_size=79, initial_indent='    ', level_indent='    ')[source]
get_docstring_type_array(type_array)[source]
get_item(item_name)[source]
get_keywords()[source]
get_min_record_entries()[source]
get_model()[source]
get_package()[source]
get_record_size()[source]
get_subpackage_description(line_size=79, initial_indent='        ', level_indent='    ')[source]
get_type_array(type_array)[source]
get_type_string()[source]
property is_mname
is_mult_or_trans()[source]
set_path(path)[source]
supports_aux()[source]
class MFInputFileStructure(dfn_file, path, common, model_file)[source]

Bases: object

MODFLOW Input File Stucture class. Loads file structure information for individual input file types.

Parameters
  • dfn_file (string) – the definition file used to define the structure of this input file

  • path (tuple) – path defining the location of the container of this input file structure within the overall simulation structure

  • common (bool) – is this the common dfn file

  • model_file (bool) – this file belongs to a specific model type

valid

simulation structure validity

Type

bool

path

path defining the location of this input file structure within the overall simulation structure

Type

tuple

read_as_arrays

if this input file structure is the READASARRAYS version of a package

Type

bool

is_valid() : bool

Checks all structures objects within the file for validity

get_data_structure(path: string)[source]

Returns a data structure of it exists, otherwise returns None. Data structure type returned is based on the tuple/list “path”

Notes

Examples

get_data_structure(path)[source]
is_valid()[source]
class MFModelStructure(model_type, utl_struct_objs)[source]

Bases: object

Defines the structure of a MF6 model and its packages

Parameters

model_type (string) – abbreviation of model type

valid

simulation structure validity

Type

bool

name_file_struct_obj

describes the structure of the simulation name file

Type

MFInputFileStructure

package_struct_objs

describes the structure of the simulation packages

Type

dict

model_type

dictionary containing simulation package structure

Type

string

add_namefile : (dfn_file : DfnFile, model_file=True : bool)

Adds a namefile structure object to the model

add_package(dfn_file : DfnFile, model_file=True : bool)[source]

Adds a package structure object to the model

is_valid() : bool

Checks all structures objects within the model for validity

get_data_structure(path: string)[source]

Returns a data structure of it exists, otherwise returns None. Data structure type returned is based on the tuple/list “path”

Notes

Examples

add_namefile(dfn_file, common)[source]
add_package(dfn_file, common)[source]
get_data_structure(path)[source]
get_package_struct(package_type)[source]
is_valid()[source]
class MFSimulationStructure[source]

Bases: object

Defines the structure of a MF6 simulation and its packages and models.

name_file_struct_obj

describes the structure of the simulation name file

Type

MFInputFileStructure

package_struct_objs

describes the structure of the simulation packages

Type

dict

model_struct_objs

describes the structure of the supported model types

Type

dict

utl_struct_objs

describes the structure of the supported utility packages

Type

dict

common

common file information

Type

dict

model_type

placeholder

Type

string

process_dfn : (dfn_file : DfnFile)

reads in the contents of a dfn file, storing that contents in the appropriate object

add_namefile : (dfn_file : DfnFile, model_file=True : bool)

Adds a namefile structure object to the simulation

add_util : (dfn_file : DfnFile)

Adds a utility package structure object to the simulation

add_package(dfn_file : DfnFile, model_file=True : bool)[source]

Adds a package structure object to the simulation

store_common(dfn_file: DfnFile)[source]

Stores the contents of the common dfn file

add_model(model_type: string)[source]

Adds a model structure object to the simulation

is_valid() : bool

Checks all structures objects within the simulation for validity

get_data_structure(path: string)[source]

Returns a data structure of it exists, otherwise returns None. Data structure type returned is based on the tuple/list “path”

tag_read_as_arrays()[source]

Searches through all packages and tags any packages with a name that indicates they are the READASARRAYS version of a package.

Notes

Examples

add_model(model_type)[source]
add_namefile(dfn_file, model_file=True)[source]
add_package(dfn_file, model_file=True)[source]
add_util(dfn_file)[source]
get_data_structure(path)[source]
is_valid()[source]
property model_types
process_dfn(dfn_file)[source]
store_common(dfn_file)[source]
tag_read_as_arrays()[source]
class MFStructure(internal_request=False, load_from_dfn_files=False)[source]

Bases: object

Singleton class for accessing the contents of the json structure file (only one instance of this class can exist, which loads the json file on initialization)

Parameters
  • mf_version (int) – version of MODFLOW

  • valid (bool) – whether the structure information loaded from the dfn files is valid

  • sim_struct (MFSimulationStructure) – Object containing file structure for all simulation files

  • dimension_dict (dict) – Dictionary mapping paths to dimension information to the dataitem whose dimension information is being described

get_version_string()[source]