CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-dustpy

Dust evolution in protoplanetary disks

Overview
Eval results
Files

plotting.mddocs/

Plotting Functions

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.

Capabilities

Static Plotting

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
    """

Interactive Plotting

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
    """

Usage Examples

Basic Static Plotting

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)

Plotting from Files

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()

Interactive Exploration

# 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")

Customized Plotting

# 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()

Plotting Different Data Formats

# 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")

Plot Panel Description

Both panel() and ipanel() generate comprehensive multi-panel plots that include:

Panel Layout

  1. Gas Surface Density - Radial profile of gas surface density
  2. Dust Surface Density - 2D map of dust surface density vs. radius and particle mass
  3. Particle Size Distribution - Size distribution at highlighted radial position
  4. Stokes Number - 2D map of Stokes numbers
  5. Dust-to-Gas Ratio - Radial profile of total dust-to-gas ratio
  6. Radial Velocity - Dust and gas radial velocities
  7. Relative Velocity - Relative velocities between particle sizes
  8. Scale Heights - Dust and gas scale heights

Visual Elements

  • Fragmentation Limit: Line showing where particles fragment due to high-velocity collisions
  • Drift Limit: Line showing maximum particle sizes before rapid radial drift
  • Stokes = 1 Line: Transition between gas-coupled and decoupled dust evolution
  • Highlighted Bins: Visual indicators for selected mass bins and radial positions

Color Coding

  • Gas quantities typically shown in blue/cyan colors
  • Dust quantities shown in warm colors (red/orange/yellow)
  • Logarithmic color scales for wide dynamic ranges
  • Contour lines for better readability

Advanced Plotting Options

Working with Simulation Objects

# 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")

Batch Plotting

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 memory

Integration with Analysis

from 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

docs

constants.md

dust-physics.md

gas-physics.md

grid-stellar.md

index.md

plotting.md

simulation-control.md

simulation.md

utilities.md

tile.json