mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
212 stars 125 forks source link

Investigate the HDF4 dependency problem for old Muon files #38214

Open robertapplin opened 1 month ago

robertapplin commented 1 month ago

Description We currently use the Nexus API to load files into Mantid. This API makes a choice between using HDF4 or HDF5 depending on the type of the nexus file. The problem is that the Nexus API is now unsupported.

We also want to consolidate the methods we use to load nexus files into Mantid. However, two of the muon load algorithms (LoadMuonNexus1 and LoadMuonNexus2) are used to load old muon nexus files which are in a HDF4 format.

We want to move away from using the Nexus API during this consolidation, and also to avoid using something which is unsupported. How might we do this?

Solutions considered One solution might be to use the following code https://github.com/nexusformat/code/blob/5b803b3a0014bd9759b3d846da3cd3c1cfafd7d5/applications/NXconvert/nxconvert_common.cpp#L4

to convert old HDF4 nexus files into a HDF5 format before loading the data. We would then no longer require HDF4 as a dependency in our codebase. The problem with this is that we would be loading the file twice, once to do the conversion and a second time for the actual loading. Another problem is that we would still rely on the Nexus API code to do the conversion.

A better solution would be to isolate the HDF4 loading related code in Mantid into its own library so we can confine where it is being used. We could then re-write the code so that we use HDF4 directly rather than using it indirectly through the Nexus API. This way we no longer use an API which is unsupported, and we also make it clear that HDF4 is only be used in the isolated library.

Acceptance Criteria

robertapplin commented 1 month ago

It appears the loading of HDF4 muon files is done by the LoadMuonNexus1 and LoadMuonNexus2 algorithms, and the loading of HDF5 muon files is done by LoadMuonNexusV2.