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

Commit

Permalink
Renamed the merged bodies back to the original name so that the movie…
Browse files Browse the repository at this point in the history
… doesn't skip any frames
  • Loading branch information
daminton committed Jan 16, 2023
1 parent 3508e3a commit de41865
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion examples/Fragmentation/Fragmentation_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def encounter_combiner(sim):
"""

# Only keep a minimal subset of necessary data from the simulation and encounter datasets
keep_vars = ['rh','vh','Gmass','radius']
keep_vars = ['name','rh','vh','Gmass','radius']
data = sim.data[keep_vars]
enc = sim.encounters[keep_vars].load()

Expand All @@ -141,6 +141,18 @@ def encounter_combiner(sim):

# The following will combine the two datasets along the time dimension, sort the time dimension, and then fill in any time gaps with interpolation
ds = xr.combine_nested([data,enc],concat_dim='time').sortby("time").interpolate_na(dim="time")

# Rename the merged Target body so that their data can be combined
tname=[n for n in ds['name'].data if "Target" in n]
nottname=[n for n in ds['name'].data if "Target" not in n]
dslist = []
for n in tname:
dsnew = ds.sel(name=n)
dsnew['name'] = "Target"
dslist.append(dsnew)

newds = xr.merge(dslist,compat="no_conflicts")
ds = xr.combine_nested([ds.sel(name=nottname),newds],concat_dim="name")

# Interpolate in time to make a smooth, constant time step dataset
# Add a bit of padding to the time, otherwise there are some issues with the interpolation in the last few frames.
Expand Down

0 comments on commit de41865

Please sign in to comment.