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

bug: Flopy does not load an MF6 EVT package with a Boundary Name #2353

Open
javgs-bd opened this issue Nov 2, 2024 · 0 comments
Open

bug: Flopy does not load an MF6 EVT package with a Boundary Name #2353

javgs-bd opened this issue Nov 2, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@javgs-bd
Copy link

javgs-bd commented Nov 2, 2024

Describe the bug
When trying to load a model with a package that has an EVT boundary name on it, Flopy throws an error

To Reproduce

  1. Place the model in the temp.zip file attached on a sim_ws folder. That path should be stored in the model_path variable (MF6 exe is located in a subfolder of the cwd called 'bin').

temp.zip

  1. Run:
bin_folder   = cwd / 'bin'
model_name    = 'model'
exe_name     = bin_folder / 'mf6.exe'

sim = flopy.mf6.MFSimulation.load( 
                                    sim_name = model_name,
                                    version = 'mf6', 
                                    exe_name = exe_name,
                                    sim_ws = model_path,
                                )
gwf = sim.get_model()
  1. See complete errorlog below

Expected behavior
Load without error

Desktop (please complete the following information):

  • OS: Widows11
    3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
    numpy version: 1.25.1
    matplotlib version: 3.7.2
    flopy version: 3.8.2
    shapefile version: 2.3.1

Additional context

First I thought the problem first was the dot "." in the package filename (model.dwstr.evt) and then the dot in the boundary name. However, I've changed both of these to standard names (for instance to model.evt and revt). Flopy always throws the same error starting with the following. As if it were expecting a different length or structure for the first line in the stress period data section.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatautil.py:82, in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     81         data = data.replace("D", "e")
---> 82     return float(data)
     83 except (ValueError, TypeError):

ValueError: could not convert string to float: 'revt'

Whole error log in the original case:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatautil.py:82, in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     81         data = data.replace("D", "e")
---> 82     return float(data)
     83 except (ValueError, TypeError):

ValueError: could not convert string to float: 'ewstr.evt'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatautil.py:85, in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     84 try:
---> 85     return float(PyListUtil.clean_numeric(data))
     86 except (ValueError, TypeError):

ValueError: could not convert string to float: '.'

During handling of the above exception, another exception occurred:

MFDataException                           Traceback (most recent call last)
File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mffileaccess.py:1282, in MFFileAccessList.read_list_data_from_file(self, file_handle, storage, current_key, current_line, data_line, store_internal)
   1281 try:
-> 1282     data_line = self.load_list_line(
   1283         storage,
   1284         arr_line,
   1285         line_num,
   1286         data_loaded,
   1287         True,
   1288         current_key=current_key,
   1289         data_line=data_line,
   1290     )[1:]
   1291     line_num += 1

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mffileaccess.py:1966, in MFFileAccessList.load_list_line(self, storage, arr_line, line_num, data_loaded, build_type_list, current_key, data_index_start, data_set, ignore_optional_vars, data_line, zero_based)
   1960         data_item.type = di_type
   1961     (
   1962         data_index,
   1963         more_data_expected,
   1964         data_line,
   1965         unknown_repeats,
-> 1966     ) = self._append_data_list(
   1967         storage,
   1968         data_item,
   1969         arr_line,
   1970         arr_line_len,
   1971         data_index,
   1972         var_index,
   1973         repeat_count,
   1974         current_key,
   1975         data_line,
   1976         zero_based=zero_based,
   1977     )
   1978 if more_data_expected is None:
   1979     # indeterminate amount of data expected.
   1980     # keep reading data until eoln

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mffileaccess.py:2281, in MFFileAccessList._append_data_list(self, storage, data_item, arr_line, arr_line_len, data_index, var_index, repeat_count, current_key, data_line, add_to_last_line, zero_based)
   2280 else:
-> 2281     data_converted = convert_data(
   2282         arr_line[data_index],
   2283         self._data_dimensions,
   2284         data_item.type,
   2285         data_item,
   2286         sub_amt=sub_amt,
   2287     )
   2288     if (
   2289         data_item.indicates_file_name()
   2290         or data_item.file_nam_in_nam_file()
   2291     ):

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatautil.py:93, in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     92                 type_, value_, traceback_ = sys.exc_info()
---> 93                 raise MFDataException(
     94                     data_dimensions.structure.get_model(),
     95                     data_dimensions.structure.get_package(),
     96                     data_dimensions.structure.path,
     97                     "converting data",
     98                     data_dimensions.structure.name,
     99                     inspect.stack()[0][3],
    100                     type_,
    101                     value_,
    102                     traceback_,
    103                     message,
    104                     False,
    105                 )
    106 elif data_type == DatumType.integer:

