From 0215fb8bc7b987fd0c51b889cdf5f47b3b39fc5d Mon Sep 17 00:00:00 2001 From: "Leaf, Andrew T" Date: Tue, 27 Aug 2024 15:47:25 -0500 Subject: [PATCH] fix(MF6model.write_input): handle case of single obs package --- mfsetup/mf6model.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mfsetup/mf6model.py b/mfsetup/mf6model.py index 8fc9da71..c54079ba 100644 --- a/mfsetup/mf6model.py +++ b/mfsetup/mf6model.py @@ -243,7 +243,6 @@ def _set_idomain(self): # re-write the input files # todo: integrate this better with setup_dis # to reduce the number of times the arrays need to be remade - self._setup_array('dis', 'botm', data={i: arr for i, arr in enumerate(botm)}, datatype='array3d', resample_method='linear', @@ -981,7 +980,14 @@ def write_input(self): remove_inactive_bcs(package_instance, external_files=external_files) if hasattr(model, 'obs'): - for obs_package_instance in model.obs: + # handle case of single obs package, in which case model.obs + # will be a ModflowUtlobs package instance + try: + len(model.obs) + obs_packages = model.obs + except: + obs_packages = [model.obs] + for obs_package_instance in obs_packages: remove_inactive_obs(obs_package_instance) # write the model with flopy