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

Commit

Permalink
Browse files Browse the repository at this point in the history
Can now save a NETCDF input file when calling .save on a Simulation object
  • Loading branch information
daminton committed Sep 5, 2022
1 parent b4ef786 commit 11ebb85
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ def swiftest_xr2infile(ds, param, framenum=-1):
A set of three input files for a Swiftest run
"""
frame = ds.isel(time=framenum)

# For NETCDF input file type, just do a dump of the system at the correct time frame
if param['IN_TYPE'] == "NETCDF_DOUBLE" or param['IN_TYPE'] == "NETCDF_FLOAT":
frame.to_netcdf(path=param['NC_IN'])
return

# All other file types need seperate files for each of the inputs
cb = frame.where(frame.id == 0, drop=True)
pl = frame.where(frame.id > 0, drop=True)
pl = pl.where(np.invert(np.isnan(pl['Gmass'])), drop=True).drop_vars(['J_2', 'J_4'])
Expand Down Expand Up @@ -1015,6 +1022,7 @@ def swifter_xr2infile(ds, param, framenum=-1):
A set of input files for a Swifter run
"""
frame = ds.isel(time=framenum)

cb = frame.where(frame.id == 0, drop=True)
pl = frame.where(frame.id > 0, drop=True)
pl = pl.where(np.invert(np.isnan(pl['Gmass'])), drop=True).drop_vars(['J_2', 'J_4'])
Expand Down Expand Up @@ -1060,6 +1068,7 @@ def swifter_xr2infile(ds, param, framenum=-1):
# Now make Swiftest files
print(f"{param['IN_TYPE']} is an unknown input file type")

return

def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}):
swifter_param = {}
Expand Down

0 comments on commit 11ebb85

Please sign in to comment.