logqbit 0.4__tar.gz → 0.4.1__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.
- logqbit-0.4.1/PKG-INFO +95 -0
- logqbit-0.4.1/README.md +74 -0
- {logqbit-0.4 → logqbit-0.4.1}/pyproject.toml +3 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/browser.py +36 -2
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/cli.py +27 -24
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/logfolder.py +14 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/metadata.py +6 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/plotter.py +14 -3
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/registry.py +36 -5
- logqbit-0.4.1/tests/conftest.py +9 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_browser.py +14 -2
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_plotter.py +5 -1
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_registry.py +74 -0
- logqbit-0.4/PKG-INFO +0 -185
- logqbit-0.4/README.md +0 -164
- {logqbit-0.4 → logqbit-0.4.1}/.gitignore +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/LICENSE +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/__init__.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/assets/browser.svg +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/assets/live_plotter.svg +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/detail_view.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/live_plotter.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/misc/svg2ico.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/src/logqbit/templates/move_from_labrad.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/for_all_pythons.ps1 +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_flush_issue.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_live_plotter.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_logfolder.py +0 -0
- {logqbit-0.4 → logqbit-0.4.1}/tests/test_metadata.py +0 -0
logqbit-0.4.1/PKG-INFO
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: logqbit
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Simple data logger and live plotter for lab-scale experiments.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Qiujv/logqbit
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: numba>=0.65.0
|
|
9
|
+
Requires-Dist: numpy>=2.3.3
|
|
10
|
+
Requires-Dist: pandas>=2.3.3
|
|
11
|
+
Requires-Dist: pyarrow>=21.0.0
|
|
12
|
+
Requires-Dist: pyqtgraph>=0.14.0
|
|
13
|
+
Requires-Dist: pyside6>=6.9.3
|
|
14
|
+
Requires-Dist: ruamel-yaml>=0.18.15
|
|
15
|
+
Requires-Dist: send2trash>=1.8.3
|
|
16
|
+
Requires-Dist: tqdm>=4.67.1
|
|
17
|
+
Requires-Dist: typing-extensions>=4.15.0
|
|
18
|
+
Provides-Extra: labrad
|
|
19
|
+
Requires-Dist: pylabrad>=0.98.3; extra == 'labrad'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# LogQbit
|
|
23
|
+
|
|
24
|
+
LogQbit 是一个面向实验室场景的轻量数据记录工具包,适合记录中小规模实验数据。
|
|
25
|
+
|
|
26
|
+
它的核心设计目标是:
|
|
27
|
+
|
|
28
|
+
- 用简单的接口和运行逻辑实验数据。
|
|
29
|
+
- 基于目录的实验数据组织,用通用可读的格式储存数据。
|
|
30
|
+
- 在需要时再启用浏览器和实时绘图等 GUI 能力。
|
|
31
|
+
|
|
32
|
+
完整文档见:https://qiujv.github.io/logqbit/
|
|
33
|
+
|
|
34
|
+
## 安装
|
|
35
|
+
|
|
36
|
+
常规安装:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install logqbit
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
如果你不想让安装过程修改当前 Python 环境,可以跳过依赖解析:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install --no-deps logqbit
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
通常 `logqbit.logfolder.LogFolder`、`logqbit.registry.Registry` 等核心接口仍然可用;
|
|
49
|
+
但浏览器、实时绘图和快捷方式等 GUI 功能仍然依赖 `PySide6`、`pyqtgraph` 等组件。
|
|
50
|
+
|
|
51
|
+
更详细的安装说明见:https://qiujv.github.io/logqbit/install/
|
|
52
|
+
|
|
53
|
+
## 用例
|
|
54
|
+
|
|
55
|
+
### 用例 1:记录一组实验数据
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pathlib import Path
|
|
59
|
+
|
|
60
|
+
from logqbit.logfolder import LogFolder
|
|
61
|
+
|
|
62
|
+
lf = LogFolder.new("./demo_data", title="My Experiment")
|
|
63
|
+
|
|
64
|
+
lf.add_row(x=0.0, y=1.2)
|
|
65
|
+
lf.add_row(x=1.0, y=1.8)
|
|
66
|
+
lf.flush()
|
|
67
|
+
|
|
68
|
+
lf.meta.plot_axes = ["x"]
|
|
69
|
+
lf.const["temperature"] = "300 K"
|
|
70
|
+
|
|
71
|
+
print(lf.df)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 用例 2:打开数据查看器
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
logqbit browser
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
或者也可以通过 `logqbit shortcuts` 创建桌面快捷方式(仅 Windows 可用)。
|
|
81
|
+
|
|
82
|
+
### 用例 3:快速生成示例数据并打开浏览器
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
logqbit browser-demo
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
这会在当前目录创建 `logqbit_example/`,生成多组示例数据,并启动图形化浏览器。
|
|
89
|
+
|
|
90
|
+
更多内容:
|
|
91
|
+
|
|
92
|
+
- 文档首页:https://qiujv.github.io/logqbit/
|
|
93
|
+
- 命令行工具:https://qiujv.github.io/logqbit/cli/
|
|
94
|
+
- LabRAD 迁移:https://qiujv.github.io/logqbit/migration_guide/
|
|
95
|
+
- Python API:https://qiujv.github.io/logqbit/api/
|
logqbit-0.4.1/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# LogQbit
|
|
2
|
+
|
|
3
|
+
LogQbit 是一个面向实验室场景的轻量数据记录工具包,适合记录中小规模实验数据。
|
|
4
|
+
|
|
5
|
+
它的核心设计目标是:
|
|
6
|
+
|
|
7
|
+
- 用简单的接口和运行逻辑实验数据。
|
|
8
|
+
- 基于目录的实验数据组织,用通用可读的格式储存数据。
|
|
9
|
+
- 在需要时再启用浏览器和实时绘图等 GUI 能力。
|
|
10
|
+
|
|
11
|
+
完整文档见:https://qiujv.github.io/logqbit/
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
常规安装:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install logqbit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
如果你不想让安装过程修改当前 Python 环境,可以跳过依赖解析:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install --no-deps logqbit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
通常 `logqbit.logfolder.LogFolder`、`logqbit.registry.Registry` 等核心接口仍然可用;
|
|
28
|
+
但浏览器、实时绘图和快捷方式等 GUI 功能仍然依赖 `PySide6`、`pyqtgraph` 等组件。
|
|
29
|
+
|
|
30
|
+
更详细的安装说明见:https://qiujv.github.io/logqbit/install/
|
|
31
|
+
|
|
32
|
+
## 用例
|
|
33
|
+
|
|
34
|
+
### 用例 1:记录一组实验数据
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
|
|
39
|
+
from logqbit.logfolder import LogFolder
|
|
40
|
+
|
|
41
|
+
lf = LogFolder.new("./demo_data", title="My Experiment")
|
|
42
|
+
|
|
43
|
+
lf.add_row(x=0.0, y=1.2)
|
|
44
|
+
lf.add_row(x=1.0, y=1.8)
|
|
45
|
+
lf.flush()
|
|
46
|
+
|
|
47
|
+
lf.meta.plot_axes = ["x"]
|
|
48
|
+
lf.const["temperature"] = "300 K"
|
|
49
|
+
|
|
50
|
+
print(lf.df)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 用例 2:打开数据查看器
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
logqbit browser
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
或者也可以通过 `logqbit shortcuts` 创建桌面快捷方式(仅 Windows 可用)。
|
|
60
|
+
|
|
61
|
+
### 用例 3:快速生成示例数据并打开浏览器
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
logqbit browser-demo
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
这会在当前目录创建 `logqbit_example/`,生成多组示例数据,并启动图形化浏览器。
|
|
68
|
+
|
|
69
|
+
更多内容:
|
|
70
|
+
|
|
71
|
+
- 文档首页:https://qiujv.github.io/logqbit/
|
|
72
|
+
- 命令行工具:https://qiujv.github.io/logqbit/cli/
|
|
73
|
+
- LabRAD 迁移:https://qiujv.github.io/logqbit/migration_guide/
|
|
74
|
+
- Python API:https://qiujv.github.io/logqbit/api/
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
+
import os
|
|
6
7
|
import shutil
|
|
7
8
|
import subprocess
|
|
8
9
|
import sys
|
|
10
|
+
import threading
|
|
9
11
|
from collections.abc import Iterable
|
|
10
12
|
from dataclasses import dataclass, field
|
|
11
13
|
from importlib.resources import files
|
|
@@ -53,15 +55,17 @@ try: # pragma: no cover - fallback for direct execution
|
|
|
53
55
|
)
|
|
54
56
|
from .logfolder import LogFolder
|
|
55
57
|
from .metadata import LogMetadata
|
|
58
|
+
from .plotter import warmup_plotter_jit
|
|
56
59
|
except ImportError: # pragma: no cover - fallback for direct execution
|
|
60
|
+
from detail_view import PandasTableModel # type: ignore # noqa: F401
|
|
57
61
|
from detail_view import ( # type: ignore
|
|
58
|
-
PandasTableModel,
|
|
59
62
|
RecordDetailView,
|
|
60
63
|
RecordDetailWindow,
|
|
61
64
|
record_watch_paths,
|
|
62
65
|
)
|
|
63
|
-
from logfolder import LogFolder # type: ignore
|
|
66
|
+
from logfolder import LogFolder # type: ignore # noqa: F401
|
|
64
67
|
from metadata import LogMetadata # type: ignore
|
|
68
|
+
from plotter import warmup_plotter_jit # type: ignore
|
|
65
69
|
|
|
66
70
|
logger = logging.getLogger(__name__)
|
|
67
71
|
|
|
@@ -81,6 +85,10 @@ SETTINGS_ORG = "LogQbit"
|
|
|
81
85
|
SETTINGS_APP = "LogBrowser"
|
|
82
86
|
SETTINGS_RECENT_DIRS_KEY = "recent/directories"
|
|
83
87
|
SETTINGS_THEME_KEY = "ui/theme"
|
|
88
|
+
DISABLE_RECENT_DIRS_ENV = "LOGQBIT_BROWSER_DISABLE_RECENT_DIRS"
|
|
89
|
+
DISABLE_JIT_WARMUP_ENV = "LOGQBIT_BROWSER_DISABLE_JIT_WARMUP"
|
|
90
|
+
|
|
91
|
+
_plotter_jit_warmup_started = False
|
|
84
92
|
|
|
85
93
|
def _load_window_icon() -> QIcon:
|
|
86
94
|
try:
|
|
@@ -96,6 +104,28 @@ def _load_window_icon() -> QIcon:
|
|
|
96
104
|
WINDOW_ICON = _load_window_icon()
|
|
97
105
|
|
|
98
106
|
|
|
107
|
+
def _start_plotter_jit_warmup() -> None:
|
|
108
|
+
global _plotter_jit_warmup_started
|
|
109
|
+
if _plotter_jit_warmup_started:
|
|
110
|
+
return
|
|
111
|
+
if os.environ.get(DISABLE_JIT_WARMUP_ENV):
|
|
112
|
+
return
|
|
113
|
+
_plotter_jit_warmup_started = True
|
|
114
|
+
|
|
115
|
+
def run_warmup() -> None:
|
|
116
|
+
try:
|
|
117
|
+
warmup_plotter_jit()
|
|
118
|
+
except Exception as exc: # pragma: no cover - defensive
|
|
119
|
+
logger.debug("Failed to warm up plotter JIT: %s", exc)
|
|
120
|
+
|
|
121
|
+
thread = threading.Thread(
|
|
122
|
+
target=run_warmup,
|
|
123
|
+
name="logqbit-plotter-jit-warmup",
|
|
124
|
+
daemon=True,
|
|
125
|
+
)
|
|
126
|
+
thread.start()
|
|
127
|
+
|
|
128
|
+
|
|
99
129
|
def _next_export_logfolder_path(parent_path: Path) -> Path:
|
|
100
130
|
parent_path = Path(parent_path)
|
|
101
131
|
max_index = max(
|
|
@@ -401,6 +431,9 @@ class SettingsManager:
|
|
|
401
431
|
self._settings.sync()
|
|
402
432
|
|
|
403
433
|
def update_recent_directories(self, path: Path) -> list[Path]:
|
|
434
|
+
if os.environ.get(DISABLE_RECENT_DIRS_ENV):
|
|
435
|
+
return self.load_recent_directories()
|
|
436
|
+
|
|
404
437
|
self.load_recent_directories()
|
|
405
438
|
|
|
406
439
|
resolved = Path(path)
|
|
@@ -564,6 +597,7 @@ class LogBrowserWindow(QMainWindow):
|
|
|
564
597
|
self._update_window_title()
|
|
565
598
|
self._sync_directory_watcher()
|
|
566
599
|
self.refresh_logs()
|
|
600
|
+
QTimer.singleShot(500, _start_plotter_jit_warmup)
|
|
567
601
|
|
|
568
602
|
def _build_ui(self) -> None:
|
|
569
603
|
central = QWidget(self)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Command-line interface for logqbit utilities."""
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
-
import shutil
|
|
5
4
|
import subprocess
|
|
6
5
|
import sys
|
|
7
6
|
from importlib.resources import files
|
|
@@ -51,8 +50,8 @@ def copy_template(template_name: str, output_path: Path | None = None) -> int:
|
|
|
51
50
|
output_path.write_bytes(src.read())
|
|
52
51
|
|
|
53
52
|
print(f"✓ Template copied to: {output_path}")
|
|
54
|
-
print(
|
|
55
|
-
print(
|
|
53
|
+
print("\nNext steps:")
|
|
54
|
+
print(" 1. Edit the file to configure your paths")
|
|
56
55
|
print(f" 2. Run: python {output_path.name}")
|
|
57
56
|
|
|
58
57
|
return 0
|
|
@@ -62,6 +61,19 @@ def copy_template(template_name: str, output_path: Path | None = None) -> int:
|
|
|
62
61
|
return 1
|
|
63
62
|
|
|
64
63
|
|
|
64
|
+
def _windows_gui_python_executable() -> Path:
|
|
65
|
+
exe = Path(sys.executable)
|
|
66
|
+
if sys.platform == "win32" and exe.name.lower() != "pythonw.exe":
|
|
67
|
+
pythonw = exe.with_name("pythonw.exe")
|
|
68
|
+
if pythonw.exists():
|
|
69
|
+
return pythonw
|
|
70
|
+
return exe
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _powershell_single_quoted(value: object) -> str:
|
|
74
|
+
return "'" + str(value).replace("'", "''") + "'"
|
|
75
|
+
|
|
76
|
+
|
|
65
77
|
def create_shortcuts(output_dir: Path | None = None) -> int:
|
|
66
78
|
"""Create desktop shortcuts for logqbit-browser and logqbit-live-plotter.
|
|
67
79
|
|
|
@@ -75,20 +87,8 @@ def create_shortcuts(output_dir: Path | None = None) -> int:
|
|
|
75
87
|
Exit code (0 for success, 1 for error)
|
|
76
88
|
"""
|
|
77
89
|
try:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
plotter_exe = shutil.which("logqbit-live-plotter")
|
|
81
|
-
|
|
82
|
-
if not browser_exe:
|
|
83
|
-
print("Error: logqbit-browser.exe not found in PATH", file=sys.stderr)
|
|
84
|
-
print("Please ensure logqbit is installed.", file=sys.stderr)
|
|
85
|
-
return 1
|
|
86
|
-
|
|
87
|
-
if not plotter_exe:
|
|
88
|
-
print("Error: logqbit-live-plotter.exe not found in PATH", file=sys.stderr)
|
|
89
|
-
print("Please ensure logqbit is installed.", file=sys.stderr)
|
|
90
|
-
return 1
|
|
91
|
-
|
|
90
|
+
gui_python = _windows_gui_python_executable()
|
|
91
|
+
|
|
92
92
|
# Get icon paths from package
|
|
93
93
|
assets_dir = files("logqbit") / "assets"
|
|
94
94
|
browser_svg = assets_dir / "browser.svg"
|
|
@@ -126,7 +126,7 @@ def create_shortcuts(output_dir: Path | None = None) -> int:
|
|
|
126
126
|
try:
|
|
127
127
|
svg_to_ico(svg_str, ico_str)
|
|
128
128
|
print(f" ✓ Created: {ico_path}")
|
|
129
|
-
except (PermissionError, OSError)
|
|
129
|
+
except (PermissionError, OSError):
|
|
130
130
|
# Package directory might be read-only, try user's local data dir
|
|
131
131
|
import tempfile
|
|
132
132
|
temp_ico = Path(tempfile.gettempdir()) / f"logqbit_{name}.ico"
|
|
@@ -174,13 +174,15 @@ def create_shortcuts(output_dir: Path | None = None) -> int:
|
|
|
174
174
|
shortcuts = [
|
|
175
175
|
{
|
|
176
176
|
"name": "LogQbit Browser",
|
|
177
|
-
"target":
|
|
177
|
+
"target": gui_python,
|
|
178
|
+
"arguments": "-m logqbit.browser",
|
|
178
179
|
"icon": str(browser_ico),
|
|
179
180
|
"output": output_dir / "LogQbit Browser.lnk"
|
|
180
181
|
},
|
|
181
182
|
{
|
|
182
183
|
"name": "LogQbit Live Plotter",
|
|
183
|
-
"target":
|
|
184
|
+
"target": gui_python,
|
|
185
|
+
"arguments": "-m logqbit.live_plotter",
|
|
184
186
|
"icon": str(plotter_ico),
|
|
185
187
|
"output": output_dir / "LogQbit Live Plotter.lnk"
|
|
186
188
|
}
|
|
@@ -190,9 +192,10 @@ def create_shortcuts(output_dir: Path | None = None) -> int:
|
|
|
190
192
|
# PowerShell script to create shortcut with icon
|
|
191
193
|
ps_script = f"""
|
|
192
194
|
$WshShell = New-Object -ComObject WScript.Shell
|
|
193
|
-
$Shortcut = $WshShell.CreateShortcut(
|
|
194
|
-
$Shortcut.TargetPath =
|
|
195
|
-
$Shortcut.
|
|
195
|
+
$Shortcut = $WshShell.CreateShortcut({_powershell_single_quoted(sc['output'])})
|
|
196
|
+
$Shortcut.TargetPath = {_powershell_single_quoted(sc['target'])}
|
|
197
|
+
$Shortcut.Arguments = {_powershell_single_quoted(sc['arguments'])}
|
|
198
|
+
$Shortcut.IconLocation = {_powershell_single_quoted(sc['icon'])}
|
|
196
199
|
$Shortcut.Save()
|
|
197
200
|
"""
|
|
198
201
|
|
|
@@ -400,7 +403,7 @@ def main() -> int:
|
|
|
400
403
|
)
|
|
401
404
|
|
|
402
405
|
# browser-demo command
|
|
403
|
-
|
|
406
|
+
subparsers.add_parser(
|
|
404
407
|
"browser-demo",
|
|
405
408
|
help="Create example data and launch browser",
|
|
406
409
|
)
|
|
@@ -23,6 +23,15 @@ yaml = get_parser()
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class LogFolder:
|
|
26
|
+
"""Directory-backed experiment log with data, metadata, and constants.
|
|
27
|
+
|
|
28
|
+
A ``LogFolder`` manages three files under one directory:
|
|
29
|
+
|
|
30
|
+
- ``data.feather`` for tabular records
|
|
31
|
+
- ``metadata.json`` for lightweight metadata
|
|
32
|
+
- ``const.yaml`` for constant parameters and configuration
|
|
33
|
+
"""
|
|
34
|
+
|
|
26
35
|
def __init__(
|
|
27
36
|
self,
|
|
28
37
|
path: str | Path,
|
|
@@ -61,10 +70,12 @@ class LogFolder:
|
|
|
61
70
|
|
|
62
71
|
@property
|
|
63
72
|
def df_path(self) -> Path:
|
|
73
|
+
"""Path to the backing ``data.feather`` file."""
|
|
64
74
|
return self._handler.path
|
|
65
75
|
|
|
66
76
|
@classmethod
|
|
67
77
|
def new(cls, parent_path: Path, title: str = "untitled") -> "LogFolder":
|
|
78
|
+
"""Create the next numeric log directory under ``parent_path``."""
|
|
68
79
|
# TODO: add locking or something.
|
|
69
80
|
parent_path = Path(parent_path)
|
|
70
81
|
max_index = max(
|
|
@@ -102,6 +113,7 @@ class LogFolder:
|
|
|
102
113
|
func: Callable[[float], dict[str, float | list[float]]],
|
|
103
114
|
axes: list[float | list[float]] | dict[str, float | list[float]],
|
|
104
115
|
):
|
|
116
|
+
"""Run a parameter sweep and append returned rows to this log."""
|
|
105
117
|
if not isinstance(axes, dict): # Assumes isinstance(axes, list)
|
|
106
118
|
fsig = inspect.signature(func)
|
|
107
119
|
axes = dict(zip(fsig.parameters.keys(), axes))
|
|
@@ -128,6 +140,7 @@ class LogFolder:
|
|
|
128
140
|
self.add_row(**step_kws, **ret_kws)
|
|
129
141
|
|
|
130
142
|
def add_const(self, meta: dict = None, /, **kwargs):
|
|
143
|
+
"""Append constant values to ``const.yaml`` and save immediately."""
|
|
131
144
|
if meta is None:
|
|
132
145
|
meta = {}
|
|
133
146
|
meta.update(kwargs)
|
|
@@ -135,6 +148,7 @@ class LogFolder:
|
|
|
135
148
|
self.reg.save()
|
|
136
149
|
|
|
137
150
|
def add_const_to_head(self, meta: dict = None, /, **kwargs):
|
|
151
|
+
"""Insert constant values at the top of ``const.yaml`` and save."""
|
|
138
152
|
if meta is None:
|
|
139
153
|
meta = {}
|
|
140
154
|
meta.update(kwargs)
|
|
@@ -41,6 +41,12 @@ class _MetaField(Generic[_T]):
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class LogMetadata:
|
|
44
|
+
"""JSON-backed metadata helper for a log folder.
|
|
45
|
+
|
|
46
|
+
Common fields such as ``title``, ``star``, and ``plot_axes`` are exposed as
|
|
47
|
+
descriptors and synchronized to ``metadata.json`` on assignment.
|
|
48
|
+
"""
|
|
49
|
+
|
|
44
50
|
title = _MetaField("title", "untitled", str)
|
|
45
51
|
star = _MetaField("star", 0, int)
|
|
46
52
|
trash = _MetaField("trash", False, bool)
|
|
@@ -14,7 +14,6 @@ from numba import njit, prange
|
|
|
14
14
|
from PySide6.QtCore import QEvent, Qt, Signal
|
|
15
15
|
from PySide6.QtGui import QColor, QIcon
|
|
16
16
|
from PySide6.QtWidgets import (
|
|
17
|
-
QAbstractItemView,
|
|
18
17
|
QHBoxLayout,
|
|
19
18
|
QLabel,
|
|
20
19
|
QListView,
|
|
@@ -117,6 +116,20 @@ def _build_grids_rect(ys, zs, col_starts, col_sizes, max_ny, nx_col, top_y, step
|
|
|
117
116
|
return z_final, y_final
|
|
118
117
|
|
|
119
118
|
|
|
119
|
+
def warmup_plotter_jit() -> None:
|
|
120
|
+
"""Compile numba-backed 2D plotting helpers before the first real plot."""
|
|
121
|
+
x = np.array([0.0, 0.0, 1.0, 1.0], dtype=np.float64)
|
|
122
|
+
y = np.array([0.0, 1.0, 0.0, 1.0], dtype=np.float64)
|
|
123
|
+
z = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float64)
|
|
124
|
+
col_starts = np.array([0, 2], dtype=np.int64)
|
|
125
|
+
col_sizes = np.array([2, 2], dtype=np.int64)
|
|
126
|
+
top_y = np.array([2.0, 2.0], dtype=np.float64)
|
|
127
|
+
step_c = np.array([1.0, 1.0], dtype=np.float64)
|
|
128
|
+
|
|
129
|
+
_is_lexsorted(x, y)
|
|
130
|
+
_build_grids_rect(y, z, col_starts, col_sizes, 2, 2, top_y, step_c)
|
|
131
|
+
|
|
132
|
+
|
|
120
133
|
class TagBar(QWidget):
|
|
121
134
|
"""
|
|
122
135
|
Single QListWidget holding axes / fields / ignored items in one row,
|
|
@@ -514,5 +527,3 @@ class PlotManager:
|
|
|
514
527
|
cmap = pg.colormap.get("CET-D1")
|
|
515
528
|
return cmap
|
|
516
529
|
|
|
517
|
-
|
|
518
|
-
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import copy
|
|
1
2
|
import os
|
|
2
3
|
import re
|
|
3
4
|
import sys
|
|
4
5
|
import tempfile
|
|
5
6
|
import warnings
|
|
7
|
+
from collections import deque
|
|
6
8
|
from collections.abc import Mapping, Sequence, Set
|
|
7
9
|
from pathlib import Path
|
|
8
10
|
from typing import TYPE_CHECKING
|
|
@@ -14,13 +16,15 @@ from typing_extensions import deprecated
|
|
|
14
16
|
|
|
15
17
|
if TYPE_CHECKING:
|
|
16
18
|
from ruamel.yaml.constructor import BaseConstructor
|
|
17
|
-
from ruamel.yaml.nodes import ScalarNode
|
|
19
|
+
from ruamel.yaml.nodes import ScalarNode
|
|
18
20
|
from ruamel.yaml.representer import BaseRepresenter
|
|
19
21
|
|
|
20
22
|
_sentinel = object()
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class FileSnap:
|
|
26
|
+
"""Track a file's modification time and size for cheap change detection."""
|
|
27
|
+
|
|
24
28
|
__slots__ = ("path", "mtime", "size")
|
|
25
29
|
|
|
26
30
|
def __init__(self, path: Path):
|
|
@@ -58,7 +62,7 @@ class Registry:
|
|
|
58
62
|
NOTE: Local operations is useful for batch update without frequent file I/O.
|
|
59
63
|
"""
|
|
60
64
|
|
|
61
|
-
def __init__(self, path: str | Path, create: bool = True):
|
|
65
|
+
def __init__(self, path: str | Path, create: bool = True, history_size: int = 2):
|
|
62
66
|
path = Path(path)
|
|
63
67
|
if path.exists():
|
|
64
68
|
pass
|
|
@@ -72,6 +76,9 @@ class Registry:
|
|
|
72
76
|
self.root: CommentedMap = self.load()
|
|
73
77
|
self._snap = FileSnap(self.path)
|
|
74
78
|
|
|
79
|
+
self._undo_stack: deque[CommentedMap] = deque(maxlen=history_size)
|
|
80
|
+
self._redo_stack: deque[CommentedMap] = deque(maxlen=history_size)
|
|
81
|
+
|
|
75
82
|
def __getitem__(self, key: str):
|
|
76
83
|
return self.get(key)
|
|
77
84
|
|
|
@@ -119,12 +126,14 @@ class Registry:
|
|
|
119
126
|
"""Reloads the file if it has changed since the last load."""
|
|
120
127
|
if self._snap.changed():
|
|
121
128
|
self.root = self.load()
|
|
129
|
+
self._undo_stack.clear()
|
|
130
|
+
self._redo_stack.clear()
|
|
122
131
|
|
|
123
132
|
def load(self, path: str | Path | None = None) -> CommentedMap:
|
|
124
133
|
# NOTE: `yaml.load` also returns `CommentedSeq`, `float`, `str`, `None`
|
|
125
134
|
# or other build-in types depending on the top-level YAML content. But
|
|
126
135
|
# only `CommentedMap` is legal for the use case of this class.
|
|
127
|
-
path = self.path if path is None else path
|
|
136
|
+
path = self.path if path is None else Path(path)
|
|
128
137
|
with open(path, "r", encoding="utf-8") as f:
|
|
129
138
|
root = self.yaml.load(f)
|
|
130
139
|
if root is None:
|
|
@@ -132,12 +141,18 @@ class Registry:
|
|
|
132
141
|
root.fa.set_block_style()
|
|
133
142
|
return root
|
|
134
143
|
|
|
135
|
-
def save(self, path: str | Path | None = None):
|
|
136
|
-
path = self.path if path is None else path
|
|
144
|
+
def save(self, path: str | Path | None = None, *, record_history: bool = True):
|
|
145
|
+
path = self.path if path is None else Path(path)
|
|
146
|
+
is_primary_path = path == self.path
|
|
147
|
+
if record_history and is_primary_path:
|
|
148
|
+
self._undo_stack.append(self.load(path))
|
|
149
|
+
self._redo_stack.clear()
|
|
137
150
|
fd, tmp = tempfile.mkstemp(dir=path.parent, prefix=path.stem, suffix=".tmp")
|
|
138
151
|
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
|
139
152
|
self.yaml.dump(self.root, f)
|
|
140
153
|
Path(tmp).replace(path)
|
|
154
|
+
if is_primary_path:
|
|
155
|
+
self._snap = FileSnap(self.path)
|
|
141
156
|
|
|
142
157
|
@deprecated("For backward compatibility only.")
|
|
143
158
|
def copy(self) -> dict:
|
|
@@ -148,6 +163,22 @@ class Registry:
|
|
|
148
163
|
def cwd(self) -> str:
|
|
149
164
|
return self["data_folder"]
|
|
150
165
|
|
|
166
|
+
def undo(self) -> bool:
|
|
167
|
+
if not self._undo_stack:
|
|
168
|
+
return False
|
|
169
|
+
self._redo_stack.append(copy.deepcopy(self.root))
|
|
170
|
+
self.root = self._undo_stack.pop()
|
|
171
|
+
self.save(record_history=False)
|
|
172
|
+
return True
|
|
173
|
+
|
|
174
|
+
def redo(self) -> bool:
|
|
175
|
+
if not self._redo_stack:
|
|
176
|
+
return False
|
|
177
|
+
self._undo_stack.append(copy.deepcopy(self.root))
|
|
178
|
+
self.root = self._redo_stack.pop()
|
|
179
|
+
self.save(record_history=False)
|
|
180
|
+
return True
|
|
181
|
+
|
|
151
182
|
|
|
152
183
|
def get_parser() -> YAML:
|
|
153
184
|
yaml = YAML()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.fixture(autouse=True)
|
|
7
|
+
def disable_browser_side_effects(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
8
|
+
monkeypatch.setenv("LOGQBIT_BROWSER_DISABLE_RECENT_DIRS", "1")
|
|
9
|
+
monkeypatch.setenv("LOGQBIT_BROWSER_DISABLE_JIT_WARMUP", "1")
|
|
@@ -8,8 +8,6 @@ from PySide6.QtCore import Qt
|
|
|
8
8
|
from PySide6.QtTest import QTest
|
|
9
9
|
|
|
10
10
|
from logqbit.browser import (
|
|
11
|
-
COL_CREATE_MACHINE,
|
|
12
|
-
COL_CREATE_TIME,
|
|
13
11
|
COL_ID,
|
|
14
12
|
COL_PLOT_AXES,
|
|
15
13
|
COL_ROWS,
|
|
@@ -18,6 +16,7 @@ from logqbit.browser import (
|
|
|
18
16
|
LogListTableModel,
|
|
19
17
|
LogRecord,
|
|
20
18
|
PandasTableModel,
|
|
19
|
+
SettingsManager,
|
|
21
20
|
ensure_application,
|
|
22
21
|
export_records,
|
|
23
22
|
)
|
|
@@ -371,6 +370,19 @@ class TestLogListTableModel:
|
|
|
371
370
|
assert headers == expected
|
|
372
371
|
|
|
373
372
|
|
|
373
|
+
class TestSettingsManager:
|
|
374
|
+
def test_update_recent_directories_can_be_disabled(
|
|
375
|
+
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
376
|
+
) -> None:
|
|
377
|
+
monkeypatch.setenv("LOGQBIT_BROWSER_DISABLE_RECENT_DIRS", "1")
|
|
378
|
+
manager = SettingsManager()
|
|
379
|
+
original = list(manager.load_recent_directories())
|
|
380
|
+
|
|
381
|
+
manager.update_recent_directories(tmp_path)
|
|
382
|
+
|
|
383
|
+
assert manager.load_recent_directories() == original
|
|
384
|
+
|
|
385
|
+
|
|
374
386
|
class TestPandasTableModel:
|
|
375
387
|
"""Tests for PandasTableModel class."""
|
|
376
388
|
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import pytest
|
|
7
7
|
|
|
8
|
-
from logqbit.plotter import _build_grids_rect, _is_lexsorted
|
|
8
|
+
from logqbit.plotter import _build_grids_rect, _is_lexsorted, warmup_plotter_jit
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class TestIsLexsorted:
|
|
@@ -158,3 +158,7 @@ class TestBuildGridsRect:
|
|
|
158
158
|
assert not np.isnan(y_final[1, 2])
|
|
159
159
|
assert not np.isnan(y_final[2, 2])
|
|
160
160
|
assert not np.isnan(y_final[3, 2])
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_warmup_plotter_jit() -> None:
|
|
164
|
+
warmup_plotter_jit()
|
|
@@ -73,6 +73,80 @@ def test_reload_detects_external_change(temp_yaml):
|
|
|
73
73
|
assert reg.get("period_ns") == 12345
|
|
74
74
|
|
|
75
75
|
|
|
76
|
+
def test_undo_redo_for_set(temp_yaml):
|
|
77
|
+
reg = Registry(temp_yaml)
|
|
78
|
+
|
|
79
|
+
reg["period_ns"] = 12345
|
|
80
|
+
assert reg.get("period_ns") == 12345
|
|
81
|
+
|
|
82
|
+
assert reg.undo()
|
|
83
|
+
assert reg.get("period_ns") == 50000
|
|
84
|
+
assert Registry(temp_yaml).get("period_ns") == 50000
|
|
85
|
+
|
|
86
|
+
assert reg.redo()
|
|
87
|
+
assert reg.get("period_ns") == 12345
|
|
88
|
+
assert Registry(temp_yaml).get("period_ns") == 12345
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_undo_redo_for_manual_root_save(temp_yaml):
|
|
92
|
+
reg = Registry(temp_yaml)
|
|
93
|
+
|
|
94
|
+
reg.root["local_only"] = "temp"
|
|
95
|
+
reg.save()
|
|
96
|
+
assert reg.get("local_only") == "temp"
|
|
97
|
+
|
|
98
|
+
assert reg.undo()
|
|
99
|
+
with pytest.raises(KeyError):
|
|
100
|
+
reg.get("local_only")
|
|
101
|
+
with pytest.raises(KeyError):
|
|
102
|
+
Registry(temp_yaml).get("local_only")
|
|
103
|
+
|
|
104
|
+
assert reg.redo()
|
|
105
|
+
assert reg.get("local_only") == "temp"
|
|
106
|
+
assert Registry(temp_yaml).get("local_only") == "temp"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_undo_history_limit(temp_yaml):
|
|
110
|
+
reg = Registry(temp_yaml, history_size=2)
|
|
111
|
+
|
|
112
|
+
reg["period_ns"] = 1
|
|
113
|
+
reg["period_ns"] = 2
|
|
114
|
+
reg["period_ns"] = 3
|
|
115
|
+
|
|
116
|
+
assert reg.undo()
|
|
117
|
+
assert reg.get("period_ns") == 2
|
|
118
|
+
assert reg.undo()
|
|
119
|
+
assert reg.get("period_ns") == 1
|
|
120
|
+
assert not reg.undo()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_save_to_other_path_does_not_record_history(temp_yaml, tmp_path):
|
|
124
|
+
reg = Registry(temp_yaml)
|
|
125
|
+
export_path = tmp_path / "export.yaml"
|
|
126
|
+
|
|
127
|
+
reg.save(export_path)
|
|
128
|
+
|
|
129
|
+
assert export_path.exists()
|
|
130
|
+
assert not reg.undo()
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_undo_restores_external_file_state_before_save(temp_yaml):
|
|
134
|
+
reg = Registry(temp_yaml)
|
|
135
|
+
text = temp_yaml.read_text(encoding="utf-8")
|
|
136
|
+
temp_yaml.write_text(text.replace("50_000", "12345"), encoding="utf-8")
|
|
137
|
+
|
|
138
|
+
reg.root["local_only"] = "temp"
|
|
139
|
+
reg.save()
|
|
140
|
+
|
|
141
|
+
assert reg.get("period_ns") == 50000
|
|
142
|
+
assert reg.get("local_only") == "temp"
|
|
143
|
+
|
|
144
|
+
assert reg.undo()
|
|
145
|
+
assert reg.get("period_ns") == 12345
|
|
146
|
+
with pytest.raises(KeyError):
|
|
147
|
+
reg.get("local_only")
|
|
148
|
+
|
|
149
|
+
|
|
76
150
|
def test_create_false_raises(tmp_path):
|
|
77
151
|
path = tmp_path / "missing.yaml"
|
|
78
152
|
with pytest.raises(FileNotFoundError):
|
logqbit-0.4/PKG-INFO
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: logqbit
|
|
3
|
-
Version: 0.4
|
|
4
|
-
Summary: Simple data logger and live plotter for lab-scale experiments.
|
|
5
|
-
Project-URL: Homepage, https://github.com/Qiujv/logqbit
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Requires-Python: >=3.11
|
|
8
|
-
Requires-Dist: numba>=0.65.0
|
|
9
|
-
Requires-Dist: numpy>=2.3.3
|
|
10
|
-
Requires-Dist: pandas>=2.3.3
|
|
11
|
-
Requires-Dist: pyarrow>=21.0.0
|
|
12
|
-
Requires-Dist: pyqtgraph>=0.14.0
|
|
13
|
-
Requires-Dist: pyside6>=6.9.3
|
|
14
|
-
Requires-Dist: ruamel-yaml>=0.18.15
|
|
15
|
-
Requires-Dist: send2trash>=1.8.3
|
|
16
|
-
Requires-Dist: tqdm>=4.67.1
|
|
17
|
-
Requires-Dist: typing-extensions>=4.15.0
|
|
18
|
-
Provides-Extra: labrad
|
|
19
|
-
Requires-Dist: pylabrad>=0.98.3; extra == 'labrad'
|
|
20
|
-
Description-Content-Type: text/markdown
|
|
21
|
-
|
|
22
|
-
# LogQbit
|
|
23
|
-
|
|
24
|
-
*LogQbit* 是一个轻量且可扩展的实验数据记录工具包。
|
|
25
|
-
它最初用于记录 量子比特(qubit)实验测量数据,但凭借灵活的数据格式和实时可视化功能,同样适用于 任意中小规模(≤MB级)实验数据 的采集与管理。
|
|
26
|
-
|
|
27
|
-
*LogQbit* is a lightweight and extensible data logging toolkit for lab-scale experiments.
|
|
28
|
-
It was originally developed for recording quantum qubit measurement data,
|
|
29
|
-
but its flexible format and real-time visualization tools make it suitable for any small to medium (≤MB-level) experimental dataset.
|
|
30
|
-
|
|
31
|
-
通过使用 `logqbit`,你可以:
|
|
32
|
-
|
|
33
|
-
- 以最少的样板代码记录结构化实验数据;
|
|
34
|
-
|
|
35
|
-
- 使用集成的实时绘图工具可视化数据流;
|
|
36
|
-
|
|
37
|
-
- 通过交互式日志浏览器查看与分析记录的数据。
|
|
38
|
-
|
|
39
|
-
With `logqbit`, you can:
|
|
40
|
-
|
|
41
|
-
- Record structured experimental data with minimal boilerplate.
|
|
42
|
-
|
|
43
|
-
- Visualize data streams in real time with an integrated live plotter.
|
|
44
|
-
|
|
45
|
-
- Browse and analyze logged results through an interactive log browser.
|
|
46
|
-
|
|
47
|
-
无论是量子比特读出、参数扫描,还是传感器输出记录,
|
|
48
|
-
`logqbit` 都能为你提供一个简洁而可靠的实验数据采集与回溯工作流。
|
|
49
|
-
|
|
50
|
-
Whether you are monitoring qubit readouts, scanning a parameter sweep, or simply logging sensor outputs,
|
|
51
|
-
`logqbit` provides a simple and robust workflow for capturing and revisiting your experimental data.
|
|
52
|
-
|
|
53
|
-
## 安装 Installation
|
|
54
|
-
|
|
55
|
-
从 PyPI 安装 / Install from PyPI:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
pip install logqbit
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## 命令行工具 Command-Line Tools
|
|
62
|
-
|
|
63
|
-
安装后,以下命令可用:
|
|
64
|
-
|
|
65
|
-
After installation, the following commands are available:
|
|
66
|
-
|
|
67
|
-
- `logqbit-browser [directory]` - 启动交互式日志浏览器 GUI / Launch the interactive log browser GUI
|
|
68
|
-
- `logqbit-live-plotter` - 启动实时绘图窗口 / Launch the live plotting window
|
|
69
|
-
- `logqbit browser-demo` - 创建示例数据并启动浏览器 / Create example data and launch browser
|
|
70
|
-
- `logqbit copy-template <name>` - 复制迁移/工具模板到工作目录 / Copy migration/utility templates to your working directory
|
|
71
|
-
- `logqbit shortcuts` - 在桌面创建带自定义图标的快捷方式 / Create desktop shortcuts with custom icons
|
|
72
|
-
|
|
73
|
-
### 快速体验 Quick Demo
|
|
74
|
-
|
|
75
|
-
想快速体验 logqbit browser 的功能?运行以下命令:
|
|
76
|
-
|
|
77
|
-
Want to quickly experience logqbit browser? Run:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
logqbit browser-demo
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
这将创建示例数据并自动启动浏览器:
|
|
84
|
-
|
|
85
|
-
This will create example data and automatically launch the browser:
|
|
86
|
-
|
|
87
|
-
- `logqbit_example/` - 包含 3 个示例日志文件夹 / Contains 3 example log folders
|
|
88
|
-
- **示例 0** - 线性关系:`y = 2x + 1` 和 `z = x²` / Linear relationship: `y = 2x + 1` and `z = x²`
|
|
89
|
-
- **示例 1** - 带噪声的正弦信号 / Noisy sinusoidal signal
|
|
90
|
-
- **示例 2** - 2D 参数扫描(共振模拟)/ 2D parameter scan (resonance simulation)
|
|
91
|
-
|
|
92
|
-
浏览器将自动打开并显示示例数据。
|
|
93
|
-
|
|
94
|
-
The browser will automatically open and display the example data.
|
|
95
|
-
|
|
96
|
-
### 从 LabRAD 迁移数据 Data Migration from LabRAD
|
|
97
|
-
|
|
98
|
-
如果你有 LabRAD 格式的现有数据,可以轻松迁移:
|
|
99
|
-
|
|
100
|
-
If you have existing data in LabRAD format, you can easily migrate it:
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
# 复制迁移模板 / Copy the migration template
|
|
104
|
-
logqbit copy-template move_from_labrad
|
|
105
|
-
|
|
106
|
-
# 编辑 move_from_labrad.py 设置路径 / Edit move_from_labrad.py to set your paths
|
|
107
|
-
# 然后运行 / Then run it
|
|
108
|
-
python move_from_labrad.py
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
详细说明请参阅 [迁移指南](docs/migration_guide.md)。
|
|
112
|
-
|
|
113
|
-
See [Migration Guide](docs/migration_guide.md) for detailed instructions.
|
|
114
|
-
|
|
115
|
-
### 创建桌面快捷方式 Create Desktop Shortcuts
|
|
116
|
-
|
|
117
|
-
在桌面创建 LogQbit Browser 和 Live Plotter 的快捷方式(带自定义图标):
|
|
118
|
-
|
|
119
|
-
Create desktop shortcuts for LogQbit Browser and Live Plotter with custom icons:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
# 在桌面创建快捷方式 / Create shortcuts on desktop
|
|
123
|
-
logqbit shortcuts
|
|
124
|
-
|
|
125
|
-
# 在指定目录创建快捷方式 / Create shortcuts in a specific directory
|
|
126
|
-
logqbit shortcuts -o "C:\MyShortcuts"
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
这将创建以下快捷方式:
|
|
130
|
-
|
|
131
|
-
This will create the following shortcuts:
|
|
132
|
-
|
|
133
|
-
- **LogQbit Browser.lnk** - 日志浏览器快捷方式 / Log browser shortcut
|
|
134
|
-
- **LogQbit Live Plotter.lnk** - 实时绘图工具快捷方式 / Live plotter shortcut
|
|
135
|
-
|
|
136
|
-
每个快捷方式都配有对应的自定义图标。
|
|
137
|
-
|
|
138
|
-
Each shortcut comes with its corresponding custom icon.
|
|
139
|
-
|
|
140
|
-
## 文档 Documentation
|
|
141
|
-
|
|
142
|
-
- [首页 index](docs/index.md)
|
|
143
|
-
- [迁移指南 Migration Guide](docs/migration_guide.md) - 从 LabRAD 迁移数据 / Migrate data from LabRAD format
|
|
144
|
-
|
|
145
|
-
## 快速开始 Quick Start
|
|
146
|
-
|
|
147
|
-
### 基本用法 Basic Usage
|
|
148
|
-
|
|
149
|
-
```python
|
|
150
|
-
from pathlib import Path
|
|
151
|
-
from logqbit.logfolder import LogFolder
|
|
152
|
-
|
|
153
|
-
# 创建项目文件夹 / Create project folder
|
|
154
|
-
project_folder = Path('test')
|
|
155
|
-
project_folder.mkdir(exist_ok=True)
|
|
156
|
-
|
|
157
|
-
# 创建新的日志文件夹 / Create a new log folder
|
|
158
|
-
lf = LogFolder.new(project_folder)
|
|
159
|
-
|
|
160
|
-
# 添加数据行 / Add data rows
|
|
161
|
-
lf.add_row(x=1.5, y=2.0)
|
|
162
|
-
lf.add_row(x=233, y=[1, 3, 5])
|
|
163
|
-
|
|
164
|
-
# 访问数据 / Access data
|
|
165
|
-
print(lf.df)
|
|
166
|
-
|
|
167
|
-
# [可选] 设置元数据 / [Optional] Set metadata
|
|
168
|
-
lf.meta.title = "My Experiment"
|
|
169
|
-
lf.meta.star = 1
|
|
170
|
-
lf.meta.plot_axes = ["x"]
|
|
171
|
-
|
|
172
|
-
# [可选] 添加常量配置 / [Optional] Add constant configuration
|
|
173
|
-
lf.const["temperature"] = "300 K"
|
|
174
|
-
lf.const["description"] = "Test measurement"
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### API 说明 API Reference
|
|
178
|
-
|
|
179
|
-
**LogFolder 主要属性和方法 Main Attributes and Methods:**
|
|
180
|
-
|
|
181
|
-
- `lf.df` - 获取完整数据帧 / Get full dataframe
|
|
182
|
-
- `lf.meta` - 元数据(标题、星标、标签等)/ Metadata (title, star, tags, etc.)
|
|
183
|
-
- `lf.const` - 常量配置(实验参数等)/ Constant configuration (experiment parameters, etc.)
|
|
184
|
-
- `lf.add_row(**kwargs)` - 添加数据行 / Add data row
|
|
185
|
-
- `lf.flush()` - 强制保存数据 / Force save data
|
logqbit-0.4/README.md
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
# LogQbit
|
|
2
|
-
|
|
3
|
-
*LogQbit* 是一个轻量且可扩展的实验数据记录工具包。
|
|
4
|
-
它最初用于记录 量子比特(qubit)实验测量数据,但凭借灵活的数据格式和实时可视化功能,同样适用于 任意中小规模(≤MB级)实验数据 的采集与管理。
|
|
5
|
-
|
|
6
|
-
*LogQbit* is a lightweight and extensible data logging toolkit for lab-scale experiments.
|
|
7
|
-
It was originally developed for recording quantum qubit measurement data,
|
|
8
|
-
but its flexible format and real-time visualization tools make it suitable for any small to medium (≤MB-level) experimental dataset.
|
|
9
|
-
|
|
10
|
-
通过使用 `logqbit`,你可以:
|
|
11
|
-
|
|
12
|
-
- 以最少的样板代码记录结构化实验数据;
|
|
13
|
-
|
|
14
|
-
- 使用集成的实时绘图工具可视化数据流;
|
|
15
|
-
|
|
16
|
-
- 通过交互式日志浏览器查看与分析记录的数据。
|
|
17
|
-
|
|
18
|
-
With `logqbit`, you can:
|
|
19
|
-
|
|
20
|
-
- Record structured experimental data with minimal boilerplate.
|
|
21
|
-
|
|
22
|
-
- Visualize data streams in real time with an integrated live plotter.
|
|
23
|
-
|
|
24
|
-
- Browse and analyze logged results through an interactive log browser.
|
|
25
|
-
|
|
26
|
-
无论是量子比特读出、参数扫描,还是传感器输出记录,
|
|
27
|
-
`logqbit` 都能为你提供一个简洁而可靠的实验数据采集与回溯工作流。
|
|
28
|
-
|
|
29
|
-
Whether you are monitoring qubit readouts, scanning a parameter sweep, or simply logging sensor outputs,
|
|
30
|
-
`logqbit` provides a simple and robust workflow for capturing and revisiting your experimental data.
|
|
31
|
-
|
|
32
|
-
## 安装 Installation
|
|
33
|
-
|
|
34
|
-
从 PyPI 安装 / Install from PyPI:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
pip install logqbit
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 命令行工具 Command-Line Tools
|
|
41
|
-
|
|
42
|
-
安装后,以下命令可用:
|
|
43
|
-
|
|
44
|
-
After installation, the following commands are available:
|
|
45
|
-
|
|
46
|
-
- `logqbit-browser [directory]` - 启动交互式日志浏览器 GUI / Launch the interactive log browser GUI
|
|
47
|
-
- `logqbit-live-plotter` - 启动实时绘图窗口 / Launch the live plotting window
|
|
48
|
-
- `logqbit browser-demo` - 创建示例数据并启动浏览器 / Create example data and launch browser
|
|
49
|
-
- `logqbit copy-template <name>` - 复制迁移/工具模板到工作目录 / Copy migration/utility templates to your working directory
|
|
50
|
-
- `logqbit shortcuts` - 在桌面创建带自定义图标的快捷方式 / Create desktop shortcuts with custom icons
|
|
51
|
-
|
|
52
|
-
### 快速体验 Quick Demo
|
|
53
|
-
|
|
54
|
-
想快速体验 logqbit browser 的功能?运行以下命令:
|
|
55
|
-
|
|
56
|
-
Want to quickly experience logqbit browser? Run:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
logqbit browser-demo
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
这将创建示例数据并自动启动浏览器:
|
|
63
|
-
|
|
64
|
-
This will create example data and automatically launch the browser:
|
|
65
|
-
|
|
66
|
-
- `logqbit_example/` - 包含 3 个示例日志文件夹 / Contains 3 example log folders
|
|
67
|
-
- **示例 0** - 线性关系:`y = 2x + 1` 和 `z = x²` / Linear relationship: `y = 2x + 1` and `z = x²`
|
|
68
|
-
- **示例 1** - 带噪声的正弦信号 / Noisy sinusoidal signal
|
|
69
|
-
- **示例 2** - 2D 参数扫描(共振模拟)/ 2D parameter scan (resonance simulation)
|
|
70
|
-
|
|
71
|
-
浏览器将自动打开并显示示例数据。
|
|
72
|
-
|
|
73
|
-
The browser will automatically open and display the example data.
|
|
74
|
-
|
|
75
|
-
### 从 LabRAD 迁移数据 Data Migration from LabRAD
|
|
76
|
-
|
|
77
|
-
如果你有 LabRAD 格式的现有数据,可以轻松迁移:
|
|
78
|
-
|
|
79
|
-
If you have existing data in LabRAD format, you can easily migrate it:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# 复制迁移模板 / Copy the migration template
|
|
83
|
-
logqbit copy-template move_from_labrad
|
|
84
|
-
|
|
85
|
-
# 编辑 move_from_labrad.py 设置路径 / Edit move_from_labrad.py to set your paths
|
|
86
|
-
# 然后运行 / Then run it
|
|
87
|
-
python move_from_labrad.py
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
详细说明请参阅 [迁移指南](docs/migration_guide.md)。
|
|
91
|
-
|
|
92
|
-
See [Migration Guide](docs/migration_guide.md) for detailed instructions.
|
|
93
|
-
|
|
94
|
-
### 创建桌面快捷方式 Create Desktop Shortcuts
|
|
95
|
-
|
|
96
|
-
在桌面创建 LogQbit Browser 和 Live Plotter 的快捷方式(带自定义图标):
|
|
97
|
-
|
|
98
|
-
Create desktop shortcuts for LogQbit Browser and Live Plotter with custom icons:
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# 在桌面创建快捷方式 / Create shortcuts on desktop
|
|
102
|
-
logqbit shortcuts
|
|
103
|
-
|
|
104
|
-
# 在指定目录创建快捷方式 / Create shortcuts in a specific directory
|
|
105
|
-
logqbit shortcuts -o "C:\MyShortcuts"
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
这将创建以下快捷方式:
|
|
109
|
-
|
|
110
|
-
This will create the following shortcuts:
|
|
111
|
-
|
|
112
|
-
- **LogQbit Browser.lnk** - 日志浏览器快捷方式 / Log browser shortcut
|
|
113
|
-
- **LogQbit Live Plotter.lnk** - 实时绘图工具快捷方式 / Live plotter shortcut
|
|
114
|
-
|
|
115
|
-
每个快捷方式都配有对应的自定义图标。
|
|
116
|
-
|
|
117
|
-
Each shortcut comes with its corresponding custom icon.
|
|
118
|
-
|
|
119
|
-
## 文档 Documentation
|
|
120
|
-
|
|
121
|
-
- [首页 index](docs/index.md)
|
|
122
|
-
- [迁移指南 Migration Guide](docs/migration_guide.md) - 从 LabRAD 迁移数据 / Migrate data from LabRAD format
|
|
123
|
-
|
|
124
|
-
## 快速开始 Quick Start
|
|
125
|
-
|
|
126
|
-
### 基本用法 Basic Usage
|
|
127
|
-
|
|
128
|
-
```python
|
|
129
|
-
from pathlib import Path
|
|
130
|
-
from logqbit.logfolder import LogFolder
|
|
131
|
-
|
|
132
|
-
# 创建项目文件夹 / Create project folder
|
|
133
|
-
project_folder = Path('test')
|
|
134
|
-
project_folder.mkdir(exist_ok=True)
|
|
135
|
-
|
|
136
|
-
# 创建新的日志文件夹 / Create a new log folder
|
|
137
|
-
lf = LogFolder.new(project_folder)
|
|
138
|
-
|
|
139
|
-
# 添加数据行 / Add data rows
|
|
140
|
-
lf.add_row(x=1.5, y=2.0)
|
|
141
|
-
lf.add_row(x=233, y=[1, 3, 5])
|
|
142
|
-
|
|
143
|
-
# 访问数据 / Access data
|
|
144
|
-
print(lf.df)
|
|
145
|
-
|
|
146
|
-
# [可选] 设置元数据 / [Optional] Set metadata
|
|
147
|
-
lf.meta.title = "My Experiment"
|
|
148
|
-
lf.meta.star = 1
|
|
149
|
-
lf.meta.plot_axes = ["x"]
|
|
150
|
-
|
|
151
|
-
# [可选] 添加常量配置 / [Optional] Add constant configuration
|
|
152
|
-
lf.const["temperature"] = "300 K"
|
|
153
|
-
lf.const["description"] = "Test measurement"
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### API 说明 API Reference
|
|
157
|
-
|
|
158
|
-
**LogFolder 主要属性和方法 Main Attributes and Methods:**
|
|
159
|
-
|
|
160
|
-
- `lf.df` - 获取完整数据帧 / Get full dataframe
|
|
161
|
-
- `lf.meta` - 元数据(标题、星标、标签等)/ Metadata (title, star, tags, etc.)
|
|
162
|
-
- `lf.const` - 常量配置(实验参数等)/ Constant configuration (experiment parameters, etc.)
|
|
163
|
-
- `lf.add_row(**kwargs)` - 添加数据行 / Add data row
|
|
164
|
-
- `lf.flush()` - 强制保存数据 / Force save data
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|