Skip to content

[Scripting] Add block listing and per-block statistics - #288

Closed
BenWibking wants to merge 1 commit into
analysis-4-parallelfrom
analysis-5-blocks
Closed

BenWibking wants to merge 1 commit into
analysis-4-parallelfrom
analysis-5-blocks

Conversation

@BenWibking

@BenWibking BenWibking commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

A plotfile's own grid structure, alongside the leaf-cell view.

  • listBlocks (C++) and Dataset.blocks() (Python) list every grid (FAB) by level and native FAB index, with:
    • valid box and physical bounds
    • cell count and covered cells (Python adds covered_fraction)
    • data file and offset
  • blockStatistics and Dataset.block_statistics(fields) give per-grid minima and maxima from the decoded data, NaN ignored; an all-NaN block reports NaN.
    • A stored field's extrema cover the whole on-disk FAB, covered and stored ghost cells included.
    • A derived field's extrema cover its valid box.
    • Each entry says which box it covered.
  • python/examples/plotfile_fab_minmax.py ports Kangaroo's script of the same name onto these, keeping its arguments and report. The next PR compares the two.

Example:

with amrexplorer.open_plotfile(args.plotfile) as ds:
    names = ds.stored_fields
    levels = range(ds.finest_level + 1)
    for level in levels:
        nfabs = ds.levels[level]["num_grids"]
        print(f"Level {level}: {nfabs} FABs")
        for entry in ds.block_statistics(names, level=level, grid=args.fab):
            print(f"  FAB {entry['grid']}:")
            for c, name in enumerate(names):
                lo = entry["minimum"][name]
                hi = entry["maximum"][name]
                print(f"    {c:02d} {name}: min={lo:.6e} max={hi:.6e}")

Tests

  • test_blocks.py:
    • listing order and covered counts
    • extrema including stored ghost cells and covered cells
    • NaN handling
  • test_batch.py cancels block_statistics with a CancelToken.
  • The headless ctest suite passes (65 tests).

Stack

Part of a stack replacing #276. Review and merge in order; each PR shows only its own layer.

  1. [Scripting] Generalize PlotfileDataset and the cache budget for analysis tools #289 Prepare PlotfileDataset and the cache budget for analysis
  2. [Scripting] Add iteration plans for leaf-cell chunks #285 Exact leaf-cell plans and chunks (C++)
  3. [Scripting] Add the amrexplorer Python package for batch analysis #286 The amrexplorer Python package (bindings)
  4. [Scripting] Add map-reduce parallel reductions over leaf cells #287 Parallel reductions and batch helpers
  5. [Scripting] Add block listing and per-block statistics #288 Block listing and per-block statistics ← this PR
  6. [Scripting] Add manual validation tools for the analysis package #290 Validation tools

🤖 Generated with Claude Code

src/analysis lists a plotfile's grids (FABs) by level and native FAB
index, with valid box, bounds, covered cells, and data file, and
computes per-grid minima and maxima of fields from the decoded data,
NaN ignored. The Python package exposes both as Dataset.blocks and
Dataset.block_statistics.

python/examples/plotfile_fab_minmax.py ports Kangaroo's script of the
same name onto them, keeping its arguments and report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenWibking
BenWibking removed this pull request from stack #291 October 29, 2026 03:53
@BenWibking
BenWibking added this pull request to stack #292 October 29, 2026 03:53
@BenWibking

Copy link
Copy Markdown
Contributor Author

Dropping this layer from the stack: per-block analysis is only used by the plotfile_fab_minmax.py demo, so it isn't needed. The commit is still preserved on the analysis-deferred branch.

@BenWibking BenWibking closed this Nov 2, 2026
@BenWibking
BenWibking deleted the analysis-5-blocks branch November 2, 2026 16:20
@BenWibking
BenWibking removed this pull request from stack #292 November 2, 2026 16:22
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