easyreflectometry 1.0.0__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.

Potentially problematic release.


This version of easyreflectometry might be problematic. Click here for more details.

Files changed (47) hide show
  1. easyreflectometry-1.0.0/.gitignore +49 -0
  2. easyreflectometry-1.0.0/AUTHORS.rst +11 -0
  3. easyreflectometry-1.0.0/LICENSE +29 -0
  4. easyreflectometry-1.0.0/PKG-INFO +96 -0
  5. easyreflectometry-1.0.0/README.md +19 -0
  6. easyreflectometry-1.0.0/pyproject.toml +157 -0
  7. easyreflectometry-1.0.0/src/easyreflectometry/__init__.py +6 -0
  8. easyreflectometry-1.0.0/src/easyreflectometry/__version__.py +1 -0
  9. easyreflectometry-1.0.0/src/easyreflectometry/calculators/__init__.py +31 -0
  10. easyreflectometry-1.0.0/src/easyreflectometry/calculators/bornagain/calculator.py +200 -0
  11. easyreflectometry-1.0.0/src/easyreflectometry/calculators/bornagain/wrapper.py +351 -0
  12. easyreflectometry-1.0.0/src/easyreflectometry/calculators/calculator_base.py +179 -0
  13. easyreflectometry-1.0.0/src/easyreflectometry/calculators/factory.py +16 -0
  14. easyreflectometry-1.0.0/src/easyreflectometry/calculators/refl1d/calculator.py +35 -0
  15. easyreflectometry-1.0.0/src/easyreflectometry/calculators/refl1d/wrapper.py +270 -0
  16. easyreflectometry-1.0.0/src/easyreflectometry/calculators/refnx/calculator.py +35 -0
  17. easyreflectometry-1.0.0/src/easyreflectometry/calculators/refnx/wrapper.py +165 -0
  18. easyreflectometry-1.0.0/src/easyreflectometry/calculators/wrapper_base.py +213 -0
  19. easyreflectometry-1.0.0/src/easyreflectometry/data.py +74 -0
  20. easyreflectometry-1.0.0/src/easyreflectometry/experiment/__init__.py +13 -0
  21. easyreflectometry-1.0.0/src/easyreflectometry/experiment/model.py +224 -0
  22. easyreflectometry-1.0.0/src/easyreflectometry/experiment/model_collection.py +35 -0
  23. easyreflectometry-1.0.0/src/easyreflectometry/experiment/resolution_functions.py +51 -0
  24. easyreflectometry-1.0.0/src/easyreflectometry/fitting.py +65 -0
  25. easyreflectometry-1.0.0/src/easyreflectometry/main.py +10 -0
  26. easyreflectometry-1.0.0/src/easyreflectometry/measurement/data.py +11 -0
  27. easyreflectometry-1.0.0/src/easyreflectometry/parameter_utils.py +35 -0
  28. easyreflectometry-1.0.0/src/easyreflectometry/plot.py +61 -0
  29. easyreflectometry-1.0.0/src/easyreflectometry/sample/__init__.py +31 -0
  30. easyreflectometry-1.0.0/src/easyreflectometry/sample/assemblies/base_assembly.py +163 -0
  31. easyreflectometry-1.0.0/src/easyreflectometry/sample/assemblies/gradient_layer.py +162 -0
  32. easyreflectometry-1.0.0/src/easyreflectometry/sample/assemblies/multilayer.py +99 -0
  33. easyreflectometry-1.0.0/src/easyreflectometry/sample/assemblies/repeating_multilayer.py +74 -0
  34. easyreflectometry-1.0.0/src/easyreflectometry/sample/assemblies/surfactant_layer.py +241 -0
  35. easyreflectometry-1.0.0/src/easyreflectometry/sample/base_core.py +50 -0
  36. easyreflectometry-1.0.0/src/easyreflectometry/sample/base_element_collection.py +63 -0
  37. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/layers/layer.py +91 -0
  38. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py +242 -0
  39. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/layers/layer_collection.py +24 -0
  40. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/materials/material.py +66 -0
  41. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/materials/material_collection.py +28 -0
  42. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/materials/material_density.py +155 -0
  43. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/materials/material_mixture.py +192 -0
  44. easyreflectometry-1.0.0/src/easyreflectometry/sample/elements/materials/material_solvated.py +148 -0
  45. easyreflectometry-1.0.0/src/easyreflectometry/sample/sample.py +94 -0
  46. easyreflectometry-1.0.0/src/easyreflectometry/special/calculations.py +78 -0
  47. easyreflectometry-1.0.0/src/easyreflectometry/special/parsing.py +83 -0
