flopy.mf6.data.mfdatastorage module
- class DataStorage(sim_data, model_or_sim, data_dimensions, get_file_entry, data_storage_type=DataStorageType.internal_array, data_structure_type=DataStructureType.ndarray, layer_shape=(1,), layered=False, stress_period=0, data_path=())[source]
Bases:
object
Stores and retrieves data.
- Parameters:
sim_data (simulation data class) – reference to the simulation data class
data_dimensions (data dimensions class) – a data dimensions class for the data being stored
get_file_entry (method reference) – method that returns the file entry for the stored data
data_storage_type (enum) – how the data will be stored (internally, as a constant, as an external file)
data_structure_type (enum) – what internal type is the data stored in (ndarray, recarray, scalar)
layer_shape (int) – number of data layers
layered (bool) – is the data layered
layer_storage (MultiList<LayerStorage>) – one or more dimensional list of LayerStorage
- data_structure_type
what internal type is the data stored in (ndarray, recarray, scalar)
- pre_data_comments
any comments before the start of the data
- Type:
string
- post_data_comments
any comments after the end of the data
- Type:
string
- override_data_type : (index, data_type)
overrides the data type used in a recarray at index “index” with data type “data_type”
- get_const_val(layer)[source]
gets the constant value of a given layer. data storage type for layer must be “internal_constant”.
- has_data(layer) : bool
returns true if data exists for the specified layer, false otherwise
- get_data(layer) : ndarray/recarray/string
returns the data for the specified layer
- update_item(data, key_index)
updates the data in a recarray at index “key_index” with data “data”. data is a list containing all data for a single record in the recarray. . data structure type must be recarray
- append_data(data)[source]
appends data “data” to the end of a recarray. data structure type must be recarray
- set_data(data, layer=None, multiplier=[1.0]
sets the data being stored to “data” for layer “layer”, replacing all data for that layer. a multiplier can be specified.
- get_active_layer_indices() : list
returns the indices of all layers expected to contain data
- store_internal(data, layer=None, const=False, multiplier=[1.0])[source]
store data “data” at layer “layer” internally
- store_external(file_path, layer=None, multiplier=[1.0], print_format=None,
data=None, do_not_verify=False) store data “data” at layer “layer” externally in file “file_path”
- external_to_external(new_external_file, multiplier=None, layer=None)[source]
copies existing external data to the new file location and points to the new file
- external_to_internal(layer_num=None, store_internal=False) :
- ndarray/recarray
loads existing external data for layer “layer_num” and returns it. if store_internal is True it also storages the data internally, changing the storage type for “layer_num” layer to internal.
- internal_to_external(new_external_file, multiplier=None, layer=None,
print_format=None)
stores existing internal data for layer “layer” to external file “new_external_file”
- read_data_from_file(layer, fd=None, multiplier=None) : (ndarray, int)
reads in data from a given file “fd” as data from layer “layer”. returns data as an ndarray along with the size of the data
- to_string(val, type, is_cellid=False, possible_cellid=False)
converts data “val” of type “type” to a string. is_cellid is True if the data type is known to be a cellid and is treated as such. when possible_cellid is True the data is checked to see if it matches the shape/dimensions of a cellid before using it as one.
- resolve_data_size(index) : int
resolves the size of a given data element in a recarray based on the names in the existing rec_array. assumes repeating data element names follow the format <data_element_name>_X. returns the number of times the data element repeats.
Notes
Examples
- build_type_list(data_set=None, data=None, resolve_data_shape=True, key=None, nseg=None, cellid_expanded=False, min_size=False, overwrite_existing_type_list=True)[source]
- internal_to_external(new_external_file, multiplier=None, layer=None, print_format=None, binary=False)[source]
- set_data(data, layer=None, multiplier=None, key=None, autofill=False, check_data=False, preserve_record=False)[source]
- store_external(file_path, layer=None, multiplier=None, print_format=None, data=None, do_not_verify=False, binary=False, preserve_record=False)[source]
- class DataStorageType(value)[source]
Bases:
Enum
Enumeration of different ways that data can be stored
- external_file = 3
- internal_array = 1
- internal_constant = 2
- class DataStructureType(value)[source]
Bases:
Enum
Enumeration of different data structures used to store data
- ndarray = 1
- recarray = 2
- scalar = 3
- class LayerStorage(data_storage, lay_indexes, data_storage_type=DataStorageType.internal_array, data_type=None)[source]
Bases:
object
Stores a single layer of data.
- Parameters:
data_storage (DataStorage) – Parent data storage object that layer is contained in
lay_num (int) – Layer number of layered being stored
data_storage_type (DataStorageType) – Method used to store the data
- internal_data
data being stored, if full data is being stored internally in memory
- Type:
ndarray or recarray
- data_const_value
constant value of data being stored, if data is a constant
- Type:
int/float
- data_storage_type
method used to store the data
- Type:
- factor
factor to multiply the data by
- Type:
int/float
- get_const_val(layer)
gets the constant value of a given layer. data storage type for layer must be “internal_constant”.
- get_data(layer) : ndarray/recarray/string
returns the data for the specified layer
- set_data(data, layer=None, multiplier=[1.0]
sets the data being stored to “data” for layer “layer”, replacing all data for that layer. a multiplier can be specified.
Notes
Examples
- property name