Skip to content

Commit 2921d40

Browse files
authored
Merge pull request #101 from scipp/filter-nan
fix: remove non-finite values
2 parents 0c9dbb4 + 0cf0c30 commit 2921d40

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/ess/amor/orso.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ def build_orso_iofq_dataset(
6161
r = sc.values(iofq.data)
6262
sr = sc.stddevs(iofq.data)
6363
sqz = sigma_q.to(unit="1/angstrom", copy=False)
64-
data = (qz, r, sr, sqz)
6564

66-
return OrsoIofQDataset(
67-
OrsoDataset(header, np.column_stack([_extract_values_array(d) for d in data]))
68-
)
65+
data = np.column_stack(tuple(map(_extract_values_array, (qz, r, sr, sqz))))
66+
data = data[np.isfinite(data).all(axis=-1)]
67+
return OrsoIofQDataset(OrsoDataset(header, data))
6968

7069

7170
def _extract_values_array(var: sc.Variable) -> np.ndarray:

tests/amor/pipeline_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,19 @@ def test_run_data_pipeline(amor_pipeline: sciline.Pipeline):
6969
@pytest.mark.filterwarnings("ignore:Invalid transformation, missing attribute")
7070
def test_run_full_pipeline(amor_pipeline: sciline.Pipeline):
7171
amor_pipeline[SampleRotation[SampleRun]] = sc.scalar(0.85, unit="deg")
72+
# Make the Q range cover a larger interval than the experiment is sensitive to.
73+
# This let's us test the non-covered regions are filtered from the ORSO data.
74+
amor_pipeline[QBins] = sc.geomspace(
75+
dim="Q", start=0.005, stop=0.15, num=391, unit="1/angstrom"
76+
)
7277
amor_pipeline[Filename[SampleRun]] = amor.data.amor_sample_run(608)
7378
res = amor_pipeline.compute(orso.OrsoIofQDataset)
7479
assert res.info.data_source.experiment.instrument == "Amor"
7580
assert res.info.reduction.software.name == "ess.reflectometry"
7681
assert res.data.ndim == 2
7782
assert res.data.shape[1] == 4
7883
assert np.all(res.data[:, 1] >= 0)
84+
assert np.isfinite(res.data).all()
7985

8086

8187
@pytest.mark.filterwarnings("ignore:Failed to convert .* into a transformation")

0 commit comments

Comments
 (0)