From 642c64622889ce90342a97a7d0c41408e739b98a Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sun, 1 Jan 2023 16:02:51 -0500 Subject: [PATCH] Fixed Python driver bugs --- python/swiftest/swiftest/simulation_class.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index e4fa80049..612aeb4b0 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -328,8 +328,6 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi else: if read_old_output 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") @@ -1279,9 +1277,8 @@ def get_feature(self, arg_list: str | List[str] | None = None, verbose: bool | N key = valid_var[arg] if key in feature_dict: if arg == "minimum_fragment_gmass": - if self.param['FRAGMENTATION']: - print(f"{arg:<{self._getter_column_width}} {feature_dict[key]} {self.DU_name}^3 / {self.TU_name}^2 ") - print(f"{'minimum_fragment_mass':<{self._getter_column_width}} {feature_dict[key] / self.GU} {self.MU_name}") + print(f"{arg:<{self._getter_column_width}} {feature_dict[key]} {self.DU_name}^3 / {self.TU_name}^2 ") + print(f"{'minimum_fragment_mass':<{self._getter_column_width}} {feature_dict[key] / self.GU} {self.MU_name}") else: print(f"{arg:<{self._getter_column_width}} {feature_dict[key]}") else: @@ -2174,7 +2171,6 @@ def add_solar_system_body(self, return - def set_ephemeris_date(self, ephemeris_date: str | None = None, verbose: bool | None = None, @@ -2638,7 +2634,8 @@ def write_param(self, if verbose: print(f"Writing parameter inputs to file {param_file}") param['! VERSION'] = f"{codename} input file" - + + self.simdir.mkdir(parents=True, exist_ok=True) # Check to see if the parameter type matches the output type. If not, we need to convert if codename == "Swifter" or codename == "Swiftest": if param['IN_TYPE'] == "ASCII": @@ -2781,7 +2778,6 @@ def _preprocess(ds, param): return - def read_collisions(self): col_files = glob(f"{self.simdir}{os.path.sep}collision_*.nc") if len(col_files) == 0: @@ -2801,7 +2797,6 @@ def _preprocess(ds, param): return - def follow(self, codestyle="Swifter"): """ An implementation of the Swift tool_follow algorithm. Under development. Currently only for Swift simulations. @@ -2871,8 +2866,8 @@ def save(self, if "verbose" in kwargs: verbose = kwargs['verbose'] else: - verbose = self%verbose - + verbose = self.verbose + if codename is None: codename = self.codename if param_file is None: @@ -2880,6 +2875,7 @@ def save(self, if param is None: param = self.param + self.simdir.mkdir(parents=True, exist_ok=True) if codename == "Swiftest": infile_name = Path(self.simdir) / param['NC_IN'] io.swiftest_xr2infile(ds=self.data, param=param, in_type=self.param['IN_TYPE'], infile_name=infile_name, framenum=framenum, verbose=verbose)