Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed Python driver bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 1, 2023
1 parent 6e6f8d2 commit 642c646
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -2871,15 +2866,16 @@ 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:
param_file = self.param_file
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)
Expand Down

0 comments on commit 642c646

Please sign in to comment.