Dust evolution in protoplanetary disks
Simple plotting functions for visualizing DustPy simulation data and results. The plotting module provides both static and interactive visualization capabilities optimized for dust evolution analysis in protoplanetary disks.
Function for creating static plots of simulation data with customizable display options.
from dustpy import plot
def plot.panel(data, filename="data", extension="hdf5", im=0, ir=0, it=0, show_limits=True, show_St1=True):
"""
Create static plots of simulation data.
Generates a multi-panel figure showing various aspects of the
dust and gas evolution including surface densities, particle
sizes, Stokes numbers, and velocity profiles.
Parameters:
- data: Simulation object or path to data file
- filename: Name of data file (default: "data")
- extension: File extension ("hdf5", "h5", or "dump")
- im: Mass bin index to highlight (default: 0)
- ir: Radial index to highlight (default: 0)
- it: Time snapshot index to display (default: 0)
- show_limits: Whether to show fragmentation and drift limits (default: True)
- show_St1: Whether to show Stokes number = 1 line (default: True)
Returns:
matplotlib.figure.Figure: Generated figure object
"""Function for creating interactive plots with slider controls for exploring simulation data.
def plot.ipanel(data, filename="data", extension="hdf5", im=0, ir=0, it=0, show_limits=True, show_St1=True):
"""
Create interactive plots of simulation data with slider controls.
Generates the same multi-panel layout as panel() but with
interactive sliders to explore different time snapshots,
mass bins, and radial positions in real-time.
Parameters:
- data: Simulation object or path to data file
- filename: Name of data file (default: "data")
- extension: File extension ("hdf5", "h5", or "dump")
- im: Initial mass bin index (default: 0)
- ir: Initial radial index (default: 0)
- it: Initial time snapshot index (default: 0)
- show_limits: Whether to show fragmentation and drift limits (default: True)
- show_St1: Whether to show Stokes number = 1 line (default: True)
Returns:
matplotlib widgets interface: Interactive plot with sliders
"""from dustpy import Simulation, plot
# Run simulation
sim = Simulation()
sim.makegrids()
sim.initialize()
sim.run()
# Create static plot
fig = plot.panel(sim)
fig.savefig("dust_evolution.png", dpi=300)import matplotlib.pyplot as plt
from dustpy import plot
# Plot from HDF5 file
fig = plot.panel(None, filename="simulation_output", extension="hdf5")
plt.show()
# Plot from dump file
fig = plot.panel(None, filename="simulation_dump", extension="dump")
plt.show()# Create interactive plot for data exploration
plot.ipanel(sim, show_limits=True, show_St1=True)
# Interactive plot from file
plot.ipanel(None, filename="simulation_data", extension="hdf5")# Plot specific time snapshot and highlighted indices
fig = plot.panel(sim,
it=10, # 10th time snapshot
im=20, # Highlight 20th mass bin
ir=50, # Highlight 50th radial bin
show_limits=False, # Don't show limit lines
show_St1=False) # Don't show St=1 line
# Customize further with matplotlib
fig.suptitle("Dust Evolution at t = 10,000 years", fontsize=16)
plt.tight_layout()
plt.show()# Plot HDF5 data
plot.panel(None, filename="dustpy_output", extension="hdf5", it=0)
# Plot h5 data (alternative extension)
plot.panel(None, filename="dustpy_output", extension="h5", it=0)
# Plot dump file data
plot.panel(None, filename="dustpy_snapshot", extension="dump")Both panel() and ipanel() generate comprehensive multi-panel plots that include:
# Direct simulation object plotting
sim = Simulation()
# ... run simulation ...
# Plot current state
fig = plot.panel(sim)
# Access simulation time information
current_time = sim.t / (365.25 * 24 * 3600) # Convert to years
fig.suptitle(f"Dust Evolution at t = {current_time:.0f} years")import os
# Plot multiple time snapshots
data_files = ["output_t0.hdf5", "output_t1.hdf5", "output_t2.hdf5"]
for i, filename in enumerate(data_files):
fig = plot.panel(None, filename=filename.replace('.hdf5', ''), extension="hdf5")
fig.savefig(f"evolution_step_{i:03d}.png", dpi=200)
plt.close(fig) # Close to save memoryfrom dustpy import utils
# Extract data for custom analysis
data = utils.read_data(sim)
# Create standard plot
fig = plot.panel(sim)
# Add custom analysis to existing plot
ax = fig.axes[0] # Get first subplot
ax.axvline(data.r_drift_barrier, color='green', linestyle='--',
label='Custom drift barrier')
ax.legend()Install with Tessl CLI
npx tessl i tessl/pypi-dustpy