Kernel crash when using fpd_file.make_updated_fpd_file
I am experiencing kernel crashes when trying to use the fpd_file.make_update_fpd_file
method. This occurs even when using a very simple function such as:
def test_func(image, scanYind, scanXind):
new_im = image + 10
return new_im
h5filename = 'data.hdf5'
out_filename = 'data_plus10.hdf5'
fpdf.make_updated_fpd_file(h5filename, out_filename, test_func)**
I have done some debugging of fpd_file.make_updated_fpd_file
and isolated the problem to the initialization of the new HDF5 file where the existing file structure is copied to the new file. In particular, the crash occurs at line 3321.
h5f.copy(h5f[k], new_file)
Further testing has turned out to make the situation more complex. For example, I mimicked the behavior in fpd_file.make_updated_fpd_file
to try to make a new version of an fpd file where I did not reshape the data, like this:
h5filename = "unshaped.hdf5"
data_4d, h5f = fpdf.fpd_to_tuple(h5filename, group_names=['fpd_data',])
with h5py.File('unshaped_copy.hdf5', 'w') as new_file:
### copy everything
for k, v in h5f.items():
h5f.copy(h5f[k], new_file)
for k, v in h5f.attrs.items():
#new_file.attrs.create(k, v)
new_file.attrs[k] = v
This works just fine. Although, interestingly, the new file is ~12kB smaller than the original.
Now, if I do something to the data, such as calculating the center of mass, and then try to save it in the same way. It fails. The code I used is:
h5filename = "unshaped.hdf5"
data_4d, h5f = fpdf.fpd_to_tuple(h5filename, group_names=['fpd_data',])
com_yx = fpdp.center_of_mass(data_4d.data, nc=None, nr=None, thr=100,
aperture=None, parallel=False, progress_bar=False, print_stats=True)
with h5py.File('unshaped_copy.hdf5', 'w') as new_file:
### copy everything
for k, v in h5f.items():
h5f.copy(h5f[k], new_file)
for k, v in h5f.attrs.items():
#new_file.attrs.create(k, v)
new_file.attrs[k] = v
Note that I have not actually changed the data, only calculated the center of mass. The crash occurs after > 99% of the data has been written to the new file.
Finally, if I run the same code as above, but this time calculate the center of mass on, for example, the sum pattern it works just fine:
h5filename = "unshaped.hdf5"
data_4d, sum_dif, h5f = fpdf.fpd_to_tuple(h5filename, group_names=['fpd_data','fpd_sum_dif',])
com_yx = fpdp.center_of_mass(sum_dif.data.reshape([1,1,256,256]), nc=None, nr=None, thr=100,
aperture=None, parallel=False, progress_bar=False, print_stats=True)
with h5py.File('unshaped_copy.hdf5', 'w') as new_file:
### copy everything
for k, v in h5f.items():
h5f.copy(h5f[k], new_file)
for k, v in h5f.attrs.items():
#new_file.attrs.create(k, v)
new_file.attrs[k] = v
It appears that as soon as anything is done with the data in the fpd_data group, copying the file structure to a new file crashes the kernel.