scietex.hal.vacuum-gauge 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.
Files changed (53) hide show
  1. scietex_hal_vacuum_gauge-1.0.0/LICENSE +21 -0
  2. scietex_hal_vacuum_gauge-1.0.0/PKG-INFO +89 -0
  3. scietex_hal_vacuum_gauge-1.0.0/README.md +43 -0
  4. scietex_hal_vacuum_gauge-1.0.0/pyproject.toml +53 -0
  5. scietex_hal_vacuum_gauge-1.0.0/setup.cfg +4 -0
  6. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/__init__.py +15 -0
  7. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/base/__init__.py +25 -0
  8. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/base/analog.py +273 -0
  9. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/base/atmosphere.py +74 -0
  10. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/edwards/__init__.py +20 -0
  11. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/edwards/analog.py +115 -0
  12. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/edwards/calibration_data.py +139 -0
  13. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/__init__.py +20 -0
  14. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/analog.py +202 -0
  15. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/__init__.py +0 -0
  16. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/v1/__init__.py +30 -0
  17. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/v1/client.py +11 -0
  18. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/v1/emulation.py +11 -0
  19. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/v2/__init__.py +21 -0
  20. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/erstevak/rs485/v2/client.py +12 -0
  21. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/leybold/__init__.py +19 -0
  22. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/leybold/analog.py +120 -0
  23. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/py.typed +0 -0
  24. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/__init__.py +0 -0
  25. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/__init__.py +0 -0
  26. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/checksum.py +48 -0
  27. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/decoder.py +130 -0
  28. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/framer.py +163 -0
  29. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/__init__.py +30 -0
  30. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/client.py +555 -0
  31. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/data.py +187 -0
  32. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/decoder.py +21 -0
  33. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/emulation.py +336 -0
  34. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/emulation_utils.py +268 -0
  35. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/framer.py +21 -0
  36. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v1/request.py +168 -0
  37. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/__init__.py +0 -0
  38. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/client.py +869 -0
  39. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/data.py +441 -0
  40. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/decoder.py +79 -0
  41. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/framer.py +38 -0
  42. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/thyracont/rs485/v2/request.py +185 -0
  43. scietex_hal_vacuum_gauge-1.0.0/src/scietex/hal/vacuum_gauge/version.py +8 -0
  44. scietex_hal_vacuum_gauge-1.0.0/src/scietex.hal.vacuum_gauge.egg-info/PKG-INFO +89 -0
  45. scietex_hal_vacuum_gauge-1.0.0/src/scietex.hal.vacuum_gauge.egg-info/SOURCES.txt +51 -0
  46. scietex_hal_vacuum_gauge-1.0.0/src/scietex.hal.vacuum_gauge.egg-info/dependency_links.txt +1 -0
  47. scietex_hal_vacuum_gauge-1.0.0/src/scietex.hal.vacuum_gauge.egg-info/requires.txt +13 -0
  48. scietex_hal_vacuum_gauge-1.0.0/src/scietex.hal.vacuum_gauge.egg-info/top_level.txt +1 -0
  49. scietex_hal_vacuum_gauge-1.0.0/tests/test_base.py +209 -0
  50. scietex_hal_vacuum_gauge-1.0.0/tests/test_edwards_analog.py +145 -0
  51. scietex_hal_vacuum_gauge-1.0.0/tests/test_erstevak_analog.py +188 -0
  52. scietex_hal_vacuum_gauge-1.0.0/tests/test_leybold_analog.py +102 -0
  53. scietex_hal_vacuum_gauge-1.0.0/tests/test_version.py +47 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anton Bondarenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: scietex.hal.vacuum_gauge
3
+ Version: 1.0.0
4
+ Summary: Scietex Vacuum Gauge HAL package
5
+ Author-email: Anton Bondarenko <bond.anton@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Anton Bondarenko
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/bond-anton/scietex.hal.vacuum_gauge
28
+ Project-URL: Bug Tracker, https://github.com/bond-anton/scietex.hal.vacuum_gauge/issues
29
+ Classifier: Programming Language :: Python :: 3
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Requires-Python: >=3.9
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: numpy<3.0.0,>=2.0.0
36
+ Requires-Dist: scietex.hal.analog-sensor<2.0.0,>=1.0.0
37
+ Requires-Dist: scietex.hal.serial<2.0.0,>=1.0.0
38
+ Provides-Extra: dev
39
+ Provides-Extra: test
40
+ Requires-Dist: flake8; extra == "test"
41
+ Requires-Dist: pytest; extra == "test"
42
+ Requires-Dist: pytest-asyncio; extra == "test"
43
+ Provides-Extra: lint
44
+ Requires-Dist: pylint; extra == "lint"
45
+ Dynamic: license-file
46
+
47
+ # scietex.hal.vacuum_gauge
48
+
49
+ `scietex.hal.vacuum_gauge` is a Python library for interfacing with and emulating vacuum gauges
50
+ from various manufacturers, including Edwards, Leybold, and Erstevak. It provides a modular
51
+ framework for converting analog voltage outputs to pressure readings and communicating with gauges
52
+ over RS485 protocols. The library is designed for use in scientific and industrial applications,
53
+ offering both client-side interaction with physical hardware and server-side emulation for testing
54
+ and development.
55
+
56
+ ## Features
57
+ - **Analog Gauge Support**: Convert voltage outputs to pressure readings (in millibars)
58
+ for Edwards (APG-M, APG-L), Leybold (TTR 101 N), and Erstevak (MTP4D, MTM9D) gauges using
59
+ interpolation or exponential formulas.
60
+ - **RS485 Communication**: Full support for Erstevak’s RS485 protocol (version 1),
61
+ including client-side control and server-side emulation.
62
+ - **Modular Design**: Organized into subpackages (`base`, `edwards`, `leybold`, `erstevak`)
63
+ for easy extension to additional manufacturers or models.
64
+ - **Atmospheric Adjustments**: Apply gas-specific correction factors to pressure calculations.
65
+ - **Emulation**: Simulate Erstevak gauge behavior for testing without physical hardware.
66
+ - **Backends**: Supports `pymodbus` and `pyserial` for flexible RS485 communication.
67
+
68
+ ## System Requirements
69
+
70
+ - **Python**: 3.9 or higher.
71
+ - **Operating Systems**: Compatible with **Linux** and **macOS**.
72
+
73
+ ## Installation
74
+
75
+ To install the package, execute the following command in your terminal:
76
+
77
+ ```bash
78
+ pip install scietex.hal.vacuum_gauge
79
+ ```
80
+
81
+ ## Contribution
82
+ We welcome contributions to the project! Whether it's bug fixes, feature enhancements,
83
+ or documentation improvements, your input is valuable. Please feel free to submit
84
+ pull requests or open issues to discuss potential changes.
85
+
86
+ ## License
87
+
88
+ This project is licensed under the MIT License. For more details, please refer
89
+ to the `LICENSE` file included in the repository.
@@ -0,0 +1,43 @@
1
+ # scietex.hal.vacuum_gauge
2
+
3
+ `scietex.hal.vacuum_gauge` is a Python library for interfacing with and emulating vacuum gauges
4
+ from various manufacturers, including Edwards, Leybold, and Erstevak. It provides a modular
5
+ framework for converting analog voltage outputs to pressure readings and communicating with gauges
6
+ over RS485 protocols. The library is designed for use in scientific and industrial applications,
7
+ offering both client-side interaction with physical hardware and server-side emulation for testing
8
+ and development.
9
+
10
+ ## Features
11
+ - **Analog Gauge Support**: Convert voltage outputs to pressure readings (in millibars)
12
+ for Edwards (APG-M, APG-L), Leybold (TTR 101 N), and Erstevak (MTP4D, MTM9D) gauges using
13
+ interpolation or exponential formulas.
14
+ - **RS485 Communication**: Full support for Erstevak’s RS485 protocol (version 1),
15
+ including client-side control and server-side emulation.
16
+ - **Modular Design**: Organized into subpackages (`base`, `edwards`, `leybold`, `erstevak`)
17
+ for easy extension to additional manufacturers or models.
18
+ - **Atmospheric Adjustments**: Apply gas-specific correction factors to pressure calculations.
19
+ - **Emulation**: Simulate Erstevak gauge behavior for testing without physical hardware.
20
+ - **Backends**: Supports `pymodbus` and `pyserial` for flexible RS485 communication.
21
+
22
+ ## System Requirements
23
+
24
+ - **Python**: 3.9 or higher.
25
+ - **Operating Systems**: Compatible with **Linux** and **macOS**.
26
+
27
+ ## Installation
28
+
29
+ To install the package, execute the following command in your terminal:
30
+
31
+ ```bash
32
+ pip install scietex.hal.vacuum_gauge
33
+ ```
34
+
35
+ ## Contribution
36
+ We welcome contributions to the project! Whether it's bug fixes, feature enhancements,
37
+ or documentation improvements, your input is valuable. Please feel free to submit
38
+ pull requests or open issues to discuss potential changes.
39
+
40
+ ## License
41
+
42
+ This project is licensed under the MIT License. For more details, please refer
43
+ to the `LICENSE` file included in the repository.
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scietex.hal.vacuum_gauge"
7
+ dynamic = ["version"]
8
+ description = "Scietex Vacuum Gauge HAL package"
9
+ authors = [
10
+ { name = "Anton Bondarenko", email = "bond.anton@gmail.com" },
11
+ ]
12
+ license = { file = "LICENSE" }
13
+ readme = "README.md"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ requires-python = ">=3.9"
20
+ dependencies = [
21
+ "numpy >= 2.0.0, < 3.0.0",
22
+ "scietex.hal.analog-sensor >= 1.0.0, < 2.0.0",
23
+ "scietex.hal.serial >= 1.0.0, < 2.0.0",
24
+ ]
25
+
26
+ [project.urls]
27
+ "Homepage" = "https://github.com/bond-anton/scietex.hal.vacuum_gauge"
28
+ "Bug Tracker" = "https://github.com/bond-anton/scietex.hal.vacuum_gauge/issues"
29
+
30
+ [project.optional-dependencies]
31
+ dev = []
32
+ test = ["flake8", "pytest", "pytest-asyncio"]
33
+ lint = ["pylint"]
34
+
35
+ [tool.setuptools.dynamic]
36
+ version = {attr = "scietex.hal.vacuum_gauge.version.__version__"}
37
+
38
+ [tool.setuptools.package-data]
39
+ "scietex.hal.vacuum_gauge" = ["py.typed"]
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.black]
45
+ line-length = 100
46
+
47
+ [tool.mypy]
48
+ python_version = "3.9"
49
+
50
+ [tool.pytest.ini_options]
51
+ pythonpath = [
52
+ "src"
53
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ """
2
+ Vacuum Gauge Package.
3
+
4
+ This package provides a modular framework for interfacing with vacuum gauges over serial
5
+ communication protocols, such as RS485, within the `scietex.hal` ecosystem. It supports both
6
+ client-side interaction with physical vacuum gauges and server-side emulation for testing and
7
+ development. The package is designed to be extensible, allowing for the addition of support for
8
+ different gauge manufacturers and models through subpackages.
9
+
10
+ Currently, the package includes support for Erstevak vacuum gauges via the `erstevak` subpackage,
11
+ which implements the Erstevak RS485 protocol (version 1). Future expansions may include additional
12
+ manufacturers or protocol versions.
13
+ """
14
+
15
+ from .version import __version__
@@ -0,0 +1,25 @@
1
+ """
2
+ Base Vacuum Gauge Subpackage.
3
+
4
+ This subpackage provides foundational classes and utilities for working with analog vacuum gauges.
5
+ It includes abstract and concrete implementations for converting analog voltage outputs to pressure
6
+ readings in millibars (mbar), supporting various atmospheric gases and customizable gauge
7
+ parameters. These components serve as building blocks for specific gauge implementations
8
+ (e.g., in the `edwards` subpackage).
9
+
10
+ Classes:
11
+ Atmosphere: An enumeration of supported atmospheric gases for pressure conversion adjustments.
12
+ ExponentialVacuumGauge: An abstract base class for vacuum gauges with exponential output.
13
+ InterpolationVacuumGauge: A class for vacuum gauges using linear interpolation based on
14
+ calibration data.
15
+
16
+ Modules:
17
+ atmosphere: Defines the `Atmosphere` enumeration for gas type handling.
18
+ analog: Contains the core vacuum gauge classes `ExponentialVacuumGauge` and
19
+ `InterpolationVacuumGauge`.
20
+ """
21
+
22
+ from .atmosphere import Atmosphere
23
+ from .analog import ExponentialVacuumGauge, InterpolationVacuumGauge
24
+
25
+ __all__ = ["Atmosphere", "ExponentialVacuumGauge", "InterpolationVacuumGauge"]
@@ -0,0 +1,273 @@
1
+ """
2
+ Analog Vacuum Gauge Module.
3
+
4
+ This module provides functionality for working with analog vacuum gauges, converting analog
5
+ output voltage to pressure readings in millibar (mbar) units. It supports various atmospheric
6
+ gases and allows customization of the gauge model and atmosphere.
7
+
8
+ Classes:
9
+ - ExponentialVacuumGauge: An abstract base class for handling analog vacuum gauge operations
10
+ with exponential output, including voltage-to-pressure conversion. This class is intended
11
+ to be inherited by subclasses that implement specific gauge models.
12
+ - InterpolationVacuumGauge: A class for handling analog vacuum gauges using linear interpolation
13
+ based on calibration data, converting voltage to pressure with atmospheric gas adjustments.
14
+
15
+ Key Features:
16
+ - Supports multiple atmospheric gases with customizable conversion factors.
17
+ - Converts analog voltage readings to pressure values in millibars (mbar).
18
+ - Configurable gauge model, voltage range, pressure range, and atmosphere for accurate
19
+ calculations.
20
+ - Offers both exponential and interpolation-based conversion methods.
21
+ """
22
+
23
+ from typing import Union, Optional
24
+ import numpy as np
25
+ from numpy.typing import NDArray
26
+
27
+ from scietex.hal.analog_sensor import AnalogSensorInterface, LinearInterpolatorSensor
28
+ from .atmosphere import Atmosphere
29
+
30
+
31
+ # pylint: disable=too-few-public-methods
32
+ class ExponentialVacuumGauge(AnalogSensorInterface):
33
+ """
34
+ An abstract base class for handling analog vacuum gauges with exponential output.
35
+
36
+ This class provides a foundation for converting analog output voltage from a vacuum gauge into
37
+ pressure readings in millibars (mbar) using an exponential relationship.
38
+ It supports customization for different atmospheric gases and gauge-specific parameters.
39
+ Subclasses should override `convert_voltage` to implement model-specific conversion logic.
40
+
41
+ Attributes:
42
+ model_name (str): The model identifier of the vacuum gauge.
43
+ offset_voltage (float): Voltage offset used in the pressure calculation.
44
+ scale (float): Scaling factor for the voltage difference in the exponential pressure
45
+ conversion.
46
+ v_min (float): Minimum voltage threshold; inputs below this are clamped to `p_min`.
47
+ v_max (float): Maximum voltage threshold; inputs above this are clamped to `p_max`.
48
+ p_min (float): Minimum pressure output in mbar before atmospheric scaling (e.g., 5e-5).
49
+ p_max (float): Maximum pressure output in mbar before atmospheric scaling (e.g., 1.5e3).
50
+ atmosphere (Atmosphere): The atmospheric gas used for calculations.
51
+ atmosphere_factor (dict[Atmosphere, float]): A dictionary mapping atmospheric gases to
52
+ their respective conversion factors. Defaults to 1.0 for all supported gases.
53
+
54
+ Methods:
55
+ convert_voltage(voltage: Union[float, NDArray[np.float64]])
56
+ -> Union[float, NDArray[np.float64]]:
57
+ Converts analog output voltage to pressure (mbar) based on the gauge model and
58
+ atmosphere.
59
+ """
60
+
61
+ atmosphere_factor = {
62
+ Atmosphere.AIR: 1.0,
63
+ Atmosphere.AR: 1.0,
64
+ Atmosphere.CO: 1.0,
65
+ Atmosphere.CO2: 1.0,
66
+ Atmosphere.H2: 1.0,
67
+ Atmosphere.HE: 1.0,
68
+ Atmosphere.N2: 1.0,
69
+ Atmosphere.O2: 1.0,
70
+ Atmosphere.NE: 1.0,
71
+ Atmosphere.KR: 1.0,
72
+ Atmosphere.XE: 1.0,
73
+ }
74
+
75
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
76
+ def __init__(
77
+ self,
78
+ model_name: str,
79
+ offset_voltage: float = 5.0,
80
+ scale: float = 1.0,
81
+ v_min: float = 0.0,
82
+ v_max: float = 10.0,
83
+ p_min: float = 5e-5,
84
+ p_max: float = 1.5e3,
85
+ atmosphere: Optional[Union[str, Atmosphere]] = None,
86
+ ):
87
+ """
88
+ Initializes the ExponentialVacuumGauge instance.
89
+
90
+ Args:
91
+ model_name (str): The model identifier of the vacuum gauge.
92
+ offset_voltage (float, optional): Voltage offset for the pressure calculation.
93
+ Defaults to 5.0.
94
+ scale (float, optional): Scaling factor for the voltage difference in the exponential
95
+ pressure conversion. Defaults to 1.0.
96
+ v_min (float, optional): Minimum voltage threshold; inputs below this are clamped to
97
+ `p_min`. Defaults to 0.0.
98
+ v_max (float, optional): Maximum voltage threshold; inputs above this are clamped to
99
+ `p_max`. Defaults to 10.0.
100
+ p_min (float, optional): Minimum pressure output in mbar before atmospheric scaling.
101
+ Defaults to 5e-5.
102
+ p_max (float, optional): Maximum pressure output in mbar before atmospheric scaling.
103
+ Defaults to 1.5e3.
104
+ atmosphere (Optional[Union[str, Atmosphere]], optional): The atmospheric gas used for
105
+ calculations, either as an `Atmosphere` member or its string value (e.g., "Air").
106
+ Defaults to `Atmosphere.AIR` if not provided.
107
+ """
108
+ super().__init__(model_name)
109
+ self.offset_voltage: float = offset_voltage
110
+ self.scale: float = scale
111
+ self.v_min: float = v_min
112
+ self.v_max: float = v_max
113
+ self.p_min: float = p_min
114
+ self.p_max: float = p_max
115
+ self.atmosphere: Atmosphere
116
+ if isinstance(atmosphere, str):
117
+ self.atmosphere = Atmosphere.from_string(atmosphere)
118
+ else:
119
+ self.atmosphere = atmosphere if atmosphere is not None else Atmosphere.AIR
120
+
121
+ def convert_voltage(
122
+ self, voltage: Union[float, NDArray[np.float64]]
123
+ ) -> Union[float, NDArray[np.float64]]:
124
+ """
125
+ Converts analog output voltage to pressure (mbar).
126
+
127
+ This method calculates pressure in millibars (mbar) from analog voltage using an
128
+ exponential formula: `pressure = 10 ** ((voltage - offset_voltage) / scale)`.
129
+ Voltages below `v_min` or above `v_max` are clamped to `p_min` or `p_max`, respectively.
130
+ The entire pressure result, including clamps, is then scaled by the atmospheric gas factor.
131
+ This is a basic implementation and should be overridden in subclasses for model-specific
132
+ conversion logic.
133
+
134
+ Args:
135
+ voltage (Union[float, NDArray[np.float64]]): The analog output voltage(s) from the
136
+ vacuum gauge. Can be a single float or a NumPy array.
137
+
138
+ Returns:
139
+ Union[float, NDArray[np.float64]]: The calculated pressure in millibars (mbar),
140
+ matching the input type (float or array).
141
+ """
142
+ voltage_array = np.asarray(voltage)
143
+ clamped_voltage = np.clip(voltage_array, self.v_min, self.v_max)
144
+ pressure = np.where(
145
+ clamped_voltage == self.v_min,
146
+ self.p_min,
147
+ np.where(
148
+ clamped_voltage == self.v_max,
149
+ self.p_max,
150
+ 10 ** ((clamped_voltage - self.offset_voltage) / self.scale),
151
+ ),
152
+ )
153
+ pressure *= self.atmosphere_factor[self.atmosphere]
154
+ return pressure if isinstance(voltage, np.ndarray) else float(pressure)
155
+
156
+
157
+ # pylint: disable=too-few-public-methods
158
+ class InterpolationVacuumGauge(LinearInterpolatorSensor):
159
+ """
160
+ A class for handling analog vacuum gauges using linear interpolation based on calibration data.
161
+
162
+ This class extends `LinearInterpolatorSensor` to convert analog output voltage from a vacuum
163
+ gauge into pressure readings in millibars (mbar) using linear interpolation over provided
164
+ calibration data. It supports atmospheric gas adjustments and enforces voltage and pressure
165
+ limits. It is designed for vacuum gauges where pressure is mapped directly from voltage via
166
+ calibration points (e.g., Edwards APG-M or APG-L).
167
+
168
+ Attributes:
169
+ model_name (str): The model identifier of the vacuum gauge.
170
+ data (NDArray[np.float64]): 2D array with shape (n, 2) containing voltage (column 0) and
171
+ pressure (column 1) calibration points.
172
+ v_min (float): Minimum voltage threshold; inputs below this are clamped to `p_min`.
173
+ v_max (float): Maximum voltage threshold; inputs above this are clamped to `p_max`.
174
+ p_min (float): Minimum pressure output in mbar before atmospheric scaling (e.g., 1e-6).
175
+ p_max (float): Maximum pressure output in mbar before atmospheric scaling (e.g., 1000).
176
+ atmosphere (Atmosphere): The atmospheric gas used for calculations.
177
+ atmosphere_factor (dict[Atmosphere, float]): A dictionary mapping atmospheric gases to
178
+ their respective conversion factors. Defaults to 1.0 for all supported gases.
179
+
180
+ Methods:
181
+ convert_voltage(voltage: Union[float, NDArray[np.float64]])
182
+ -> Union[float, NDArray[np.float64]]:
183
+ Converts analog output voltage to pressure (mbar) using linear interpolation, adjusted
184
+ by atmospheric gas factor, with clamping at specified limits.
185
+ """
186
+
187
+ atmosphere_factor = {
188
+ Atmosphere.AIR: 1.0,
189
+ Atmosphere.AR: 1.0,
190
+ Atmosphere.CO: 1.0,
191
+ Atmosphere.CO2: 1.0,
192
+ Atmosphere.H2: 1.0,
193
+ Atmosphere.HE: 1.0,
194
+ Atmosphere.N2: 1.0,
195
+ Atmosphere.O2: 1.0,
196
+ Atmosphere.NE: 1.0,
197
+ Atmosphere.KR: 1.0,
198
+ Atmosphere.XE: 1.0,
199
+ }
200
+
201
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
202
+ def __init__(
203
+ self,
204
+ model_name: str,
205
+ data: NDArray[np.float64],
206
+ v_min: float = 0.0,
207
+ v_max: float = 10.0,
208
+ p_min: float = 1e-6,
209
+ p_max: float = 1000.0,
210
+ atmosphere: Optional[Union[str, Atmosphere]] = None,
211
+ extrapolate: Optional[bool] = None,
212
+ ):
213
+ """
214
+ Initializes the InterpolationVacuumGauge instance.
215
+
216
+ Args:
217
+ model_name (str): The model identifier of the vacuum gauge.
218
+ data (NDArray[np.float64]): 2D array with shape (n, 2) containing voltage (column 0)
219
+ and pressure (column 1) calibration points.
220
+ v_min (float, optional): Minimum voltage threshold; inputs below this are clamped to
221
+ `p_min`. Defaults to 0.0.
222
+ v_max (float, optional): Maximum voltage threshold; inputs above this are clamped to
223
+ `p_max`. Defaults to 10.0.
224
+ p_min (float, optional): Minimum pressure output in mbar before atmospheric scaling.
225
+ Defaults to 1e-6.
226
+ p_max (float, optional): Maximum pressure output in mbar before atmospheric scaling.
227
+ Defaults to 1000.0.
228
+ atmosphere (Optional[Union[str, Atmosphere]], optional): The atmospheric gas used for
229
+ calculations, either as an `Atmosphere` member or its string value (e.g., "Air").
230
+ Defaults to `Atmosphere.AIR` if not provided.
231
+ extrapolate (Optional[bool], optional): Whether to extrapolate beyond the calibration
232
+ data. Defaults to None (uses `LinearInterpolatorSensor` default behavior).
233
+ """
234
+ super().__init__(model_name, data, extrapolate=extrapolate)
235
+ self.v_min: float = v_min
236
+ self.v_max: float = v_max
237
+ self.p_min: float = p_min
238
+ self.p_max: float = p_max
239
+ self.atmosphere: Atmosphere
240
+ if isinstance(atmosphere, str):
241
+ self.atmosphere = Atmosphere.from_string(atmosphere)
242
+ else:
243
+ self.atmosphere = atmosphere if atmosphere is not None else Atmosphere.AIR
244
+
245
+ def convert_voltage(
246
+ self, voltage: Union[float, NDArray[np.float64]]
247
+ ) -> Union[float, NDArray[np.float64]]:
248
+ """
249
+ Converts analog output voltage to pressure (mbar) using linear interpolation.
250
+
251
+ This method uses linear interpolation from the provided calibration data to compute
252
+ pressure, clamps the result to `p_min` or `p_max` if the input voltage is outside `v_min`
253
+ or `v_max`, and then scales the entire pressure result (including clamps) by the
254
+ atmospheric gas factor.
255
+
256
+ Args:
257
+ voltage (Union[float, NDArray[np.float64]]): The analog output voltage(s) from the
258
+ vacuum gauge. Can be a single float or a NumPy array.
259
+
260
+ Returns:
261
+ Union[float, NDArray[np.float64]]: The calculated pressure in millibars (mbar),
262
+ matching the input type (float or array).
263
+ """
264
+ voltage_array = np.asarray(voltage)
265
+ clamped_voltage = np.clip(voltage_array, self.v_min, self.v_max)
266
+ interpolated_pressure = super().convert_voltage(clamped_voltage)
267
+ pressure = np.where(
268
+ clamped_voltage == self.v_min,
269
+ self.p_min,
270
+ np.where(clamped_voltage == self.v_max, self.p_max, interpolated_pressure),
271
+ )
272
+ pressure *= self.atmosphere_factor[self.atmosphere]
273
+ return pressure if isinstance(voltage, np.ndarray) else float(pressure)
@@ -0,0 +1,74 @@
1
+ """
2
+ Atmosphere Enum Module.
3
+
4
+ This module defines the `Atmosphere` enumeration, which represents the supported atmospheric gases
5
+ for vacuum gauge calculations. These gases are used to adjust pressure readings based on the
6
+ specific gas being measured. The enumeration supports initialization from string values for
7
+ compatibility with stored or serialized data.
8
+
9
+ Classes:
10
+ - Atmosphere: An enumeration of supported atmospheric gases with string values and a method
11
+ to convert from strings.
12
+
13
+ Methods:
14
+ - from_string: Converts a string representation of a gas to the corresponding `Atmosphere`
15
+ member.
16
+ """
17
+
18
+ from enum import Enum
19
+
20
+
21
+ class Atmosphere(Enum):
22
+ """
23
+ Enumeration of supported atmospheric gases for vacuum gauge calculations.
24
+
25
+ Members:
26
+ AIR: Represents air, with value "Air".
27
+ AR: Represents argon, with value "Ar".
28
+ CO: Represents carbon monoxide, with value "CO".
29
+ CO2: Represents carbon dioxide, with value "CO2".
30
+ H2: Represents hydrogen, with value "H2".
31
+ HE: Represents helium, with value "He".
32
+ N2: Represents nitrogen, with value "N2".
33
+ O2: Represents oxygen, with value "O2".
34
+ NE: Represents neon, with value "Ne".
35
+ KR: Represents krypton, with value "Kr".
36
+ XE: Represents xenon, with value "Xe".
37
+
38
+ Methods:
39
+ from_string(cls, value: str) -> 'Atmosphere':
40
+ Class method to convert a string to an `Atmosphere` member.
41
+ """
42
+
43
+ AIR = "Air"
44
+ AR = "Ar"
45
+ CO = "CO"
46
+ CO2 = "CO2"
47
+ H2 = "H2"
48
+ HE = "He"
49
+ N2 = "N2"
50
+ O2 = "O2"
51
+ NE = "Ne"
52
+ KR = "Kr"
53
+ XE = "Xe"
54
+
55
+ @classmethod
56
+ def from_string(cls, value: str) -> "Atmosphere":
57
+ """
58
+ Converts a string representation of a gas to the corresponding `Atmosphere` member.
59
+
60
+ Args:
61
+ value (str): The string representation of the gas (e.g., "Air", "H2", "Ne").
62
+
63
+ Returns:
64
+ Atmosphere: The corresponding `Atmosphere` member.
65
+
66
+ Raises:
67
+ ValueError: If the string does not match any supported gas value.
68
+ """
69
+ for member in cls:
70
+ if member.value == value:
71
+ return member
72
+ raise ValueError(
73
+ f"Unknown atmosphere gas: {value}. Supported values are: {[m.value for m in cls]}"
74
+ )
@@ -0,0 +1,20 @@
1
+ """
2
+ Edwards Vacuum Gauge Subpackage.
3
+
4
+ This subpackage provides implementations of analog vacuum gauges specific to Edwards models.
5
+ It includes classes for converting analog voltage outputs to pressure readings in millibars (mbar)
6
+ using calibration data and atmospheric gas adjustments. The classes are designed for use with
7
+ Edwards APG-M and APG-L vacuum gauges, leveraging interpolation-based conversion methods.
8
+
9
+ Classes:
10
+ APGMGauge: A vacuum gauge class for the Edwards APG-M model, using linear interpolation.
11
+ APGLGauge: A vacuum gauge class for the Edwards APG-L model, using linear interpolation.
12
+
13
+ Modules:
14
+ analog: Contains the implementation of Edwards-specific vacuum gauge classes.
15
+ calibration_data: Provides calibration data arrays for Edwards APG-M and APG-L models.
16
+ """
17
+
18
+ from .analog import APGMGauge, APGLGauge
19
+
20
+ __all__ = ["APGMGauge", "APGLGauge"]