pymagnetos 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymagnetos/__init__.py +15 -0
- pymagnetos/cli.py +40 -0
- pymagnetos/core/__init__.py +19 -0
- pymagnetos/core/_config.py +340 -0
- pymagnetos/core/_data.py +132 -0
- pymagnetos/core/_processor.py +905 -0
- pymagnetos/core/config_models.py +57 -0
- pymagnetos/core/gui/__init__.py +6 -0
- pymagnetos/core/gui/_base_mainwindow.py +819 -0
- pymagnetos/core/gui/widgets/__init__.py +19 -0
- pymagnetos/core/gui/widgets/_batch_processing.py +319 -0
- pymagnetos/core/gui/widgets/_configuration.py +167 -0
- pymagnetos/core/gui/widgets/_files.py +129 -0
- pymagnetos/core/gui/widgets/_graphs.py +93 -0
- pymagnetos/core/gui/widgets/_param_content.py +20 -0
- pymagnetos/core/gui/widgets/_popup_progressbar.py +29 -0
- pymagnetos/core/gui/widgets/_text_logger.py +32 -0
- pymagnetos/core/signal_processing.py +1004 -0
- pymagnetos/core/utils.py +85 -0
- pymagnetos/log.py +126 -0
- pymagnetos/py.typed +0 -0
- pymagnetos/pytdo/__init__.py +6 -0
- pymagnetos/pytdo/_config.py +24 -0
- pymagnetos/pytdo/_config_models.py +59 -0
- pymagnetos/pytdo/_tdoprocessor.py +1052 -0
- pymagnetos/pytdo/assets/config_default.toml +84 -0
- pymagnetos/pytdo/gui/__init__.py +26 -0
- pymagnetos/pytdo/gui/_worker.py +106 -0
- pymagnetos/pytdo/gui/main.py +617 -0
- pymagnetos/pytdo/gui/widgets/__init__.py +8 -0
- pymagnetos/pytdo/gui/widgets/_buttons.py +66 -0
- pymagnetos/pytdo/gui/widgets/_configuration.py +78 -0
- pymagnetos/pytdo/gui/widgets/_graphs.py +280 -0
- pymagnetos/pytdo/gui/widgets/_param_content.py +137 -0
- pymagnetos/pyuson/__init__.py +7 -0
- pymagnetos/pyuson/_config.py +26 -0
- pymagnetos/pyuson/_config_models.py +71 -0
- pymagnetos/pyuson/_echoprocessor.py +1901 -0
- pymagnetos/pyuson/assets/config_default.toml +92 -0
- pymagnetos/pyuson/gui/__init__.py +26 -0
- pymagnetos/pyuson/gui/_worker.py +135 -0
- pymagnetos/pyuson/gui/main.py +767 -0
- pymagnetos/pyuson/gui/widgets/__init__.py +7 -0
- pymagnetos/pyuson/gui/widgets/_buttons.py +95 -0
- pymagnetos/pyuson/gui/widgets/_configuration.py +85 -0
- pymagnetos/pyuson/gui/widgets/_graphs.py +248 -0
- pymagnetos/pyuson/gui/widgets/_param_content.py +193 -0
- pymagnetos-0.1.0.dist-info/METADATA +23 -0
- pymagnetos-0.1.0.dist-info/RECORD +51 -0
- pymagnetos-0.1.0.dist-info/WHEEL +4 -0
- pymagnetos-0.1.0.dist-info/entry_points.txt +7 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# This configuration file specifies the default values if they are not filled in the
|
|
2
|
+
# per-experiment config.toml file.
|
|
3
|
+
|
|
4
|
+
expid = ""
|
|
5
|
+
data_directory = "." # path or "."
|
|
6
|
+
|
|
7
|
+
[files]
|
|
8
|
+
[files.pickup]
|
|
9
|
+
# Pickup coil binary file
|
|
10
|
+
ext = ".pu"
|
|
11
|
+
header = 2
|
|
12
|
+
precision = 4 # number of bytes/element
|
|
13
|
+
endian = "<" # endian, ">" for big-endian, "<" for little-endian
|
|
14
|
+
order = "F" # order style in the binary file, "F" for Fortran, "C" for C
|
|
15
|
+
[files.oscillo]
|
|
16
|
+
# Oscilloscope binary file
|
|
17
|
+
ext = ".tdo"
|
|
18
|
+
header = 2
|
|
19
|
+
precision = 4 # number of bytes/element
|
|
20
|
+
endian = "<" # endian, ">" for big-endian, "<" for little-endian
|
|
21
|
+
order = "F" # order style in the binary file, "F" for Fortran, "C" for C
|
|
22
|
+
|
|
23
|
+
[measurements]
|
|
24
|
+
# Measurements settings
|
|
25
|
+
# Link a physical measurement to a channel of the oscilloscope
|
|
26
|
+
# For oscillo data saved with LabVIEW, they correspond to the columns in the file (0-based)
|
|
27
|
+
signal = 0
|
|
28
|
+
|
|
29
|
+
# Parameters are values that should be fixed once and for all for a given experiment
|
|
30
|
+
[parameters]
|
|
31
|
+
pickup_surface = 1 # surface of the pickup coil (m²)
|
|
32
|
+
|
|
33
|
+
pickup_number = 1 # number of pickup(s) used and save in the pickup bin file
|
|
34
|
+
pickup_index = 0 # index of the pickup to use for analysis, 0-based
|
|
35
|
+
|
|
36
|
+
# Settings are analysis-specific and can be changed afterwards
|
|
37
|
+
[settings]
|
|
38
|
+
# Settings for TDO signal extraction from raw data
|
|
39
|
+
max_time = 1 # crop signals until this time in seconds
|
|
40
|
+
|
|
41
|
+
spectro_nperseg = 1024 # spectrogram : number of points per segment
|
|
42
|
+
spectro_win_size = 4096 # spectrogram : fft window size
|
|
43
|
+
spectro_noverlap = -1 # size of windows overlap, set to -1 to be nperseg / 2
|
|
44
|
+
|
|
45
|
+
barycenters_fwindow = 732421.875 # half size of the window to use around frequency maxima in spectrogram
|
|
46
|
+
barycenters_fast = true # use fast algo to find barycenters or not
|
|
47
|
+
|
|
48
|
+
time_offset = 0
|
|
49
|
+
|
|
50
|
+
# Settings for TDO signal analysis
|
|
51
|
+
poly_window = [60, 84] # field-range in which to do the polynomial fit
|
|
52
|
+
poly_deg = 3 # polynomial degree
|
|
53
|
+
npoints_interp_inverse = 100000 # number of points for interpolation in 1/B
|
|
54
|
+
fft_window = [64, 80] # field-range in which to interpolate in 1/B
|
|
55
|
+
fft_pad_mult = 100 # multiplier of signal size to adjust 0-padding size for FFT
|
|
56
|
+
max_bfreq = 70000 # maximum B-frequency (in T) to plot and save
|
|
57
|
+
|
|
58
|
+
# Settings for display/plotting
|
|
59
|
+
offset = 1000 # offset B up/down curves to see them better
|
|
60
|
+
|
|
61
|
+
[metadata]
|
|
62
|
+
# Parameters on how to handle binary files headers
|
|
63
|
+
[metadata.index_map]
|
|
64
|
+
# map a metadata to its index in the header (0-based)
|
|
65
|
+
samplerate = 0
|
|
66
|
+
temperature = 1
|
|
67
|
+
[metadata.conversion_map]
|
|
68
|
+
# determine whether conversion to numeric is required
|
|
69
|
+
samplerate = true
|
|
70
|
+
temperature = true
|
|
71
|
+
|
|
72
|
+
[nx]
|
|
73
|
+
# NeXus file consolidation
|
|
74
|
+
|
|
75
|
+
[nexus]
|
|
76
|
+
[nexus.groups]
|
|
77
|
+
# NeXus groups attributes
|
|
78
|
+
root = {name = ""}
|
|
79
|
+
# processed/analysis
|
|
80
|
+
analysis = {}
|
|
81
|
+
# data
|
|
82
|
+
data = {}
|
|
83
|
+
[nexus.datasets]
|
|
84
|
+
# NeXus datasets attributes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Application for TDO experiments during high-magnetic field."""
|
|
2
|
+
|
|
3
|
+
from PyQt6 import QtWidgets
|
|
4
|
+
|
|
5
|
+
from .main import MainWindow
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def run(exec: bool = True) -> None | MainWindow:
|
|
9
|
+
"""
|
|
10
|
+
Build and run the app.
|
|
11
|
+
|
|
12
|
+
Set `exec=False` in an interactive prompt to interact with the GUI from the shell.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
exec : bool, optional
|
|
17
|
+
Execute the process thread. Set to False in an interactive prompt. Default is
|
|
18
|
+
True.
|
|
19
|
+
"""
|
|
20
|
+
app = QtWidgets.QApplication([])
|
|
21
|
+
win = MainWindow()
|
|
22
|
+
win.show()
|
|
23
|
+
if exec:
|
|
24
|
+
app.exec()
|
|
25
|
+
else:
|
|
26
|
+
return win
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Worker that connects to an TDOProcessor object."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot
|
|
6
|
+
|
|
7
|
+
from pymagnetos.pytdo import TDOProcessor
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DataWorker(QObject):
|
|
11
|
+
"""
|
|
12
|
+
Wrapper around the TDOProcessor class.
|
|
13
|
+
|
|
14
|
+
It exposes the EchoProcessor methods as slots and emits a signal when the task is
|
|
15
|
+
finished.
|
|
16
|
+
|
|
17
|
+
Signals
|
|
18
|
+
-------
|
|
19
|
+
sig_load_finished : emits when loading data is finished.
|
|
20
|
+
sig_extract_finished : emits when extracting the TDO signal is finished.
|
|
21
|
+
sig_offset_finished : emits when the adjusting the pickup/signal offset is finished.
|
|
22
|
+
sig_align_finished : emits when the magnetic field is aligned on the TDO signal.
|
|
23
|
+
sig_analyse_finished : emits when the TDO signal is analysed (detrended and FFT in
|
|
24
|
+
1/B).
|
|
25
|
+
sig_tdocsv_finished : emits when the TDO signal is saved as CSV.
|
|
26
|
+
sig_rescsv_finished : emits when the analysis is saved as CSV.
|
|
27
|
+
sig_save_nexus_finished : emits when saving the NeXus file is finished.
|
|
28
|
+
sig_load_csv_finished : emits when loading a CSV file is finished.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
sig_load_finished = pyqtSignal()
|
|
32
|
+
sig_extract_finished = pyqtSignal()
|
|
33
|
+
sig_offset_finished = pyqtSignal()
|
|
34
|
+
sig_align_finished = pyqtSignal()
|
|
35
|
+
sig_analyse_finished = pyqtSignal()
|
|
36
|
+
sig_batch_progress = pyqtSignal(int) # required by upstream core.gui lib
|
|
37
|
+
sig_batch_finished = pyqtSignal() # required by upstream core.gui lib
|
|
38
|
+
sig_tdocsv_finished = pyqtSignal()
|
|
39
|
+
sig_rescsv_finished = pyqtSignal()
|
|
40
|
+
sig_save_nexus_finished = pyqtSignal()
|
|
41
|
+
sig_load_csv_finished = pyqtSignal()
|
|
42
|
+
|
|
43
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
44
|
+
super().__init__()
|
|
45
|
+
|
|
46
|
+
self.proc = TDOProcessor(*args, **kwargs)
|
|
47
|
+
if self.proc.is_nexus_file:
|
|
48
|
+
self.is_dataloaded = True
|
|
49
|
+
else:
|
|
50
|
+
self.is_dataloaded = False
|
|
51
|
+
|
|
52
|
+
@pyqtSlot()
|
|
53
|
+
def load_data(self):
|
|
54
|
+
"""Load data."""
|
|
55
|
+
self.proc.load_oscillo()
|
|
56
|
+
self.is_dataloaded = True
|
|
57
|
+
self.sig_load_finished.emit()
|
|
58
|
+
|
|
59
|
+
@pyqtSlot()
|
|
60
|
+
def extract_tdo(self):
|
|
61
|
+
"""Extract TDO signal."""
|
|
62
|
+
self.proc.extract_tdo()
|
|
63
|
+
self.sig_extract_finished.emit()
|
|
64
|
+
|
|
65
|
+
@pyqtSlot()
|
|
66
|
+
def time_offset(self):
|
|
67
|
+
"""Apply time offset on experiment time vector."""
|
|
68
|
+
self.proc.apply_time_offset()
|
|
69
|
+
self.sig_offset_finished.emit()
|
|
70
|
+
|
|
71
|
+
def align_field(self):
|
|
72
|
+
self.proc.align_field()
|
|
73
|
+
self.sig_align_finished.emit()
|
|
74
|
+
|
|
75
|
+
@pyqtSlot()
|
|
76
|
+
def analyse(self):
|
|
77
|
+
"""Remove background and oversample in 1/B."""
|
|
78
|
+
self.proc.analyse()
|
|
79
|
+
self.sig_analyse_finished.emit()
|
|
80
|
+
|
|
81
|
+
@pyqtSlot()
|
|
82
|
+
def batch_process(self):
|
|
83
|
+
return
|
|
84
|
+
|
|
85
|
+
@pyqtSlot(str)
|
|
86
|
+
def save_tdo_csv(self, fname: str | Path):
|
|
87
|
+
"""Save TDO signal as CSV."""
|
|
88
|
+
self.proc.save_tdo_csv(filename=fname)
|
|
89
|
+
self.sig_tdocsv_finished.emit()
|
|
90
|
+
|
|
91
|
+
@pyqtSlot(str)
|
|
92
|
+
def save_results_csv(self, fname: str | Path):
|
|
93
|
+
"""Save results as CSV."""
|
|
94
|
+
self.proc.save_results_csv(filename_prefix=fname)
|
|
95
|
+
self.sig_rescsv_finished.emit()
|
|
96
|
+
|
|
97
|
+
@pyqtSlot(str)
|
|
98
|
+
def save_as_nexus(self, fname: str | Path):
|
|
99
|
+
"""Save data as NeXus."""
|
|
100
|
+
self.proc.save(filename=fname)
|
|
101
|
+
self.sig_save_nexus_finished.emit()
|
|
102
|
+
|
|
103
|
+
@pyqtSlot(str)
|
|
104
|
+
def load_csv_file(self, fname: str):
|
|
105
|
+
self.proc.load_csv(fname)
|
|
106
|
+
self.sig_load_csv_finished.emit()
|