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

Commit

Permalink
Merge branch 'Simulation_API_improvements' into debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Nov 22, 2022
2 parents bd77020 + f0fb208 commit 80e6d97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion python/swiftest/swiftest/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 12 additions & 6 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 80e6d97

Please sign in to comment.