Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ess/beer/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def cluster_events_by_streak(
# adding them to the binned data coords achieves this.
for coord in ('two_theta', 'Ltotal'):
da.bins.coords[coord] = sc.bins_like(da, da.coords[coord])
# Making them scalar also keeps them after binning,
# but without having to store them for each event.
da.coords['tc'] = da.coords['tc'].mean()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can we just use the mean here? Shouldn't this be a per-cluster coord?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should really be a "per Ltotal" coord. But there is no binning here that has that granularity, so either it is per event or a scalar.

The name was bad so I renamed tc to frame_cutoff_time.


h = da.bins.concat().hist(coarse_d=1000)
i_peaks, _ = find_peaks(
Expand Down
21 changes: 21 additions & 0 deletions tests/diffraction/test_peaks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import urllib.request

import pytest
import scipp as sc

from ess.diffraction.peaks import dspacing_peaks_from_cif


def _cifdb_is_reachable(timeout=5):
try:
req = urllib.request.Request('http://cod.ibt.lt', method="HEAD")
with urllib.request.urlopen(req, timeout=timeout): # noqa: S310
return True
except Exception:
return False


@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_retreived_peak_list_has_expected_units():
d = dspacing_peaks_from_cif(
'codid::9011998',
Expand All @@ -12,6 +27,9 @@ def test_retreived_peak_list_has_expected_units():
assert d.unit == 'barn'


@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_intensity_threshold_is_taken_into_account():
d = dspacing_peaks_from_cif(
'codid::9011998',
Expand All @@ -26,6 +44,9 @@ def test_intensity_threshold_is_taken_into_account():
assert len(d) == 0


@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_retreived_peak_list_with_temperature_kwarg():
d = dspacing_peaks_from_cif(
'codid::9011998', sc.scalar(50, unit='barn'), uiso_temperature=300
Expand Down
Loading