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

Commit

Permalink
Refactored read_old_output to read_data because I can never remember it
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 16, 2023
1 parent 324e47c commit 852b645
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/Basic_Simulation/output_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import matplotlib.pyplot as plt

# Read in the simulation output and store it as an Xarray dataset.
sim = swiftest.Simulation(read_old_output=True)
sim = swiftest.Simulation(read_data=True)

# Plot of the data and save the output plot.
colors = ['white' if x == 'Massive Body' else 'black' for x in sim.data['particle_type']]
Expand Down
2 changes: 1 addition & 1 deletion examples/Chambers2013/scattermovie.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def update(self,frame):

return self.slist

sim = swiftest.Simulation(read_old_output=True)
sim = swiftest.Simulation(read_data=True)
print('Making animation')
anim = AnimatedScatter(sim.data,sim.param)
print('Animation finished')
12 changes: 6 additions & 6 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Simulation:
This is a class that defines the basic Swift/Swifter/Swiftest simulation object
"""

def __init__(self,read_param: bool = False, read_old_output: bool = False, simdir: os.PathLike | str = "simdata", **kwargs: Any):
def __init__(self,read_param: bool = False, read_data: bool = False, simdir: os.PathLike | str = "simdata", **kwargs: Any):
"""
Parameters
Expand All @@ -66,7 +66,7 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi
inside the current working directory, which can be changed by passing `param_file` as an argument.
- The argument has an equivalent parameter or set of parameters in the parameter input file.
3. Default values (see below)
read_old_output : bool, default False
read_data : bool, default False
If true, read in a pre-existing binary input file given by the argument `output_file_name` if it exists.
Parameter input file equivalent: None
simdir : PathLike, default `"simdir"`
Expand Down Expand Up @@ -341,8 +341,8 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi
# If the user asks to read in an old parameter file or output file, override any default parameters with values from the file
# If the file doesn't exist, flag it for now so we know to create it
param_file_found = False
if read_param or read_old_output:
if self.read_param(read_init_cond = not read_old_output):
if read_param or read_data:
if self.read_param(read_init_cond = not read_data):
# We will add the parameter file to the kwarg list. This will keep the set_parameter method from
# overriding everything with defaults when there are no arguments passed to Simulation()
kwargs['param_file'] = self.param_file
Expand All @@ -362,7 +362,7 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi
self.write_param()

# Read in an old simulation file if requested
if read_old_output:
if read_data:
binpath = os.path.join(self.simdir, self.param['BIN_OUT'])
if os.path.exists(binpath):
self.read_output_file()
Expand Down Expand Up @@ -746,7 +746,7 @@ def set_parameter(self, verbose: bool = True, **kwargs):
"init_cond_file_type": "NETCDF_DOUBLE",
"init_cond_file_name": None,
"init_cond_format": "EL",
"read_old_output": False,
"read_data": False,
"output_file_type": "NETCDF_DOUBLE",
"output_file_name": None,
"output_format": "XVEL",
Expand Down

0 comments on commit 852b645

Please sign in to comment.