diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index f03fb622f..a4f370773 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -817,11 +817,12 @@ def process_netcdf_input(ds, param): ds : xarray dataset """ + ds = ds.where(~np.isnan(ds.id) ,drop=True) if param['OUT_TYPE'] == "NETCDF_DOUBLE": ds = fix_types(ds,ftype=np.float64) elif param['OUT_TYPE'] == "NETCDF_FLOAT": 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 "id" in ds.dims: if len(np.unique(ds['name'])) == len(ds['name']): diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 4ac07386c..9e18a8ff8 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -323,12 +323,14 @@ def __init__(self,read_param: bool = False, read_old_output_file: bool = False, self.simdir = Path(simdir) if self.simdir.exists(): if not self.simdir.is_dir(): - msg = f"Cannot create the {self.simdir} directory: File exists." + msg = f"Cannot create the {self.simdir.resolve()} directory: File exists." msg += "\nDelete the file or change the location of param_file" - warnings.warn(msg,stacklevel=2) + raise NotADirectoryError(msg) else: - self.simdir.mkdir(parents=True, exist_ok=False) - + if read_old_output_file or read_param: + raise NotADirectoryError(f"Cannot find directory {self.simdir.resolve()} ") + else: + self.simdir.mkdir(parents=True, exist_ok=False) # Set the location of the parameter input file, choosing the default if it isn't specified. param_file = kwargs.pop("param_file",Path.cwd() / self.simdir / "param.in") @@ -376,7 +378,7 @@ def __init__(self,read_param: bool = False, read_old_output_file: bool = False, if os.path.exists(binpath): self.read_output_file() else: - warnings.warn(f"BIN_OUT file {binpath} not found.",stacklevel=2) + raise FileNotFoundError(f"BIN_OUT file {binpath} not found.") return def _run_swiftest_driver(self): @@ -2770,7 +2772,7 @@ def _preprocess(ds, param): return io.process_netcdf_input(ds,param) partial_func = partial(_preprocess, param=self.param) - self.enc = xr.open_mfdataset(enc_files,parallel=True,preprocess=partial_func,mask_and_scale=True) + self.enc = xr.open_mfdataset(enc_files,parallel=True,combine="nested",concat_dim="time",join="left",preprocess=partial_func,mask_and_scale=True) self.enc = io.process_netcdf_input(self.enc, self.param) return