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

Commit

Permalink
updated to use sim.data instead of ds
Browse files Browse the repository at this point in the history
  • Loading branch information
cwishard committed Dec 6, 2022
1 parent d4981a1 commit 7e8b751
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/Basic_Simulation/output_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
import matplotlib.pyplot as plt

# Read in the simulation output and store it as an Xarray dataset
ds = swiftest.Simulation(param_file="simdata/param.in", read_old_output_file=True).data
sim = swiftest.Simulation(read_old_output_file=True)

# Plot of the data and save the output plot
colors = ['white' if x == 'Massive Body' else 'black' for x in ds['particle_type']]
sizes = [100 if x == 'Massive Body' else 10 for x in ds['particle_type']]
colors = ['white' if x == 'Massive Body' else 'black' for x in sim.data['particle_type']]
sizes = [100 if x == 'Massive Body' else 10 for x in sim.data['particle_type']]

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5,3))
ax.set(xlabel="Semimajor Axis (AU)", ylabel="Eccentricity", title="Simulation Start")
ax.scatter(ds['a'].isel(time=0), ds['e'].isel(time=0), c=colors, s=sizes, edgecolor='black')
ax.set(xlabel="Semimajor Axis (AU)", ylabel="Eccentricity", title="Simulation Initial Conditions (t=0)")
ax.scatter(sim.data['a'].isel(time=0), sim.data['e'].isel(time=0), c=colors, s=sizes, edgecolor='black')
ax.set_xlim(0, 2.0)
ax.set_ylim(0, 0.4)
ax.text(1.5, 0.35, f"t = {ds['time'].isel(time=0).values} years", size=10, ha="left")
ax.text(1.5, 0.35, f"t = {sim.data['time'].isel(time=0).values} years", size=10, ha="left")
plt.tight_layout()
plt.show()
fig.savefig("output.eps", dpi=300, facecolor='white', transparent=False, bbox_inches="tight")
fig.savefig("output.eps", dpi=300, facecolor='white', transparent=False, bbox_inches="tight")

0 comments on commit 7e8b751

Please sign in to comment.