From 11ebb856017b09343815882cbd9ec8cbff168c9d Mon Sep 17 00:00:00 2001 From: David Minton Date: Mon, 5 Sep 2022 16:29:00 -0400 Subject: [PATCH] Can now save a NETCDF input file when calling .save on a Simulation object --- python/swiftest/swiftest/io.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index f387492a4..ae12125b6 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -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']) @@ -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']) @@ -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 = {}