diff --git a/packages/esssans/docs/user-guide/loki/loki-direct-beam.ipynb b/packages/esssans/docs/user-guide/loki/loki-direct-beam.ipynb index 26c8b9f99..83e03afc1 100644 --- a/packages/esssans/docs/user-guide/loki/loki-direct-beam.ipynb +++ b/packages/esssans/docs/user-guide/loki/loki-direct-beam.ipynb @@ -247,7 +247,7 @@ "source": [ "from scipp.scipy.interpolate import interp1d\n", "\n", - "Iq_theory = sc.io.load_hdf5(loki.data.loki_tutorial_poly_gauss_I0())\n", + "Iq_theory = loki.data.loki_tutorial_poly_gauss_I0_data()\n", "f = interp1d(Iq_theory, 'Q')\n", "I0 = f(sc.midpoints(workflow.compute(QBins))).data[0]\n", "I0" diff --git a/packages/esssans/src/ess/loki/data.py b/packages/esssans/src/ess/loki/data.py index d92cff38a..c5c65c72c 100644 --- a/packages/esssans/src/ess/loki/data.py +++ b/packages/esssans/src/ess/loki/data.py @@ -2,6 +2,8 @@ # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) from pathlib import Path +import numpy as np +import scipp as sc from ess.sans.types import ( BackgroundRun, DirectBeamFilename, @@ -164,6 +166,31 @@ def loki_tutorial_poly_gauss_I0() -> Path: return Path(_registry.get_path('PolyGauss_I0-50_Rg-60.h5')) +def loki_tutorial_poly_gauss_I0_data() -> sc.DataArray: + """Return the analytical I(Q) model for the tutorial Poly-Gauss sample. + + The model is the SasView ``poly_gauss_coil`` model with an intensity at zero + Q of 50, a radius of gyration of 60 angstrom, a polydispersity of 1.02, and + a background of 0.2. + """ + q = sc.geomspace( + dim='Q', + start=0.0005237261180003165, + stop=0.5, + num=150, + unit='1/angstrom', + ) + radius_of_gyration = sc.scalar(60.0, unit='angstrom') + # Preserve the float32 parameter values used to compute the original reference. + polydispersity = float(np.float32(1.02)) + background = float(np.float32(0.2)) + + u = polydispersity - 1.0 + z = (q * radius_of_gyration) ** 2 / (1.0 + 2.0 * u) + form_factor = 2.0 * ((1.0 + u * z) ** (-1.0 / u) + z - 1.0) / ((1.0 + u) * z**2) + return sc.DataArray(50.0 * form_factor + background, coords={'Q': q}) + + def loki_tutorial_direct_beam_all_pixels() -> DirectBeamFilename: """File containing direct beam function computed using the direct beam iterations notebook, summing all pixels.""" diff --git a/packages/esssans/tests/loki/directbeam_test.py b/packages/esssans/tests/loki/directbeam_test.py index 15ce38a32..5f087efac 100644 --- a/packages/esssans/tests/loki/directbeam_test.py +++ b/packages/esssans/tests/loki/directbeam_test.py @@ -14,7 +14,7 @@ def _get_I0(qbins: sc.Variable) -> sc.Variable: - Iq_theory = sc.io.load_hdf5(loki.data.loki_tutorial_poly_gauss_I0()) + Iq_theory = loki.data.loki_tutorial_poly_gauss_I0_data() f = interp1d(Iq_theory, 'Q') return f(sc.midpoints(qbins)).data[0]