ExoJAX Plotting Capabilities: A Complete Guide to Visualizing Spectral Data and Model Outputs

ExoJAX provides a dedicated exojax.plot package with Matplotlib-based utilities for visualizing radiative transfer coefficients, opacity grids, DIT/MODIT matrices, and atmospheric contribution functions.

ExoJAX, an open-source toolkit for exoplanet atmospheric modeling hosted at hajimekawahara/exojax, includes specialized plotting capabilities that allow researchers to inspect every stage of the forward-modeling pipeline. These visualization tools help validate radiative transfer calculations, opacity grids, and atmospheric structures before finalizing synthetic spectral models.

Radiative Transfer Visualization

The src/exojax/plot/rtplot.py module handles diagnostic plots for radiative transfer solutions. These functions let you verify that scattering and transmission coefficients are behaving as expected across your wavelength grid.

Comparing Pure Absorption Models

The comparison_with_pure_absorption function (lines 22–45) generates side-by-side comparison panels showing transmission coefficients, scattering coefficients, cumulative optical depth, contribution functions, and pure-absorption reference spectra. This is essential for validating when scattering becomes significant in your model atmosphere.

import numpy as np
from exojax.plot.rtplot import comparison_with_pure_absorption

# Dummy inputs representing RT calculations

cumThat = np.linspace(0, 1, 100)
Qhat = np.exp(-cumThat)
spectrum = np.random.rand(100)
trans_coeff = np.random.rand(100)
scat_coeff = np.random.rand(100)
piB = np.random.rand(100)

# Generate comparison panels

spec, spec_pure = comparison_with_pure_absorption(
    cumThat, Qhat, spectrum, trans_coeff, scat_coeff, piB
)

Source: comparison_with_pure_absorptionsrc/exojax/plot/rtplot.py lines 22–45

Opacity and Line-Basis Density Visualization

The src/exojax/plot/opaplot.py module provides tools for inspecting opacity calculations and line-basis density (LBD) distributions. These plots help verify that your molecular line lists are being sampled correctly across the temperature and pressure grid.

Line-Basis Density (LBD) Plots

The plot_lbd function (lines 5–44) visualizes the density of line-basis coefficients in the (E-lower, γ) plane. This helps identify which regions of the parameter space dominate the opacity calculation for a given spectral order.

import numpy as np
from exojax.plot.opaplot import plot_lbd

# Create synthetic LBD coefficient cube

order = 0
lbd_coeff = np.random.randn(1, 50, 30, 20)
elower_grid = np.linspace(0, 40000, 50)
ngamma_ref_grid = np.logspace(-2, 2, 30)
n_Texp_grid = np.linspace(0, 2, 20)
multi_index_uniqgrid = np.column_stack(
    (np.random.randint(0, 5, size=30), np.random.randint(0, 5, size=30))
)
nu_grid = np.linspace(2000, 25000, 2000)

plot_lbd(
    lbd_coeff, elower_grid, ngamma_ref_grid,
    n_Texp_grid, multi_index_uniqgrid, nu_grid,
    vmin=-70, vmax=-20, order=order
)

Source: plot_lbdsrc/exojax/plot/opaplot.py lines 5–44

Broadening Parameter Grids

The plot_broadening_parameters_grids function (lines 122–61) visualizes the sampling of reference broadening widths (γ) and temperature exponents (nT) across your spectral grid. This ensures that your opacity calculations cover the necessary parameter space for accurate convolution.

import numpy as np
from exojax.plot.opaplot import plot_broadening_parameters_grids

gamma_ref_grid = np.logspace(-2, 2, 80)
n_Texp_grid = np.linspace(0, 2, 60)
nu_grid = np.linspace(2000, 25000, 2000)
resolution = 0.01

plot_broadening_parameters_grids(
    gamma_ref_grid, n_Texp_grid, nu_grid,
    resolution, gamma_ref_grid, n_Texp_grid,
    crit=300000, figname="broadpar_grid.png"
)

Source: plot_broadening_parameters_gridssrc/exojax/plot/opaplot.py lines 122–61

DIT and MODIT Grid Matrix Visualization

The src/exojax/plot/ditplot.py module contains utilities for visualizing Discrete Integration Tree (DIT) and Modified DIT (MODIT) grids. These plots help verify that your opacity grids are correctly constructed for the DIT algorithm.

DIT Grid Matrices

The module provides two primary functions: plot_dgmn (lines 7–33) for visualizing DIT grids for σD and γL, and plot_dgm (lines 35–63) for the γL-only matrix. These plots display the grid matrices against pressure layers to ensure proper sampling of line broadening parameters.

import numpy as np
from exojax.plot.ditplot import plot_dgmn, plot_dgm

# Pressure layers and DIT grids

Parr = np.logspace(-6, 2, 50)
dgm_ngammaL = np.random.rand(50, 30)
ngammaLM = np.random.rand(50, 200)

# Plot DIT grid for gammaL

plot_dgmn(Parr, dgm_ngammaL, ngammaLM, js=0, je=10)

# Full DIT matrix visualization

