Skip to content

feat: native XYZTS (tsheader_procP3) support in XYTSFile#368

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/update-volumetric-xyzts-support
Draft

feat: native XYZTS (tsheader_procP3) support in XYTSFile#368
Copilot wants to merge 5 commits into
masterfrom
copilot/update-volumetric-xyzts-support

Conversation

Copilot AI commented May 25, 2026

Copy link
Copy Markdown

Summary

Generalises the existing XYTSFile parser in qcore/xyts.py to natively support EMOD3D v3.0.13 volumetric xyzts proc-local files (tsheader_procP3, 72-byte header) without requiring any user flag.

Background

In EMOD3D ≥ v3.0.13, volumetric output (ts_xyz) writes one proc-local file per MPI rank. Each file uses the tsheader_procP3 header (72 bytes) that stores loc_nx / loc_ny / loc_nz and then appends nt × ncomp × local_nz × local_ny × local_nx contiguous float32 values. ncomp is 3, 6, or 9 depending on ts_xyz_ncomp. Filenames follow the *_xyzts-* pattern.

The previous reader required proc_local_file=True and only handled local_nz == 1 surface slices.

Changes

qcore/xyts.py

Area Change
Module docstring Documents all three supported layouts
_MAX_GRID_DIM constant Named constant (= 0xFFFF) used in endianness detection; includes explanatory comment
XYTSFile.ncomp New dataclass attribute; always 3 for standard XYTS
__init__ – Step 1 (detection) If the 7th header word ≠ 1, treat as proc-local XYZTS; determine endianness from local_nx / local_ny plausibility against _MAX_GRID_DIM
__init__ – Step 3 (ncomp) Derive ncomp from file size; validate result ∈ {3, 6, 9} with a descriptive ValueError
__init__ – Step 4 (memmap) 5-D shape (nt, ncomp, local_nz, local_ny, local_nx) for XYZTS; 4-D (backwards-compatible) for proc-local XYTS with local_nz == 1
tslice_get Raises ValueError with guidance for XYZTS files (local_nz > 1)
pgv Raises ValueError for XYZTS files
proc_local_file flag Retained for backwards compatibility (proc-local XYTS, local_nz == 1)

qcore/test/test_xyts/test_xyts.py

Ten new tests using fully synthetic binary data (no network required):

  • test_xyzts_auto_detection – parametrised over endianness and ncomp ∈ {3, 6, 9}
  • test_xyzts_data_shape – 5-D memmap shape check (both endians)
  • test_xyzts_payload_values – round-trip value accuracy
  • test_xyzts_tslice_get_raisesValueError guard
  • test_xyzts_pgv_raisesValueError guard
  • test_xyzts_meta_onlymeta_only=True leaves data=None

Testing

python -m pytest qcore/test/test_xyts/test_xyts.py -k "xyzts" -v
# → 10 passed

Copilot AI and others added 4 commits May 25, 2026 03:44
Agent-Logs-Url: https://github.com/ucgmsim/qcore/sessions/6829334f-dcbc-47d2-9f97-d63ebff1bb3a

Co-authored-by: lispandfound <12835929+lispandfound@users.noreply.github.com>
…leanup)

Agent-Logs-Url: https://github.com/ucgmsim/qcore/sessions/6829334f-dcbc-47d2-9f97-d63ebff1bb3a

Co-authored-by: lispandfound <12835929+lispandfound@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ucgmsim/qcore/sessions/6829334f-dcbc-47d2-9f97-d63ebff1bb3a

Co-authored-by: lispandfound <12835929+lispandfound@users.noreply.github.com>

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.

You've accidentally committed in the egg-info directory

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed in 2da41e0 — added qcore_utils.egg-info/ to .gitignore and unstaged all five files.

Comment thread qcore/xyts.py Outdated
nz = np.fromfile(xytf, dtype=">i4", count=7)[-1]
if nz == 0x00000001:
# ---------------------------------------------------------------
# Step 1 – determine endianness and whether this is a proc-local

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.

Step 1, step 2 nonsense not required.

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.

Byte layout of header is helpful. everything else is noise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 2da41e0 — replaced the "Step 1/2/3/4" banner comments with a single block that shows the byte layout of both header variants (standard XYTS and proc-local XYZTS). All other prose removed.

Comment thread qcore/test/test_xyts/test_xyts.py Outdated


# ---------------------------------------------------------------------------
# XYZTS-specific tests (use synthetic data; no network required)

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.

This header can be deleted.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed in 2da41e0.

Comment thread qcore/test/test_xyts/test_xyts.py Outdated
Comment on lines +258 to +262
# Common dimensions used across XYZTS tests
_LOCAL_NX, _LOCAL_NY, _LOCAL_NZ = 4, 5, 3
_GLOBAL_NX, _GLOBAL_NY = 20, 20
_NT = 6

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.

rather than fixing these a composite hypothesis strategy to generate them is better.

Comment thread qcore/test/test_xyts/test_xyts.py Outdated
Comment on lines +264 to +267
@pytest.fixture(scope="module")
def rng() -> np.random.Generator:
"""Fixed-seed random number generator for reproducible tests."""
return np.random.default_rng(42)

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.

hypothesis does this better.

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.

Make use of hypothesis to automatically generate payloads and then parse them. See the test_timeseries.py code for inspiration

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 2da41e0. Replaced the rng-fixture + @parametrize tests with a @st.composite strategy xyzts_file_data that generates endianness, ncomp, all dimensions, and the full payload via hypothesis.extra.numpy.arrays. Four @given tests now cover round-trip parsing, tslice_get guard, pgv guard, and meta_only — closely following the test_timeseries.py pattern.

…xyts.py comments, remove egg-info

Agent-Logs-Url: https://github.com/ucgmsim/qcore/sessions/83689858-8f50-44f9-83e1-452c23694707

Co-authored-by: lispandfound <12835929+lispandfound@users.noreply.github.com>
Copilot AI requested a review from lispandfound May 25, 2026 04:02
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.

2 participants