From c4424c549607d25ae2d31030c355b3a6f4cb1598 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Mon, 21 Nov 2022 17:28:08 -0500 Subject: [PATCH] Changed it so that it no longer says it is saving to files when adding bodies --- python/swiftest/swiftest/io.py | 5 ++-- python/swiftest/swiftest/simulation_class.py | 25 +++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 672d762a3..3f5008bb9 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -1068,7 +1068,7 @@ def select_active_from_frame(ds, param, framenum=-1): return frame -def swiftest_xr2infile(ds, param, in_type="NETCDF_DOUBLE", infile_name=None,framenum=-1): +def swiftest_xr2infile(ds, param, in_type="NETCDF_DOUBLE", infile_name=None,framenum=-1,verbose=True): """ Writes a set of Swiftest input files from a single frame of a Swiftest xarray dataset @@ -1101,7 +1101,8 @@ def swiftest_xr2infile(ds, param, in_type="NETCDF_DOUBLE", infile_name=None,fram if infile_name is None: infile_name = param['NC_IN'] frame = unclean_string_values(frame) - print(f"Writing initial conditions to file {infile_name}") + if verbose: + print(f"Writing initial conditions to file {infile_name}") frame.to_netcdf(path=infile_name) return frame diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index e4dae6068..cc35103a6 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -2098,7 +2098,7 @@ def add_solar_system_body(self, J2=J2, J4=J4, t=t) dsnew = self._combine_and_fix_dsnew(dsnew) - self.save() + self.save(verbose=False) return dsnew @@ -2352,7 +2352,7 @@ def input_to_array(val,t,n=None): J2=J2, J4=J4,t=t) dsnew = self._combine_and_fix_dsnew(dsnew) - self.save() + self.save(verbose=False) return dsnew @@ -2483,7 +2483,14 @@ def write_param(self, param_file = self.param_file if param is None: param = self.param - print(f"Writing parameter inputs to file {param_file}") + + if "verbose" in kwargs: + verbose = kwargs['verbose'] + else: + verbose = self.verbose + + if verbose: + print(f"Writing parameter inputs to file {param_file}") param['! VERSION'] = f"{codename} input file" # Check to see if the parameter type matches the output type. If not, we need to convert @@ -2649,6 +2656,12 @@ def save(self, ------- None """ + + if "verbose" in kwargs: + verbose = kwargs['verbose'] + else: + verbose = self%verbose + if codename is None: codename = self.codename if param_file is None: @@ -2658,15 +2671,15 @@ def save(self, if codename == "Swiftest": infile_name = Path(self.sim_dir) / param['NC_IN'] - io.swiftest_xr2infile(ds=self.data, param=param, in_type=self.param['IN_TYPE'], infile_name=infile_name, framenum=framenum) - self.write_param(param_file=param_file) + io.swiftest_xr2infile(ds=self.data, param=param, in_type=self.param['IN_TYPE'], infile_name=infile_name, framenum=framenum, verbose=verbose) + self.write_param(param_file=param_file,**kwargs) elif codename == "Swifter": if codename == "Swiftest": swifter_param = io.swiftest2swifter_param(param) else: swifter_param = param io.swifter_xr2infile(self.data, swifter_param, framenum) - self.write_param(param_file, param=swifter_param) + self.write_param(param_file, param=swifter_param,**kwargs) else: warnings.warn(f'Saving to {codename} not supported',stacklevel=2)