Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance H5 I/O #2

Merged
merged 16 commits into from
Feb 14, 2025
Merged

Enhance H5 I/O #2

merged 16 commits into from
Feb 14, 2025

Conversation

dimitrivlachos
Copy link
Contributor

@dimitrivlachos dimitrivlachos commented Jan 27, 2025

Create a generic H5 writer — along with unit tests — that can take
generic data and write it to a file. As well as adding more robust error
handling to the reader.

  • Create new subdirectory h5 in include/dx2 to logically group h5
    related code.
  • Create new header file dx2/h5/h5write.hpp to define the writer.
  • Move h5read_processed into dx2/h5 and add error handling.
  • Create new test file test/test_write_h5_array.cxx for validation.
  • Modify CMakeLists.txt to include the new header file, tests and
    changes to allow this to be included by other projects.

@dimitrivlachos dimitrivlachos force-pushed the h5_writer branch 4 times, most recently from 729df1d to 7244d40 Compare January 28, 2025 11:39
@dimitrivlachos dimitrivlachos changed the title Add basic H5 writer and test Enhance H5 I/O Jan 28, 2025
@dimitrivlachos dimitrivlachos self-assigned this Jan 30, 2025
@dimitrivlachos dimitrivlachos added the enhancement New feature or request label Jan 30, 2025
@dimitrivlachos dimitrivlachos marked this pull request as ready for review February 3, 2025 09:08
@dimitrivlachos dimitrivlachos force-pushed the h5_writer branch 2 times, most recently from 6d65bd2 to d79c340 Compare February 4, 2025 18:27
)
export(EXPORT DX2Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/DX2Targets.cmake"
)
Copy link
Contributor Author

@dimitrivlachos dimitrivlachos Feb 7, 2025

Choose a reason for hiding this comment

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

@ndevenish I probably shouldn't keep all of this commented. Should I? Or is it something we can come back to later when we're going to need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The decision is we will revisit this later when we need it as the repo is still in an early state

Copy link
Contributor

@jbeilstenedmands jbeilstenedmands left a comment

Choose a reason for hiding this comment

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

Thanks for adding this. This all looks and works fine, I'm not sure we need to fix the cmake installation as part of this work, better to address that separately in my opinion.
Just to note that when we use these functions to write multiple data arrays to a single h5 file, if we want the file to be readable as a dials reflection table, we will need to ensure that the arrays in a group all have the same length (in the leading/trailing? dimension for multi-dimensional vectors) - but I think this should be enforced by the reflection table class using these functions, rather than checking in these functions on each call to write.

@dimitrivlachos
Copy link
Contributor Author

Thanks for adding this. This all looks and works fine, I'm not sure we need to fix the cmake installation as part of this work, better to address that separately in my opinion.

I agree. I think this will be fine to merge as-is — especially in these early stages — and we can come back and fix this as needed.

Just to note that when we use these functions to write multiple data arrays to a single h5 file, if we want the file to be readable as a dials reflection table, we will need to ensure that the arrays in a group all have the same length (in the leading/trailing? dimension for multi-dimensional vectors) - but I think this should be enforced by the reflection table class using these functions, rather than checking in these functions on each call to write.

Correct @jbeilstenedmands. As it stands, this implementation of write_data_to_h5_file naïvely writes any array of data, anywhere you ask it to. This is intentional, as the act of ensuring array length matching is not intrinsic to writing data to an H5 file. It is conceivable that write_data_to_h5_file could be used on its own, thus ensuring array length integrity across datasets in a reflection table will be the responsibility of the reflection table class and not the h5write implementation. 😄

Copy link
Member

@ndevenish ndevenish left a comment

Choose a reason for hiding this comment

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

After discussion we want to make some changes going on but this is fine to go in now for cross-development purposes.

@dimitrivlachos dimitrivlachos merged commit 556051d into main Feb 14, 2025
5 checks passed
@dimitrivlachos dimitrivlachos deleted the h5_writer branch February 14, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants