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: Error when loading an mf6 model with time series package #1867

Closed
OnnoEbbens opened this issue Jul 7, 2023 · 2 comments
Closed

bug: Error when loading an mf6 model with time series package #1867

OnnoEbbens opened this issue Jul 7, 2023 · 2 comments
Assignees
Labels

Comments

@OnnoEbbens
Copy link
Contributor

Describe the bug
When I try to read a model using flopy.mf6.MFSimulation.load I get a MFDataException error when it tries to read the time series data.

To Reproduce
Run this notebook with the code below at the end:

sim.write_simulation()
sim2 = flopy.mf6.MFSimulation.load("mfsim.nam", sim_ws=workspace, exe_name="mf6")

Full error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mfdatautil.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mfdatautil.py) in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     80                     data = data.replace("d", "e")
---> 81                 return float(data)
     82             except (ValueError, TypeError):

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

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mfdatautil.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mfdatautil.py) in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     83                 try:
---> 84                     return float(PyListUtil.clean_numeric(data))
     85                 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)
[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mffileaccess.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mffileaccess.py) in read_list_data_from_file(self, file_handle, storage, current_key, current_line, data_line, store_internal)
   1223         try:
-> 1224             data_line = self.load_list_line(
   1225                 storage,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mffileaccess.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mffileaccess.py) in 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)
   1911                                         unknown_repeats,
-> 1912                                     ) = self._append_data_list(
   1913                                         storage,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mffileaccess.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mffileaccess.py) in _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)
   2222                 else:
-> 2223                     data_converted = convert_data(
   2224                         arr_line[data_index],

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mfdatautil.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mfdatautil.py) in convert_data(data, data_dimensions, data_type, data_item, sub_amt)
     91                     type_, value_, traceback_ = sys.exc_info()
---> 92                     raise MFDataException(
     93                         data_dimensions.structure.get_model(),

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

During handling of the above exception, another exception occurred:

MFDataException                           Traceback (most recent call last)
[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfpackage.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfpackage.py) in load(self, block_header, fd, strict)
    885                         )
--> 886                     next_line = dataset.load(
    887                         line,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mfdatalist.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mfdatalist.py) in load(self, first_line, file_handle, block_header, pre_data_comments, external_file_info)
   2026         self._load_prep(block_header)
-> 2027         return super().load(
   2028             first_line,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mfdatalist.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mfdatalist.py) in load(self, first_line, file_handle, block_header, pre_data_comments, external_file_info)
   1398             )
-> 1399             result = file_access.load_from_package(
   1400                 first_line, file_handle, storage, pre_data_comments

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mffileaccess.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mffileaccess.py) in load_from_package(self, first_line, file_handle, storage, pre_data_comments)
   1152                 self._data_line,
-> 1153             ) = self.read_list_data_from_file(
   1154                 file_handle,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\data\mffileaccess.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/data/mffileaccess.py) in read_list_data_from_file(self, file_handle, storage, current_key, current_line, data_line, store_internal)
   1283                 type_, value_, traceback_ = sys.exc_info()
-> 1284                 raise MFDataException(
   1285                     struct.get_model(),

MFDataException: An error occurred in data element "stress_period_data" model "gwf6" package "ghb". 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 "tiees" can not be converted to float.
(2) Unable to process line 1 of data list: "  2 1 10  tides      15.00000000  Estuary-L2
"

During handling of the above exception, another exception occurred:

MFDataException                           Traceback (most recent call last)
[~\AppData\Local\Temp\ipykernel_15480\896463903.py](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/oebbe/02_python/flopy/~/AppData/Local/Temp/ipykernel_15480/896463903.py) in ()
      1 sim.write_simulation()
----> 2 sim2 = flopy.mf6.MFSimulation.load("mfsim.nam", sim_ws=workspace, exe_name="mf6")

[c:\Users\oebbe\02_python\flopy\flopy\mf6\modflow\mfsimulation.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/modflow/mfsimulation.py) in load(cls, sim_name, version, exe_name, sim_ws, strict, verbosity_level, load_only, verify_data, write_headers, lazy_io)
    782             if verbosity_level.value >= VerbosityLevel.normal.value:
    783                 print(f"  loading model {item[0].lower()}...")
--> 784             instance._models[item[2]] = model_obj.load(
    785                 instance,
    786                 instance.structure.model_struct_objs[item[0].lower()],

[c:\Users\oebbe\02_python\flopy\flopy\mf6\modflow\mfgwf.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/modflow/mfgwf.py) in load(cls, simulation, structure, modelname, model_nam_file, version, exe_name, strict, model_rel_path, load_only)
    125         load_only=None,
    126     ):
--> 127         return mfmodel.MFModel.load_base(
    128             simulation,
    129             structure,

[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfmodel.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfmodel.py) in load_base(cls, simulation, structure, modelname, model_nam_file, mtype, version, exe_name, strict, model_rel_path, load_only)
    799                     print(f"    loading package {ftype}...")
    800                 # load package
--> 801                 instance.load_package(ftype, fname, pname, strict, None)
    802                 sim_data = simulation.simulation_data
    803                 if ftype == "dis" and not sim_data.max_columns_user_set:

[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfmodel.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfmodel.py) in load_package(self, ftype, fname, pname, strict, ref_path, dict_package_name, parent_package)
   1864         )
   1865         try:
-> 1866             package.load(strict)
   1867         except ReadAsArraysException:
   1868             #  create ReadAsArrays package and load it instead

[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfpackage.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfpackage.py) in load(self, strict)
   2670 
   2671         try:
-> 2672             self._load_blocks(fd_input_file, strict)
   2673         except ReadAsArraysException as err:
   2674             fd_input_file.close()

[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfpackage.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfpackage.py) in _load_blocks(self, fd_input_file, strict, max_blocks)
   2847                         )
   2848 
-> 2849                         cur_block.load(
   2850                             block_header_info, fd_input_file, strict
   2851                         )

[c:\Users\oebbe\02_python\flopy\flopy\mf6\mfpackage.py](file:///C:/Users/oebbe/02_python/flopy/flopy/mf6/mfpackage.py) in load(self, block_header, fd, strict)
    892                     )
    893                 except MFDataException as mfde:
--> 894                     raise MFDataException(
    895                         mfdata_except=mfde,
    896                         model=self._container_package.model_name,

MFDataException: An error occurred in data element "stress_period_data" model "tutorial03_mf6_data" package "ghb". 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 "tiees" can not be converted to float.
(2) Unable to process line 1 of data list: "  2 1 10  tides      15.00000000  Estuary-L2
"
(3) Error occurred while loading data "stress_period_data" in block "period" from file "C:\Users\oebbe\AppData\Local\Temp\tmpoziwbxlz\tutorial03_mf6_data.ghb".

Desktop (please complete the following information):

  • OS: Windows
  • Flopy version 3.4.1 & 3.3.6
@OnnoEbbens OnnoEbbens added the bug label Jul 7, 2023
spaulins-usgs added a commit that referenced this issue Jul 20, 2023
…kage (#1867) (#1873)

Co-authored-by: scottrp <45947939+scottrp@users.noreply.github.com>
@spaulins-usgs
Copy link
Contributor

@OnnoEbbens, I just committed a PR to the develop branch that should fix this problem. Please use the develop branch of flopy and confirm that this fixes the issue.

@OnnoEbbens
Copy link
Contributor Author

Thanks a lot!

wpbonelli pushed a commit that referenced this issue Aug 25, 2023
…kage (#1867) (#1873)

Co-authored-by: scottrp <45947939+scottrp@users.noreply.github.com>
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