Skip to content

Crop component and tag arrays with the voxels in head_only_h5 - #944

Merged
agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/head-only-component-arrays
Nov 4, 2026
Merged

agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/head-only-component-arrays

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Title: Crop component and tag arrays with the voxels in head_only_h5

Fixes #943

extract_head only sliced /data and copied every other dataset unchanged. On a geometry file that also has /ID, /rigidE, /rigidH (from #geometry_objects_write) or /tag_data, the result had a cropped /data next to full-body component and tag arrays. #geometry_objects_read uses the component arrays whenever all three are present, so the head was given the IDs, rigid flags and tags from the bottom of the body without any error.

Change:

  • data, tag_data, ID, rigidE and rigidH are all cropped along the last (z) axis from first_head_plane, keeping their dtype, chunking/compression options and dataset attributes. ID is node-based (nz+1), so the same slice leaves it one node longer than data, as the reader expects.
  • Everything else (material keys, groups, root attributes) is still copied as before.

Testing:

  • Added test_extract_head_crops_component_and_tag_arrays_with_the_voxels in tests/toolboxes/test_head_only_h5.py. It fails on master (/ID comes back uncropped) and passes with this change.
  • pytest tests/toolboxes/test_head_only_h5.py: 5 passed.
  • black and isort (line length 100) on the changed files.

@agianno
agianno merged commit 8678299 into gprMax:master Nov 4, 2026
14 checks passed
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.

head_only_h5 crops /data but copies /ID, /rigidE, /rigidH and /tag_data uncropped

2 participants