RATapi 0.0.0.dev13__cp314-cp314-win_amd64.whl

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 (59) hide show
  1. ratapi/__init__.py +29 -0
  2. ratapi/classlist.py +620 -0
  3. ratapi/controls.py +258 -0
  4. ratapi/eventManager.dll +0 -0
  5. ratapi/events.py +88 -0
  6. ratapi/examples/__init__.py +25 -0
  7. ratapi/examples/absorption/__init__.py +1 -0
  8. ratapi/examples/absorption/absorption.py +172 -0
  9. ratapi/examples/absorption/volume_thiol_bilayer.py +144 -0
  10. ratapi/examples/convert_rascal_project/Model_IIb.py +90 -0
  11. ratapi/examples/convert_rascal_project/__init__.py +1 -0
  12. ratapi/examples/convert_rascal_project/convert_rascal.py +49 -0
  13. ratapi/examples/data/D2O_spin_down.dat +100 -0
  14. ratapi/examples/data/D2O_spin_up.dat +101 -0
  15. ratapi/examples/data/DSPC_D2O.dat +82 -0
  16. ratapi/examples/data/DSPC_SMW.dat +82 -0
  17. ratapi/examples/data/H2O_spin_down.dat +102 -0
  18. ratapi/examples/data/H2O_spin_up.dat +102 -0
  19. ratapi/examples/data/__init__.py +1 -0
  20. ratapi/examples/data/c_PLP0016596.dat +146 -0
  21. ratapi/examples/data/c_PLP0016601.dat +97 -0
  22. ratapi/examples/data/c_PLP0016607.dat +104 -0
  23. ratapi/examples/data/d2o_background_data.dat +82 -0
  24. ratapi/examples/domains/__init__.py +1 -0
  25. ratapi/examples/domains/alloy_domains.py +34 -0
  26. ratapi/examples/domains/domains_XY_model.py +75 -0
  27. ratapi/examples/domains/domains_custom_XY.py +86 -0
  28. ratapi/examples/domains/domains_custom_layers.py +60 -0
  29. ratapi/examples/domains/domains_standard_layers.py +92 -0
  30. ratapi/examples/languages/__init__.py +1 -0
  31. ratapi/examples/languages/custom_bilayer.py +72 -0
  32. ratapi/examples/languages/run_custom_file_languages.py +41 -0
  33. ratapi/examples/languages/setup_problem.py +130 -0
  34. ratapi/examples/normal_reflectivity/DSPC_custom_XY.py +149 -0
  35. ratapi/examples/normal_reflectivity/DSPC_custom_layers.py +130 -0
  36. ratapi/examples/normal_reflectivity/DSPC_data_background.py +220 -0
  37. ratapi/examples/normal_reflectivity/DSPC_function_background.py +219 -0
  38. ratapi/examples/normal_reflectivity/DSPC_standard_layers.py +210 -0
  39. ratapi/examples/normal_reflectivity/__init__.py +1 -0
  40. ratapi/examples/normal_reflectivity/background_function.py +16 -0
  41. ratapi/examples/normal_reflectivity/custom_XY_DSPC.py +141 -0
  42. ratapi/examples/normal_reflectivity/custom_bilayer_DSPC.py +89 -0
  43. ratapi/inputs.py +595 -0
  44. ratapi/models.py +717 -0
  45. ratapi/outputs.py +821 -0
  46. ratapi/project.py +1080 -0
  47. ratapi/rat_core.cp314-win_amd64.pyd +0 -0
  48. ratapi/run.py +140 -0
  49. ratapi/utils/__init__.py +1 -0
  50. ratapi/utils/convert.py +564 -0
  51. ratapi/utils/custom_errors.py +40 -0
  52. ratapi/utils/enums.py +204 -0
  53. ratapi/utils/orso.py +247 -0
  54. ratapi/utils/plotting.py +1235 -0
  55. ratapi/wrappers.py +147 -0
  56. ratapi-0.0.0.dev13.dist-info/METADATA +61 -0
  57. ratapi-0.0.0.dev13.dist-info/RECORD +59 -0
  58. ratapi-0.0.0.dev13.dist-info/WHEEL +5 -0
  59. ratapi-0.0.0.dev13.dist-info/top_level.txt +1 -0
