nexusformat / features

Work on NeXus features and recipes by the NIAC and friends
0 stars 6 forks source link

Add geometry feature #31

Closed matthew-d-jones closed 6 years ago

matthew-d-jones commented 6 years ago

Example code demonstrates how to write shape information from an OFF file to an NXoff_geometry group in a NeXus file. It also shows how to output entire instrument geometry, comprising NXoff_geometry, NXcylindrical_geometry and NXtransformations as a single OFF file which can then be opened in CAD software.

A file passes as compatible with the feature if it has at least one NXoff_geometry or NXcylindrical_geometry group containing the expected datasets for that NXclass.

Includes example file example_nx_geometry.nxs

To Test: You can test by adding these lines to 8CB1EBAE3B2DA51D/recipe.py and running it:

if __name__ == "__main__":
    nx_file = h5py.File("../../../examples/example_nx_geometry.nxs", "r")
    example = NeXusOFF(nx_file["raw_data_1"])
    example.output_shape_to_off_file("example.off")

I've been using Geomview to render OFF files. The download page contains OSX build instructions and rpm and deb packages, or on Ubuntu you can just apt install geomview.

matthew-d-jones commented 6 years ago

@zjttoefs Example code now demonstrates outputting complete geometry to an OFF file; I've updated the PR description.

zjttoefs commented 6 years ago

Looked a bit more in detail. I've pushed a commit with a class name that's at least somewhat better. I've also changed the title. No need for "example". Still need to confirm it actually merges multiple OFF buckets correctly (and if so under which circumstances).