dgm_sigmaD = np.random.rand(50, 20)
dgm_gammaL = np.random.rand(50, 30)
sigmaDM = np.random.rand(50, 200)
gammaLM = np.random.rand(50, 200)
plot_dgm(dgm_sigmaD, dgm_gammaL, sigmaDM, gammaLM, js=0, je=10)

Sources: plot_dgmnsrc/exojax/plot/ditplot.py lines 7–33; plot_dgmsrc/exojax/plot/ditplot.py lines 35–63

Atmospheric Optical Depth and Contribution Functions

The src/exojax/plot/atmplot.py module provides diagnostic tools for atmospheric structure and radiative transfer verification. These functions visualize how different atmospheric layers contribute to the final spectrum.

Optical Depth Maps

The plottau function (lines 10–56) generates log-scaled optical depth (τ) or Δτ maps as 2-D color plots. You can optionally overlay temperature-pressure (T-P) profiles to correlate atmospheric structure with opacity.

import numpy as np
from exojax.plot.atmplot import plottau

nugrid = np.linspace(2000, 25000, 500)
dtauM = np.exp(-np.outer(np.logspace(-6, 2, 30), np.linspace(0, 1, 500)))
Tarr = np.linspace(3000, 500, 30)
Parr = np.logspace(-6, 2, 30)

plottau(nugrid, dtauM, Tarr=Tarr, Parr=Parr, unit="cm-1", mode=None)

Source: plottausrc/exojax/plot/atmplot.py lines 10–56

Contribution Function Analysis

The plotcf function (lines 75–151) creates contribution function maps showing the weighting of each atmospheric layer to the emergent spectrum. You can apply normalization, log scaling, and custom colormaps to highlight which pressure levels dominate the signal.

import numpy as np
from exojax.plot.atmplot import plotcf

nus = np.linspace(2000, 25000, 300)
dtauM = np.exp(-np.outer(np.logspace(-6, 2, 30), np.linspace(0, 1, 300)))
Tarr = np.linspace(3000, 500, 30)
Parr = np.logspace(-6, 2, 30)
dParr = np.gradient(Parr)

cf = plotcf(
    nus, dtauM, Tarr, Parr, dParr,
    unit="cm-1", log=False, normalize=True,
    cmap="viridis", leftxlabel="Temperature (K)"
)

Source: plotcfsrc/exojax/plot/atmplot.py lines 75–151

Maximum Contribution Points

The plot_maxpoint function (lines 71–119) highlights the specific pressure levels that dominate the contribution function for a given molecule or collision-induced absorption (CIA). This helps identify the atmospheric regions probed by specific spectral features.

import numpy as np
from exojax.plot.atmplot import plot_maxpoint

mask = np.random.choice([False, True], size=200, p=[0.9, 0.1])
Parr = np.logspace(-6, 2, 200)
maxcf = np.random.randint(0, 200, size=200)
maxcia = np.random.randint(0, 200, size=200)

plot_maxpoint(mask, Parr, maxcf, maxcia, mol="CO")

Source: plot_maxpointsrc/exojax/plot/atmplot.py lines 71–119

Summary

ExoJAX plotting capabilities provide comprehensive visualization tools across four specialized modules:

  • rtplot.py – Validates radiative transfer solutions through side-by-side comparison panels showing transmission coefficients, scattering effects, and pure-absorption references.
  • opaplot.py – Inspects opacity calculations via line-basis density maps and broadening parameter grids.
  • ditplot.py – Verifies DIT and MODIT algorithm grids through matrix visualizations of broadening and Doppler parameters.
  • atmplot.py – Diagnoses atmospheric structure using optical depth maps, contribution function visualizations, and maximum contribution point highlighting.

All functions return underlying numerical arrays where appropriate, enabling further customization or overlay of additional graphics.

Frequently Asked Questions

What file contains the ExoJAX plotting functions for radiative transfer comparison?

The comparison_with_pure_absorption function and other radiative transfer plotting tools reside in src/exojax/plot/rtplot.py. This module generates side-by-side panels comparing transmission coefficients, scattering effects, and pure-absorption reference spectra to validate your RT calculations.

How can I visualize which atmospheric layers contribute most to my synthetic spectrum?

Use the plotcf function from src/exojax/plot/atmplot.py (lines 75–151) to generate contribution function maps. This displays the weighting of each pressure layer to the emergent spectrum. For highlighting specific pressure levels, use plot_maxpoint (lines 71–119) to identify the atmospheric regions probed by specific molecular lines or CIA features.

What is the purpose of the DIT plot functions in ExoJAX?

The plot_dgmn and plot_dgm functions in src/exojax/plot/ditplot.py visualize the Discrete Integration Tree (DIT) and Modified DIT (MODIT) grids used for rapid opacity calculations. These plots display the sampling of Doppler broadening parameters (σD) and Lorentz broadening parameters (γL) across atmospheric pressure layers, helping verify that your grids adequately sample the line parameter space.

Can I overlay temperature-pressure profiles on optical depth plots?

Yes, the plottau function in src/exojax/plot/atmplot.py (lines 10–56) accepts optional Tarr and Parr parameters. When provided, the function overlays the temperature-pressure profile on the log-scaled optical depth map, allowing you to correlate atmospheric structure with opacity sources visually.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →