Issue in writing 'binary_hdr' group in make_updated_fpd_file
This issue is similar, but distinct from issue 38. The following code causes the kernel to crash on a Windows machine when data.hdf5
was created using a DM file to define the scan shape. The crash does not occur if the scan shape was not given during the packing operation.
import fpd.fpd_file as fpdf
h5filename = "data.hdf5"
new_filename = "data_new.hdf5"
def test_func(image, scanYind, scanXind, value):
new_im = image + value
return new_im
fpdf.make_updated_fpd_file(h5filename, new_filename, test_func,
func_kwargs={'value': 10},
ow=True, reopen_file=True)
I have done some testing using the code below; commenting each line until I found the line that cause the kernel to crash. All of the write commands work with the exception of the h5f.copy(h5f['fpd_expt']['binary_hdr'], new_file)
line.
import h5py
closef, h5f = fpdf._get_hdf5_file_from_obj(h5filename)
with h5py.File('./test.hdf5', 'w') as new_file:
h5f.copy(h5f['fpd_expt']['DAC'], new_file)
h5f.copy(h5f['fpd_expt']['DM0'], new_file)
h5f.copy(h5f['fpd_expt']['Exposure'], new_file)
h5f.copy(h5f['fpd_expt']['Threshold'], new_file)
h5f.copy(h5f['fpd_expt']['Unixtime'], new_file)
h5f.copy(h5f['fpd_expt']['binary_hdr'], new_file)
h5f.copy(h5f['fpd_expt']['fpd_sum_dif'], new_file)
h5f.copy(h5f['fpd_expt']['fpd_sum_im'], new_file)
h5f.copy(h5f['fpd_expt']['merlin_hdr'], new_file)
h5f.copy(h5f['fpd_expt']['fpd_data'], new_file)
I cannot see anything strange in the contents of h5f['fpd_expt']['binary_hdr']. It contains three members: 'data', 'dim1', and 'dim2'. The shape of each of these is as expected: (scanX, scanY), (scanX,), and (scanY,). The values in 'dim1' and 'dim2' are floating point numbers defining the scan axes. Finally, the contents of each value in 'data' are bytes that decode to the binary header of the original MIB file. For example, h5f['fpd_expt']['binary_hdr']['data'][0,0]
returns:
b'MQ1,000001,00384,01,0256,0256,U16, 1x1,01,2020-12-09 16:06:12.094825,0.002028,0,0,0,3.200000E+1,5.110000E+2,0.000000E+0,0.000000E+0,0.000000E+0,0.000000E+0,0.000000E+0,0.000000E+0,3RX,059,511,000,000,000,000,000,000,100,255,200,125,100,100,098,100,104,050,128,004,255,084,128,135,125,511,511,MQ1A,2020-12-09T21:06:12.094825686Z,2027820ns,12,'
All values in h5f['fpd_expt']['binary_hdr']['data']
are similar with the exception that the frame number, time stamp, etc. advance as expected and the header appears to be identical to that contained in the same portion of the hdf5 file from unshaped data.