Skip to content

Commit

Permalink
Broadening test updates: use old cubic parametrisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed Jul 21, 2023
1 parent afafe9d commit de627ae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion euphonic/cli/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def energy_broadening_func(x):
dos = dos.broaden(x_width=energy_broadening_func,
shape=args.shape,
method='convolve',
width_interpolation_error=args.adaptive_error)
width_interpolation_error=args.adaptive_error,
fit='cubic')

elif args.inst_broadening:
# Fixed-width broadening
Expand Down
3 changes: 2 additions & 1 deletion euphonic/qpoint_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def _calculate_dos(self, dos_bins: Quantity,
dos = _width_interpolated_broadening(dos_bins_calc,
freqs, mode_widths,
combined_weights,
adaptive_error)
adaptive_error,
fit='cubic')
else:
bin_idx = np.digitize(freqs, dos_bins_calc)
# Create DOS with extra bin either side, for any points
Expand Down
12 changes: 8 additions & 4 deletions tests_and_analysis/test/euphonic_test/test_broadening.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def width_function(x):
width_function=width_function,
width_convention='STD',
weights=(y * bin_width), # Convert from spectrum heights to counts
adaptive_error=1e-5)
adaptive_error=1e-5,
fit='cubic')


npt.assert_allclose(exact, poly_broadened.to('1/meV').magnitude,
Expand All @@ -69,7 +70,8 @@ def test_area_unchanged_for_broadened_dos(material, qpt_freqs_json,
ebins,
qpt_freqs.frequencies,
mode_widths, weights,
0.01)
0.01,
fit='cubic')
ebins_centres = ebins.magnitude[:-1] + 0.5*np.diff(ebins.magnitude)
assert dos.y_data.units == 1/ebins.units
dos_area = simps(dos.y_data.magnitude, ebins_centres)
Expand Down Expand Up @@ -98,7 +100,8 @@ def test_lower_bound_widths_broadened(material, qpt_freqs_json,
weights = np.ones(qpt_freqs.frequencies.shape) * \
np.full(qpt_freqs.n_qpts, 1/qpt_freqs.n_qpts)[:, np.newaxis]
dos = width_interpolated_broadening(ebins, qpt_freqs.frequencies,
mode_widths, weights, 0.01)
mode_widths, weights, 0.01,
fit='cubic')
expected_dos = get_expected_spectrum1d(expected_dos_json)
npt.assert_allclose(expected_dos.y_data.magnitude, dos.magnitude)

Expand All @@ -114,7 +117,8 @@ def test_uneven_bin_width_raises_warning():
np.arange(100, 155, 0.2)))*ureg('meV')
with pytest.warns(UserWarning):
width_interpolated_broadening(ebins, qpt_freqs.frequencies,
mode_widths, weights, 0.01)
mode_widths, weights, 0.01,
fit='cubic')


@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions tests_and_analysis/test/euphonic_test/test_spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ def fwhm_function(x):
fixed_broad = spec1d.broaden(fwhm)
variable_broad_sigma = spec1d.broaden(
sigma_function, width_convention='std',
width_interpolation_error=1e-5)
width_interpolation_error=1e-3)
variable_broad_fwhm = spec1d.broaden(
fwhm_function, width_convention='FWHM',
width_interpolation_error=1e-5)
width_interpolation_error=1e-3)

check_spectrum1d(variable_broad_sigma, variable_broad_fwhm)
check_spectrum1d(variable_broad_sigma, fixed_broad, y_atol=1e-4)
Expand Down
4 changes: 2 additions & 2 deletions tests_and_analysis/test/euphonic_test/test_spectrum2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def sigma_function(x):

fixed_broad_y = spectrum.broaden(y_width=fwhm)
variable_broad_y = spectrum.broaden(
y_width=sigma_function, width_convention='std')
y_width=sigma_function, width_convention='std', fit='cubic')

check_spectrum2d(fixed_broad_y, variable_broad_y)

Expand All @@ -398,7 +398,7 @@ def sigma_function(x):
) * spectrum.get_bin_edges().units
fixed_broad_x = spectrum.broaden(x_width=fwhm)
variable_broad_x = spectrum.broaden(
x_width=sigma_function, width_convention='std')
x_width=sigma_function, width_convention='std', fit='cubic')
check_spectrum2d(fixed_broad_x, variable_broad_x, z_atol=1e-10)

@pytest.mark.parametrize(
Expand Down

0 comments on commit de627ae

Please sign in to comment.