reciprocalspaceship 0.9.7__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. reciprocalspaceship-1.0.7/PKG-INFO +85 -0
  2. reciprocalspaceship-1.0.7/README.md +62 -0
  3. reciprocalspaceship-1.0.7/reciprocalspaceship/VERSION +1 -0
  4. reciprocalspaceship-1.0.7/reciprocalspaceship/__init__.py +53 -0
  5. reciprocalspaceship-1.0.7/reciprocalspaceship/algorithms/__init__.py +7 -0
  6. reciprocalspaceship-1.0.7/reciprocalspaceship/algorithms/intensity.py +82 -0
  7. reciprocalspaceship-1.0.7/reciprocalspaceship/algorithms/merge.py +69 -0
  8. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/algorithms/scale_merged_intensities.py +121 -85
  9. reciprocalspaceship-1.0.7/reciprocalspaceship/commandline/cifdump.py +115 -0
  10. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/commandline/mtzdump.py +49 -25
  11. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/concat.py +15 -14
  12. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/dataseries.py +27 -19
  13. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/dataset.py +807 -355
  14. reciprocalspaceship-1.0.7/reciprocalspaceship/decorators.py +166 -0
  15. reciprocalspaceship-1.0.7/reciprocalspaceship/dtypes/__init__.py +33 -0
  16. reciprocalspaceship-1.0.7/reciprocalspaceship/dtypes/base.py +37 -0
  17. reciprocalspaceship-1.0.7/reciprocalspaceship/dtypes/floating.py +694 -0
  18. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/dtypes/inference.py +14 -14
  19. reciprocalspaceship-1.0.7/reciprocalspaceship/dtypes/integer.py +540 -0
  20. reciprocalspaceship-1.0.7/reciprocalspaceship/dtypes/internals.py +1377 -0
  21. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/dtypes/summarize.py +7 -4
  22. reciprocalspaceship-1.0.7/reciprocalspaceship/io/__init__.py +13 -0
  23. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/io/ccp4map.py +3 -2
  24. reciprocalspaceship-1.0.7/reciprocalspaceship/io/common.py +17 -0
  25. reciprocalspaceship-1.0.7/reciprocalspaceship/io/crystfel.py +552 -0
  26. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/io/csv.py +11 -2
  27. reciprocalspaceship-1.0.7/reciprocalspaceship/io/dials.py +319 -0
  28. reciprocalspaceship-1.0.7/reciprocalspaceship/io/dials_mpi.py +44 -0
  29. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/io/mtz.py +123 -35
  30. reciprocalspaceship-1.0.7/reciprocalspaceship/io/pickle.py +34 -0
  31. reciprocalspaceship-1.0.7/reciprocalspaceship/io/precognition.py +140 -0
  32. reciprocalspaceship-1.0.7/reciprocalspaceship/stats/__init__.py +11 -0
  33. reciprocalspaceship-1.0.7/reciprocalspaceship/stats/completeness.py +173 -0
  34. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/__init__.py +60 -0
  35. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/asu.py +233 -0
  36. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/binning.py +94 -0
  37. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/cell.py +71 -0
  38. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/grid.py +56 -0
  39. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/math.py +31 -0
  40. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/phases.py +73 -0
  41. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/rfree.py +97 -0
  42. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/stats.py +119 -0
  43. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/utils/structurefactors.py +35 -53
  44. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/symmetry.py +118 -0
  45. reciprocalspaceship-1.0.7/reciprocalspaceship/utils/units.py +19 -0
  46. reciprocalspaceship-1.0.7/reciprocalspaceship.egg-info/PKG-INFO +85 -0
  47. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship.egg-info/SOURCES.txt +18 -12
  48. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship.egg-info/entry_points.txt +1 -1
  49. reciprocalspaceship-1.0.7/reciprocalspaceship.egg-info/requires.txt +35 -0
  50. reciprocalspaceship-1.0.7/setup.py +109 -0
  51. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/conftest.py +51 -19
  52. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/test_dataseries.py +23 -26
  53. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/test_dataset.py +309 -104
  54. reciprocalspaceship-1.0.7/tests/test_dataset_anomalous.py +224 -0
  55. reciprocalspaceship-1.0.7/tests/test_dataset_binning.py +114 -0
  56. reciprocalspaceship-1.0.7/tests/test_dataset_grid.py +103 -0
  57. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/test_dataset_index.py +22 -14
  58. reciprocalspaceship-1.0.7/tests/test_dataset_preserve_attributes.py +135 -0
  59. reciprocalspaceship-1.0.7/tests/test_dataset_signatures.py +53 -0
  60. reciprocalspaceship-1.0.7/tests/test_dataset_symops.py +294 -0
  61. reciprocalspaceship-1.0.7/tests/test_decorators.py +163 -0
  62. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/test_summarize_mtz_dtypes.py +3 -1
  63. reciprocalspaceship-0.9.7/PKG-INFO +0 -42
  64. reciprocalspaceship-0.9.7/README.md +0 -47
  65. reciprocalspaceship-0.9.7/reciprocalspaceship/VERSION +0 -1
  66. reciprocalspaceship-0.9.7/reciprocalspaceship/__init__.py +0 -38
  67. reciprocalspaceship-0.9.7/reciprocalspaceship/algorithms/__init__.py +0 -2
  68. reciprocalspaceship-0.9.7/reciprocalspaceship/algorithms/merge.py +0 -56
  69. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/__init__.py +0 -31
  70. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/anomalousdifference.py +0 -17
  71. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/base.py +0 -254
  72. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/batch.py +0 -17
  73. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/hklindex.py +0 -16
  74. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/intensity.py +0 -32
  75. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/m_isym.py +0 -17
  76. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/mtzint.py +0 -18
  77. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/mtzreal.py +0 -18
  78. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/phase.py +0 -35
  79. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/stddev.py +0 -47
  80. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/structurefactor.py +0 -50
  81. reciprocalspaceship-0.9.7/reciprocalspaceship/dtypes/weight.py +0 -17
  82. reciprocalspaceship-0.9.7/reciprocalspaceship/io/__init__.py +0 -12
  83. reciprocalspaceship-0.9.7/reciprocalspaceship/io/crystfel.py +0 -230
  84. reciprocalspaceship-0.9.7/reciprocalspaceship/io/precognition.py +0 -78
  85. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/__init__.py +0 -13
  86. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/asu.py +0 -208
  87. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/binning.py +0 -40
  88. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/cell.py +0 -59
  89. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/phases.py +0 -60
  90. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/rfree.py +0 -70
  91. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/stats.py +0 -66
  92. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/symop.py +0 -37
  93. reciprocalspaceship-0.9.7/reciprocalspaceship/utils/units.py +0 -10
  94. reciprocalspaceship-0.9.7/reciprocalspaceship.egg-info/PKG-INFO +0 -42
  95. reciprocalspaceship-0.9.7/reciprocalspaceship.egg-info/requires.txt +0 -19
  96. reciprocalspaceship-0.9.7/setup.py +0 -92
  97. reciprocalspaceship-0.9.7/tests/test_dataset_anomalous.py +0 -132
  98. reciprocalspaceship-0.9.7/tests/test_dataset_grid.py +0 -51
  99. reciprocalspaceship-0.9.7/tests/test_dataset_preserve_attributes.py +0 -170
  100. reciprocalspaceship-0.9.7/tests/test_dataset_symops.py +0 -112
  101. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/LICENSE +0 -0
  102. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/MANIFEST.in +0 -0
  103. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship/commandline/__init__.py +0 -0
  104. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship.egg-info/dependency_links.txt +0 -0
  105. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/reciprocalspaceship.egg-info/top_level.txt +0 -0
  106. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/setup.cfg +0 -0
  107. {reciprocalspaceship-0.9.7 → reciprocalspaceship-1.0.7}/tests/__init__.py +0 -0
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: reciprocalspaceship
3
+ Version: 1.0.7
4
+ Summary: Tools for exploring reciprocal space
5
+ Home-page: https://rs-station.github.io/reciprocalspaceship/
6
+ Author: Kevin M. Dalton, Jack B. Greisman
7
+ Author-email: kmdalton@g.harvard.edu, greisman@g.harvard.edu
8
+ License: MIT
9
+ Project-URL: Bug Tracker, https://github.com/rs-station/reciprocalspaceship/issues
10
+ Project-URL: Documentation, https://rs-station.github.io/reciprocalspaceship/
11
+ Project-URL: Source Code, https://github.com/rs-station/reciprocalspaceship
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Programming Language :: Python
20
+ Requires-Python: >=3.9
21
+ License-File: LICENSE
22
+ Requires-Dist: gemmi<=0.7.3,>=0.7.0
23
+ Requires-Dist: pandas<=2.3.3,>=2.2.2
24
+ Requires-Dist: numpy
25
+ Requires-Dist: scipy
26
+ Requires-Dist: ipython
27
+ Requires-Dist: msgpack
28
+ Requires-Dist: setuptools
29
+ Requires-Dist: joblib
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
33
+ Requires-Dist: pytest-xdist; extra == "dev"
34
+ Provides-Extra: doc
35
+ Requires-Dist: sphinx; extra == "doc"
36
+ Requires-Dist: sphinx_rtd_theme; extra == "doc"
37
+ Requires-Dist: nbsphinx; extra == "doc"
38
+ Requires-Dist: sphinx-design; extra == "doc"
39
+ Requires-Dist: sphinxcontrib-autoprogram; extra == "doc"
40
+ Requires-Dist: autodocsumm; extra == "doc"
41
+ Requires-Dist: jupyter; extra == "doc"
42
+ Requires-Dist: tqdm; extra == "doc"
43
+ Requires-Dist: matplotlib; extra == "doc"
44
+ Requires-Dist: seaborn; extra == "doc"
45
+ Requires-Dist: celluloid; extra == "doc"
46
+ Requires-Dist: scikit-image; extra == "doc"
47
+ Provides-Extra: examples
48
+ Requires-Dist: jupyter; extra == "examples"
49
+ Requires-Dist: tqdm; extra == "examples"
50
+ Requires-Dist: matplotlib; extra == "examples"
51
+ Requires-Dist: seaborn; extra == "examples"
52
+ Requires-Dist: celluloid; extra == "examples"
53
+ Requires-Dist: scikit-image; extra == "examples"
54
+ Dynamic: author
55
+ Dynamic: author-email
56
+ Dynamic: classifier
57
+ Dynamic: description
58
+ Dynamic: home-page
59
+ Dynamic: license
60
+ Dynamic: license-file
61
+ Dynamic: project-url
62
+ Dynamic: provides-extra
63
+ Dynamic: requires-dist
64
+ Dynamic: requires-python
65
+ Dynamic: summary
66
+
67
+
68
+ ``reciprocalspaceship`` provides a ``pandas``-style interface for
69
+ analyzing and manipulating reflection data from crystallography
70
+ experiments. Using this library, it is possible to interactively work
71
+ with crystallographic data in Python, enabling easy integration with
72
+ modern scientific computing libraries. ``reciprocalspaceship`` is
73
+ intended to support the rapid prototyping of new crystallographic methods
74
+ and custom analyses while maintaining clear, reproducible, and performant
75
+ code.
76
+
77
+ Features of this library include:
78
+
79
+ - Crystallographically-aware ``pandas`` objects, datatypes, and syntax
80
+ that are familiar to Python users.
81
+ - Convenient integration with `GEMMI <https://gemmi.readthedocs.io/en/latest/>`__
82
+ to provide built-in methods and support for developing functions that
83
+ use space groups, unit cell parameters, and crystallographic symmetry
84
+ operations.
85
+ - Support for reading and writing MTZ reflection files.
@@ -0,0 +1,62 @@
1
+ # 1 / 🚀 = reciprocalspaceship
2
+ ![Build](https://github.com/rs-station/reciprocalspaceship/workflows/Build/badge.svg)
3
+ [![Documentation](https://github.com/rs-station/reciprocalspaceship/workflows/Documentation/badge.svg)](https://rs-station.github.io/reciprocalspaceship)
4
+ [![PyPI](https://img.shields.io/pypi/v/reciprocalspaceship?color=blue)](https://pypi.org/project/reciprocalspaceship/)
5
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/reciprocalspaceship/badges/version.svg)](https://anaconda.org/conda-forge/reciprocalspaceship)
6
+ [![codecov](https://codecov.io/gh/rs-station/reciprocalspaceship/branch/main/graph/badge.svg)](https://codecov.io/gh/rs-station/reciprocalspaceship)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rs-station/reciprocalspaceship/blob/main/LICENSE)
8
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/rs-station/reciprocalspaceship/main?filepath=docs%2Fexamples)
9
+ [![DOI](https://img.shields.io/badge/DOI-10.1107%2FS160057672100755X-blue)](https://doi.org/10.1107/S160057672100755X)
10
+
11
+ Tools for exploring reciprocal space.
12
+
13
+ `reciprocalspaceship` provides a `pandas`-style interface for
14
+ analyzing and manipulating reflection data from crystallography
15
+ experiments. Using this library, it is possible to interactively
16
+ work with crystallographic data in Python, enabling easy
17
+ integration with modern scientific computing libraries. `reciprocalspaceship`
18
+ is intended to support the rapid prototyping of new crystallographic methods and
19
+ custom analyses while maintaining clear and performant code.
20
+
21
+ Features of this library include:
22
+
23
+ - Crystallographically-aware `pandas` objects, datatypes, and syntax that are familiar to Python users.
24
+ - Convenient integration with [GEMMI](https://gemmi.readthedocs.io/en/latest/) to provide built-in methods and
25
+ support for developing functions that use space groups, unit cell parameters, and crystallographic
26
+ symmetry operations.
27
+ - Support for reading and writing MTZ reflection files.
28
+
29
+ <p align="center">
30
+ <img src="docs/img/screenshot.png" width=750 title="Screenshot of Jupyter Notebook">
31
+ </p>
32
+
33
+ ## Installation
34
+
35
+ The fastest way to install `reciprocalspaceship` is using `pip`:
36
+
37
+ ```
38
+ pip install reciprocalspaceship
39
+ ```
40
+
41
+ or using `conda`:
42
+
43
+ ```
44
+ conda install -c conda-forge reciprocalspaceship
45
+ ```
46
+
47
+ For more installation information, see our [installation guide](https://rs-station.github.io/reciprocalspaceship/userguide/installation.html).
48
+
49
+ ## Quickstart
50
+
51
+ To get started with `reciprocalspaceship`, see our [quickstart guide](https://rs-station.github.io/reciprocalspaceship/examples/quickstart.html).
52
+
53
+ ## Documentation
54
+
55
+ For more details on the use of `reciprocalspaceship`, check out our [documentation](https://rs-station.github.io/reciprocalspaceship).
56
+
57
+ ## Reference
58
+
59
+ Our paper describing the library was published in the Journal of Applied Crystallography: [link to paper](https://doi.org/10.1107/S160057672100755X).
60
+ Please cite this publication for any work that makes use of this library.
61
+
62
+ We also have a pre-print describing the library on [bioRxiv](https://www.biorxiv.org/content/10.1101/2021.02.03.429617v1).
@@ -0,0 +1,53 @@
1
+ # Version number for reciprocalspaceship
2
+ def getVersionNumber():
3
+ version = None
4
+ try:
5
+ from setuptools.version import metadata
6
+
7
+ version = metadata.version("reciprocalspaceship")
8
+ except ImportError:
9
+ from setuptools.version import pkg_resources
10
+
11
+ version = pkg_resources.require("reciprocalspaceship")[0].version
12
+
13
+ return version
14
+
15
+
16
+ __version__ = getVersionNumber()
17
+
18
+ # Import submodules
19
+ from reciprocalspaceship import algorithms, stats
20
+
21
+ # Top-Level API
22
+ from reciprocalspaceship.concat import concat
23
+ from reciprocalspaceship.dataseries import DataSeries
24
+ from reciprocalspaceship.dataset import DataSet
25
+
26
+ # Add support for MTZ data types:
27
+ # see http://www.ccp4.ac.uk/html/f2mtz.html
28
+ from reciprocalspaceship.dtypes import AnomalousDifferenceDtype # D
29
+ from reciprocalspaceship.dtypes import BatchDtype # B
30
+ from reciprocalspaceship.dtypes import FriedelIntensityDtype # K
31
+ from reciprocalspaceship.dtypes import FriedelStructureFactorAmplitudeDtype # G
32
+ from reciprocalspaceship.dtypes import HendricksonLattmanDtype # A
33
+ from reciprocalspaceship.dtypes import HKLIndexDtype # H
34
+ from reciprocalspaceship.dtypes import IntensityDtype # J
35
+ from reciprocalspaceship.dtypes import M_IsymDtype # Y
36
+ from reciprocalspaceship.dtypes import MTZIntDtype # I
37
+ from reciprocalspaceship.dtypes import MTZRealDtype # R
38
+ from reciprocalspaceship.dtypes import NormalizedStructureFactorAmplitudeDtype # E
39
+ from reciprocalspaceship.dtypes import PhaseDtype # P
40
+ from reciprocalspaceship.dtypes import StandardDeviationDtype # Q
41
+ from reciprocalspaceship.dtypes import StandardDeviationFriedelIDtype # M
42
+ from reciprocalspaceship.dtypes import StandardDeviationFriedelSFDtype # L
43
+ from reciprocalspaceship.dtypes import StructureFactorAmplitudeDtype # F
44
+ from reciprocalspaceship.dtypes import WeightDtype # W
45
+ from reciprocalspaceship.dtypes import summarize_mtz_dtypes
46
+ from reciprocalspaceship.io import (
47
+ read_cif,
48
+ read_crystfel,
49
+ read_csv,
50
+ read_mtz,
51
+ read_pickle,
52
+ read_precognition,
53
+ )
@@ -0,0 +1,7 @@
1
+ from reciprocalspaceship.algorithms.intensity import (
2
+ compute_intensity_from_structurefactor,
3
+ )
4
+ from reciprocalspaceship.algorithms.merge import merge
5
+ from reciprocalspaceship.algorithms.scale_merged_intensities import (
6
+ scale_merged_intensities,
7
+ )
@@ -0,0 +1,82 @@
1
+ import numpy as np
2
+
3
+ import reciprocalspaceship as rs
4
+ from reciprocalspaceship.decorators import inplace
5
+
6
+
7
+ @inplace
8
+ def compute_intensity_from_structurefactor(
9
+ ds,
10
+ F_key,
11
+ SigF_key,
12
+ output_columns=None,
13
+ inplace=False,
14
+ ):
15
+ """
16
+ Compute intensities (I) and uncertainty estimates (SigI) from structure
17
+ factor amplitudes (F) and their uncertainties (SigF) using error propagation
18
+
19
+ Intensity computed as I = SigF*SigF + F*F. Intensity error estimate
20
+ approximated as SigI = abs(2*F*SigF)
21
+
22
+ Parameters
23
+ ----------
24
+ ds : DataSet
25
+ Input DataSet containing columns with F_key and SigF_key labels
26
+ F_key : str
27
+ Column label for structure factor amplitudes
28
+ SigF_key : str
29
+ Column label for structure factor error estimates
30
+ output_columns : list or tuple of column names
31
+ Column labels to be added to ds for calculated I and
32
+ SigI, respectively. output_columns must have len=2.
33
+ inplace : bool
34
+ Whether to modify the DataSet in place or create a copy
35
+
36
+ Returns
37
+ -------
38
+ DataSet
39
+ DataSet with 2 additional columns corresponding to calculated
40
+ intensities and intensity error estimates
41
+
42
+ """
43
+
44
+ if output_columns is None:
45
+ output_columns = ["I_calc", "SigI_calc"]
46
+ (
47
+ I_key,
48
+ SigI_key,
49
+ ) = output_columns
50
+
51
+ if I_key in ds.columns:
52
+ raise ValueError(
53
+ f"Input {ds.__class__.__name__} already contains column '{I_key}'."
54
+ f"Try again and use the output_columns argument to pick a new"
55
+ f"output column name."
56
+ )
57
+ if SigI_key in ds.columns:
58
+ raise ValueError(
59
+ f"Input {ds.__class__.__name__} already contains column '{SigI_key}'."
60
+ f"Try again and use the output_columns argument to pick a new"
61
+ f"output column name."
62
+ )
63
+
64
+ # Confirm F_key and SigF_key are of the correct dtype
65
+ if not isinstance(ds.dtypes[F_key], rs.StructureFactorAmplitudeDtype):
66
+ raise ValueError(
67
+ f"Column {F_key} is not of type rs.StructureFactorAmplitudeDtype."
68
+ f"Try again and provide structure factor amplitudes for F_key"
69
+ )
70
+ if not isinstance(ds.dtypes[SigF_key], rs.StandardDeviationDtype):
71
+ raise ValueError(
72
+ f"Column {SigF_key} is not of type rs.StandardDeviationDtype."
73
+ f"Try again and provide standard deviations for SigF_key"
74
+ )
75
+
76
+ # Initialize outputs
77
+ ds[I_key] = (ds[F_key] * ds[F_key] + ds[SigF_key] * ds[SigF_key]).astype(
78
+ "Intensity"
79
+ )
80
+ ds[SigI_key] = (2 * ds[F_key] * ds[SigF_key]).abs().astype("Stddev")
81
+
82
+ return ds
@@ -0,0 +1,69 @@
1
+ import numpy as np
2
+
3
+
4
+ def merge(dataset, intensity_key="I", sigma_key="SIGI", anomalous=True, sort=False):
5
+ """
6
+ Merge dataset using inverse-variance weights.
7
+
8
+ Parameters
9
+ ----------
10
+ dataset : rs.DataSet
11
+ Unmerged DataSet containing scaled intensities and uncertainties
12
+ intensity_key : str (optional)
13
+ Column name for intensities
14
+ sigma_key : str (optional)
15
+ Column name for uncertainties
16
+ anomalous : bool (optional)
17
+ If True, do not merge Friedel mates
18
+ sort : bool (optional)
19
+ If True, index of returned DataSet will be sorted
20
+
21
+ Returns
22
+ -------
23
+ rs.DataSet
24
+ Merged DataSet object
25
+ """
26
+
27
+ if dataset.merged:
28
+ raise ValueError(
29
+ "rs.algorithms.merge() can only be called with an unmerged DataSet"
30
+ )
31
+
32
+ # Map observations to reciprocal ASU
33
+ ds = dataset.hkl_to_asu(anomalous=anomalous)
34
+ ds["w"] = ds[sigma_key] ** -2
35
+ ds["wI"] = ds[intensity_key] * ds["w"]
36
+ g = ds.groupby(["H", "K", "L"])
37
+
38
+ result = g[["w", "wI"]].sum()
39
+ result["I"] = result["wI"] / result["w"]
40
+ result["SIGI"] = np.sqrt(1 / result["w"]).astype("Stddev")
41
+ result["N"] = g.size()
42
+ result.merged = True
43
+
44
+ # Reshape anomalous data and use to compute IMEAN / SIGIMEAN
45
+ if anomalous:
46
+ result = result.unstack_anomalous()
47
+ result.loc[:, ["N(+)", "N(-)"]] = result[["N(+)", "N(-)"]].fillna(0).astype("I")
48
+ result["IMEAN"] = result[["wI(+)", "wI(-)"]].sum(axis=1) / result[
49
+ ["w(+)", "w(-)"]
50
+ ].sum(axis=1).astype("Intensity")
51
+ result["SIGIMEAN"] = np.sqrt(1 / (result[["w(+)", "w(-)"]].sum(axis=1))).astype(
52
+ "Stddev"
53
+ )
54
+
55
+ # Adjust SIGIMEAN for centric reflections due to duplicated values in
56
+ # Friedel columns
57
+ centrics = result.label_centrics()["CENTRIC"]
58
+ result.loc[centrics, "SIGIMEAN"] *= np.sqrt(2)
59
+
60
+ result = result[
61
+ ["IMEAN", "SIGIMEAN", "I(+)", "SIGI(+)", "I(-)", "SIGI(-)", "N(+)", "N(-)"]
62
+ ]
63
+ else:
64
+ result = result[["I", "SIGI", "N"]]
65
+
66
+ if sort:
67
+ return result.sort_index()
68
+
69
+ return result