@@ -0,0 +1,49 @@
1
+ # QtCreator
2
+ *.autosave
3
+
4
+ # QtCreator Qml
5
+ *.qmlproject.user
6
+ *.qmlproject.user.*
7
+
8
+ # QtCreator Python
9
+ *.pyproject.user
10
+ *.pyproject.user.*
11
+
12
+ # QtCreator CMake
13
+ CMakeLists.txt.user*
14
+
15
+ # Python
16
+ __pycache__
17
+ .venv
18
+ .coverage
19
+ .pyc
20
+
21
+ # Poetry
22
+ dist
23
+ poetry.lock
24
+ *.egg-info
25
+
26
+ # PyInstaller
27
+ build
28
+ *.spec
29
+
30
+ # Jupyter
31
+ .ipynb_checkpoints
32
+
33
+ # macOS
34
+ .DS_Store
35
+ *.app
36
+ *.dmg
37
+
38
+ # Docs
39
+ docs/_build
40
+
41
+ # VSCode
42
+ .vscode
43
+
44
+ # Misc
45
+ ..*
46
+ *.log
47
+ *.zip
48
+ .ci/
49
+ .idea/
@@ -0,0 +1,11 @@
1
+ =======
2
+ Credits
3
+ =======
4
+
5
+ Contributors
6
+ ------------
7
+
8
+ * Andrew R. McCluskey <andrew.mccluskey@ess.eu>
9
+ * Andrew Sazonov <andrew.sazonov@ess.eu>
10
+ * Simon Ward <simon.ward@ess.eu>
11
+ * Andreas Pedersen <andreas.pedersen@ess.eu>
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Easyscience contributors (https://github.com/EasyScience)
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.1
2
+ Name: easyreflectometry
3
+ Version: 1.0.0
4
+ Summary: A reflectometry python package built on the EasyScience framework.
5
+ Project-URL: homepage, https://docs.easyreflectometry.org
6
+ Project-URL: documentation, https://docs.easyreflectometry.org
7
+ Author: EasyScience contributors
8
+ License: BSD 3-Clause License
9
+
10
+ Copyright (c) 2024, Easyscience contributors (https://github.com/EasyScience)
11
+ All rights reserved.
12
+
13
+ Redistribution and use in source and binary forms, with or without
14
+ modification, are permitted provided that the following conditions are met:
15
+
16
+ 1. Redistributions of source code must retain the above copyright notice, this
17
+ list of conditions and the following disclaimer.
18
+
19
+ 2. Redistributions in binary form must reproduce the above copyright notice,
20
+ this list of conditions and the following disclaimer in the documentation
21
+ and/or other materials provided with the distribution.
22
+
23
+ 3. Neither the name of the copyright holder nor the names of its
24
+ contributors may be used to endorse or promote products derived from
25
+ this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ License-File: AUTHORS.rst
38
+ License-File: LICENSE
39
+ Classifier: Development Status :: 3 - Alpha
40
+ Classifier: License :: OSI Approved :: BSD License
41
+ Classifier: Operating System :: OS Independent
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3 :: Only
44
+ Classifier: Programming Language :: Python :: 3.9
45
+ Classifier: Programming Language :: Python :: 3.10
46
+ Classifier: Programming Language :: Python :: 3.11
47
+ Classifier: Programming Language :: Python :: 3.12
48
+ Classifier: Topic :: Scientific/Engineering
49
+ Requires-Python: <3.12,>=3.9
50
+ Requires-Dist: easyscience>=0.6.0
51
+ Requires-Dist: orsopy>=0.0.4
52
+ Requires-Dist: refl1d>=0.8.14
53
+ Requires-Dist: refnx>=0.1.15
54
+ Requires-Dist: scipp>=23.12.0
55
+ Provides-Extra: dev
56
+ Requires-Dist: build; extra == 'dev'
57
+ Requires-Dist: codecov>=2.1.11; extra == 'dev'
58
+ Requires-Dist: coverage; extra == 'dev'
59
+ Requires-Dist: coveralls; extra == 'dev'
60
+ Requires-Dist: flake8>=6.0.0; extra == 'dev'
61
+ Requires-Dist: ipykernel; extra == 'dev'
62
+ Requires-Dist: jupyter>=1.0.0; extra == 'dev'
63
+ Requires-Dist: jupyterlab; extra == 'dev'
64
+ Requires-Dist: plopp; extra == 'dev'
65
+ Requires-Dist: pytest-cov>=3.0.0; extra == 'dev'
66
+ Requires-Dist: pytest>=5.2; extra == 'dev'
67
+ Requires-Dist: ruff; extra == 'dev'
68
+ Requires-Dist: toml>=0.10; extra == 'dev'
69
+ Requires-Dist: yapf>=0.31.0; extra == 'dev'
70
+ Provides-Extra: docs
71
+ Requires-Dist: myst-parser; extra == 'docs'
72
+ Requires-Dist: nbsphinx; extra == 'docs'
73
+ Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
74
+ Requires-Dist: sphinx-book-theme; extra == 'docs'
75
+ Requires-Dist: toml; extra == 'docs'
76
+ Description-Content-Type: text/markdown
77
+
78
+ ![Logo](https://github.com/easyScience/EasyReflectometryLib/raw/master/docs/src/_static/logo.png)
79
+ [![CI badge](https://github.com/easyScience/EasyReflectometryLib/actions/workflows/python-ci.yml/badge.svg)](https://github.com/easyScience/easyReflectometryLib/actions/workflows/python-ci.yml)
80
+ [![PyPI badge](http://img.shields.io/pypi/v/EasyReflectometryLib.svg)](https://pypi.python.org/pypi/EasyReflectometryLib)
81
+ [![Coverage badge](https://codecov.io/gh/easyScience/EasyReflectometryLib/branch/master/graph/badge.svg?token=LcnB8AMGkw)](https://codecov.io/gh/easyScience/EasyReflectometryLib)
82
+ [![Quality badge](https://www.codefactor.io/repository/github/easyscience/easyreflectometrylib/badge)](https://www.codefactor.io/repository/github/easyscience/easyreflectometrylib)
83
+ [![Docs badge](https://img.shields.io/badge/docs-built-blue)](http://docs.easyreflectometry.org)
84
+
85
+ # About
86
+
87
+ A reflectometry python package and an application.
88
+
89
+ This repo and documentation is for the `easyreflectometry` Python package that is built on the `easyscience` [framework](https://easyscience.software).
90
+ To get more information about the application visit [`easyreflectometry.org`](https://easyreflectometry.org)
91
+
92
+ # Installation
93
+
94
+ ```sh
95
+ python -m pip install easyreflectometry
96
+ ```
@@ -0,0 +1,19 @@
1
+ ![Logo](https://github.com/easyScience/EasyReflectometryLib/raw/master/docs/src/_static/logo.png)
2
+ [![CI badge](https://github.com/easyScience/EasyReflectometryLib/actions/workflows/python-ci.yml/badge.svg)](https://github.com/easyScience/easyReflectometryLib/actions/workflows/python-ci.yml)
3
+ [![PyPI badge](http://img.shields.io/pypi/v/EasyReflectometryLib.svg)](https://pypi.python.org/pypi/EasyReflectometryLib)
4
+ [![Coverage badge](https://codecov.io/gh/easyScience/EasyReflectometryLib/branch/master/graph/badge.svg?token=LcnB8AMGkw)](https://codecov.io/gh/easyScience/EasyReflectometryLib)
5
+ [![Quality badge](https://www.codefactor.io/repository/github/easyscience/easyreflectometrylib/badge)](https://www.codefactor.io/repository/github/easyscience/easyreflectometrylib)
6
+ [![Docs badge](https://img.shields.io/badge/docs-built-blue)](http://docs.easyreflectometry.org)
7
+
8
+ # About
9
+
10
+ A reflectometry python package and an application.
11
+
12
+ This repo and documentation is for the `easyreflectometry` Python package that is built on the `easyscience` [framework](https://easyscience.software).
13
+ To get more information about the application visit [`easyreflectometry.org`](https://easyreflectometry.org)
14
+
15
+ # Installation
16
+
17
+ ```sh
18
+ python -m pip install easyreflectometry
19
+ ```
@@ -0,0 +1,157 @@
1
+ [build-system]
2
+ requires = [
3
+ "hatchling<=1.21.0",
4
+ "setuptools-git-versioning",
5
+ ]
6
+ build-backend = "hatchling.build"
7
+
8
+ [tool.setuptools-git-versioning]
9
+ enabled = true
10
+
11
+ [project]
12
+ name = "easyreflectometry"
13
+ dynamic = ["version"]
14
+ description = "A reflectometry python package built on the EasyScience framework."
15
+ readme = "README.md"
16
+ authors = [{name = "EasyScience contributors"}]
17
+ license = { file = "LICENSE" }
18
+ classifiers = [
19
+ "License :: OSI Approved :: BSD License",
20
+ "Operating System :: OS Independent",
21
+ "Topic :: Scientific/Engineering",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Development Status :: 3 - Alpha"
29
+ ]
30
+ requires-python = ">=3.9,<3.12"
31
+ dependencies = [
32
+ "easyscience>=0.6.0",
33
+ "scipp>=23.12.0",
34
+ "refnx>=0.1.15",
35
+ "refl1d>=0.8.14",
36
+ "orsopy>=0.0.4"
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "build",
42
+ "codecov>=2.1.11",
43
+ "coverage",
44
+ "coveralls",
45
+ "flake8>=6.0.0",
46
+ "ipykernel",
47
+ "jupyter>=1.0.0",
48
+ "jupyterlab",
49
+ "plopp",
50
+ "pytest>=5.2",
51
+ "pytest-cov>=3.0.0",
52
+ "ruff",
53
+ "toml>=0.10",
54
+ "yapf>=0.31.0",
55
+ ]
56
+ docs = [
57
+ "myst_parser",
58
+ "nbsphinx",
59
+ "sphinx_book_theme",
60
+ "sphinx_autodoc_typehints",
61
+ "toml"
62
+ ]
63
+
64
+ [project.urls]
65
+ homepage = "https://docs.easyreflectometry.org"
66
+ documentation = "https://docs.easyreflectometry.org"
67
+
68
+ [tool.hatch.version]
69
+ path = "src/easyreflectometry/__version__.py"
70
+
71
+ [tool.hatch.metadata]
72
+ allow-direct-references = true
73
+
74
+ [tool.hatch.build.targets.sdist]
75
+ packages = ["src"]
76
+
77
+ [tool.hatch.build.targets.wheel]
78
+ packages = ["src/easyreflectometry"]
79
+
80
+ [tool.coverage.run]
81
+ source = ["src/easyreflectometry"]
82
+
83
+ [tool.github.info]
84
+ organization = 'easyScience'
85
+ repo = "easyreflectometry"
86
+
87
+ [tool.ruff]
88
+ line-length = 127
89
+ exclude = [
90
+ "docs",
91
+ ]
92
+
93
+ [tool.ruff.format]
94
+ quote-style = "single"
95
+
96
+ [tool.ruff.per-file-ignores]
97
+ # allow asserts in test files
98
+ "*test_*.py" = ["S101"]
99
+
100
+ [tool.ruff.lint]
101
+ ignore-init-module-imports = true
102
+ select = [
103
+ # flake8 settings from existing CI setup
104
+ "E9", "F63", "F7", "F82",
105
+ # Code should be polished to fulfill all cases below
106
+ # https://docs.astral.sh/ruff/rules/
107
+ # pycodestyle
108
+ "E",
109
+ # Pyflakes
110
+ "F",
111
+ # pyupgrade
112
+ # "UP",
113
+ # flake8-bugbear
114
+ # "B",
115
+ # flake8-simplify
116
+ # "SIM",
117
+ # isort
118
+ "I",
119
+ # flake8-bandit
120
+ "S",
121
+ ]
122
+
123
+ [tool.ruff.lint.isort]
124
+ force-single-line = true
125
+
126
+ [tool.tox]
127
+ legacy_tox_ini = """
128
+ [tox]
129
+ isolated_build = True
130
+ envlist = py{3.9,3.10,3.11,3.12}
131
+ [gh-actions]
132
+ python =
133
+ 3.9: py39
134
+ 3.10: py310
135
+ 3.11: py311
136
+ 3.12: py312
137
+ [gh-actions:env]
138
+ PLATFORM =
139
+ ubuntu-latest: linux
140
+ macos-latest: macos
141
+ windows-latest: windows
142
+ [testenv]
143
+ passenv =
144
+ CI
145
+ GITHUB_ACTIONS
146
+ GITHUB_ACTION
147
+ GITHUB_REF
148
+ GITHUB_REPOSITORY
149
+ GITHUB_HEAD_REF
150
+ GITHUB_RUN_ID
151
+ GITHUB_SHA
152
+ COVERAGE_FILE
153
+ deps = coverage
154
+ commands =
155
+ pip install -e '.[dev]'
156
+ pytest --cov --cov-report=xml
157
+ """
@@ -0,0 +1,6 @@
1
+ from importlib import metadata
2
+
3
+ try:
4
+ __version__ = metadata.version(__package__ or __name__)
5
+ except metadata.PackageNotFoundError:
6
+ __version__ = '0.0.0'
@@ -0,0 +1 @@
1
+ __version__ = '1.0.0'
@@ -0,0 +1,31 @@
1
+ import traceback
2
+
3
+ from .calculator_base import CalculatorBase
4
+ from .factory import CalculatorFactory
5
+
6
+ imported_calculators = []
7
+
8
+ try:
9
+ from .refnx.calculator import Refnx
10
+
11
+ imported_calculators.append(Refnx)
12
+ except Exception:
13
+ traceback.print_exc()
14
+ print('Warning: refnx is not installed')
15
+
16
+ # try:
17
+ # from .bornagain.calculator import BornAgain
18
+ # imported_calculators.append(BornAgain)
19
+ # except Exception:
20
+ # traceback.print_exc()
21
+ # print('Warning: BornAgain python is not installed')
22
+
23
+ try:
24
+ from .refl1d.calculator import Refl1d # noqa: F401
25
+
26
+ imported_calculators.append(Refl1d)
27
+ except Exception:
28
+ traceback.print_exc()
29
+ print('Warning: refl1d is not installed')
30
+
31
+ __all__ = [CalculatorBase, CalculatorFactory] + imported_calculators
@@ -0,0 +1,200 @@
1
+ __author__ = 'github.com/arm61'
2
+
3
+ import numpy as np
4
+ from easyreflectometry.experiment import Model
5
+ from easyreflectometry.sample import Layer
6
+ from easyreflectometry.sample import Material
7
+ from easyreflectometry.sample import MaterialMixture
8
+ from easyreflectometry.sample import Multilayer
9
+ from easyscience.Objects.Inferface import ItemContainer
10
+
11
+ from ..calculator_base import CalculatorBase
12
+ from .wrapper import BornAgainWrapper
13
+
14
+ """
15
+ THIS CODE IS NOT FUNCTIONAL
16
+ PLEASE CONSULT ONE OF THE OTHER CALCULATORS FOR A FUNCTIONAL EXAMPLE
17
+ """
18
+
19
+
20
+ class BornAgain(CalculatorBase):
21
+ """
22
+ Calculator for BornAgain
23
+ """
24
+
25
+ name = 'BornAgain'
26
+
27
+ _material_link = {
28
+ 'sld': 'real',
29
+ 'isld': 'imag',
30
+ }
31
+
32
+ _layer_link = {
33
+ 'thickness': 'thickness',
34
+ 'roughness': 'sigma',
35
+ }
36
+
37
+ _item_link = {
38
+ 'repetitions': 'repeats',
39
+ }
40
+
41
+ _model_link = {
42
+ 'scale': 'scale',
43
+ 'background': 'background',
44
+ 'resolution': 'resolution',
45
+ }
46
+
47
+ def __init__(self):
48
+ super().__init__()
49
+ self._wrapper = BornAgainWrapper()
50
+
51
+ def reset_storage(self) -> None:
52
+ """
53
+ Reset the storage area of the calculator
54
+ """
55
+ self._wrapper.reset_storage()
56
+
57
+ def create(self, model: Material | Layer | Multilayer | Model) -> list[ItemContainer]:
58
+ """
59
+ Creation function
60
+
61
+ :param model: Object to be created
62
+ :type model: Union[Material, Layer, Item, Model]
63
+ :return: Item containers of the objects
64
+ :rtype: List[ItemContainer]
65
+ """
66
+ r_list = []
67
+ t_ = type(model)
68
+ if issubclass(t_, Material):
69
+ key = model.uid
70
+ if key not in self._wrapper.storage['material'].keys():
71
+ self._wrapper.create_material(key)
72
+ r_list.append(
73
+ ItemContainer(
74
+ key,
75
+ self._material_link,
76
+ self._wrapper.get_material_value,
77
+ self._wrapper.update_material,
78
+ )
79
+ )
80
+ elif issubclass(t_, MaterialMixture):
81
+ key = model.uid
82
+ if key not in self._wrapper.storage['material'].keys():
83
+ self._wrapper.create_material(key)
84
+ r_list.append(
85
+ ItemContainer(
86
+ key,
87
+ self._material_link,
88
+ self._wrapper.get_material_value,
89
+ self._wrapper.update_material,
90
+ )
91
+ )
92
+ elif issubclass(t_, Layer):
93
+ key = model.uid
94
+ if key not in self._wrapper.storage['layer'].keys():
95
+ self._wrapper.create_layer(key)
96
+ r_list.append(
97
+ ItemContainer(
98
+ key,
99
+ self._layer_link,
100
+ self._wrapper.get_layer_value,
101
+ self._wrapper.update_layer,
102
+ )
103
+ )
104
+ self.assign_material_to_layer(model.material.uid, key)
105
+ elif issubclass(t_, Multilayer):
106
+ key = model.uid
107
+ self._wrapper.create_item(key)
108
+ r_list.append(
109
+ ItemContainer(
110
+ key,
111
+ self._item_link,
112
+ self._wrapper.get_item_value,
113
+ self._wrapper.update_item,
114
+ )
115
+ )
116
+ for i in model.layers:
117
+ self.add_layer_to_item(i.uid, model.uid)
118
+ elif issubclass(t_, Model):
119
+ self._wrapper.create_model()
120
+ r_list.append(
121
+ ItemContainer(
122
+ 'model',
123
+ self._model_link,
124
+ self._wrapper.get_model_value,
125
+ self._wrapper.update_model,
126
+ )
127
+ )
128
+ for i in model.structure:
129
+ self.add_item_to_model(i.uid)
130
+ return r_list
131
+
132
+ def assign_material_to_layer(self, material_id: int, layer_id: int) -> None:
133
+ """
134
+ Assign a material to a layer.
135
+
136
+ :param material_name: The material name
137
+ :type material_name: str
138
+ :param layer_name: The layer name
139
+ :type layer_name: str
140
+ """
141
+ self._wrapper.assign_material_to_layer(material_id, layer_id)
142
+
143
+ def add_layer_to_item(self, layer_id: int, item_id: int) -> None:
144
+ """
145
+ Add a layer to the item stack
146
+
147
+ :param item_id: The item id
148
+ :type item_id: int
149
+ :param layer_id: The layer id
150
+ :type layer_id: int
151
+ """
152
+ self._wrapper.add_layer_to_item(layer_id, item_id)
153
+
154
+ def remove_layer_from_item(self, layer_id: int, item_id: int) -> None:
155
+ """
156
+ Remove a layer from an item stack
157
+
158
+ :param item_id: The item id
159
+ :param layer_id: The layer id
160
+ """
161
+ self._wrapper.remove_layer_from_item(layer_id, item_id)
162
+
163
+ def add_item_to_model(self, item_id: int) -> None:
164
+ """
165
+ Add a layer to the item stack
166
+
167
+ :param item_id: The item id
168
+ :type item_id: int
169
+ """
170
+ self._wrapper.add_item(item_id)
171
+
172
+ def remove_item_from_model(self, item_id: int) -> None:
173
+ """
174
+ Remove a layer from the item stack
175
+
176
+ :param item_id: The item id
177
+ :type item_id: int
178
+ :param layer_id: The layer id
179
+ :type layer_id: int
180
+ """
181
+ self._wrapper.remove_item(item_id)
182
+
183
+ def fit_func(self, x_array: np.ndarray) -> np.ndarray:
184
+ """
185
+ Function to perform a fit
186
+ :param x_array: points to be calculated at
187
+ :type x_array: np.ndarray
188
+ :return: calculated points
189
+ :rtype: np.ndarray
190
+ """
191
+ return self._wrapper.calculate(x_array)
192
+
193
+ def sld_profile(self) -> tuple([np.ndarray, np.ndarray]):
194
+ """
195
+ Return the scattering length density profile.
196
+
197
+ :return: z and sld(z)
198
+ :rtype: tuple[np.ndarray, np.ndarray]
199
+ """
200
+ return self._wrapper.sld_profile()