RATapi 0.0.0.dev10__cp313-cp313-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 +141 -0
  10. ratapi/examples/convert_rascal_project/Model_IIb.py +87 -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 +31 -0
  26. ratapi/examples/domains/domains_XY_model.py +72 -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 +69 -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 +138 -0
  42. ratapi/examples/normal_reflectivity/custom_bilayer_DSPC.py +87 -0
  43. ratapi/inputs.py +588 -0
  44. ratapi/models.py +677 -0
  45. ratapi/outputs.py +821 -0
  46. ratapi/project.py +1074 -0
  47. ratapi/rat_core.cp313-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 +1231 -0
  55. ratapi/wrappers.py +144 -0
  56. ratapi-0.0.0.dev10.dist-info/METADATA +61 -0
  57. ratapi-0.0.0.dev10.dist-info/RECORD +59 -0
  58. ratapi-0.0.0.dev10.dist-info/WHEEL +5 -0
  59. ratapi-0.0.0.dev10.dist-info/top_level.txt +1 -0
ratapi/wrappers.py ADDED
@@ -0,0 +1,144 @@
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 matlab.engine
27
+
28
+ future = matlab.engine.start_matlab(background=True)
29
+
30
+ return future
31
+
32
+
33
+ class MatlabWrapper:
34
+ """Creates a python callback for a MATLAB function.
35
+
36
+ Parameters
37
+ ----------
38
+ filename : string
39
+ The path of the file containing MATLAB function
40
+
41
+ """
42
+
43
+ loader = start_matlab()
44
+ loader_error_message = "matlabengine is required to use MatlabWrapper"
45
+
46
+ def __init__(self, filename: str) -> None:
47
+ if self.loader is None:
48
+ raise ImportError(self.loader_error_message) from None
49
+
50
+ self.engine = self.loader.result()
51
+ path = pathlib.Path(filename)
52
+ self.engine.cd(str(path.parent), nargout=0)
53
+ self.function_name = path.stem
54
+
55
+ def getHandle(self) -> Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]:
56
+ """Return a wrapper for the custom MATLAB function.
57
+
58
+ Returns
59
+ -------
60
+ wrapper : Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]
61
+ The wrapper function for the MATLAB callback
62
+
63
+ """
64
+
65
+ def handle(*args):
66
+ if len(args) == 2:
67
+ output = getattr(self.engine, self.function_name)(
68
+ np.array(args[0], "float"), # xdata
69
+ np.array(args[1], "float"), # params
70
+ nargout=1,
71
+ )
72
+ return np.array(output, "float").tolist()
73
+ else:
74
+ matlab_args = [
75
+ np.array(args[0], "float"), # params
76
+ np.array(args[1], "float"), # bulk in
77
+ np.array(args[2], "float"), # bulk out
78
+ float(args[3] + 1), # contrast
79
+ ]
80
+ if len(args) > 4:
81
+ matlab_args.append(float(args[4] + 1)) # domain number
82
+
83
+ output, sub_rough = getattr(self.engine, self.function_name)(
84
+ *matlab_args,
85
+ nargout=2,
86
+ )
87
+ return np.array(output, "float").tolist(), float(sub_rough)
88
+
89
+ return handle
90
+
91
+
92
+ def use_shared_matlab(name, custom_error_message):
93
+ """Connect asynchronously to shared MATLAB engine instance with the given name.
94
+
95
+ Parameters
96
+ ----------
97
+ name : str
98
+ The name of shared MATLAB engine instance
99
+ custom_error_message : str
100
+ The custom error message in case of failed connection
101
+
102
+ Returns
103
+ -------
104
+ future : matlab.engine.futureresult.FutureResult
105
+ A future used to get the actual matlab engine.
106
+
107
+ """
108
+ with suppress(ImportError):
109
+ import matlab.engine
110
+
111
+ MatlabWrapper.loader = matlab.engine.connect_matlab(name, background=True)
112
+ MatlabWrapper.loader_error_message = custom_error_message
113
+ return MatlabWrapper.loader
114
+
115
+
116
+ class DylibWrapper:
117
+ """Creates a python callback for a function in dynamic library.
118
+
119
+ Parameters
120
+ ----------
121
+ filename : str
122
+ The path of the dynamic library
123
+ function_name : str
124
+ The name of the function to call
125
+
126
+ """
127
+
128
+ def __init__(self, filename, function_name) -> None:
129
+ self.engine = ratapi.rat_core.DylibEngine(filename, function_name)
130
+
131
+ def getHandle(self) -> Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]:
132
+ """Return a wrapper for the custom dynamic library function.
133
+
134
+ Returns
135
+ -------
136
+ wrapper : Callable[[ArrayLike, ArrayLike, ArrayLike, int, int], tuple[ArrayLike, float]]
137
+ The wrapper function for the dynamic library callback
138
+
139
+ """
140
+
141
+ def handle(*args):
142
+ return self.engine.invoke(*args)
143
+
144
+ return handle
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: ratapi
3
+ Version: 0.0.0.dev10
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=uqNt_IF1Vn6iWj9jYl6lYWwURfxAGpQXe3Se6Epa-SU,18944
5
+ ratapi/events.py,sha256=JFLnu0dJII1klA16cnRFwkyvMGWH-_Q8jYO2YGbRNcc,2877
6
+ ratapi/inputs.py,sha256=hM4qo-Nf3Kbphw3utQtYPECUcfnP0jyiEM8UI5v8oc8,23364
7
+ ratapi/models.py,sha256=A7u-CCAQ5_Wpo-k13ywtBrC-qGImBRrjEXZyZViFVDM,26469
8
+ ratapi/outputs.py,sha256=J0AVOotYXxsxxtP-gu-DAWAmK0z97VBvAwxU3GEX7SI,30083
9
+ ratapi/project.py,sha256=EaW8MFnUJ0Ky0NLfW1TDGA_Z6rfY2S7ozy7jxOH7Bwk,46196
10
+ ratapi/rat_core.cp313-win_amd64.pyd,sha256=BxyaKRJwgnGTfVuKTc1K2MB5VXTqSB_aiqUp2U0m0rk,1409024
11
+ ratapi/run.py,sha256=5XNN53yMk_fBlCm8wJClRI-bpZDIBWOp-oKwI3oLNw8,4157
12
+ ratapi/wrappers.py,sha256=LWO2VCw4UCzory81mDSyuWKjdosICpJHK4qSdmReKHM,4459
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=2ld-XIxtElesoSpwe0do2qq_lGGrRFBd_8FLOXfmhy8,4779
17
+ ratapi/examples/convert_rascal_project/Model_IIb.py,sha256=iKQleExleh5PWhjEV18HQKZaGSXOd-lKBDHmdG_wUCo,2430
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=D1X3GB9q9_GQ5W4qpdfG9HgNso2hWWZusu8gVtjfnFQ,963
33
+ ratapi/examples/domains/domains_XY_model.py,sha256=dD1H1BR1OmmGhM_kjMQpuKeOmI_-lB-B_IUdC-6uvSI,2236
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=hRHxiGHcsIeJ2e_ByPYolixdXkMA31owiwXTUwmjFeM,2188
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=piHQ5QI1yaAF1NOV4n3LBUIhtOMppzy4vph1tZOK8Ws,4767
49
+ ratapi/examples/normal_reflectivity/custom_bilayer_DSPC.py,sha256=ivDLVSNN1ALbPv_JRrGKDT0DeyYkXO7_fWTIserXf4s,2961
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=dlw1iE9Rf0PBXhRDGoyRe4ru9bHrCgjWhC9r853VZsQ,46204
56
+ ratapi-0.0.0.dev10.dist-info/METADATA,sha256=sDFKwCJpz0ZlJmSj4LDbwdwT29VRj9ZKgdXtgE_7DCg,2240
57
+ ratapi-0.0.0.dev10.dist-info/WHEEL,sha256=qV0EIPljj1XC_vuSatRWjn02nZIz3N1t8jsZz7HBr2U,101
58
+ ratapi-0.0.0.dev10.dist-info/top_level.txt,sha256=oUt3ThfFk1ORT-zYQ6yL2HjSPK-Rajryvytqix3vmhc,7
59
+ ratapi-0.0.0.dev10.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1 @@
1
+ ratapi