diff --git a/python/swiftest/swiftest/init_cond.py b/python/swiftest/swiftest/init_cond.py index ea28bcb8c..1d43fb599 100644 --- a/python/swiftest/swiftest/init_cond.py +++ b/python/swiftest/swiftest/init_cond.py @@ -329,7 +329,6 @@ def vec2xr(param: Dict, infodims = ['id', 'vec'] # The central body is always given id 0 - if GMpl is not None: icb = (~np.isnan(GMpl)) & (idvals == 0) ipl = (~np.isnan(GMpl)) & (idvals != 0) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 3f5008bb9..e4d5ff139 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -175,11 +175,11 @@ def read_swiftest_param(param_file_name, param, verbose=True): param[uc] = param[uc].upper() for i in int_param: - if i in param and type(i) != int: - param[i] = int(param[i]) + if i in param and type(param[i]) != int: + param[i] = int(float(param[i])) for f in float_param: - if f in param and type(f) is str: + if f in param and type(param[f]) is str: param[f] = real2float(param[f]) for b in bool_param: diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index cc35103a6..834f6e40a 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -2045,26 +2045,31 @@ def add_solar_system_body(self, body_list.append(init_cond.solar_system_horizons(n, self.param, date, idval=ephemeris_id[i])) #Convert the list receieved from the solar_system_horizons output and turn it into arguments to vec2xr - name,v1,v2,v3,v4,v5,v6,ephemeris_id,GMpl,Rpl,rhill,Ip1,Ip2,Ip3,rotx,roty,rotz,J2,J4 = tuple(np.squeeze(np.hsplit(np.array(body_list),19))) + if len(body_list) == 1: + name,v1,v2,v3,v4,v5,v6,ephemeris_id,GMpl,Rpl,rhill,Ip1,Ip2,Ip3,rotx,roty,rotz,J2,J4 = tuple(np.hsplit(np.array(body_list[0]),19)) + else: + name,v1,v2,v3,v4,v5,v6,ephemeris_id,GMpl,Rpl,rhill,Ip1,Ip2,Ip3,rotx,roty,rotz,J2,J4 = tuple(np.squeeze(np.hsplit(np.array(body_list),19))) + ephemeris_id = ephemeris_id.astype(int) v1 = v1.astype(np.float64) v2 = v2.astype(np.float64) v3 = v3.astype(np.float64) v4 = v4.astype(np.float64) v5 = v5.astype(np.float64) v6 = v6.astype(np.float64) - ephemeris_id = ephemeris_id.astype(int) + rhill = rhill.astype(np.float64) + J2 = J2.astype(np.float64) + J4 = J4.astype(np.float64) + GMpl = GMpl.astype(np.float64) Rpl = Rpl.astype(np.float64) - rhill = rhill.astype(np.float64) Ip1 = Ip1.astype(np.float64) Ip2 = Ip2.astype(np.float64) Ip3 = Ip3.astype(np.float64) rotx = rotx.astype(np.float64) roty = roty.astype(np.float64) rotz = rotz.astype(np.float64) - J2 = J2.astype(np.float64) - J4 = J4.astype(np.float64) + if all(np.isnan(GMpl)): GMpl = None @@ -2098,7 +2103,8 @@ def add_solar_system_body(self, J2=J2, J4=J4, t=t) dsnew = self._combine_and_fix_dsnew(dsnew) - self.save(verbose=False) + if dsnew['npl'] > 0 or dsnew['ntp'] > 0: + self.save(verbose=False) return dsnew