From 17521dad90a4ab915d59f0b6b99b4316db139215 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 27 Feb 2024 15:40:08 -0500 Subject: [PATCH] Updated the io reader to be able to read in a case with no cartesian coordinates or orbital elements (a central body only) --- swiftest/io.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/swiftest/io.py b/swiftest/io.py index 33fdb1e8f..4628fe17a 100644 --- a/swiftest/io.py +++ b/swiftest/io.py @@ -858,9 +858,15 @@ def select_active_from_frame(ds, param, framenum=-1): # Select only the active particles at this time step # Remove the inactive particles if param['OUT_FORM'] == 'XV' or param['OUT_FORM'] == 'XVEL': - iactive = iframe[count_dim].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['rh'].isel(space=0))), drop=True)[count_dim] + if 'rh' in iframe: + iactive = iframe[count_dim].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['rh'].isel(space=0))), drop=True)[count_dim] + else: + iactive = iframe[count_dim].where(~np.isnan(iframe['Gmass'])) else: - iactive = iframe[count_dim].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['a'])), drop = True)[count_dim] + if 'a' in iframe: + iactive = iframe[count_dim].where((~np.isnan(iframe['Gmass'])) | (~np.isnan(iframe['a'])), drop = True)[count_dim] + else: + iactive = iframe[count_dim].where(~np.isnan(iframe['Gmass'])) if count_dim == "id": frame = frame.sel(id=iactive.values) elif count_dim == "name":