Skip to content

[Self consistency] Replace DataFrame-based tally conversion with n-D OFB tallies - #84

Closed
SteSeg wants to merge 6 commits into
eepeterson:developfrom
SteSeg:self-consistency_1_tallies
Closed

[Self consistency] Replace DataFrame-based tally conversion with n-D OFB tallies#84
SteSeg wants to merge 6 commits into
eepeterson:developfrom
SteSeg:self-consistency_1_tallies

Conversation

@SteSeg

@SteSeg SteSeg commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

[Self consistency] Replace DataFrame-based tally conversion with nD OFB tallies

Summary

This PR removes the intermediate pandas.DataFrame step when converting OpenMC tallies from a statepoint file to benchmark_results.h5.

Previously, tallies were converted as:

OpenMC tally -> pandas.DataFrame -> xarray.DataArray -> HDF5

Because DataFrames are inherently 2D, this imposed shape limitations and made it harder to preserve full tally structure.

With this PR, tallies are handled as true multi-dimensional arrays, consistent with OpenMC and with the OFB specification model.

What changes

  • Introduced BaseTally and Tally objects for OFB tally handling.
  • Added src/openmc_fusion_benchmarks/backends/ to support transport-code-specific conversions.
  • Implemented OpenMC backend conversion in src/openmc_fusion_benchmarks/backends/openmc/.
  • Updated result handling so dimensions are preserved according to the benchmark specification:
    • score
    • nuclide
    • filters
    • and any additional dimensions required by the spec.

Why this matters

  • Preserves physical/data structure of tallies end-to-end.
  • Removes artificial 2D constraints from the conversion pipeline.
  • Establishes a backend abstraction for future transport codes.
  • Aligns benchmark_results.h5 tally representation with OFB specification semantics.

Usage example

import openmc_fusion_benchmarks as ofb

# Load OFB benchmark results
br = ofb.BenchmarkResults("benchmark_results.h5")

# List available tallies
print(br.tallies)

# Retrieve one tally by name
my_tally = br.get_tally(name="mytally")

# Access mean values (xarray-backed)
mean = my_tally.mean

# Inspect shape
print(mean.shape)

Notes for reviewers

This PR is part of a stacked series.
Related PRs in this series use the [Self consistency] prefix.

@SteSeg SteSeg closed this Aug 14, 2026
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.

1 participant