From c25423da6b5a91350353cbc9d4e3c26f5d7f03ac Mon Sep 17 00:00:00 2001 From: David A Minton Date: Tue, 6 Dec 2022 13:42:12 -0500 Subject: [PATCH] Fixed some of the typing issues with encounter data --- python/swiftest/swiftest/io.py | 2 +- python/swiftest/swiftest/simulation_class.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 6621f8c19..f4be8a56a 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -823,7 +823,7 @@ def process_netcdf_input(ds, param): ds = fix_types(ds,ftype=np.float32) ds = ds.where(ds.id >=0 ,drop=True) # Check if the name variable contains unique values. If so, make name the dimension instead of id - if len(np.unique(ds['name'])) == len(ds['name']): + if "name" not in ds.dims and len(np.unique(ds['name'])) == len(ds['name']): ds = ds.swap_dims({"id" : "name"}) ds = ds.reset_coords("id") diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 25b83a0f3..16629f08c 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -2771,6 +2771,7 @@ def _preprocess(ds, param): partial_func = partial(_preprocess, param=self.param) self.enc = xr.open_mfdataset(enc_files,parallel=True,combine="nested", concat_dim="encounter",preprocess=partial_func) + self.enc = io.process_netcdf_input(self.enc, self.param) return