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

Commit

Permalink
Went back to "collisions" and "encounters" for storage names
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 5, 2023
1 parent c25ac25 commit 4669f6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/Fragmentation/swiftest_fragmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
Each subdirectory contains:
data.nc : A NetCDF file containing the simulation output.
init_cond.nc : A NetCDF file containing the initial conditions for the simulation.
collision_000001.nc : A NetCDF file containing the data for the collision.
encounter_000001.nc : A NetCDF file containing the data for the close encounter.
collision_000001.nc : A NetCDF file containing the data for the collisions.
encounter_000001.nc : A NetCDF file containing the data for the close encounters.
dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0.
dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0.
dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation.
Expand Down
32 changes: 16 additions & 16 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi
but not each other (SyMBA only). *Note.* Only mtiny or gmtiny is accepted, not both.
Parameter input file equivalent: `GMTINY`
close_encounter_check : bool, default True
Check for close encounter between bodies. If set to True, then the radii of massive bodies must be included
Check for close encounters between bodies. If set to True, then the radii of massive bodies must be included
in initial conditions.
Parameter input file equivalent: `CHK_CLOSE`
encounter_save : {"NONE","TRAJECTORY","CLOSEST", "BOTH"}, default "NONE"
Indicate if and how encounter data should be saved. If set to "TRAJECTORY", the position and velocity vectors
of all bodies undergoing close encounter are saved at each intermediate step to the encounter files.
of all bodies undergoing close encounters are saved at each intermediate step to the encounter files.
If set to "CLOSEST", the position and velocities at the point of closest approach between pairs of bodies are
computed and stored to the encounter files. If set to "BOTH", then this stores the values that would be computed
in "TRAJECTORY" and "CLOSEST". If set to "NONE" no trajectory information is saved.
Expand Down Expand Up @@ -316,8 +316,8 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi
self.param = {}
self.data = xr.Dataset()
self.init_cond = xr.Dataset()
self.encounter = xr.Dataset()
self.collision = xr.Dataset()
self.encounters = xr.Dataset()
self.collisions = xr.Dataset()

self.simdir = Path(simdir)
if self.simdir.exists():
Expand Down Expand Up @@ -1035,7 +1035,7 @@ def set_feature(self,
Parameters
----------
close_encounter_check : bool, optional
Check for close encounter between bodies. If set to True, then the radii of massive bodies must be included
Check for close encounters between bodies. If set to True, then the radii of massive bodies must be included
in initial conditions.
encounter_save : {"NONE","TRAJECTORY","CLOSEST","BOTH"}, default "NONE"
Indicate if and how encounter data should be saved. If set to "TRAJECTORY", the position and velocity vectors
Expand Down Expand Up @@ -2758,7 +2758,7 @@ def read_encounter(self):
return

if self.verbose:
print("Reading encounter history file as .encounter")
print("Reading encounter history file as .encounters")

enc_files.sort()

Expand All @@ -2767,28 +2767,28 @@ def _preprocess(ds, param):
return io.process_netcdf_input(ds,param)
partial_func = partial(_preprocess, param=self.param)

self.encounter = xr.open_mfdataset(enc_files,parallel=True,combine="nested",concat_dim="time",join="left",preprocess=partial_func,mask_and_scale=True)
self.encounter = io.process_netcdf_input(self.encounter, self.param)
self.encounters = xr.open_mfdataset(enc_files,parallel=True,combine="nested",concat_dim="time",join="left",preprocess=partial_func,mask_and_scale=True)
self.encounters = io.process_netcdf_input(self.encounters, self.param)
# Remove any overlapping time values
tgood,tid = np.unique(self.encounter.time,return_index=True)
self.encounter = self.encounter.isel(time=tid)
tgood,tid = np.unique(self.encounters.time,return_index=True)
self.encounters = self.encounters.isel(time=tid)
# Remove any NaN values
tgood=self.encounter.time.where(~np.isnan(self.encounter.time),drop=True)
self.encounter = self.encounter.sel(time=tgood)
tgood=self.encounters.time.where(~np.isnan(self.encounters.time),drop=True)
self.encounters = self.encounters.sel(time=tgood)

return

def read_collision(self):

col_file = self.simdir / "collision.nc"
col_file = self.simdir / "collisions.nc"
if not os.path.exists(col_file):
return

if self.verbose:
print("Reading collision history file as .collision")
print("Reading collisions history file as .collisions")

self.collision = xr.open_dataset(col_file)
self.collision = io.process_netcdf_input(self.collision, self.param)
self.collisions = xr.open_dataset(col_file)
self.collisions = io.process_netcdf_input(self.collisions, self.param)

return

Expand Down

0 comments on commit 4669f6e

Please sign in to comment.