You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by TIPJhonTellez March 23, 2022
thanks for reading. I am currently trying to load a MODFLOW6 simulation with the FloPy library and when migrating to version 3.3.5 I receive the following error "IndexError: list index out of range".
The next code run succesfully in FloPy version 3.3.4 like i write before makes and error the version 3.3.5
CODE:
#Importar librerias necesarias : OS y FloPy
import os
import sys
import flopy
from flopy.export import vtk
import numpy as np
print(sys.version)
print("flopy version: {}".format(flopy.__version__))
#Nombre del modelo
name = "2_Modelo2_grilla_k"
#Nombre del namefile
nam_file = "2_Modelo2_grilla_k.nam"
#Ruta de la ubicacion de la simulación
model_ws = os.getcwd()
#Ruta de los archivos a importar
model_output = os.path.join(model_ws, "VTKs")
#Ruta de MODFLOW
sim_path = "."
#Imprimimos los valores para verificar que sean correctos
print(model_ws, model_output, nam_file, name, sim_path)
#Carga la simulacion, en este caso los archivos de la simulacion generada por modflow o modelmuse
simulacion = flopy.mf6.MFSimulation.load(
sim_name=name, exe_name="mf6", sim_ws="."
)
#Carga del modelo
modelo = simulacion.get_model()
print("simulación cargada")
The next code is the ERROR:
3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] flopy version: 3.3.5
C:\Users\USUARIO\Downloads\Tutoriales Hidegatari\Modelmuse2\Modelmuse2
C:\Users\USUARIO\Downloads\Tutoriales Hidegatari\Modelmuse2\Modelmuse2\VTKs
2_Modelo2_grilla_k.nam
2_Modelo2_grilla_k
.
loading simulation...
loading simulation name file...
loading tdis package...
loading model gwf6...
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Input In [4], in <cell line: 23>()
20 print(model_ws, model_output, nam_file, name, sim_path)
22 #Carga la simulacion, en este caso los archivos de la simulacion generada por modflow o modelmuse
---> 23 simulacion = flopy.mf6.MFSimulation.load(
24 sim_name=name, exe_name="mf6", sim_ws="."
25 )
26 #simulacion = flopy.mf6.MFSimulation.load(sim_name=name, sim_ws=".")
27
28 #Carga del modelo
29 modelo = simulacion.get_model()
File ~\anaconda3\envs\Flopy335\lib\site-packages\flopy\mf6\modflow\mfsimulation.py:715, in MFSimulation.load(cls, sim_name, version, exe_name, sim_ws, strict, verbosity_level, load_only, verify_data, write_headers)
713 if verbosity_level.value >= VerbosityLevel.normal.value:
714 print(f" loading model {item[0].lower()}...")
--> 715 instance._models[item[2]] = model_obj.load(
716 instance,
717 instance.structure.model_struct_objs[item[0].lower()],
718 item[2],
719 name_file,
720 version,
721 exe_name,
722 strict,
723 path,
724 load_only,
725 )
727 # load exchange packages and dependent packages
728 try:
File ~\anaconda3\envs\Flopy335\lib\site-packages\flopy\mf6\modflow\mfgwf.py:127, in ModflowGwf.load(cls, simulation, structure, modelname, model_nam_file, version, exe_name, strict, model_rel_path, load_only)
114 @classmethod
115 def load(
116 cls,
(...)
125 load_only=None,
126 ):
--> 127 return mfmodel.MFModel.load_base(
128 simulation,
129 structure,
130 modelname,
131 model_nam_file,
132 "gwf",
133 version,
134 exe_name,
135 strict,
136 model_rel_path,
137 load_only,
138 )
File ~\anaconda3\envs\Flopy335\lib\site-packages\flopy\mf6\mfmodel.py:795, in MFModel.load_base(cls, simulation, structure, modelname, model_nam_file, mtype, version, exe_name, strict, model_rel_path, load_only)
792 if model_rel_path and model_rel_path != ".":
793 # strip off model relative path from the file path
794 filemgr = simulation.simulation_data.mfpath
--> 795 fname = filemgr.strip_model_relative_path(modelname, fname)
796 if (
797 simulation.simulation_data.verbosity_level.value
798 >= VerbosityLevel.normal.value
799 ):
800 print(f" loading package {ftype}...")
File ~\anaconda3\envs\Flopy335\lib\site-packages\flopy\mf6\mfbase.py:288, in MFFileMgmt.strip_model_relative_path(self, model_name, path)
286 new_path = ""
287 for i, mrp in enumerate(model_rel_path_lst):
--> 288 if mrp != path_lst[i]:
289 new_path = os.path.join(new_path, path_lst[i])
290 for rp in path_lst[len(model_rel_path_lst) :]:
IndexError: list index out of range
```</div>
The text was updated successfully, but these errors were encountered:
Discussed in #1383
Originally posted by TIPJhonTellez March 23, 2022
thanks for reading. I am currently trying to load a MODFLOW6 simulation with the FloPy library and when migrating to version 3.3.5 I receive the following error "IndexError: list index out of range".
The next code run succesfully in FloPy version 3.3.4 like i write before makes and error the version 3.3.5
CODE:
The next code is the ERROR:
The text was updated successfully, but these errors were encountered: