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

Commit

Permalink
Set the step size for the disruption movie to be an order of magnitud…
Browse files Browse the repository at this point in the history
…e larger to make the movies faster
  • Loading branch information
daminton committed Dec 14, 2022
1 parent 4355bae commit 241b325
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 3 additions & 2 deletions examples/Fragmentation/Fragmentation_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def encounter_combiner(sim):
# Remove any encounter data at the same time steps that appear in the data to prevent duplicates
t_not_duplicate = ~enc['time'].isin(data['time'])
enc = enc.where(t_not_duplicate,drop=True)
tgood=enc.time.where(~np.isnan(enc.time),drop=True)
enc = enc.sel(time=tgood)

# 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")
Expand All @@ -107,7 +109,6 @@ class AnimatedScatter(object):
def __init__(self, sim, animfile, title, style, nskip=1):

self.ds = encounter_combiner(sim)

nframes = int(self.ds['time'].size)
self.sim = sim
self.title = title
Expand Down Expand Up @@ -203,7 +204,7 @@ def data_stream(self, frame=0):
minimum_fragment_gmass = 0.2 * body_Gmass[style][1] # Make the minimum fragment mass a fraction of the smallest body
gmtiny = 0.99 * body_Gmass[style][1] # Make GMTINY just smaller than the smallest original body. This will prevent runaway collisional cascades
sim.set_parameter(fragmentation=True, encounter_save="trajectory", gmtiny=gmtiny, minimum_fragment_gmass=minimum_fragment_gmass, verbose=False)
sim.run(dt=1e-4, tstop=1.0e-3, istep_out=1, dump_cadence=1)
sim.run(dt=1e-3, tstop=1.0e-3, istep_out=1, dump_cadence=1)

print("Generating animation")
anim = AnimatedScatter(sim,movie_filename,movie_titles[style],style,nskip=1)
9 changes: 1 addition & 8 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,19 +816,12 @@ def process_netcdf_input(ds, param):
ds : xarray dataset
"""
#
#ds = ds.where(ds.id >=0,drop=True)

if param['OUT_TYPE'] == "NETCDF_DOUBLE":
ds = fix_types(ds,ftype=np.float64)
elif param['OUT_TYPE'] == "NETCDF_FLOAT":
ds = fix_types(ds,ftype=np.float32)

# # Check if the name variable contains unique values. If so, make name the dimension instead of id
# if "id" in ds.dims:
# if len(np.unique(ds['name'])) == len(ds['name']):
# ds = ds.swap_dims({"id" : "name"})
# if "id" in ds:
# ds = ds.reset_coords("id")

return ds

def swiftest2xr(param, verbose=True):
Expand Down

0 comments on commit 241b325

Please sign in to comment.