Skip to content

Plot scattering cross section#92

Merged
rcjackson merged 4 commits into
ARM-DOE:mainfrom
jtgasparik:plot_scattering_cross_section
Jul 24, 2026
Merged

Plot scattering cross section#92
rcjackson merged 4 commits into
ARM-DOE:mainfrom
jtgasparik:plot_scattering_cross_section

Conversation

@jtgasparik

Copy link
Copy Markdown
Collaborator

Function and associated pytest-mpl to plot the differential scattering cross section of a particle integrated over the solid angle of light collection, $\Delta C_{\rm sca}$, computed from computed parameters $\tau$ and $\sigma$.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new visualization helper to plot the differential scattering cross section, (\Delta C_{\rm sca}), derived from the Moteki & Kondo (\tau)/(\sigma) fit outputs, and introduces a pytest-mpl image-comparison test to validate the plot output.

Changes:

  • Added plot_scattering_cross_section(...) to compute and plot (\Delta C_{\rm sca}(t)) using the normalized incident irradiance profile.
  • Added a new pytest-mpl test (test_plot_scattering_cross_section) that runs the tau/sigma workflow and snapshots the resulting figure.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
pysp2/util/normalized_derivative_method.py Adds plot_scattering_cross_section to compute and plot the derived scattering cross section from Moteki & Kondo outputs.
tests/test_vis.py Adds a pytest-mpl image regression test that exercises the new plotting function end-to-end.
Comments suppressed due to low confidence (2)

pysp2/util/normalized_derivative_method.py:1358

  • The time-axis conversion for time_units='s' is inverted: the code multiplies by 1e6 (microseconds) while labeling seconds. This makes the x-axis values incorrect and also forces the incident-irradiance evaluation to use inconsistent units.
    if time_units == "us":
        t_plot = t
        x_label = r"Time ($\rm \mu$s)"
    elif time_units == "s":
        t_plot = t * 1e6

pysp2/util/normalized_derivative_method.py:1285

  • Docstring defaults/units don’t match the actual signature: calibration_constant defaults to 1.22e-17/2.44, and h is treated as a bin width in microseconds (consistent with compute_normalized_incident_irradiance_moteki_kondo() and plot_incident_irradiance), not seconds.
    calibration_constant : float, default 1.22e-17  # (m²/2.44 mV)
        Scale factor applied to S / (I/I0).
        Default value from Moteki & Kondo (2008).
    h : float, default 0.4e-6
        Sampling interval in seconds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1256 to +1260
The cross section is computed as:

ΔC_sca(t) = calibration_constant * S(t) / I(t)

where I(t)/I0 is obtained from compute_normalized_incident_irradiance_moteki_kondo(...).
Comment thread tests/test_vis.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@rcjackson rcjackson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot gave good suggestions this time. I have nothing else to add! Merging after tests pass.

@rcjackson
rcjackson merged commit 07c6aee into ARM-DOE:main Jul 24, 2026
20 checks passed
@jtgasparik
jtgasparik deleted the plot_scattering_cross_section branch July 24, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants