rheed-realtime-analyzer 0.2.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 (46) hide show
  1. rheed_realtime_analyzer-0.2.0/PKG-INFO +152 -0
  2. rheed_realtime_analyzer-0.2.0/README.md +129 -0
  3. rheed_realtime_analyzer-0.2.0/pyproject.toml +42 -0
  4. rheed_realtime_analyzer-0.2.0/rheed_core/__init__.py +2 -0
  5. rheed_realtime_analyzer-0.2.0/rheed_core/__main__.py +4 -0
  6. rheed_realtime_analyzer-0.2.0/rheed_core/config.yaml +35 -0
  7. rheed_realtime_analyzer-0.2.0/rheed_core/core/__init__.py +0 -0
  8. rheed_realtime_analyzer-0.2.0/rheed_core/core/buffers.py +42 -0
  9. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/AFM.py +382 -0
  10. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Analysis.py +778 -0
  11. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Analysis_umich.py +175 -0
  12. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Dataset.py +580 -0
  13. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Fit.py +567 -0
  14. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Fitter1D.py +1210 -0
  15. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Fitting.py +158 -0
  16. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Packed_functions.py +224 -0
  17. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/Viz.py +583 -0
  18. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft codes/XRD.py +97 -0
  19. rheed_realtime_analyzer-0.2.0/rheed_core/core/draft_bridge.py +291 -0
  20. rheed_realtime_analyzer-0.2.0/rheed_core/core/features.py +88 -0
  21. rheed_realtime_analyzer-0.2.0/rheed_core/core/logging.py +67 -0
  22. rheed_realtime_analyzer-0.2.0/rheed_core/core/offline_analysis.py +172 -0
  23. rheed_realtime_analyzer-0.2.0/rheed_core/core/pipeline.py +79 -0
  24. rheed_realtime_analyzer-0.2.0/rheed_core/core/policy.py +101 -0
  25. rheed_realtime_analyzer-0.2.0/rheed_core/core/preprocess.py +76 -0
  26. rheed_realtime_analyzer-0.2.0/rheed_core/core/state.py +104 -0
  27. rheed_realtime_analyzer-0.2.0/rheed_core/core/types.py +65 -0
  28. rheed_realtime_analyzer-0.2.0/rheed_core/io/__init__.py +0 -0
  29. rheed_realtime_analyzer-0.2.0/rheed_core/io/collector_base.py +25 -0
  30. rheed_realtime_analyzer-0.2.0/rheed_core/io/dummy_collector.py +75 -0
  31. rheed_realtime_analyzer-0.2.0/rheed_core/io/dummy_operator.py +16 -0
  32. rheed_realtime_analyzer-0.2.0/rheed_core/io/operator_base.py +16 -0
  33. rheed_realtime_analyzer-0.2.0/rheed_core/main.py +86 -0
  34. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/PKG-INFO +152 -0
  35. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/SOURCES.txt +44 -0
  36. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/dependency_links.txt +1 -0
  37. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/entry_points.txt +2 -0
  38. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/requires.txt +9 -0
  39. rheed_realtime_analyzer-0.2.0/rheed_realtime_analyzer.egg-info/top_level.txt +1 -0
  40. rheed_realtime_analyzer-0.2.0/setup.cfg +4 -0
  41. rheed_realtime_analyzer-0.2.0/tests/test_draft_bridge.py +41 -0
  42. rheed_realtime_analyzer-0.2.0/tests/test_offline_analysis.py +59 -0
  43. rheed_realtime_analyzer-0.2.0/tests/test_pipeline.py +32 -0
  44. rheed_realtime_analyzer-0.2.0/tests/test_policy.py +25 -0
  45. rheed_realtime_analyzer-0.2.0/tests/test_state.py +17 -0
  46. rheed_realtime_analyzer-0.2.0/tests/test_state_relax_tau.py +26 -0
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: rheed-realtime-analyzer
3
+ Version: 0.2.0
4
+ Summary: Sidecar analytics framework for real-time RHEED monitoring
5
+ Keywords: RHEED,PLD,real-time,analysis,materials
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Science/Research
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Topic :: Scientific/Engineering
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: numpy>=1.24
16
+ Requires-Dist: PyYAML>=6.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=8.0; extra == "dev"
19
+ Requires-Dist: build>=1.2; extra == "dev"
20
+ Requires-Dist: twine>=5.0; extra == "dev"
21
+ Requires-Dist: notebook>=7.0; extra == "dev"
22
+ Requires-Dist: ipykernel>=6.0; extra == "dev"
23
+
24
+ # RHEED Real-Time Analyzer
25
+
26
+ Python sidecar framework for real-time RHEED analytics in a TSST-centered PLD workflow.
27
+
28
+ ## Scope
29
+
30
+ - Keeps TSST as authoritative control and safety gate.
31
+ - Runs independent analytics and policy logic.
32
+ - Starts in advisory mode, with closed-loop hooks for later bounded control.
33
+
34
+ ## Installation
35
+
36
+ ### Option A: Conda environment (recommended)
37
+
38
+ ```bash
39
+ conda create -n rheed-rt python=3.11 -y
40
+ conda activate rheed-rt
41
+ pip install -r requirements.txt
42
+ pip install -e .
43
+ ```
44
+
45
+ ### Option B: Dev environment (tests + notebook + publishing tools)
46
+
47
+ ```bash
48
+ conda create -n rheed-rt-dev python=3.11 -y
49
+ conda activate rheed-rt-dev
50
+ pip install -r requirements-dev.txt
51
+ pip install -e .[dev]
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ Run a short dummy sidecar session:
57
+
58
+ ```bash
59
+ rheed-sidecar --duration 10
60
+ ```
61
+
62
+ This writes JSONL events to `logs/events.jsonl` by default.
63
+
64
+ ## Test
65
+
66
+ ```bash
67
+ pytest -q
68
+ ```
69
+
70
+ Detailed test and demo notes are in `tests/README.md`.
71
+
72
+ ## Build And Publish
73
+
74
+ Detailed release instructions are in `docs/PUBLISHING.md`.
75
+
76
+ ### Automated release via GitHub Actions
77
+
78
+ This repo includes `.github/workflows/main.yml` with keyword-triggered release on pushes to `main`:
79
+
80
+ - `#major` -> bump `X.0.0`
81
+ - `#minor` -> bump `x.Y.0`
82
+ - `#patch` -> bump `x.y.Z`
83
+
84
+ Example commit message:
85
+
86
+ ```text
87
+ feat: add TSST adapter #major
88
+ ```
89
+
90
+ When triggered, the workflow will:
91
+
92
+ 1. bump versions in `pyproject.toml` and `rheed_core/__init__.py`
93
+ 2. create/push a release commit and `vX.Y.Z` tag
94
+ 3. build and publish to PyPI using `pypa/gh-action-pypi-publish`
95
+
96
+ Note: configure PyPI Trusted Publishing for this repository/workflow before first automated release.
97
+
98
+ ### Local package build check
99
+
100
+ ```bash
101
+ python -m build
102
+ twine check dist/*
103
+ ```
104
+
105
+ ## Current Capabilities
106
+
107
+ - Dummy real-time collector with noisy oscillatory intensity and synthetic image frames.
108
+ - Rolling preprocessing + feature extraction (signal + image proxies).
109
+ - Oscillation tracker with period/phase/amplitude/confidence estimation.
110
+ - Draft-integrated cycle analysis (peak segmentation + per-cycle relaxation `tau` estimate).
111
+ - Offline reusable analysis pipeline adapted from draft code:
112
+ - range selection
113
+ - denoise chain
114
+ - peak-to-peak cycle splitting
115
+ - tail/background cleanup
116
+ - per-cycle relaxation fitting
117
+ - Advisory-first policy engine for drift, frame quality, period instability, and amplitude decay.
118
+ - Replayable JSONL event logging.
119
+
120
+ ## Draft Integration
121
+
122
+ Legacy analysis ideas from `rheed_core/core/draft codes/` are bridged into the runtime path through:
123
+
124
+ - `rheed_core/core/draft_bridge.py`: FFT band-pass, median filtering, peak detection, cycle segmentation, and linearized `tau` fitting.
125
+ - `rheed_core/core/preprocess.py`: optional median + FFT filtering in streaming mode.
126
+ - `rheed_core/core/features.py`: Gaussian-moment-like image spread and drift estimation.
127
+ - `rheed_core/core/state.py`: latest cycle relaxation-time tracking.
128
+ - `rheed_core/core/policy.py`: advisory on unstable relaxation-time behavior.
129
+
130
+ ## Notebook Demos
131
+
132
+ - `tests/demo_draft_bridge.ipynb`: draft-derived signal processing + `tau` fitting utilities.
133
+ - `tests/demo_pipeline_integration.ipynb`: end-to-end sidecar usage with draft-aware config.
134
+ - `tests/demo_offline_analysis.ipynb`: second-pass offline flow mirroring real draft workflow.
135
+
136
+ ## Project Layout
137
+
138
+ ```text
139
+ rheed_core/
140
+ main.py
141
+ config.yaml
142
+ core/
143
+ io/
144
+ tests/
145
+ docs/
146
+ ```
147
+
148
+ ## Roadmap
149
+
150
+ 1. Replace dummy collector with TSST stream adapter.
151
+ 2. Validate feature/state outputs against recorded experimental datasets.
152
+ 3. Introduce bounded command outputs behind explicit safety constraints.
@@ -0,0 +1,129 @@
1
+ # RHEED Real-Time Analyzer
2
+
3
+ Python sidecar framework for real-time RHEED analytics in a TSST-centered PLD workflow.
4
+
5
+ ## Scope
6
+
7
+ - Keeps TSST as authoritative control and safety gate.
8
+ - Runs independent analytics and policy logic.
9
+ - Starts in advisory mode, with closed-loop hooks for later bounded control.
10
+
11
+ ## Installation
12
+
13
+ ### Option A: Conda environment (recommended)
14
+
15
+ ```bash
16
+ conda create -n rheed-rt python=3.11 -y
17
+ conda activate rheed-rt
18
+ pip install -r requirements.txt
19
+ pip install -e .
20
+ ```
21
+
22
+ ### Option B: Dev environment (tests + notebook + publishing tools)
23
+
24
+ ```bash
25
+ conda create -n rheed-rt-dev python=3.11 -y
26
+ conda activate rheed-rt-dev
27
+ pip install -r requirements-dev.txt
28
+ pip install -e .[dev]
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ Run a short dummy sidecar session:
34
+
35
+ ```bash
36
+ rheed-sidecar --duration 10
37
+ ```
38
+
39
+ This writes JSONL events to `logs/events.jsonl` by default.
40
+
41
+ ## Test
42
+
43
+ ```bash
44
+ pytest -q
45
+ ```
46
+
47
+ Detailed test and demo notes are in `tests/README.md`.
48
+
49
+ ## Build And Publish
50
+
51
+ Detailed release instructions are in `docs/PUBLISHING.md`.
52
+
53
+ ### Automated release via GitHub Actions
54
+
55
+ This repo includes `.github/workflows/main.yml` with keyword-triggered release on pushes to `main`:
56
+
57
+ - `#major` -> bump `X.0.0`
58
+ - `#minor` -> bump `x.Y.0`
59
+ - `#patch` -> bump `x.y.Z`
60
+
61
+ Example commit message:
62
+
63
+ ```text
64
+ feat: add TSST adapter #major
65
+ ```
66
+
67
+ When triggered, the workflow will:
68
+
69
+ 1. bump versions in `pyproject.toml` and `rheed_core/__init__.py`
70
+ 2. create/push a release commit and `vX.Y.Z` tag
71
+ 3. build and publish to PyPI using `pypa/gh-action-pypi-publish`
72
+
73
+ Note: configure PyPI Trusted Publishing for this repository/workflow before first automated release.
74
+
75
+ ### Local package build check
76
+
77
+ ```bash
78
+ python -m build
79
+ twine check dist/*
80
+ ```
81
+
82
+ ## Current Capabilities
83
+
84
+ - Dummy real-time collector with noisy oscillatory intensity and synthetic image frames.
85
+ - Rolling preprocessing + feature extraction (signal + image proxies).
86
+ - Oscillation tracker with period/phase/amplitude/confidence estimation.
87
+ - Draft-integrated cycle analysis (peak segmentation + per-cycle relaxation `tau` estimate).
88
+ - Offline reusable analysis pipeline adapted from draft code:
89
+ - range selection
90
+ - denoise chain
91
+ - peak-to-peak cycle splitting
92
+ - tail/background cleanup
93
+ - per-cycle relaxation fitting
94
+ - Advisory-first policy engine for drift, frame quality, period instability, and amplitude decay.
95
+ - Replayable JSONL event logging.
96
+
97
+ ## Draft Integration
98
+
99
+ Legacy analysis ideas from `rheed_core/core/draft codes/` are bridged into the runtime path through:
100
+
101
+ - `rheed_core/core/draft_bridge.py`: FFT band-pass, median filtering, peak detection, cycle segmentation, and linearized `tau` fitting.
102
+ - `rheed_core/core/preprocess.py`: optional median + FFT filtering in streaming mode.
103
+ - `rheed_core/core/features.py`: Gaussian-moment-like image spread and drift estimation.
104
+ - `rheed_core/core/state.py`: latest cycle relaxation-time tracking.
105
+ - `rheed_core/core/policy.py`: advisory on unstable relaxation-time behavior.
106
+
107
+ ## Notebook Demos
108
+
109
+ - `tests/demo_draft_bridge.ipynb`: draft-derived signal processing + `tau` fitting utilities.
110
+ - `tests/demo_pipeline_integration.ipynb`: end-to-end sidecar usage with draft-aware config.
111
+ - `tests/demo_offline_analysis.ipynb`: second-pass offline flow mirroring real draft workflow.
112
+
113
+ ## Project Layout
114
+
115
+ ```text
116
+ rheed_core/
117
+ main.py
118
+ config.yaml
119
+ core/
120
+ io/
121
+ tests/
122
+ docs/
123
+ ```
124
+
125
+ ## Roadmap
126
+
127
+ 1. Replace dummy collector with TSST stream adapter.
128
+ 2. Validate feature/state outputs against recorded experimental datasets.
129
+ 3. Introduce bounded command outputs behind explicit safety constraints.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rheed-realtime-analyzer"
7
+ version = "0.2.0"
8
+ description = "Sidecar analytics framework for real-time RHEED monitoring"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ keywords = ["RHEED", "PLD", "real-time", "analysis", "materials"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Science/Research",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Topic :: Scientific/Engineering",
20
+ ]
21
+ dependencies = [
22
+ "numpy>=1.24",
23
+ "PyYAML>=6.0",
24
+ ]
25
+
26
+ [project.optional-dependencies]
27
+ dev = [
28
+ "pytest>=8.0",
29
+ "build>=1.2",
30
+ "twine>=5.0",
31
+ "notebook>=7.0",
32
+ "ipykernel>=6.0",
33
+ ]
34
+
35
+ [project.scripts]
36
+ rheed-sidecar = "rheed_core.main:main"
37
+
38
+ [tool.setuptools.packages.find]
39
+ include = ["rheed_core*"]
40
+
41
+ [tool.setuptools.package-data]
42
+ rheed_core = ["config.yaml"]
@@ -0,0 +1,2 @@
1
+ __all__ = ["__version__"]
2
+ __version__ = "0.2.0"
@@ -0,0 +1,4 @@
1
+ from rheed_core.main import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,35 @@
1
+ runtime:
2
+ duration_s: 20.0
3
+ loop_sleep_s: 0.01
4
+
5
+ logging:
6
+ path: logs/events.jsonl
7
+
8
+ preprocess:
9
+ trend_window: 64
10
+ clip_sigma: 4.0
11
+ median_kernel_size: 5
12
+ fft_band: [0.05, 5.0]
13
+ sample_rate_hz: 20.0
14
+ fft_window: 128
15
+
16
+ state:
17
+ max_points: 400
18
+ min_period_s: 0.2
19
+ max_period_s: 30.0
20
+ tau_peak_prominence: 0.05
21
+ tau_min_points: 8
22
+
23
+ policy:
24
+ drift_threshold: 8.0
25
+ bad_frame_limit: 5
26
+ period_cv_threshold: 0.2
27
+ tau_cv_threshold: 0.35
28
+ advisory_mode: true
29
+
30
+ dummy:
31
+ sample_rate_hz: 20.0
32
+ frame_rate_hz: 2.0
33
+ osc_period_s: 4.0
34
+ noise_std: 0.15
35
+ seed: 123
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+
3
+ """Lightweight buffering primitives for streaming analytics."""
4
+
5
+ from collections import deque
6
+ from typing import Deque, Generic, Iterable, TypeVar
7
+
8
+ T = TypeVar("T")
9
+
10
+
11
+ class RingBuffer(Generic[T]):
12
+ """Typed deque wrapper with convenience helpers for recent-history access."""
13
+
14
+ def __init__(self, maxlen: int):
15
+ """Create a fixed-capacity ring buffer."""
16
+ if maxlen <= 0:
17
+ raise ValueError("maxlen must be > 0")
18
+ self._data: Deque[T] = deque(maxlen=maxlen)
19
+
20
+ def append(self, item: T) -> None:
21
+ """Append one item, evicting the oldest if full."""
22
+ self._data.append(item)
23
+
24
+ def extend(self, items: Iterable[T]) -> None:
25
+ """Append multiple items in order."""
26
+ self._data.extend(items)
27
+
28
+ def clear(self) -> None:
29
+ """Remove all items."""
30
+ self._data.clear()
31
+
32
+ def latest(self) -> T | None:
33
+ """Return most recent item or None when empty."""
34
+ return self._data[-1] if self._data else None
35
+
36
+ def as_list(self) -> list[T]:
37
+ """Materialize the current buffer contents."""
38
+ return list(self._data)
39
+
40
+ def __len__(self) -> int:
41
+ """Return current number of buffered items."""
42
+ return len(self._data)