Skip to content

Commit

Permalink
fix test for specrtum area as a fn of sidebands
Browse files Browse the repository at this point in the history
fix bug cause spectral area to change as counts change.
  • Loading branch information
deepanshs committed Jul 25, 2020
1 parent cae25e1 commit ddedd8b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Bug fixes

- Fixed bug resulting from the rotation of the fourth rank tensor with non-zero euler
angles.
- Fixed bug causing a change in the spectral area as the sampling points change. Now the
area is constant.

Other changes
'''''''''''''
Expand Down
4 changes: 3 additions & 1 deletion src/c_lib/base/base_model.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def one_d_spectrum(method,
&incre[0], &magnetic_flux_density_in_T[0], &srfiH[0],
&rair[0], &n_event[0], n_sequence, number_of_sidebands)

# normalization factor for the spectrum
norm = np.prod(incre)

# create fftw scheme __________________________________________________________

Expand Down Expand Up @@ -386,7 +388,7 @@ def one_d_spectrum(method,
interpolation,
)

temp = amp*abundance
temp = amp*abundance/norm

## reverse the spectrum if gyromagnetic ratio is positive.
if gyromagnetic_ratio < 0:
Expand Down
2 changes: 1 addition & 1 deletion src/mrsimulator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
See https://mrsimulator.readthedocs.io/en/stable/ for complete documentation.
"""
# version has to be specified at the start.
__version__ = "0.3.0a1"
__version__ = "0.3.0a2"

from .spin_system import Site # lgtm [py/import-own-module]
from .spin_system import SpinSystem # lgtm [py/import-own-module]
Expand Down
9 changes: 6 additions & 3 deletions tests/test_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_with_configuration_setting():
err_msg="Integral error from νr, integration density, integration volume.",
)

sim.methods[0].spectral_dimensions[0].count = 256
sim.config.number_of_sidebands = 256
sim.run()
y_spinning_MAS_1 = sim.methods[0].simulation.dependent_variables[0].components[0]

Expand All @@ -97,14 +97,17 @@ def test_number_of_points():
sim.methods[0].spectral_dimensions[0].count = 2048
sim.run()
y_static = sim.methods[0].simulation.dependent_variables[0].components[0]
inc = sim.methods[0].simulation.dimensions[0].increment.to("Hz").value

sim.methods[0].spectral_dimensions[0].count = 4096
sim.run()
y_static_1 = sim.methods[0].simulation.dependent_variables[0].components[0]
inc_1 = sim.methods[0].simulation.dimensions[0].increment.to("Hz").value

print(inc, inc_1)
np.testing.assert_almost_equal(
y_static.sum(),
y_static_1.sum(),
y_static.sum() * inc,
y_static_1.sum() * inc_1,
decimal=8,
err_msg="Integral error from number_of_points",
)

0 comments on commit ddedd8b

Please sign in to comment.