Skip to content

Commit 393401b

Browse files
committed
🚀 New ReflectionsData and ReflectionsCollection classes
xtl.diffraction.reflections.reflections:ReflectionsData - New class for representing one column of some type of diffraction reflections data, e.g. intensities, phases, etc - This is a wrapper around reciprocalspaceship.DataSet, which in turn is a subclass of pandas.DataFrame - The class holds information about unit-cell, space group and whether the reflections are merged or not - The reflections are indexed with a three-column (H,K,L) pd.MultiIndex - .dtype and .mtz_type properties for retrieving the rs.MTZDtype and MTZ column type - .as_dtype() and .as_mtz_type() methods for changing the rs.MTZDtype and MTZ column type - Can be instantiated directly from Python/NumPy arrays, Pandas dataframes, gemmi.Mtz instances or rs.DataSeries - Alternatively, it can be instantiated from MTZ or CIF files by specifying the file and column name in the .from_mtz() and .from_cif() methods xtl.diffraction.reflections.reflections:ReflectionsCollection - New class for representing multiple columns of diffraction reflections data, e.g. intensities, phases, etc - This is a wrapper around reciprocalspaceship.DataSet, which in turn is a subclass of pandas.DataFrame - The class holds information about unit-cell, space group and whether the reflections are merged or not - The reflections are indexed with a three-column (H,K,L) pd.MultiIndex - .dtypes and .mtz_types properties for retrieving the rs.MTZDtype and MTZ column types - .as_dtype() and .as_mtz_type() methods for changing the rs.MTZDtype and MTZ column types - Can be instantiated directly from Python/NumPy arrays, Pandas dataframes, gemmi.Mtz instances or rs.DataSeries - Alternatively, it can be instantiated from MTZ or CIF files by specifying the file in the .from_mtz() and .from_cif() methods xtl.diffraction.reflections.mtz_types:mtz_types - Dictionary mapping of str -> rs.MTZDtype for all MTZ column types pyproject.toml & requirements.txt - Added reciprocalspaceship to the dependencies list
1 parent 847b775 commit 393401b

File tree

5 files changed

+538
-0
lines changed

5 files changed

+538
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = [
4444
"pydantic>=2.11.5",
4545
"pyfai>=2023.9.0,<2024.10",
4646
"pyxray>=1.7.0",
47+
"reciprocalspaceship>=1.0.3",
4748
"requests>=2.31.0",
4849
"rich>=13.6.0",
4950
"tabulate>=0.8.10",

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pint==0.19.2
1313
pydantic==2.11.5
1414
pyfai==2023.9.0
1515
pyxray==1.7.0
16+
reciprocalspaceship==1.0.3
1617
requests==2.31.0
1718
rich==13.9.4
1819
sphinx==8.1.3
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__all__ = ['ReflectionsData', 'ReflectionsCollection', 'mtz_types']
2+
3+
from .mtz_types import mtz_types
4+
from .reflections import ReflectionsData, ReflectionsCollection
5+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import reciprocalspaceship as rs
2+
from reciprocalspaceship.dtypes.base import MTZDtype
3+
4+
5+
mtz_types: dict[str, MTZDtype] = {}
6+
"""Dictionary of MTZ column types to their corresponding rs.MTZDtype class"""
7+
8+
mtz_summary = rs.summarize_mtz_dtypes(print_summary=False)
9+
for i in range(mtz_summary.shape[0]):
10+
# Columns: ['MTZ Code', 'Name', 'Class', 'Internal']
11+
cls_name = mtz_summary['Class'][i]
12+
mtz_type = mtz_summary['MTZ Code'][i]
13+
mtz_types[mtz_type] = getattr(rs.dtypes, cls_name)

0 commit comments

Comments
 (0)