Skip to content

Including ratio plotting functionality to xs_plotting - #307

Merged
gonuke merged 12 commits into
svalinn:mainfrom
eitan-weinstein:xs_relative_plots
Oct 13, 2026
Merged

gonuke merged 12 commits into
svalinn:mainfrom
eitan-weinstein:xs_relative_plots

Conversation

@eitan-weinstein

@eitan-weinstein eitan-weinstein commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Functionally follows #314 and #317, but only in DSV output formatting, not any direct code dependency.

Similar to the ratio plotting capabilities in alara_output_processing.alara_output_plotting.py, this PR introduces new functionality to xs_plotting.py to allow for the production of plots showing the ratios of groupwise cross-sections across different group structures. Given the inherent differences in energy group bounds/number of groups between different group structures, this PR includes a function compute_groupwise_xs_ratios() that constructs a union grid of the energies between both group structures and pulls the appropriate cross-sections at those energies from the existing groupwise values. Unlike the interpolation approach in #305, this is merely pulling existing cross-section values that fall within re-adjusted energy bins so that like-sized and matching-index arrays between two group structures of different sizes can be appropriately compared. These are then divided using np.divide().

This functionality will be useful in diagnosing more precisely the effects of choice of group structure has on any given activation cross-sections.

Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated
cross-sections were processed.
emitted (str): Particle(s) emitted from the nuclear reaction
corresponding to the MT number provided.
reference_group (str): Group name of the reference group against which

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Separation of concerns: can't we just have a method that only does this and we can avoid encoding "(reference)" into the string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could even simplify this further by not including any explicit reference tag, but rather just relying on ordering in the DSV section of the YAML. in compute_groupwise_xs_ratios(), the default option for the case when no reference is explicitly provided is to just take the first key in groupwise_dict with the command:

reference_group = reference_group or next(iter(groupwise_dict))

If we just specify in the documentation that the way to set the reference group is by placing its DSV path first amongst the DSVs in the YAML, then this can be accomplished much simpler and with cleaner inputs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, I think we can delete this entry in the comments now, right?

Comment thread tools/ALARAJOYWrapper/xs_plotting.py
Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated
`groupwise_dict`.
"""

def _re_bin_xs(bin_edges, xs, midpoints):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should discuss this approach. I wonder if you can put some diagrams together with all of the different cases you expect to see. Rebinning group x-sections is a fraught topic...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given our discussion last week and my introduction of the proposed changes in #314 that would allow us to compare directly against FISPACT-II's nuclear data, I'm going to abandon the re-binning approach. Instead, I'm going to necessitate that all ratio-plotted comparisons must have the same group bounds/nGroups so that cross-section division is unambiguously non-problematic.

@gonuke gonuke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few additional comments

Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated

for dsv in dsv_list:
with open(dsv, 'r') as f:
dsv_lines = f.readlines()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not critical, but something to think about: this could be written in a way that reads one line at a time...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I may as well change that over. Shouldn't be too big of a task, saves some memory.

Comment thread tools/ALARAJOYWrapper/xs_plotting.py
Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated
`groupwise_dict`.
"""

reference_group = next(iter(groupwise_dict))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not make this an input to the method, requiring the user to name their reference, rather than inferring it?

The user could infer it in the same way from outside the method before calling this method, if they like.

@eitan-weinstein
eitan-weinstein marked this pull request as draft September 17, 2026 21:01
@eitan-weinstein

Copy link
Copy Markdown
Contributor Author

Putting on pause until after #333 so that metadata parsed from DSV header can be used for series/plot identification.

@gonuke

gonuke commented Oct 5, 2026

Copy link
Copy Markdown
Member

This was on hold for #333 that is now merged - maybe a rebase (if necessary) and I can review...

@gonuke gonuke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few comments about reading the DSV and then I'll review again.

Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated
break

# Process metadata from first line
if i == 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do this before the for loop instead of testing each time through the loop

Comment thread tools/ALARAJOYWrapper/xs_plotting.py Outdated
}
break
# Reaction data parsing, search for matching (KZA, MT) pair
else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as discussed, look at switching to a CSV reader after processing the first line

@gonuke gonuke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - thanks @eitan-weinstein

@gonuke
gonuke merged commit df60554 into svalinn:main Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants