Modflow-flopy package

78 views
Skip to first unread message

amirhosein kohzadi

unread,
Sep 6, 2022, 4:14:15 AM9/6/22
to MODFLOW Users Group
Hi, I am using package flopy in python to run my cexisting model which I have changed the content of wel package file based on my results calculated with another optimization model but when it comes to running wel package in my code, I get this error.
Here is my simple code:

import flopy
import os
import sys
first = flopy.modflow.Modflow.load("step6.mfn", version='mf2k',exe_name="mf2k.exe", verbose =True , model_ws = "step6._ws" , load_only=None , forgive=False , check =False )
And here is the error:

ValueError Traceback (most recent call last) Input In [4], in <cell line: 4>() 2 import os 3 import sys ----> 4 first = flopy.modflow.Modflow.load("step6.mfn", version='mf2k',exe_name="mf2k.exe", verbose =True , model_ws = "step6._ws" , load_only=None , forgive=False , check =False ) File C:\Python27\anaconda\lib\site-packages\flopy\modflow\mf.py:883, in Modflow.load(cls, f, version, exe_name, verbose, model_ws, load_only, forgive, check) 881 else: 882 if "check" in package_load_args: --> 883 item.package.load( 884 item.filehandle, 885 ml, 886 ext_unit_dict=ext_unit_dict, 887 check=False, 888 ) 889 else: 890 item.package.load( 891 item.filehandle, 892 ml, 893 ext_unit_dict=ext_unit_dict, 894 ) File C:\Python27\anaconda\lib\site-packages\flopy\modflow\mfwel.py:396, in ModflowWel.load(cls, f, model, nper, ext_unit_dict, check) 393 if model.verbose: 394 print("loading wel package file...") --> 396 return Package.load( 397 f, 398 model, 399 cls, 400 nper=nper, 401 check=check, 402 ext_unit_dict=ext_unit_dict, 403 ) File C:\Python27\anaconda\lib\site-packages\flopy\pakbase.py:1069, in Package.load(f, model, pak_type, ext_unit_dict, **kwargs) 1065 elif itmp > 0: 1066 current = pak_type.get_empty( 1067 itmp, aux_names=aux_names, structured=model.structured 1068 ) -> 1069 current = ulstrd( 1070 f, itmp, current, model, sfac_columns, ext_unit_dict 1071 ) 1072 if model.structured: 1073 current["k"] -= 1 File C:\Python27\anaconda\lib\site-packages\flopy\utils\flopy_io.py:498, in ulstrd(f, nlist, ra, model, sfac_columns, ext_unit_dict) 496 t = t[:ncol] 497 t = tuple(t) --> 498 ra[ii] = t 499 else: 500 # fixed format 501 t = read_fixed_var(line, ncol=ncol) 
  ValueError: invalid literal for int() with base 10: '1.0'

Luther Brown

unread,
Sep 6, 2022, 11:40:10 AM9/6/22
to mod...@googlegroups.com
My guess is that it wants an int datatype rather than float (1.0). If that doesn't fix the problem, ask in the Flopy github discussion board. 

--
You received this message because you are subscribed to the Google Groups "MODFLOW Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modflow+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modflow/c557464c-4f2d-49b3-bf9e-646b351c401en%40googlegroups.com.

Jeremy White

unread,
Sep 6, 2022, 11:40:21 AM9/6/22
to MODFLOW Users Group
I think what you are seeing is that FloPy is expecting to find an integer (i.e '1') and instead its finding a float ('1.0') in the wel file - the layer, row, and column values need to be integers...
Reply all
Reply to author
Forward
0 new messages