def setUp(self): """To test the kramers_kronig_analysis we will generate 3 EELSSpectrum instances. First a model energy loss function(ELF), in our case following the Drude bulk plasmon peak. Second, we simulate the inelastic scattering to generate a model scattering distribution (SPC). Finally, we use a lorentzian peak with integral equal to 1 to simulate a ZLP. """ # Parameters i0 = 1. t = signals.Signal(np.arange(10, 70, 10).reshape((2, 3))) # thickness t.axes_manager.set_signal_dimension(0) scale = 0.02 # Create an 3x2x2048 spectrum with Drude plasmon s = EELSSpectrum(np.zeros((2, 3, 2 * 2048))) s.set_microscope_parameters(beam_energy=300.0, convergence_angle=5, collection_angle=10.0) s.axes_manager.signal_axes[0].scale = scale k = eels_constant(s, i0, t) vpm = VolumePlasmonDrude() m = create_model(s, auto_background=False) m.append(vpm) vpm.intensity.map['values'][:] = 1 vpm.plasmon_energy.map['values'] = np.array([[8., 18.4, 15.8], [16.6, 4.3, 3.7]]) vpm.fwhm.map['values'] = np.array([[2.3, 4.8, 0.53], [3.7, 0.3, 0.3]]) vpm.intensity.map['is_set'][:] = True vpm.plasmon_energy.map['is_set'][:] = True vpm.fwhm.map['is_set'][:] = True s.data = (m.as_signal() * k).data # Create ZLP z = s.deepcopy() z.axes_manager.signal_axes[0].scale = scale z.axes_manager.signal_axes[0].offset = -10 zlp = Lorentzian() zlp.A.value = i0 zlp.gamma.value = 0.2 zlp.centre.value = 0.0 z.data[:] = zlp.function(z.axes_manager[-1].axis).reshape((1, 1, -1)) z.data *= scale self.s = s self.thickness = t self.k = k self.zlp = z
def test_eels(): s = EELSSpectrum(([0, 1])) s0 = s.deepcopy() s.axes_manager[0].convert_to_non_uniform_axis() with pytest.raises(NotImplementedError): s.align_zero_loss_peak() with pytest.raises(NotImplementedError): s.create_model(ll=s) with pytest.raises(NotImplementedError): s.fourier_log_deconvolution(0) with pytest.raises(NotImplementedError): s.fourier_ratio_deconvolution(s) with pytest.raises(NotImplementedError): s.fourier_ratio_deconvolution(s0) with pytest.raises(NotImplementedError): s0.fourier_ratio_deconvolution(s) with pytest.raises(NotImplementedError): s.richardson_lucy_deconvolution(s) with pytest.raises(NotImplementedError): s.kramers_kronig_analysis() m = s.create_model() g = EELSCLEdge('N_K') with pytest.raises(NotImplementedError): m.append(g)