def save_mantid_MDHisto(dataArray, filename):
    """Save a file that can be read in using Mantid's LoadMD"""
    import h5py
    import numpy as np
    f = h5py.File(filename, 'w')
    top = f.create_group('MDHistoWorkspace')
    top.attrs['NX_class'] = 'NXentry'
    top.attrs['SaveMDVersion'] = 2
    data = top.create_group('data')
    data.attrs['NX_class'] = 'NXdata'
    signal = data.create_dataset('signal', data=dataArray.values,
        compression='gzip')
    signal.attrs['axes'] = ':'.join(dataArray.coords.dims)
    signal.attrs['signal'] = 1
    for axis in dataArray.coords.dims:
        axis_array = dataArray.coords[axis].values
        bin_size = (axis_array[-1] - axis_array[0]) / (len(axis_array) - 1)
        axis_array -= bin_size * 0.5
        axis_array = np.append(axis_array, axis_array[-1] + bin_size)
        a = data.create_dataset(axis, data=axis_array)
        a.attrs['frame'] = 'HKL'
        a.attrs['long_name'] = axis
        a.attrs['units'] = 'A^-1'
    data.create_dataset('errors_squared', data=dataArray.values,
        compression='gzip')
    data.create_dataset('mask', data=np.zeros(dataArray.shape, dtype=np.
        int8), compression='gzip')
    data.create_dataset('num_events', data=np.ones(dataArray.shape),
        compression='gzip')
    f.close()