MFDataException: An error occurred in data element "stress_period_data" model "gwf6" package "evt". The error occurred while converting data in the "convert_data" method.
Additional Information:
(1) Data "stress_period_data" with value "ewstr.evt" can not be converted to float.

During handling of the above exception, another exception occurred:

MFDataException                           Traceback (most recent call last)
File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfpackage.py:921, in MFBlock.load(self, block_header, fd, strict)
    918         print(
    919             f"        loading data {dataset.structure.name}..."
    920         )
--> 921     next_line = dataset.load(
    922         line,
    923         fd_block,
    924         self.block_headers[-1],
    925         initial_comment,
    926         external_file_info,
    927     )
    928 except MFDataException as mfde:

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatalist.py:2008, in MFTransientList.load(self, first_line, file_handle, block_header, pre_data_comments, external_file_info)
   2007 self._load_prep(block_header)
-> 2008 return super().load(
   2009     first_line,
   2010     file_handle,
   2011     block_header,
   2012     pre_data_comments,
   2013     external_file_info,
   2014 )

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mfdatalist.py:1378, in MFList.load(self, first_line, file_handle, block_header, pre_data_comments, external_file_info)
   1371     file_access = MFFileAccessList(
   1372         self.structure,
   1373         self.data_dimensions,
   (...)
   1376         self._current_key,
   1377     )
-> 1378     result = file_access.load_from_package(
   1379         first_line, file_handle, storage, pre_data_comments
   1380     )
   1381 return result

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mffileaccess.py:1211, in MFFileAccessList.load_from_package(self, first_line, file_handle, storage, pre_data_comments)
   1206 else:
   1207     (
   1208         have_newrec_line,
   1209         newrec_line,
   1210         self._data_line,
-> 1211     ) = self.read_list_data_from_file(
   1212         file_handle,
   1213         storage,
   1214         self._current_key,
   1215         current_line,
   1216         self._data_line,
   1217     )
   1218     return [have_newrec_line, newrec_line]

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\data\mffileaccess.py:1342, in MFFileAccessList.read_list_data_from_file(self, file_handle, storage, current_key, current_line, data_line, store_internal)
   1341         type_, value_, traceback_ = sys.exc_info()
-> 1342         raise MFDataException(
   1343             struct.get_model(),
   1344             struct.get_package(),
   1345             struct.path,
   1346             "loading data list from package file",
   1347             struct.name,
   1348             inspect.stack()[0][3],
   1349             type_,
   1350             value_,
   1351             traceback_,
   1352             comment,
   1353             self._simulation_data.debug,
   1354             err,
   1355         )
   1357 if struct.type == DatumType.record or struct.type == DatumType.string:
   1358     # records only contain a single line

MFDataException: An error occurred in data element "stress_period_data" model "gwf6" package "evt". The error occurred while loading data list from package file in the "read_list_data_from_file" method.
Additional Information:
(1) Data "stress_period_data" with value "ewstr.evt" can not be converted to float.
(2) Unable to process line 1 of data list: "  1 80 1       2.00000000       0.00500000       1.50000000       1.00000000  dwstr.evt
"

During handling of the above exception, another exception occurred:

MFDataException                           Traceback (most recent call last)
Cell In[6], line 19
     11 exe_name     = bin_folder / 'mf6.exe'
     13 #--- Simulation     ------------
     14 
     15 #--- name of the simulation.
     16 #--- relative path to MODFLOW exe file from the simulation working folder.
     17 #--- path to working folder.
---> 19 sim = flopy.mf6.MFSimulation.load( 
     20                                     sim_name = model_name,
     21                                     version = 'mf6', 
     22                                     exe_name = exe_name,
     23                                     sim_ws = model_path,
     24                                 )
     25 gwf = sim.get_model()

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\modflow\mfsimulation.py:144, in MFSimulation.load(cls, sim_name, version, exe_name, sim_ws, strict, verbosity_level, load_only, verify_data, write_headers, lazy_io, use_pandas)
    129 @classmethod
    130 def load(
    131     cls,
   (...)
    142     use_pandas=True,
    143 ):
--> 144     return mfsimbase.MFSimulationBase.load(
    145         cls,
    146         sim_name,
    147         version,
    148         exe_name,
    149         sim_ws,
    150         strict,
    151         verbosity_level,
    152         load_only,
    153         verify_data,
    154         write_headers,
    155         lazy_io,
    156         use_pandas,
    157     )

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfsimbase.py:829, in MFSimulationBase.load(cls_child, sim_name, version, exe_name, sim_ws, strict, verbosity_level, load_only, verify_data, write_headers, lazy_io, use_pandas)
    827     if verbosity_level.value >= VerbosityLevel.normal.value:
    828         print(f"  loading model {item[0].lower()}...")
--> 829     instance._models[item[2]] = model_obj.load(
    830         instance,
    831         instance.structure.model_struct_objs[item[0].lower()],
    832         item[2],
    833         name_file,
    834         version,
    835         exe_name,
    836         strict,
    837         path,
    838         load_only,
    839     )
    841 # load exchange packages and dependent packages
    842 try:

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\modflow\mfgwf.py:131, in ModflowGwf.load(cls, simulation, structure, modelname, model_nam_file, version, exe_name, strict, model_rel_path, load_only)
    118 @classmethod
    119 def load(
    120     cls,
   (...)
    129     load_only=None,
    130 ):
--> 131     return mfmodel.MFModel.load_base(
    132         cls,
    133         simulation,
    134         structure,
    135         modelname,
    136         model_nam_file,
    137         "gwf6",
    138         version,
    139         exe_name,
    140         strict,
    141         model_rel_path,
    142         load_only,
    143     )

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfmodel.py:906, in MFModel.load_base(cls_child, simulation, structure, modelname, model_nam_file, mtype, version, exe_name, strict, model_rel_path, load_only)
    904     print(f"    loading package {ftype}...")
    905 # load package
--> 906 instance.load_package(ftype, fname, pname, strict, None)
    907 sim_data = simulation.simulation_data
    908 if ftype == "dis" and not sim_data.max_columns_user_set:
    909     # set column wrap to ncol

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfmodel.py:2002, in MFModel.load_package(self, ftype, fname, pname, strict, ref_path, dict_package_name, parent_package)
   1993 package = package_obj(
   1994     self,
   1995     filename=fname,
   (...)
   1999     _internal_package=True,
   2000 )
   2001 try:
-> 2002     package.load(strict)
   2003 except ReadAsArraysException:
   2004     #  create ReadAsArrays package and load it instead
   2005     package_obj = self.package_factory(f"{ftype}a", model_type)

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfpackage.py:2803, in MFPackage.load(self, strict)
   2788         raise MFDataException(
   2789             self.model_name,
   2790             self.package_name,
   (...)
   2799             self._simulation_data.debug,
   2800         )
   2802 try:
-> 2803     self._load_blocks(fd_input_file, strict)
   2804 except ReadAsArraysException as err:
   2805     fd_input_file.close()

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfpackage.py:2980, in MFPackage._load_blocks(self, fd_input_file, strict, max_blocks)
   2975 # reset comments
   2976 self.post_block_comments = MFComment(
   2977     "", self.path, self._simulation_data
   2978 )
-> 2980 cur_block.load(
   2981     block_header_info, fd_input_file, strict
   2982 )
   2984 # write post block comment
   2985 self._simulation_data.mfdata[
   2986     cur_block.block_headers[-1].blk_post_comment_path
   2987 ] = self.post_block_comments

File ~\pyenvs\flopy\lib\site-packages\flopy\mf6\mfpackage.py:929, in MFBlock.load(self, block_header, fd, strict)
    921     next_line = dataset.load(
    922         line,
    923         fd_block,
   (...)
    926         external_file_info,
    927     )
    928 except MFDataException as mfde:
--> 929     raise MFDataException(
    930         mfdata_except=mfde,
    931         model=self._container_package.model_name,
    932         package=self._container_package._get_pname(),
    933         message='Error occurred while loading data "{}" in '
    934         'block "{}" from file "{}"'
    935         ".".format(
    936             dataset.structure.name,
    937             self.structure.name,
    938             fd_block.name,
    939         ),
    940     )
    941 package_info_list = self._get_package_info(dataset)
    942 if package_info_list is not None:

MFDataException: An error occurred in data element "stress_period_data" model "model" package "dwstr.evt". The error occurred while loading data list from package file in the "read_list_data_from_file" method.
Additional Information:
(1) Data "stress_period_data" with value "ewstr.evt" can not be converted to float.
(2) Unable to process line 1 of data list: "  1 80 1       2.00000000       0.00500000       1.50000000       1.00000000  dwstr.evt
"
(3) Error occurred while loading data "stress_period_data" in block "period" from file "C:\Users\JavierGonzalez\xxxxxxx\temp\model.dwstr.evt".
@javgs-bd javgs-bd added the bug label Nov 2, 2024
@wpbonelli wpbonelli self-assigned this Nov 5, 2024
@wpbonelli wpbonelli added this to the 3.9.1 milestone Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants