Skip to content

Commit 1db57bf

Browse files
committed
Updates tutorials and adds display for excluded regions
1 parent 9d52696 commit 1db57bf

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

docs/tutorials/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The tutorials are organized into the following categories.
4646
- [Si `pd-neut-tof`](cryst-struct_pd-neut-tof_Si-SEPD.ipynb)
4747
Demonstrates a Rietveld refinement of the Si crystal structure using
4848
time-of-flight neutron powder diffraction data from SEPD at Argonne.
49-
- [NCAF `pd-neut-tof`](cryst-struct_pd-neut-tof_multidata_NCAF-WISH.py)
49+
- [NCAF `pd-neut-tof`](cryst-struct_pd-neut-tof_multidata_NCAF-WISH.ipynb)
5050
Demonstrates a Rietveld refinement of the Na2Ca3Al2F14 crystal structure
5151
using two time-of-flight neutron powder diffraction datasets (from two
5252
detector banks) of the WISH instrument at ISIS.

src/easydiffraction/experiments/collections/excluded_regions.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import numpy as np
2-
from typing import Type
1+
from typing import List, Type
32

3+
from easydiffraction.utils.utils import render_table
4+
from easydiffraction.utils.formatting import paragraph
45
from easydiffraction.core.objects import (
56
Parameter,
67
Descriptor,
@@ -73,3 +74,20 @@ def on_item_added(self, item: ExcludedRegion) -> None:
7374
pattern.x = pattern.full_x[~pattern.excluded]
7475
pattern.meas = pattern.full_meas[~pattern.excluded]
7576
pattern.meas_su = pattern.full_meas_su[~pattern.excluded]
77+
78+
def show(self) -> None:
79+
# TODO: Consider moving this to the base class
80+
# to avoid code duplication with implementations in Background, etc.
81+
# Consider using parameter names as column headers
82+
columns_headers: List[str] = ["minimum", "maximum"]
83+
columns_alignment = ["left", "left"]
84+
columns_data: List[List[float]] = []
85+
for region in self._items.values():
86+
minimum = region.minimum.value
87+
maximum = region.maximum.value
88+
columns_data.append([minimum, maximum])
89+
90+
print(paragraph("Excluded regions"))
91+
render_table(columns_headers=columns_headers,
92+
columns_alignment=columns_alignment,
93+
columns_data=columns_data)

tutorials/cryst-struct_pd-neut-tof_multiphase-LBCO-Si_McStas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@
205205
experiment.excluded_regions.add(minimum=0, maximum=40000)
206206
experiment.excluded_regions.add(minimum=108000, maximum=200000)
207207

208+
# %% [markdown]
209+
# Show excluded regions
210+
211+
# %%
212+
experiment.excluded_regions.show()
213+
208214
# %% [markdown]
209215
# Show measured data after adding excluded regions
210216

0 commit comments

Comments
 (0)