diff --git a/examples/Basic_Simulation/initial_conditions.py b/examples/Basic_Simulation/initial_conditions.py index 861556958..b58522824 100644 --- a/examples/Basic_Simulation/initial_conditions.py +++ b/examples/Basic_Simulation/initial_conditions.py @@ -20,7 +20,7 @@ Output ------ -bin.nc : A NetCDF file containing the simulation output. +data.nc : A NetCDF file containing the simulation output. 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. diff --git a/examples/Basic_Simulation/output_reader.py b/examples/Basic_Simulation/output_reader.py index fc332af0c..977c2a393 100644 --- a/examples/Basic_Simulation/output_reader.py +++ b/examples/Basic_Simulation/output_reader.py @@ -15,7 +15,7 @@ Input ------ -bin.nc : A NetCDF file containing the simulation output. +data.nc : A NetCDF file containing the simulation output. Output ------ diff --git a/examples/Fragmentation/swiftest_fragmentation.py b/examples/Fragmentation/swiftest_fragmentation.py index 067c53710..3ee13cb2a 100644 --- a/examples/Fragmentation/swiftest_fragmentation.py +++ b/examples/Fragmentation/swiftest_fragmentation.py @@ -21,7 +21,7 @@ Output ------ -disruption/bin.nc : A NetCDF file containing the simulation output. +disruption/data.nc : A NetCDF file containing the simulation output. disruption/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. disruption/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. disruption/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. @@ -30,7 +30,7 @@ disruption/init_cond.nc : A NetCDF file containing the initial conditions for the simulation. disruption/param.in : An ASCII file containing the parameters for the simulation. disruption/swiftest.log : An ASCII file containing the information on the status of the simulation as it runs. -hitandrun/bin.nc : A NetCDF file containing the simulation output. +hitandrun/data.nc : A NetCDF file containing the simulation output. hitandrun/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. hitandrun/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. hitandrun/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. @@ -39,7 +39,7 @@ hitandrun/init_cond.nc : A NetCDF file containing the initial conditions for the simulation. hitandrun/param.in : An ASCII file containing the parameters for the simulation. hitandrun/swiftest.log : An ASCII file containing the information on the status of the simulation as it runs. -supercat/bin.nc : A NetCDF file containing the simulation output. +supercat/data.nc : A NetCDF file containing the simulation output. supercat/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. supercat/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. supercat/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. diff --git a/examples/helio_gr_test/helio_gr_test.py b/examples/helio_gr_test/helio_gr_test.py index c627be7f4..77ae66740 100644 --- a/examples/helio_gr_test/helio_gr_test.py +++ b/examples/helio_gr_test/helio_gr_test.py @@ -24,7 +24,7 @@ helio_gr_mercury_precession.png : Portable Network Graphic file depicting the precession of Mercury's perihelion over time with data sourced from the JPL Horizons database, Swiftest run with general relativity, and Swiftest run without general relativity. -gr/bin.nc : A NetCDF file containing the simulation output. +gr/data.nc : A NetCDF file containing the simulation output. gr/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. gr/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. gr/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. @@ -32,7 +32,7 @@ gr/init_cond.nc : A NetCDF file containing the initial conditions for the simulation. gr/param.in : An ASCII file containing the parameters for the simulation. gr/swiftest.log : An ASCII file containing the information on the status of the simulation as it runs. -nogr/bin.nc : A NetCDF file containing the simulation output. +nogr/data.nc : A NetCDF file containing the simulation output. nogr/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. nogr/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. nogr/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. diff --git a/examples/whm_gr_test/whm_gr_test.py b/examples/whm_gr_test/whm_gr_test.py index d0d2ade69..f4dc185ab 100644 --- a/examples/whm_gr_test/whm_gr_test.py +++ b/examples/whm_gr_test/whm_gr_test.py @@ -24,7 +24,7 @@ whm_gr_mercury_precession.png : Portable Network Graphic file depicting the precession of Mercury's perihelion over time with data sourced from the JPL Horizons database, Swiftest run with general relativity, and Swiftest run without general relativity. -gr/bin.nc : A NetCDF file containing the simulation output. +gr/data.nc : A NetCDF file containing the simulation output. gr/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. gr/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. gr/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. @@ -32,7 +32,7 @@ gr/init_cond.nc : A NetCDF file containing the initial conditions for the simulation. gr/param.in : An ASCII file containing the parameters for the simulation. gr/swiftest.log : An ASCII file containing the information on the status of the simulation as it runs. -nogr/bin.nc : A NetCDF file containing the simulation output. +nogr/data.nc : A NetCDF file containing the simulation output. nogr/dump_bin1.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. nogr/dump_bin2.nc : A NetCDF file containing the necessary inputs to restart a simulation from t!=0. nogr/dump_param1.in : An ASCII file containing the necessary parameters to restart a simulation. diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index a239b9293..f5517678f 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -141,8 +141,7 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi Parameter input file equivalent: `OUT_TYPE` output_file_name : str or path-like, optional Name of output file to generate. If not supplied, then one of the default file names are used, depending on - the value passed to `output_file_type`. If one of the NetCDF types are used, the default is "bin.nc". - Otherwise, the default is "bin.dat". + the value passed to `output_file_type`. The default is "data.nc". Parameter input file equivalent: `BIN_OUT` output_format : {"XV","XVEL"}, default "XVEL" Specifies the format for the data saved to the output file. If "XV" then cartesian position and velocity @@ -312,7 +311,7 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi self.param = {} self.data = xr.Dataset() - self.ic = xr.Dataset() + self.init_cond = xr.Dataset() self.encounters = xr.Dataset() self.collisions = xr.Dataset() @@ -1508,7 +1507,7 @@ def set_output_files(self, * Swift: Only "REAL4" supported. output_file_name : str or path-like, optional Name of output file to generate. If not supplied, then one of the default file names are used, depending on - the value passed to `output_file_type`. If one of the NetCDF types are used, the default is "bin.nc". + the value passed to `output_file_type`. If one of the NetCDF types are used, the default is "data.nc". Otherwise, the default is "bin.dat". output_format : {"XV","XVEL"}, optional Specifies the format for the data saved to the output file. If "XV" then cartesian position and velocity @@ -1568,7 +1567,7 @@ def set_output_files(self, self.param['OUT_TYPE'] = output_file_type if output_file_name is None: if output_file_type in ["NETCDF_DOUBLE", "NETCDF_FLOAT"]: - self.param['BIN_OUT'] = "bin.nc" + self.param['BIN_OUT'] = "data.nc" else: self.param['BIN_OUT'] = "bin.dat" else: @@ -2157,7 +2156,7 @@ def add_solar_system_body(self, if dsnew['npl'] > 0 or dsnew['ntp'] > 0: self.save(verbose=False) - self.ic = self.data.copy(deep=True) + self.init_cond = self.data.copy(deep=True) return @@ -2456,7 +2455,7 @@ def input_to_array_3d(val,n=None): dsnew = self._combine_and_fix_dsnew(dsnew) self.save(verbose=False) - self.ic = self.data.copy(deep=True) + self.init_cond = self.data.copy(deep=True) return @@ -2563,7 +2562,7 @@ def read_param(self, param_tmp = self.param.copy() param_tmp['BIN_OUT'] = init_cond_file self.data = io.swiftest2xr(param_tmp, verbose=self.verbose) - self.ic = self.data.copy(deep=True) + self.init_cond = self.data.copy(deep=True) else: warnings.warn(f"Initial conditions file file {init_cond_file} not found.", stacklevel=2) else: @@ -2706,11 +2705,6 @@ def read_output_file(self,read_init_cond : bool = True): # This is done to handle cases where the method is called from a different working directory than the simulation # results - if "ENCOUNTER_SAVE" in self.param: - read_encounters = self.param["ENCOUNTER_SAVE"] != "NONE" - else: - read_encounters = False - param_tmp = self.param.copy() param_tmp['BIN_OUT'] = os.path.join(self.simdir, self.param['BIN_OUT']) if self.codename == "Swiftest": @@ -2718,17 +2712,15 @@ def read_output_file(self,read_init_cond : bool = True): if self.verbose: print('Swiftest simulation data stored as xarray DataSet .data') if read_init_cond: if self.verbose: - print("Reading initial conditions file as .ic") + print("Reading initial conditions file as .init_cond") if "NETCDF" in self.param['IN_TYPE']: param_tmp['BIN_OUT'] = self.simdir / self.param['NC_IN'] - - self.ic = io.swiftest2xr(param_tmp, verbose=self.verbose) + self.init_cond = io.swiftest2xr(param_tmp, verbose=False) else: - self.ic = self.data.isel(time=0) - if read_encounters: - self.read_encounters() - if read_collisions: - self.read_collisions() + self.init_cond = self.data.isel(time=0) + + self.read_encounters() + self.read_collisions() elif self.codename == "Swifter": self.data = io.swifter2xr(param_tmp, verbose=self.verbose) @@ -2740,9 +2732,13 @@ def read_output_file(self,read_init_cond : bool = True): return def read_encounters(self): + enc_files = glob(f"{self.simdir}{os.path.sep}encounter_*.nc") + if len(enc_files) == 0: + return + if self.verbose: print("Reading encounter history file as .encounters") - enc_files = glob(f"{self.simdir}{os.path.sep}encounter_*.nc") + enc_files.sort() # This is needed in order to pass the param argument down to the io.process_netcdf_input function @@ -2760,10 +2756,13 @@ def _preprocess(ds, param): def read_collisions(self): - if self.verbose: - print("Reading collision history file as .collisions") col_files = glob(f"{self.simdir}{os.path.sep}collision_*.nc") + if len(col_files) == 0: + return + col_files.sort() + if self.verbose: + print("Reading collision history file as .collisions") # This is needed in order to pass the param argument down to the io.process_netcdf_input function def _preprocess(ds, param): diff --git a/src/modules/swiftest_globals.f90 b/src/modules/swiftest_globals.f90 index 25f355152..d9590b59e 100644 --- a/src/modules/swiftest_globals.f90 +++ b/src/modules/swiftest_globals.f90 @@ -122,7 +122,7 @@ module swiftest_globals character(*), parameter :: PL_INFILE = 'pl.in' character(*), parameter :: TP_INFILE = 'tp.in' character(*), parameter :: NC_INFILE = 'in.nc' - character(*), parameter :: BIN_OUTFILE = 'bin.nc' + character(*), parameter :: BIN_OUTFILE = 'data.nc' integer(I4B), parameter :: BINUNIT = 20 !! File unit number for the binary output file integer(I4B), parameter :: PARTICLEUNIT = 44 !! File unit number for the binary particle info output file integer(I4B), parameter :: LUN = 42 !! File unit number for files that are opened and closed within a single subroutine call, and therefore should not collide