pytdo 0.2.4__tar.gz → 0.2.5__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.
- {pytdo-0.2.4 → pytdo-0.2.5}/PKG-INFO +21 -13
- {pytdo-0.2.4 → pytdo-0.2.5}/README.md +21 -13
- {pytdo-0.2.4 → pytdo-0.2.5}/pyproject.toml +2 -2
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/_core.py +19 -12
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/widgets/_configuration_tab.py +15 -2
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/widgets/_graphs.py +29 -68
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/widgets/_param_content.py +3 -3
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/processors/_tdo.py +24 -20
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/__init__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/__main__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/assets/config_default.toml +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/config/__init__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/config/_config.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/config/_types.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/config/models.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/__init__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/_workers.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/widgets/__init__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/gui/widgets/_main_buttons.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/processors/__init__.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/processors/_types.py +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/py.typed +0 -0
- {pytdo-0.2.4 → pytdo-0.2.5}/src/pytdo/sp.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pytdo
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Author: Guillaume Le Goc
|
|
6
6
|
Author-email: Guillaume Le Goc <guillaume.le-goc@lncmi.cnrs.fr>
|
|
@@ -10,7 +10,7 @@ Requires-Dist: rich>=14.2.0
|
|
|
10
10
|
Requires-Dist: scipy>=1.16.3
|
|
11
11
|
Requires-Dist: pydantic>=2.12.4
|
|
12
12
|
Requires-Dist: pyqt6>=6.10.0
|
|
13
|
-
Requires-Dist: pyuson>=0.7.
|
|
13
|
+
Requires-Dist: pyuson>=0.7.3
|
|
14
14
|
Requires-Python: >=3.12
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
|
|
@@ -24,12 +24,20 @@ Description-Content-Type: text/markdown
|
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
27
|
-
### As an app
|
|
28
|
-
If you plan to just use the graphical user interface, consider installing `pytdo` as a tool managed by uv, a modern Python package manager.
|
|
27
|
+
### Method 1 : As an app
|
|
28
|
+
If you plan to just use the graphical user interface, consider installing `pytdo` as a tool managed by [uv](https://docs.astral.sh/uv/), a modern Python package manager.
|
|
29
29
|
|
|
30
|
-
To do so, install uv : https://docs.astral.sh/uv/getting-started/installation
|
|
30
|
+
To do so, install uv (see the official installation instructions : https://docs.astral.sh/uv/getting-started/installation/) :
|
|
31
|
+
- On Windows, enter the following command in PowerShell :
|
|
32
|
+
```powershell
|
|
33
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
34
|
+
```
|
|
35
|
+
- On Linux and MacOS, enter the following in a terminal :
|
|
36
|
+
```bash
|
|
37
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
38
|
+
```
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
Once uv is installed, from the command line (PowerShell in Windows), install `pytdo` with uv :
|
|
33
41
|
```
|
|
34
42
|
uv tool install pytdo
|
|
35
43
|
```
|
|
@@ -40,13 +48,13 @@ Then, launch the GUI by running `pytdo` from the command line.
|
|
|
40
48
|
|
|
41
49
|
To update, run : `uv tool upgrade pytdo`.
|
|
42
50
|
|
|
43
|
-
### As a library
|
|
44
|
-
Installing `pytdo` as a library will allow you to use
|
|
45
|
-
Note that you can
|
|
51
|
+
### Method 2 : As a library
|
|
52
|
+
Installing `pytdo` as a library will allow you to use the graphical user interface but also use the backend library from scripts and Jupyter notebooks (e.g. you will be able to import it with `import pytdo`).
|
|
53
|
+
Note that you can use the same environment than the one for [`pyuson`](https://gitlab.in2p3.fr/himagnetos/pyuson).
|
|
46
54
|
|
|
47
|
-
1. Create a Python environment :
|
|
48
|
-
|
|
49
|
-
With
|
|
55
|
+
1. Create a Python environment with Python 3.12 :
|
|
56
|
+
|
|
57
|
+
You can use your favorite Python environment manager. With [conda](https://conda-forge.org/miniforge/), this would be :
|
|
50
58
|
```
|
|
51
59
|
conda create -n pytdo-env -c conda-forge python=3.12
|
|
52
60
|
```
|
|
@@ -85,7 +93,7 @@ pip install -e /path/to/pytdo-main
|
|
|
85
93
|
```
|
|
86
94
|
|
|
87
95
|
## Usage
|
|
88
|
-
You can use this package through the graphical user interface, or directly from Python
|
|
96
|
+
You can use this package through the graphical user interface, or directly from the Python shell, script or Jupyter notebook using the `TDOProcessor` class. All this methods rely on a TOML configuration file that specifies the experiment parameters and analysis settings.
|
|
89
97
|
|
|
90
98
|
A template configuration file is provided in the `configs` folder. Copy-paste and edit it according to your need. Each entry of the file is commented so it should be somewhat straightforward to configure. Then :
|
|
91
99
|
|
|
@@ -8,12 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
### As an app
|
|
12
|
-
If you plan to just use the graphical user interface, consider installing `pytdo` as a tool managed by uv, a modern Python package manager.
|
|
13
|
-
|
|
14
|
-
To do so, install uv : https://docs.astral.sh/uv/getting-started/installation
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
### Method 1 : As an app
|
|
12
|
+
If you plan to just use the graphical user interface, consider installing `pytdo` as a tool managed by [uv](https://docs.astral.sh/uv/), a modern Python package manager.
|
|
13
|
+
|
|
14
|
+
To do so, install uv (see the official installation instructions : https://docs.astral.sh/uv/getting-started/installation/) :
|
|
15
|
+
- On Windows, enter the following command in PowerShell :
|
|
16
|
+
```powershell
|
|
17
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
18
|
+
```
|
|
19
|
+
- On Linux and MacOS, enter the following in a terminal :
|
|
20
|
+
```bash
|
|
21
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Once uv is installed, from the command line (PowerShell in Windows), install `pytdo` with uv :
|
|
17
25
|
```
|
|
18
26
|
uv tool install pytdo
|
|
19
27
|
```
|
|
@@ -24,13 +32,13 @@ Then, launch the GUI by running `pytdo` from the command line.
|
|
|
24
32
|
|
|
25
33
|
To update, run : `uv tool upgrade pytdo`.
|
|
26
34
|
|
|
27
|
-
### As a library
|
|
28
|
-
Installing `pytdo` as a library will allow you to use
|
|
29
|
-
Note that you can
|
|
30
|
-
|
|
31
|
-
1. Create a Python environment :
|
|
35
|
+
### Method 2 : As a library
|
|
36
|
+
Installing `pytdo` as a library will allow you to use the graphical user interface but also use the backend library from scripts and Jupyter notebooks (e.g. you will be able to import it with `import pytdo`).
|
|
37
|
+
Note that you can use the same environment than the one for [`pyuson`](https://gitlab.in2p3.fr/himagnetos/pyuson).
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
1. Create a Python environment with Python 3.12 :
|
|
40
|
+
|
|
41
|
+
You can use your favorite Python environment manager. With [conda](https://conda-forge.org/miniforge/), this would be :
|
|
34
42
|
```
|
|
35
43
|
conda create -n pytdo-env -c conda-forge python=3.12
|
|
36
44
|
```
|
|
@@ -69,7 +77,7 @@ pip install -e /path/to/pytdo-main
|
|
|
69
77
|
```
|
|
70
78
|
|
|
71
79
|
## Usage
|
|
72
|
-
You can use this package through the graphical user interface, or directly from Python
|
|
80
|
+
You can use this package through the graphical user interface, or directly from the Python shell, script or Jupyter notebook using the `TDOProcessor` class. All this methods rely on a TOML configuration file that specifies the experiment parameters and analysis settings.
|
|
73
81
|
|
|
74
82
|
A template configuration file is provided in the `configs` folder. Copy-paste and edit it according to your need. Each entry of the file is commented so it should be somewhat straightforward to configure. Then :
|
|
75
83
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytdo"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.5"
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -14,7 +14,7 @@ dependencies = [
|
|
|
14
14
|
"scipy>=1.16.3",
|
|
15
15
|
"pydantic>=2.12.4",
|
|
16
16
|
"pyqt6>=6.10.0",
|
|
17
|
-
"pyuson>=0.7.
|
|
17
|
+
"pyuson>=0.7.3",
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
[project.gui-scripts]
|
|
@@ -57,6 +57,9 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
57
57
|
self.update_spectro_time_window
|
|
58
58
|
)
|
|
59
59
|
self.wconfiguration.sig_timeoffset_changed.connect(self.apply_time_offset)
|
|
60
|
+
self.wconfiguration.sig_fitdeg_changed.connect(self.remove_background)
|
|
61
|
+
self.wconfiguration.sig_npoints_interp_changed.connect(self.remove_background)
|
|
62
|
+
self.wconfiguration.sig_curveoffset_changed.connect(self.plot_tdo_detrended)
|
|
60
63
|
|
|
61
64
|
def init_buttons(self):
|
|
62
65
|
super().init_buttons()
|
|
@@ -133,14 +136,13 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
133
136
|
|
|
134
137
|
@pyqtSlot()
|
|
135
138
|
def extract_tdo_finished(self):
|
|
136
|
-
self.align_field_finished()
|
|
137
|
-
self.plot_tdo()
|
|
138
|
-
|
|
139
139
|
# Clear plots since source signal was changed
|
|
140
140
|
self.wplots.tdo_field.clearPlots()
|
|
141
141
|
self.wplots.tdo_inverse_field.clearPlots()
|
|
142
142
|
self.wplots.fft.clearPlots()
|
|
143
143
|
|
|
144
|
+
self.align_field_finished()
|
|
145
|
+
self.plot_tdo()
|
|
144
146
|
self.enable_buttons()
|
|
145
147
|
|
|
146
148
|
@pyqtSlot()
|
|
@@ -157,7 +159,7 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
157
159
|
self.wplots.tdo_field.clearPlots()
|
|
158
160
|
self.wplots.tdo_inverse_field.clearPlots()
|
|
159
161
|
self.wplots.fft.clearPlots()
|
|
160
|
-
self.
|
|
162
|
+
self.fft()
|
|
161
163
|
|
|
162
164
|
@pyqtSlot()
|
|
163
165
|
def remove_background(self):
|
|
@@ -169,6 +171,7 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
169
171
|
|
|
170
172
|
@pyqtSlot()
|
|
171
173
|
def remove_background_finished(self):
|
|
174
|
+
self.wplots.fft.clearPlots()
|
|
172
175
|
self.plot_tdo_detrended()
|
|
173
176
|
self.enable_buttons()
|
|
174
177
|
|
|
@@ -293,6 +296,8 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
293
296
|
)
|
|
294
297
|
self.flag_do_update_roi = True
|
|
295
298
|
|
|
299
|
+
self.fft()
|
|
300
|
+
|
|
296
301
|
@pyqtSlot()
|
|
297
302
|
def update_roi_from_poly(self):
|
|
298
303
|
"""
|
|
@@ -348,7 +353,7 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
348
353
|
|
|
349
354
|
# Update ROI, without recomputing
|
|
350
355
|
self.flag_do_update_roi = False
|
|
351
|
-
self.wplots.
|
|
356
|
+
self.wplots.roi2.setRegion(new_region)
|
|
352
357
|
self.flag_do_update_roi = True
|
|
353
358
|
else:
|
|
354
359
|
return
|
|
@@ -360,7 +365,6 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
360
365
|
|
|
361
366
|
## TDO signal versus field
|
|
362
367
|
self.wplots.sig_field.clearPlots()
|
|
363
|
-
self.wplots.sig_field.setAutoVisible(y=True)
|
|
364
368
|
|
|
365
369
|
# Decreasing magnetic field
|
|
366
370
|
self.wplots.sig_field.plot(
|
|
@@ -383,7 +387,6 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
383
387
|
|
|
384
388
|
## TDO signal versus time
|
|
385
389
|
self.wplots.sig_time.clearPlots()
|
|
386
|
-
self.wplots.sig_time.setAutoVisible(y=True)
|
|
387
390
|
|
|
388
391
|
# Decreasing magnetic field
|
|
389
392
|
self.wplots.sig_time.plot(
|
|
@@ -404,8 +407,11 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
404
407
|
name="B up",
|
|
405
408
|
)
|
|
406
409
|
|
|
410
|
+
@pyqtSlot()
|
|
407
411
|
def plot_tdo_detrended(self):
|
|
408
412
|
"""Plot TDO signal with background removed."""
|
|
413
|
+
if not self.check_tdo_detrended():
|
|
414
|
+
return
|
|
409
415
|
# Get parameters
|
|
410
416
|
offset = self.worker.proc.cfg.settings.offset
|
|
411
417
|
lower_b, upper_b = self.worker.proc.cfg.settings.fft_window
|
|
@@ -418,9 +424,8 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
418
424
|
|
|
419
425
|
## TDO detrended versus field
|
|
420
426
|
self.wplots.tdo_field.clearPlots()
|
|
421
|
-
self.wplots.tdo_field.setAutoVisible(y=True)
|
|
422
427
|
self.wplots.sig_field.clearPlots()
|
|
423
|
-
self.plot_tdo()
|
|
428
|
+
self.plot_tdo() # to make sure data shown is synced
|
|
424
429
|
|
|
425
430
|
# Decreasing magnetic field
|
|
426
431
|
if self.worker.proc.get_data_processed(
|
|
@@ -444,7 +449,6 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
444
449
|
pen=self.wplots.pen_bup,
|
|
445
450
|
name="B up",
|
|
446
451
|
)
|
|
447
|
-
self.wplots.tdo_field.setXRange(lower_b, upper_b, padding=0.05)
|
|
448
452
|
|
|
449
453
|
# Fit decreasing magnetic field
|
|
450
454
|
if self.worker.proc.get_data_processed(
|
|
@@ -473,7 +477,6 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
473
477
|
|
|
474
478
|
## TDO detrended versus 1/B
|
|
475
479
|
self.wplots.tdo_inverse_field.clearPlots()
|
|
476
|
-
self.wplots.tdo_inverse_field.setAutoVisible(y=True)
|
|
477
480
|
|
|
478
481
|
# Decreasing magnetic field
|
|
479
482
|
if self.worker.proc.get_data_processed(
|
|
@@ -497,7 +500,6 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
497
500
|
pen=self.wplots.pen_bup,
|
|
498
501
|
name="B up",
|
|
499
502
|
)
|
|
500
|
-
self.wplots.tdo_inverse_field.setXRange(1 / upper_b, 1 / lower_b, padding=0.05)
|
|
501
503
|
|
|
502
504
|
def plot_fft(self):
|
|
503
505
|
"""Plot FFT in 1/B."""
|
|
@@ -544,6 +546,11 @@ class MainWindow(gui.BaseMainWindow):
|
|
|
544
546
|
return False
|
|
545
547
|
return self.worker.proc._check_barycenters_computed()
|
|
546
548
|
|
|
549
|
+
def check_tdo_detrended(self) -> bool:
|
|
550
|
+
if not self.check_tdo_extracted():
|
|
551
|
+
return False
|
|
552
|
+
return self.worker.proc._check_tdo_detrended()
|
|
553
|
+
|
|
547
554
|
def dropEvent(self, e):
|
|
548
555
|
for url in e.mimeData().urls():
|
|
549
556
|
file_path = url.toLocalFile()
|
|
@@ -12,11 +12,15 @@ class ConfigurationWidget(gui.widgets.BaseConfigurationWidget):
|
|
|
12
12
|
Extra signals :
|
|
13
13
|
sig_syncroi_changed : emitted when the "Sync ROI" checkbox is changed.
|
|
14
14
|
sig_timeoffset_changed : emitted when the "Time offset" parameter is changed.
|
|
15
|
+
sig_fitdeg_changed : emitted when the n points interp 1/B parameter is changed.
|
|
15
16
|
"""
|
|
16
17
|
|
|
17
18
|
sig_syncroi_changed = pyqtSignal()
|
|
18
19
|
sig_timeoffset_changed = pyqtSignal()
|
|
19
20
|
sig_spectro_nperseg_changed = pyqtSignal()
|
|
21
|
+
sig_fitdeg_changed = pyqtSignal()
|
|
22
|
+
sig_npoints_interp_changed = pyqtSignal()
|
|
23
|
+
sig_curveoffset_changed = pyqtSignal()
|
|
20
24
|
|
|
21
25
|
def __init__(self, param_content: type):
|
|
22
26
|
super().__init__(param_content)
|
|
@@ -30,7 +34,7 @@ class ConfigurationWidget(gui.widgets.BaseConfigurationWidget):
|
|
|
30
34
|
self.syncroi_parameter = Parameter.create(
|
|
31
35
|
name="syncroi",
|
|
32
36
|
type="bool",
|
|
33
|
-
value=
|
|
37
|
+
value=False,
|
|
34
38
|
title="Sync. fit and FFT field-window",
|
|
35
39
|
)
|
|
36
40
|
self.host_parameters.addChild(self.syncroi_parameter)
|
|
@@ -43,7 +47,7 @@ class ConfigurationWidget(gui.widgets.BaseConfigurationWidget):
|
|
|
43
47
|
value=1024 / 100e6,
|
|
44
48
|
suffix="s",
|
|
45
49
|
siPrefix=True,
|
|
46
|
-
title="Spectro: time window (n/persegment)"
|
|
50
|
+
title="Spectro: time window (n/persegment)",
|
|
47
51
|
)
|
|
48
52
|
self.host_parameters.addChild(nperseg)
|
|
49
53
|
|
|
@@ -56,3 +60,12 @@ class ConfigurationWidget(gui.widgets.BaseConfigurationWidget):
|
|
|
56
60
|
self.settings_parameters.child("spectro_nperseg").sigValueChanged.connect(
|
|
57
61
|
self.sig_spectro_nperseg_changed.emit
|
|
58
62
|
)
|
|
63
|
+
self.settings_parameters.child("poly_deg").sigValueChanged.connect(
|
|
64
|
+
self.sig_fitdeg_changed.emit
|
|
65
|
+
)
|
|
66
|
+
self.settings_parameters.child(
|
|
67
|
+
"npoints_interp_inverse"
|
|
68
|
+
).sigValueChanged.connect(self.sig_npoints_interp_changed.emit)
|
|
69
|
+
self.settings_parameters.child("offset").sigValueChanged.connect(
|
|
70
|
+
self.sig_curveoffset_changed.emit
|
|
71
|
+
)
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import pyqtgraph as pg
|
|
4
4
|
from PyQt6 import QtWidgets
|
|
5
|
-
from PyQt6.QtCore import
|
|
5
|
+
from PyQt6.QtCore import pyqtSignal, pyqtSlot
|
|
6
|
+
from pyuson import gui
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
class GraphsWidget(
|
|
9
|
+
class GraphsWidget(gui.widgets.BaseGraphsWidget):
|
|
9
10
|
"""
|
|
10
11
|
The graphs area with all the plots.
|
|
11
12
|
|
|
@@ -22,8 +23,7 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
22
23
|
super().__init__()
|
|
23
24
|
|
|
24
25
|
# Flags
|
|
25
|
-
self.
|
|
26
|
-
self._sync_roi = True
|
|
26
|
+
self._sync_roi = False
|
|
27
27
|
|
|
28
28
|
# Create grid
|
|
29
29
|
grid = QtWidgets.QGridLayout()
|
|
@@ -34,8 +34,7 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
34
34
|
tdo_tab = self.create_tdo_plot()
|
|
35
35
|
fft_tab = self.create_fft_plot()
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
self.init_plot_style()
|
|
37
|
+
self.init_coordinates_on_hover()
|
|
39
38
|
|
|
40
39
|
# Add Tabs to the grid
|
|
41
40
|
grid.addWidget(field_tab, 0, 0, 1, 1)
|
|
@@ -54,16 +53,6 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
54
53
|
# Create widget
|
|
55
54
|
self.setLayout(grid)
|
|
56
55
|
|
|
57
|
-
@property
|
|
58
|
-
def time2frame_scale(self) -> float:
|
|
59
|
-
return self._time2frame_scale
|
|
60
|
-
|
|
61
|
-
@time2frame_scale.setter
|
|
62
|
-
def time2frame_scale(self, value: float):
|
|
63
|
-
self._time2frame_scale = value
|
|
64
|
-
self.field.getAxis("top").setScale(self.time2frame_scale)
|
|
65
|
-
self.dfield.getAxis("top").setScale(self.time2frame_scale)
|
|
66
|
-
|
|
67
56
|
def create_field_plot(self) -> QtWidgets.QTabWidget:
|
|
68
57
|
tab = QtWidgets.QTabWidget(self)
|
|
69
58
|
|
|
@@ -72,12 +61,14 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
72
61
|
self.field.setLabel("bottom", "time (s)")
|
|
73
62
|
self.field.setLabel("left", "field (T)")
|
|
74
63
|
self.field.showGrid(y=True)
|
|
64
|
+
self._plots_list.add(self.field)
|
|
75
65
|
|
|
76
66
|
# pickup coil voltage (measured)
|
|
77
67
|
self.dfield = pg.PlotWidget(title="Pickup")
|
|
78
68
|
self.dfield.setLabel("bottom", "time (s)")
|
|
79
69
|
self.dfield.setLabel("left", "pickup (V)")
|
|
80
70
|
self.dfield.showGrid(y=True)
|
|
71
|
+
self._plots_list.add(self.dfield)
|
|
81
72
|
|
|
82
73
|
tab.addTab(self.field, "B(t)")
|
|
83
74
|
tab.addTab(self.dfield, "Pickup")
|
|
@@ -92,16 +83,21 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
92
83
|
self.sig_field.setLabel("bottom", "field (T)")
|
|
93
84
|
self.sig_field.setLabel("left", "TDO frequency (Hz)")
|
|
94
85
|
self.sig_field.showGrid(y=True)
|
|
95
|
-
|
|
86
|
+
# Field-window selector
|
|
87
|
+
self.roi = pg.LinearRegionItem(brush=pg.mkBrush("#0000ff1a"))
|
|
88
|
+
self.roi.hoverEvent = lambda *args, **kwargs: None # disable mouse drag
|
|
89
|
+
self.roi.mouseDragEvent = lambda *args, **kwargs: None # disable mouse drag
|
|
96
90
|
self.sig_field.addItem(self.roi, ignoreBounds=True)
|
|
97
91
|
self.roi.sigRegionChangeFinished.connect(self.roi1_changed)
|
|
98
92
|
self.sig_field.getPlotItem().addLegend()
|
|
93
|
+
self._plots_list.add(self.sig_field)
|
|
99
94
|
|
|
100
95
|
# TDO signal versus time
|
|
101
96
|
self.sig_time = pg.PlotWidget(title="Signal versus time")
|
|
102
97
|
self.sig_time.setLabel("bottom", "time (s)")
|
|
103
98
|
self.sig_time.setLabel("left", "TDO frequency (Hz)")
|
|
104
99
|
self.sig_time.showGrid(y=True)
|
|
100
|
+
self._plots_list.add(self.sig_time)
|
|
105
101
|
|
|
106
102
|
tab.addTab(self.sig_field, "TDO(B)")
|
|
107
103
|
tab.addTab(self.sig_time, "TDO(t)")
|
|
@@ -117,15 +113,25 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
117
113
|
self.tdo_field.setLabel("left", "TDO detrended")
|
|
118
114
|
self.tdo_field.showGrid(y=True)
|
|
119
115
|
self.tdo_field.getPlotItem().addLegend()
|
|
120
|
-
|
|
116
|
+
# Field-window selector for FFT range
|
|
117
|
+
self.roi2 = pg.LinearRegionItem(brush=pg.mkBrush("#0000ff1a"))
|
|
118
|
+
self.roi2.hoverEvent = lambda *args, **kwargs: None # disable mouse drag
|
|
119
|
+
self.roi2.mouseDragEvent = lambda *args, **kwargs: None # disable mouse drag
|
|
121
120
|
self.tdo_field.addItem(self.roi2, ignoreBounds=True)
|
|
122
121
|
self.roi2.sigRegionChangeFinished.connect(self.roi2_changed)
|
|
122
|
+
# Vertical lines to show polynomial fit range
|
|
123
|
+
self.fit_bounds1 = pg.InfiniteLine(pen=self.pen_fitbounds, movable=False)
|
|
124
|
+
self.fit_bounds2 = pg.InfiniteLine(pen=self.pen_fitbounds, movable=False)
|
|
125
|
+
self.tdo_field.addItem(self.fit_bounds1)
|
|
126
|
+
self.tdo_field.addItem(self.fit_bounds2)
|
|
127
|
+
self._plots_list.add(self.tdo_field)
|
|
123
128
|
|
|
124
129
|
# vs 1/B
|
|
125
130
|
self.tdo_inverse_field = pg.PlotWidget(title="Oscillatory part versus 1/B")
|
|
126
131
|
self.tdo_inverse_field.setLabel("bottom", "1/B (T^-1)")
|
|
127
132
|
self.tdo_inverse_field.setLabel("left", "TDO detrended")
|
|
128
133
|
self.tdo_inverse_field.showGrid(y=True)
|
|
134
|
+
self._plots_list.add(self.tdo_inverse_field)
|
|
129
135
|
|
|
130
136
|
tab.addTab(self.tdo_field, "TDO detrended(B)")
|
|
131
137
|
tab.addTab(self.tdo_inverse_field, "TDO detrended(1/B)")
|
|
@@ -141,6 +147,7 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
141
147
|
self.fft.setLabel("left", "magnitude")
|
|
142
148
|
self.fft.showGrid(y=True)
|
|
143
149
|
self.fft.getPlotItem().addLegend()
|
|
150
|
+
self._plots_list.add(self.fft)
|
|
144
151
|
|
|
145
152
|
tab.addTab(self.fft, "FFT")
|
|
146
153
|
|
|
@@ -154,15 +161,18 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
154
161
|
self.pen_bdown = pg.mkPen("#d62728ff", width=w0)
|
|
155
162
|
self.pen_fitbup = pg.mkPen("#2ca02cb1", width=w0)
|
|
156
163
|
self.pen_fitdown = pg.mkPen("#d62728b1", width=w0)
|
|
164
|
+
self.pen_fitbounds = pg.mkPen("#7477ed99", width=w0)
|
|
157
165
|
|
|
158
166
|
@pyqtSlot()
|
|
159
167
|
def roi1_changed(self):
|
|
160
168
|
"""Update ROI in the TDO detrended panel when the ROI in the TDO panel moved."""
|
|
169
|
+
roi1 = self.roi.getRegion() # TDO panel
|
|
170
|
+
self.fit_bounds1.setPos(roi1[0])
|
|
171
|
+
self.fit_bounds2.setPos(roi1[1])
|
|
161
172
|
self.sig_roi1_changed.emit()
|
|
162
173
|
if not self._sync_roi:
|
|
163
174
|
return
|
|
164
175
|
|
|
165
|
-
roi1 = self.roi.getRegion() # TDO panel
|
|
166
176
|
roi2 = self.roi2.getRegion() # TDO detrend panel
|
|
167
177
|
|
|
168
178
|
if roi1 != roi2:
|
|
@@ -190,52 +200,3 @@ class GraphsWidget(QtWidgets.QWidget):
|
|
|
190
200
|
"""Disable moving ROIs."""
|
|
191
201
|
self.roi.setMovable(False)
|
|
192
202
|
self.roi2.setMovable(False)
|
|
193
|
-
|
|
194
|
-
def clear_all_plots(self):
|
|
195
|
-
"""Clear plots."""
|
|
196
|
-
self.field.clearPlots()
|
|
197
|
-
self.dfield.clearPlots()
|
|
198
|
-
self.sig_time.clearPlots()
|
|
199
|
-
self.sig_field.clearPlots()
|
|
200
|
-
self.tdo_field.clearPlots()
|
|
201
|
-
self.tdo_inverse_field.clearPlots()
|
|
202
|
-
self.fft.clearPlots()
|
|
203
|
-
|
|
204
|
-
def event(self, ev: QEvent | None):
|
|
205
|
-
"""Handle mouse selection while holding CTRL to make a ROI zoom in plots."""
|
|
206
|
-
if ev is None:
|
|
207
|
-
return super().event(None)
|
|
208
|
-
|
|
209
|
-
# Switch to rectangular zoom selection on the first Ctrl key press event
|
|
210
|
-
if ev.type() == QEvent.Type.KeyPress and ev.key() == Qt.Key.Key_Control:
|
|
211
|
-
if self._mouse_pan_mode:
|
|
212
|
-
self.switch_mouse_pan_mode(False)
|
|
213
|
-
|
|
214
|
-
# Switch back to pan mode on left click when releasing the Ctrl key
|
|
215
|
-
if ev.type() == QEvent.Type.KeyRelease and ev.key() == Qt.Key.Key_Control:
|
|
216
|
-
self.switch_mouse_pan_mode(True)
|
|
217
|
-
|
|
218
|
-
return super().event(ev)
|
|
219
|
-
|
|
220
|
-
def switch_mouse_pan_mode(self, state: bool):
|
|
221
|
-
"""
|
|
222
|
-
Switch mouse behavior from panning to ROI-zooming when holding CTRL.
|
|
223
|
-
|
|
224
|
-
Parameters
|
|
225
|
-
----------
|
|
226
|
-
state : bool
|
|
227
|
-
If True, all plots are set to pan mode, otherwise they are set in ROI-zoom
|
|
228
|
-
mode.
|
|
229
|
-
"""
|
|
230
|
-
# Get mode
|
|
231
|
-
mode = pg.ViewBox.PanMode if state else pg.ViewBox.RectMode
|
|
232
|
-
self._mouse_pan_mode = state
|
|
233
|
-
|
|
234
|
-
# Set mode
|
|
235
|
-
self.field.getPlotItem().getViewBox().setMouseMode(mode)
|
|
236
|
-
self.dfield.getPlotItem().getViewBox().setMouseMode(mode)
|
|
237
|
-
self.sig_time.getPlotItem().getViewBox().setMouseMode(mode)
|
|
238
|
-
self.sig_field.getPlotItem().getViewBox().setMouseMode(mode)
|
|
239
|
-
self.tdo_field.getPlotItem().getViewBox().setMouseMode(mode)
|
|
240
|
-
self.tdo_inverse_field.getPlotItem().getViewBox().setMouseMode(mode)
|
|
241
|
-
self.fft.getPlotItem().getViewBox().setMouseMode(mode)
|
|
@@ -42,7 +42,7 @@ class ParamContent(BaseParamContent):
|
|
|
42
42
|
limits=[2, np.inf],
|
|
43
43
|
value=2048,
|
|
44
44
|
step=1024,
|
|
45
|
-
title="Spectro: FFT
|
|
45
|
+
title="Spectro: FFT padding size",
|
|
46
46
|
),
|
|
47
47
|
dict(
|
|
48
48
|
name="spectro_noverlap",
|
|
@@ -50,7 +50,7 @@ class ParamContent(BaseParamContent):
|
|
|
50
50
|
limits=[-1, np.inf],
|
|
51
51
|
value=-1,
|
|
52
52
|
step=512,
|
|
53
|
-
title="Spectro: n overlap",
|
|
53
|
+
title="Spectro: n overlap (-1 : n/2)",
|
|
54
54
|
),
|
|
55
55
|
dict(
|
|
56
56
|
name="barycenters_fwindow",
|
|
@@ -117,7 +117,7 @@ class ParamContent(BaseParamContent):
|
|
|
117
117
|
limits=[1, np.inf],
|
|
118
118
|
suffix="T",
|
|
119
119
|
siPrefix=True,
|
|
120
|
-
title="Max. B-frequency",
|
|
120
|
+
title="FFT : Max. B-frequency",
|
|
121
121
|
),
|
|
122
122
|
dict(
|
|
123
123
|
name="offset",
|
|
@@ -372,16 +372,21 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
|
|
|
372
372
|
logger.error("Spectrogram not computed. Run `compute_spectrogram()` first")
|
|
373
373
|
return self
|
|
374
374
|
|
|
375
|
+
# Get parameters to log
|
|
376
|
+
fxx = self.get_data_processed("spectro_f")
|
|
377
|
+
freq_window = self.cfg.settings.barycenters_fwindow
|
|
378
|
+
nsamples = int(freq_window / np.mean(np.diff(fxx)))
|
|
375
379
|
logger.info(
|
|
376
|
-
"Finding spectrogram barycenters (frequency-window size : "
|
|
377
|
-
f"{
|
|
380
|
+
"Finding spectrogram barycenters (frequency-window half-size : "
|
|
381
|
+
f"{freq_window:2.3f}Hz, {nsamples} samples)..."
|
|
378
382
|
)
|
|
383
|
+
# Get barycenters
|
|
379
384
|
self.set_data_processed(
|
|
380
385
|
self._tdo_name,
|
|
381
386
|
sp.find_barycenters(
|
|
382
|
-
|
|
387
|
+
fxx,
|
|
383
388
|
self.get_data_processed("spectro_s"),
|
|
384
|
-
|
|
389
|
+
freq_window,
|
|
385
390
|
fast=self.cfg.settings.barycenters_fast,
|
|
386
391
|
),
|
|
387
392
|
)
|
|
@@ -392,6 +397,12 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
|
|
|
392
397
|
|
|
393
398
|
return self
|
|
394
399
|
|
|
400
|
+
def extract_tdo(self) -> Self:
|
|
401
|
+
"""Helper function that does everything required to extract the TDO signal."""
|
|
402
|
+
self.compute_spectrogram().find_barycenters()
|
|
403
|
+
|
|
404
|
+
return self
|
|
405
|
+
|
|
395
406
|
def apply_time_offset(self) -> Self:
|
|
396
407
|
"""Apply offset on the experiment time vector."""
|
|
397
408
|
if not self.get_data_processed("spectro_t", checkonly=True):
|
|
@@ -548,15 +559,20 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
|
|
|
548
559
|
|
|
549
560
|
return self
|
|
550
561
|
|
|
562
|
+
def remove_background(self) -> Self:
|
|
563
|
+
"""Helper function to detrend the signal and sort signal in 1/B."""
|
|
564
|
+
self.detrend_polyfit().oversample_inverse_field()
|
|
565
|
+
|
|
566
|
+
return self
|
|
567
|
+
|
|
551
568
|
def fft_inverse_field(self) -> Self:
|
|
552
569
|
"""
|
|
553
570
|
FFT on the signal in 1/B.
|
|
554
571
|
|
|
555
572
|
The resulting "frequencies" are therefore in units of B (teslas).
|
|
556
573
|
"""
|
|
557
|
-
#
|
|
558
|
-
|
|
559
|
-
self.oversample_inverse_field()
|
|
574
|
+
# Force oversample inverese field to update parameters
|
|
575
|
+
self.oversample_inverse_field()
|
|
560
576
|
|
|
561
577
|
# FFT
|
|
562
578
|
logger.info("FFT on TDO signal in 1/B...")
|
|
@@ -591,18 +607,6 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
|
|
|
591
607
|
|
|
592
608
|
return self
|
|
593
609
|
|
|
594
|
-
def extract_tdo(self) -> Self:
|
|
595
|
-
"""Helper function that does everything required to extract the TDO signal."""
|
|
596
|
-
self.compute_spectrogram().find_barycenters()
|
|
597
|
-
|
|
598
|
-
return self
|
|
599
|
-
|
|
600
|
-
def remove_background(self) -> Self:
|
|
601
|
-
"""Helper function to detrend the signal and sort signal in 1/B."""
|
|
602
|
-
self.detrend_polyfit().oversample_inverse_field()
|
|
603
|
-
|
|
604
|
-
return self
|
|
605
|
-
|
|
606
610
|
def collect_arrays(self, array_names_list: list[str]) -> list[np.ndarray]:
|
|
607
611
|
"""Collect and data in `data_processed`."""
|
|
608
612
|
return [self.get_data_processed(name) for name in array_names_list]
|
|
@@ -620,7 +624,7 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
|
|
|
620
624
|
If the file already exists, it is overwritten.
|
|
621
625
|
"""
|
|
622
626
|
if filename is None:
|
|
623
|
-
filename = self.get_csv_filename(suffix="-
|
|
627
|
+
filename = self.get_csv_filename(suffix="-out")
|
|
624
628
|
|
|
625
629
|
logger.info("Saving extracted TDO signal...")
|
|
626
630
|
|
|
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
|
|
File without changes
|