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

Commit

Permalink
Fixed bug in which the last frame was always selected when generating…
Browse files Browse the repository at this point in the history
… initial conditions
  • Loading branch information
daminton committed Sep 15, 2022
1 parent f481880 commit 88b2b57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def select_active_from_frame(ds, param, framenum=-1):
iactive = iframe['id'].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['xhx'])), drop=True).id
else:
iactive = iframe['id'].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['a'])), drop = True).id
frame = frame.sel(id=iactive.values)
frame = frame.isel(id=iactive.values)

return frame

Expand All @@ -904,7 +904,6 @@ def swiftest_xr2infile(ds, param, framenum=-1):
-------
A set of input files for a new Swiftest run
"""

frame = select_active_from_frame(ds, param, framenum)

if param['IN_TYPE'] == "NETCDF_DOUBLE" or param['IN_TYPE'] == "NETCDF_FLOAT":
Expand Down Expand Up @@ -1685,4 +1684,4 @@ def swifter2swift_param(swifter_param, J2=0.0, J4=0.0):
swift_param['L2'] = 'T'


return swift_param
return swift_param
4 changes: 2 additions & 2 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def initial_conditions_from_bin(self, framenum=-1, new_param=None, new_param_fil
new_param.pop('TP_IN', None)
new_param.pop('CB_IN', None)
print(f"Extracting data from dataset at time frame number {framenum} and saving it to {new_param['NC_IN']}")
frame = io.swiftest_xr2infile(self.ds, new_param)
frame = io.swiftest_xr2infile(self.ds, new_param, framenum)
print(f"Saving parameter configuration file to {new_param_file}")
self.write_param(new_param_file, param=new_param)

return frame
return frame

0 comments on commit 88b2b57

Please sign in to comment.