Plot scattering cross section#92
Merged
rcjackson merged 4 commits intoJul 24, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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(...). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
rcjackson
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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$ .