Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(time series slowness): time series data speed up #943

Merged
merged 1 commit into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion flopy/mf6/data/mfdataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ..data.mfstructure import DatumType
from .mfdatastorage import DataStorage, DataStructureType, DataStorageType
from ...utils.datautil import MultiList
from ..mfbase import ExtFileAction, MFDataException
from ..mfbase import ExtFileAction, MFDataException, VerbosityLevel
from ..utils.mfenums import DiscretizationType
from ...datbase import DataType
from .mffileaccess import MFFileAccessArray
Expand Down Expand Up @@ -435,6 +435,11 @@ def store_as_external_file(self, external_file_path, layer=None,
continue
try:
# store layer's data in external file
if self._simulation_data.verbosity_level.value >= \
VerbosityLevel.verbose.value:
print('Storing {} layer {} to external file {}..'
'.'.format(self.structure.name, current_layer[0]+1,
file_path))
factor = storage.layer_storage[current_layer].factor
external_data = {'filename': file_path,
'data': self._get_data(current_layer, True),
Expand Down
9 changes: 7 additions & 2 deletions flopy/mf6/data/mfdatalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from ..utils.mfenums import DiscretizationType
from ..data import mfstructure, mfdata
from ..mfbase import MFDataException, ExtFileAction
from ..mfbase import MFDataException, ExtFileAction, VerbosityLevel
from .mfstructure import DatumType
from ...utils import datautil
from ...datbase import DataListInterface, DataType
Expand Down Expand Up @@ -246,8 +246,13 @@ def store_as_external_file(self, external_file_path, binary=False,
data = self._get_data()
# if not empty dataset
if data is not None:
if self._simulation_data.verbosity_level.value >= \
VerbosityLevel.verbose.value:
print('Storing {} to external file {}..'
'.'.format(self.structure.name,
external_file_path))
external_data = {'filename': external_file_path,
'data': self._get_data(),
'data': data,
'binary': binary}
self._set_data(external_data)

Expand Down
5 changes: 5 additions & 0 deletions flopy/mf6/data/mfdatascalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ def get_file_entry(self, values_only=False, one_based=False,
if data_item.type == DatumType.keyword:
if current_data is not None and current_data != \
False:
if isinstance(data[index], str) and \
data[index] == '#':
# if data has been commented out,
# keep the comment
text_line.append(data[index])
text_line.append(data_item.name.upper())
else:
try:
Expand Down
2 changes: 2 additions & 0 deletions flopy/mf6/data/mffileaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ def load_from_package(self, first_line, file_handle, storage,
def read_list_data_from_file(self, file_handle, storage, current_key,
current_line=None, data_line=None,
store_internal=True):
self._data_dimensions.package_dim.locked = True
data_rec = None
data_loaded = []
self._temp_dict = {}
Expand Down Expand Up @@ -1072,6 +1073,7 @@ def read_list_data_from_file(self, file_handle, storage, current_key,
# store as rec array
storage.store_internal(data_loaded, None, False, current_key)
storage.data_dimensions.unlock()
self._data_dimensions.package_dim.locked = False
if not store_internal:
return data_rec
else:
Expand Down
4 changes: 3 additions & 1 deletion flopy/utils/datautil.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def split_data_line(line, external_file=False, delimiter_conf_length=15):
# apart the most
max_split_size = len(clean_line)
max_split_type = None
max_split_list = clean_line
for delimiter in PyListUtil.delimiter_list:
comment_split = line.strip().split('#')
alt_split = comment_split[0].strip().split(delimiter)
Expand All @@ -268,9 +269,10 @@ def split_data_line(line, external_file=False, delimiter_conf_length=15):
PyListUtil.delimiter_list[max_split_type]:
max_split_size = len(alt_split)
max_split_type = delimiter
max_split_list = alt_split

if max_split_type is not None:
clean_line = line.strip().split(max_split_type)
clean_line = max_split_list
if PyListUtil.line_num == 0:
PyListUtil.delimiter_used = max_split_type
elif PyListUtil.delimiter_used != max_split_type:
Expand Down