Describe the bug
A clear and concise description of what the bug is.
File ~/miniconda3/envs/gmdsitut/lib/python3.11/site-packages/flopy/mt3d/mtuzt.py:346, in Mt3dUzt.write_file(self)
343 f_uzt = open(f_uzt.name, "a")
345 # Concentrations associated with distributed stresses (Infil, ET)
--> 346 if self.cuzinf is not None:
347 # If any species needs to be written, then all need to be
348 # written
349 incuzinf = -1
350 for t2d in self.cuzinf:
AttributeError: 'Mt3dUzt' object has no attribute 'cuzinf'
Expected behavior
A clear and concise description of what you expected to happen.
I don't know the coding but chatGPT told me:
Looking at the source (FloPy 3.9.3 mtuzt.py
):
if incuzinf > 0:
self.cuzinf = self.assignarray(
(nrow, ncol), "cuzinf", cuzinfrch, 0.0
)
So:
self.cuzinf is only defined if incuzinf > 0.
If you call Mt3dUzt with incuzinf=0 (the default when recharge is clean), then self.cuzinf never exists.
Later code (like repr or .write_file) may still try to reference self.cuzinf, which throws:
AttributeError: 'Mt3dUzt' object has no attribute 'cuzinf'
π§ How to fix
Option 1 β Patch locally in your notebook
Right after you instantiate Mt3dUzt, add:
if not hasattr(uzt, "cuzinf"):
uzt.cuzinf = None
This prevents downstream errors when FloPy checks for the attribute.
Option 2 β Modify the FloPy source
Edit your installed FloPy file:
flopy/mt3d/mtuzt.py
Find the init method of Mt3dUzt and add a fallback:
always create attribute
self.cuzinf = None
if incuzinf > 0:
self.cuzinf = self.assignarray(
(nrow, ncol), "cuzinf", cuzinfrch, 0.0
)
This way self.cuzinf always exists, but is None if unused.
Desktop (please complete the following information):
- OS: [e.g. iOS] WSL2 under windows
- Browser [e.g. chrome, safari] jupyter notebook
Describe the bug
A clear and concise description of what the bug is.
File ~/miniconda3/envs/gmdsitut/lib/python3.11/site-packages/flopy/mt3d/mtuzt.py:346, in Mt3dUzt.write_file(self)
343 f_uzt = open(f_uzt.name, "a")
345 # Concentrations associated with distributed stresses (Infil, ET)
--> 346 if self.cuzinf is not None:
347 # If any species needs to be written, then all need to be
348 # written
349 incuzinf = -1
350 for t2d in self.cuzinf:
AttributeError: 'Mt3dUzt' object has no attribute 'cuzinf'
Expected behavior
A clear and concise description of what you expected to happen.
I don't know the coding but chatGPT told me:
Looking at the source (FloPy 3.9.3 mtuzt.py
):
if incuzinf > 0:
self.cuzinf = self.assignarray(
(nrow, ncol), "cuzinf", cuzinfrch, 0.0
)
So:
self.cuzinf is only defined if incuzinf > 0.
If you call Mt3dUzt with incuzinf=0 (the default when recharge is clean), then self.cuzinf never exists.
Later code (like repr or .write_file) may still try to reference self.cuzinf, which throws:
AttributeError: 'Mt3dUzt' object has no attribute 'cuzinf'
π§ How to fix
Option 1 β Patch locally in your notebook
Right after you instantiate Mt3dUzt, add:
if not hasattr(uzt, "cuzinf"):
uzt.cuzinf = None
This prevents downstream errors when FloPy checks for the attribute.
Option 2 β Modify the FloPy source
Edit your installed FloPy file:
flopy/mt3d/mtuzt.py
Find the init method of Mt3dUzt and add a fallback:
always create attribute
self.cuzinf = None
if incuzinf > 0:
self.cuzinf = self.assignarray(
(nrow, ncol), "cuzinf", cuzinfrch, 0.0
)
This way self.cuzinf always exists, but is None if unused.
Desktop (please complete the following information):