ratapi/wrappers.py ADDED
@@ -0,0 +1,147 @@
1
+ """Wrappers for the interface between ratapi and MATLAB custom files."""
2
+
3
+ import os
4
+ import pathlib
5
+ from collections.abc import Callable
6
+ from contextlib import suppress
7
+
8
+ import numpy as np
9
+ from numpy.typing import ArrayLike
10
+
11
+ import ratapi.rat_core
12
+
13
+
14
+ def start_matlab():
15
+ """Start MATLAB asynchronously and returns a future to retrieve the engine later.
16
+
17
+ Returns
18
+ -------
19
+ future : matlab.engine.futureresult.FutureResult
20
+ A future used to get the actual matlab engine.
21
+
22
+ """
23
+ future = None
24
+ if os.environ.get("DELAY_MATLAB_START", "0") == "0":
25
+ with suppress(ImportError):
26
+ import atexit
27
+
28
+ import matlab.engine
29
+
30
+ future = matlab.engine.start_matlab(background=True)
31
+ atexit.register(lambda: future.result())
32
+
33
+ return future
34
+
35
+
36
+ class MatlabWrapper:
37
+ """Creates a python callback for a MATLAB function.
38
+
39
+ Parameters
40
+ ----------
41
+ filename : string
42
+ The path of the file containing MATLAB function
43
+
44
+ """
45
+
46
+ loader = start_matlab()
47
+ loader_error_message = "matlabengine is required to use MatlabWrapper"
48
+
49
+ def __init__(self, filename: str) -> None:
50
+ if self.loader is None:
51
+ raise ImportError(self.loader_error_message) from None
52
+
53
+ self.engine = self.loader.result()
54
+ path = pathlib.Path(filename)
55
+ self.engine.cd(str(path.parent), nargout=0)
56
+ self.function_name = path.stem
57
+
58
+ def getHandle(self) -> Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]:
59
+ """Return a wrapper for the custom MATLAB function.
60
+
61
+ Returns
62
+ -------
63
+ wrapper : Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]
64
+ The wrapper function for the MATLAB callback
65
+
66
+ """
67
+
68
+ def handle(*args):
69
+ if len(args) == 2:
70
+ output = getattr(self.engine, self.function_name)(
71
+ np.array(args[0], "float"), # xdata
72
+ np.array(args[1], "float"), # params
73
+ nargout=1,
74
+ )
75
+ return np.array(output, "float").tolist()
76
+ else:
77
+ matlab_args = [
78
+ np.array(args[0], "float"), # params
79
+ np.array(args[1], "float"), # bulk in
80
+ np.array(args[2], "float"), # bulk out
81
+ float(args[3]), # contrast
82
+ ]
83
+ if len(args) > 4:
84
+ matlab_args.append(float(args[4])) # domain number
85
+
86
+ output, sub_rough = getattr(self.engine, self.function_name)(
87
+ *matlab_args,
88
+ nargout=2,
89
+ )
90
+ return np.array(output, "float").tolist(), float(sub_rough)
91
+
92
+ return handle
93
+
94
+
95
+ def use_shared_matlab(name, custom_error_message):
96
+ """Connect asynchronously to shared MATLAB engine instance with the given name.
97
+
98
+ Parameters
99
+ ----------
100
+ name : str
101
+ The name of shared MATLAB engine instance
102
+ custom_error_message : str
103
+ The custom error message in case of failed connection
104
+
105
+ Returns
106
+ -------
107
+ future : matlab.engine.futureresult.FutureResult
108
+ A future used to get the actual matlab engine.
109
+
110
+ """
111
+ with suppress(ImportError):
112
+ import matlab.engine
113
+
114
+ MatlabWrapper.loader = matlab.engine.connect_matlab(name, background=True)
115
+ MatlabWrapper.loader_error_message = custom_error_message
116
+ return MatlabWrapper.loader
117
+
118
+
119
+ class DylibWrapper:
120
+ """Creates a python callback for a function in dynamic library.
121
+
122
+ Parameters
123
+ ----------
124
+ filename : str
125
+ The path of the dynamic library
126
+ function_name : str
127
+ The name of the function to call
128
+
129
+ """
130
+
131
+ def __init__(self, filename, function_name) -> None:
132
+ self.engine = ratapi.rat_core.DylibEngine(filename, function_name)
133
+
134
+ def getHandle(self) -> Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]:
135
+ """Return a wrapper for the custom dynamic library function.
136
+
137
+ Returns
138
+ -------
139
+ wrapper : Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]
140
+ The wrapper function for the dynamic library callback
141
+
142
+ """
143
+
144
+ def handle(*args):
145
+ return self.engine.invoke(*args)
146
+
147
+ return handle
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: ratapi
3
+ Version: 0.0.0.dev13
4
+ Summary: Python extension for the Reflectivity Analysis Toolbox (RAT)
5
+ Project-URL: Documentation, https://rascalsoftware.github.io/RAT/
6
+ Project-URL: Repository, https://github.com/RascalSoftware/python-RAT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: matplotlib>=3.8.3
10
+ Requires-Dist: numpy>=1.20
11
+ Requires-Dist: prettytable>=3.9.0
12
+ Requires-Dist: pydantic>=2.7.2
13
+ Requires-Dist: scipy>=1.13.1
14
+ Requires-Dist: strenum>=0.4.15; python_full_version < "3.11"
15
+ Requires-Dist: tqdm>=4.66.5
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
18
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
19
+ Requires-Dist: ruff>=0.4.10; extra == "dev"
20
+ Provides-Extra: orso
21
+ Requires-Dist: orsopy>=1.2.1; extra == "orso"
22
+ Requires-Dist: pint>=0.24.4; extra == "orso"
23
+ Provides-Extra: matlab-latest
24
+ Requires-Dist: matlabengine; extra == "matlab-latest"
25
+ Provides-Extra: matlab-2025b
26
+ Requires-Dist: matlabengine==25.2.*; extra == "matlab-2025b"
27
+ Provides-Extra: matlab-2025a
28
+ Requires-Dist: matlabengine==25.1.2; extra == "matlab-2025a"
29
+ Provides-Extra: matlab-2024b
30
+ Requires-Dist: matlabengine==24.2.2; extra == "matlab-2024b"
31
+ Provides-Extra: matlab-2024a
32
+ Requires-Dist: matlabengine==24.1.4; extra == "matlab-2024a"
33
+ Provides-Extra: matlab-2023b
34
+ Requires-Dist: matlabengine==23.2.3; extra == "matlab-2023b"
35
+ Provides-Extra: matlab-2023a
36
+ Requires-Dist: matlabengine==9.14.3; extra == "matlab-2023a"
37
+
38
+ python-RAT
39
+ ==========
40
+ Python-RAT is the Python interface for the [Reflectivity Algorithm Toolbox](https://github.com/RascalSoftware/RAT) (RAT).
41
+
42
+ Install
43
+ =======
44
+ To install in local directory:
45
+
46
+ git clone --recurse-submodules https://github.com/RascalSoftware/python-RAT.git
47
+ cd python-RAT
48
+ pip install -e .
49
+
50
+ matlabengine is an optional dependency only required for Matlab custom functions. The version of matlabengine should match the version of Matlab installed on the machine. This can be installed as shown below:
51
+
52
+ pip install -e .[matlab-2023a]
53
+
54
+ Development dependencies can be installed as shown below
55
+
56
+ pip install -e .[dev]
57
+
58
+ To build wheel:
59
+
60
+ pip install build
61
+ python -m build --wheel
@@ -0,0 +1,59 @@
1
+ ratapi/__init__.py,sha256=Bdz21Q4ACFgTm9tqGv-kT5ca8NyiDKfoCT3XNI5PZxo,747
2
+ ratapi/classlist.py,sha256=x-nnXQyXSvCS5gePIPIHeNvbylxaKL6nDxPsYYrxQ34,27383
3
+ ratapi/controls.py,sha256=lKby0MMpK1RvmSEHjnl_4_JUzyBTLvZNS-AVVRYiQS4,10174
4
+ ratapi/eventManager.dll,sha256=MH2NjfJE0ReC0dudp_pWAEHDlu8mNnv3-tuVSnbRSHs,18944
5
+ ratapi/events.py,sha256=JFLnu0dJII1klA16cnRFwkyvMGWH-_Q8jYO2YGbRNcc,2877
6
+ ratapi/inputs.py,sha256=vbKvoXjABwCyadd_Wuh1DQr-iTSywk7J2v-H8_DrAW8,23727
7
+ ratapi/models.py,sha256=Y_BBKDGOnTg3EcQmoZp3OZxsls3bhq6zf8AWGflZ3gI,27703
8
+ ratapi/outputs.py,sha256=J0AVOotYXxsxxtP-gu-DAWAmK0z97VBvAwxU3GEX7SI,30083
9
+ ratapi/project.py,sha256=IutLSzznPJw27XtbHeAIYiO-OFrnxAHp7S086fMhkHI,46431
10
+ ratapi/rat_core.cp314-win_amd64.pyd,sha256=4dZFKeiBWWClI-Lq6ycMkDpokCGY2dffSmBdTYUQWqc,1368064
11
+ ratapi/run.py,sha256=5XNN53yMk_fBlCm8wJClRI-bpZDIBWOp-oKwI3oLNw8,4157
12
+ ratapi/wrappers.py,sha256=gZEHR7q7QOQrnasQCnJ-ldu3jSlgV-DB3oZWK_IVjJA,4534
13
+ ratapi/examples/__init__.py,sha256=RJeghub-4vDwxY2Dp3coaF2j_do7xJF31Rlx-F128Z8,1167
14
+ ratapi/examples/absorption/__init__.py,sha256=AvHkIykpQRjlO6efYOttHsjvQ_hdr8cMi4UMxC8MvTo,56
15
+ ratapi/examples/absorption/absorption.py,sha256=qe2Y8B8VGdY53FE0HCGTyOWkRk7AHJEoNNfEp4IM3Uw,7290
16
+ ratapi/examples/absorption/volume_thiol_bilayer.py,sha256=ZsUGcE_30YUVnPx0F2jHeupbTUFmH7qKEWmMkqVPi1U,4963
17
+ ratapi/examples/convert_rascal_project/Model_IIb.py,sha256=le0M6S1X2sXUKYmAorAl3a2XdvK5qJk6Op1WOowVAUs,2594
18
+ ratapi/examples/convert_rascal_project/__init__.py,sha256=eY25J6hnHGKjok1O-l6jas-FA81wgpYUl5ls6rVLjX4,58
19
+ ratapi/examples/convert_rascal_project/convert_rascal.py,sha256=ewZVOHkC4e8lNuRQh8R4rpaGWlr7cLAeEFBQ2E9K3cY,1650
20
+ ratapi/examples/data/D2O_spin_down.dat,sha256=drdy9BhxbwBd8K6WOqgmb9hFa7JyZ84djVBRP7hcEaQ,4995
21
+ ratapi/examples/data/D2O_spin_up.dat,sha256=BNf9GnYbfSI_N-jBkYOUCTLYyaVnOFk_QllNtAlcvsk,5027
22
+ ratapi/examples/data/DSPC_D2O.dat,sha256=asZY6C-9pkkyVuwwllNwTgUGgISIkq4_-tTJYWiyeF4,2529
23
+ ratapi/examples/data/DSPC_SMW.dat,sha256=nQ2Y7F8rLhffB6Wds_isJcS2DUB4awig8TjqOepFtCE,2556
24
+ ratapi/examples/data/H2O_spin_down.dat,sha256=tp0yBZRUmr2xS4c27jPwHeVF9bQ3nR_3UBiniOYOK80,5110
25
+ ratapi/examples/data/H2O_spin_up.dat,sha256=5xastIRtR-D91l8oov0VhWQDCOKqv0ZKDuurdYHXKhg,5078
26
+ ratapi/examples/data/__init__.py,sha256=5dxIqMk_Pyi_-MIZcdcxOovd9WsxiI0TgmKDXHIiFhQ,40
27
+ ratapi/examples/data/c_PLP0016596.dat,sha256=Zbdoyu4Z5EU9-m32wOP-D33ESYtqOQu1zEAceM3URng,5796
28
+ ratapi/examples/data/c_PLP0016601.dat,sha256=i69TFgZJq2fgEmbrvqbIyHekCj3Fd2lysJ_5KLY8eLw,3980
29
+ ratapi/examples/data/c_PLP0016607.dat,sha256=yZ4Zo34h2m0qQwKt-e1aQGtzoTmfgwYu8zqAN21lGpY,4226
30
+ ratapi/examples/data/d2o_background_data.dat,sha256=TiBb850fJNFFZkm25p9i-d9MJllKFz3iNnOj2yNPhuw,4237
31
+ ratapi/examples/domains/__init__.py,sha256=040uyVQErtF_8DGgbcPopvK_UKIf0TeQ_aL-AsipJnk,56
32
+ ratapi/examples/domains/alloy_domains.py,sha256=uEOWp_CoYL6hX-uoz_y0vPU4iyHakHpKt_aWI-uQoGE,1131
33
+ ratapi/examples/domains/domains_XY_model.py,sha256=jOc8nSJnSRvIVfFw8J6YCDLpN0nGl7eiIegHLUzx9dc,2408
34
+ ratapi/examples/domains/domains_custom_XY.py,sha256=LE2CCTAURomOfQYT43gEt-LZwrxLrwUiB7PVC1SHWBw,3072
35
+ ratapi/examples/domains/domains_custom_layers.py,sha256=9JM8T1AAQc7al0FL-RK_d1i5IKsAgbOruOGAOFbhxxk,2405
36
+ ratapi/examples/domains/domains_standard_layers.py,sha256=1cp4qD4f-YD5-_a3TBIfSO10kQpL3H8A4bJ25RCxCNc,3769
37
+ ratapi/examples/languages/__init__.py,sha256=frssBG2yVyVpurgGOHXLKS4RnDnoMXwt-BjwvEn0g30,76
38
+ ratapi/examples/languages/custom_bilayer.py,sha256=_o5RGg2-HoVKfb2EFGy26dGSKSFHldW_gLcdqE-kPWM,2325
39
+ ratapi/examples/languages/run_custom_file_languages.py,sha256=KVR4Z2h2qVtwGeL1q57uKXEEwUlJ0w6c5rO_M65ZeXw,992
40
+ ratapi/examples/languages/setup_problem.py,sha256=EuoNYYeSIRngvTYoAuep_QpAUIcXdCAeLyYL6efdZJY,5085
41
+ ratapi/examples/normal_reflectivity/DSPC_custom_XY.py,sha256=BFXESpwb5vic1KOJesS2Ek5LQtKwRO2bIJ5dlbqbj18,6617
42
+ ratapi/examples/normal_reflectivity/DSPC_custom_layers.py,sha256=YyKa_957J-8N0CGfVixFKvE6ErBeM2fueeTnpUB12V4,5391
43
+ ratapi/examples/normal_reflectivity/DSPC_data_background.py,sha256=K7W-oz-vAIqskNUH17VZ8BfvjkCwsFQrZ3UgI0E2TbQ,7525
44
+ ratapi/examples/normal_reflectivity/DSPC_function_background.py,sha256=hFDRNuD2Mfob9DUnHOdQFRsj5AOFFtQ4CCKz6X9wq4k,7622
45
+ ratapi/examples/normal_reflectivity/DSPC_standard_layers.py,sha256=y6cdBYHIIra3c4S8q4y0Na2Daeu4NHhdWCtKYDVLlgU,7207
46
+ ratapi/examples/normal_reflectivity/__init__.py,sha256=QEDy2npaDpbj6hLqKUQ9ptF8hzADRf8UYIxz7x_cFWI,60
47
+ ratapi/examples/normal_reflectivity/background_function.py,sha256=1cRJ3gzomNVLVAhho1BTrB-Bhb_Qw9NhDDTJzBU2HEE,422
48
+ ratapi/examples/normal_reflectivity/custom_XY_DSPC.py,sha256=olLBRAGw6yzZQsd86lho_qSbWZosrJFSCydbprxuseA,4892
49
+ ratapi/examples/normal_reflectivity/custom_bilayer_DSPC.py,sha256=cTLvWTF3BHHvVQWEjfusN63MKDo3UGcRvty_iTIdmvg,3096
50
+ ratapi/utils/__init__.py,sha256=iTgJ6QP0xqK1kbyIOOgt1EyztClPxuYLqzctRz49MY8,40
51
+ ratapi/utils/convert.py,sha256=MAm4gdt6PN4G6ukMrX-2AAAiybEoy7BIMSRYYyDmqSc,22370
52
+ ratapi/utils/custom_errors.py,sha256=Zbvhoy8GEJfe7GPnsBmuMc0w2Rtvc1d8u5iE6NCxxnY,1579
53
+ ratapi/utils/enums.py,sha256=mSW-hbOE6dKEmM5AucA0BlZFg2BQ4i6KMlsuYX7XEO8,6189
54
+ ratapi/utils/orso.py,sha256=pttqRzBAJP_eemdUFNSUneBMsAc_NtoeODz6GDM2hEw,8342
55
+ ratapi/utils/plotting.py,sha256=60HtY0wY22skyRnf-j_B2zbK4-oxmUyzpmFCKEwBwVM,46311
56
+ ratapi-0.0.0.dev13.dist-info/METADATA,sha256=4kGT9lYDZSyU5nRUEwd7dQ-AldUEyh105ApILkrxwXQ,2240
57
+ ratapi-0.0.0.dev13.dist-info/WHEEL,sha256=jhxrRP3tdEfm7toB1X7dl5x6f0bu6Tve2cWwIdkbL8U,101
58
+ ratapi-0.0.0.dev13.dist-info/top_level.txt,sha256=oUt3ThfFk1ORT-zYQ6yL2HjSPK-Rajryvytqix3vmhc,7
59
+ ratapi-0.0.0.dev13.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-win_amd64
5
+
@@ -0,0 +1 @@
1
+ ratapi