|
1 | 1 | import numpy as np
|
2 | 2 | import pytest
|
3 | 3 |
|
4 |
| -from diffpy.labpdfproc.functions import Gridded_circle, compute_cve |
| 4 | +from diffpy.labpdfproc.functions import Gridded_circle, apply_corr, compute_cve |
5 | 5 | from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object
|
6 | 6 |
|
7 | 7 | params1 = [
|
@@ -80,3 +80,39 @@ def test_compute_cve(mocker):
|
80 | 80 | scat_quantity="cve",
|
81 | 81 | )
|
82 | 82 | assert actual_abdo == expected_abdo
|
| 83 | + |
| 84 | + |
| 85 | +def test_apply_corr(mocker): |
| 86 | + mocker.patch("diffpy.labpdfproc.functions.N_POINTS_ON_DIAMETER", 4) |
| 87 | + mocker.patch("diffpy.labpdfproc.functions.TTH_GRID", np.array([45, 60, 90])) |
| 88 | + input_pattern = Diffraction_object(wavelength=1.54) |
| 89 | + input_pattern.insert_scattering_quantity( |
| 90 | + np.array([45, 60, 90]), |
| 91 | + np.array([2.2, 3, 4]), |
| 92 | + "tth", |
| 93 | + scat_quantity="x-ray", |
| 94 | + name="test", |
| 95 | + metadata={"thing1": 1, "thing2": "thing2"}, |
| 96 | + ) |
| 97 | + absorption_correction = Diffraction_object() |
| 98 | + absorption_correction.insert_scattering_quantity( |
| 99 | + np.array([45, 60, 90]), |
| 100 | + np.array([2.54253, 2.52852, 2.49717]), |
| 101 | + "tth", |
| 102 | + metadata={"thing1": 1, "thing2": "thing2"}, |
| 103 | + name="absorption correction, cve, for test", |
| 104 | + wavelength=1.54, |
| 105 | + scat_quantity="cve", |
| 106 | + ) |
| 107 | + actual_corr = apply_corr(input_pattern, absorption_correction) |
| 108 | + expected_corr = Diffraction_object() |
| 109 | + expected_corr.insert_scattering_quantity( |
| 110 | + np.array([45, 60, 90]), |
| 111 | + np.array([5.59357, 7.58556, 9.98868]), |
| 112 | + "tth", |
| 113 | + metadata={"thing1": 1, "thing2": "thing2"}, |
| 114 | + name="test", |
| 115 | + wavelength=1.54, |
| 116 | + scat_quantity="x-ray", |
| 117 | + ) |
| 118 | + assert actual_corr == expected_corr |
0 commit comments