test_ctf fails on slurm-power9
The test test_ctf_id16_way
fails on power9 machines.
=================================== FAILURES ===================================
__________________________ TestCtf.test_ctf_id16_way ___________________________
self = <nabu.preproc.tests.test_ctf.TestCtf object at 0x7b445538b460>
@pytest.mark.skipif(not (__has_scipy__), reason="need scipy for this test")
def test_ctf_id16_way(self):
"""test the ctf phase retrieval.
The cft filter, of the CtfFilter class is iniitalised with the geomety informations contained in geo_pars object
of the GeoPars class.
The geometry encompass the case of astigmatic wavefront with a vertical and horisontal sources which are
at distance z1_vh[0] and z1_vh[1] from the object.
In the case of parllel geometry put z1_vh[0]= z1_vh[1] = R
where R is a large value ( meters).
SI unit system is used. But the same results shudl be obtained with any homogenuous choice of the distance units.
The img_shape is the shape of the images which will be processed.
padded_img_shape is an intermediate shape which needs to be larger that the img_shape to avoid border effect due
to convolutions.
Length scale is an internal parameters which should not affect in anyway the result unless there are serious numerical
problems involving very small lenghts. You can safely let the default value.
"""
geo_pars = ctf.GeoPars(
z1_vh=self.z1_vh,
z2=self.z2,
pix_size_det=self.pix_size_det,
length_scale=self.length_scale,
wavelength=self.wavelength,
)
flats = FlatFieldArrays(
[1200] + list(self.img_shape_vh), {0: self.flats[0], 1200: self.flats[1]}, {0: self.dark}
)
ctf_filter = ctf.CtfFilter(geo_pars, self.delta_beta, lim1=1.0e-5, lim2=0.2)
my_flat = flats.get_flat(self.ipro)
my_img = self.im - self.dark
my_flat = my_flat - self.dark
new_coordinates = estimate_flat_distortion(
my_flat, my_img, tile_size=100, interpolation_kind="cubic", padding_mode="edge", correction_spike_threshold=3
)
my_flat = scipy.interpolate.interpn(
(np.arange(my_flat.shape[1]), np.arange(my_flat.shape[0])),
my_flat,
new_coordinates,
bounds_error=False,
fill_value=None,
)
my_img = my_img / my_flat
my_img = correct_spikes(my_img, self.remove_spikes_threshold)
my_shift = self.rand_disp_vh[:, self.ipro]
phase = ctf_filter.retrieve_phase(
my_img, padded_shape=self.padded_img_shape_vh, translation_vh=my_shift, normalize_by_mean=True
)
message = "retrieved phase and reference result differ beyond the accepted tolerance"
> assert np.abs(phase - self.expected_result).max() < self.abs_tol * (np.abs(self.expected_result).mean()), message
E AssertionError: retrieved phase and reference result differ beyond the accepted tolerance
E assert 0.0005956705766606563 < (0.0001 * 0.64008147)
E + where 0.0005956705766606563 = <built-in method max of numpy.ndarray object at 0x7b44551fd390>()
E + where <built-in method max of numpy.ndarray object at 0x7b44551fd390> = array([[9.60246421e-07, 1.26016514e-06, 8.91851383e-07, ...,\n 2.78403748e-07, 7.37812167e-08, 3.07323566e-07],\n...\n [5.01280016e-07, 3.46655637e-07, 4.90881522e-07, ...,\n 9.00648477e-08, 4.38987304e-07, 7.22335660e-08]]).max
E + where array([[9.60246421e-07, 1.26016514e-06, 8.91851383e-07, ...,\n 2.78403748e-07, 7.37812167e-08, 3.07323566e-07],\n...\n [5.01280016e-07, 3.46655637e-07, 4.90881522e-07, ...,\n 9.00648477e-08, 4.38987304e-07, 7.22335660e-08]]) = <ufunc 'absolute'>((array([[0.77605218, 0.78665949, 0.76604438, ..., 0.67494981, 0.69868438,\n 0.68322308],\n [0.77816565, 0.77...02,\n 0.52784877],\n [0.53927871, 0.5719489 , 0.57991512, ..., 0.52485338, 0.48796286,\n 0.5272898 ]]) - array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32)))
E + where <ufunc 'absolute'> = np.abs
E + and array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32) = <nabu.preproc.tests.test_ctf.TestCtf object at 0x7b445538b460>.expected_result
E + and 0.0001 = <nabu.preproc.tests.test_ctf.TestCtf object at 0x7b445538b460>.abs_tol
E + and 0.64008147 = <built-in method mean of numpy.ndarray object at 0x7b44551fdf30>()
E + where <built-in method mean of numpy.ndarray object at 0x7b44551fdf30> = array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32).mean
E + where array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32) = <ufunc 'absolute'>(array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32))
E + where <ufunc 'absolute'> = np.abs
E + and array([[0.7760512 , 0.7866582 , 0.7660435 , ..., 0.6749495 , 0.69868445,\n 0.6832228 ],\n [0.7781643 , 0.77...2784836],\n [0.5392782 , 0.57194924, 0.5799146 , ..., 0.52485347, 0.48796242,\n 0.52728987]], dtype=float32) = <nabu.preproc.tests.test_ctf.TestCtf object at 0x7b445538b460>.expected_result
../fransson/.venv/slurm_matilda/lib/python3.8/site-packages/nabu/preproc/tests/test_ctf.py:106: AssertionError
----------------------------- Captured stdout call -----------------------------
Magnification : h (29.995019802214998) ; v (29.995019802214998)
All images are resampled to smallest pixelsize: 0.100 um
Normalized cut-off = 0.058
Taking into account absorption assuming homogeneous object.
Set delta_beta = 0 if this is not the purpose.