From b9d236eb58146ad9f1c78d6127a8bddde37852cb Mon Sep 17 00:00:00 2001 From: Joseph Hughes Date: Sun, 12 Nov 2023 15:29:14 -0600 Subject: [PATCH] fix(model_splitter): check keys in mftransient array --- flopy/mf6/utils/model_splitter.py | 34 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/flopy/mf6/utils/model_splitter.py b/flopy/mf6/utils/model_splitter.py index 2cdd455d23..82a6d58a68 100644 --- a/flopy/mf6/utils/model_splitter.py +++ b/flopy/mf6/utils/model_splitter.py @@ -1076,20 +1076,30 @@ def _remap_transient_array(self, item, mftransient, mapped_data): d0 = {mkey: {} for mkey in self._model_dict.keys()} for per, array in enumerate(mftransient.array): - storage = mftransient._data_storage[per] - how = [ - i.data_storage_type.value - for i in storage.layer_storage.multi_dim_list - ] - binary = [i.binary for i in storage.layer_storage.multi_dim_list] - fnames = [i.fname for i in storage.layer_storage.multi_dim_list] + if per in mftransient._data_storage.keys(): + storage = mftransient._data_storage[per] + how = [ + i.data_storage_type.value + for i in storage.layer_storage.multi_dim_list + ] + binary = [ + i.binary for i in storage.layer_storage.multi_dim_list + ] + fnames = [ + i.fname for i in storage.layer_storage.multi_dim_list + ] - d = self._remap_array( - item, array, mapped_data, how=how, binary=binary, fnames=fnames - ) + d = self._remap_array( + item, + array, + mapped_data, + how=how, + binary=binary, + fnames=fnames, + ) - for mkey in d.keys(): - d0[mkey][per] = d[mkey][item] + for mkey in d.keys(): + d0[mkey][per] = d[mkey][item] for mkey, values in d0.items(): mapped_data[mkey][item] = values