pytdo 0.2.6__tar.gz → 0.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytdo
3
- Version: 0.2.6
3
+ Version: 0.2.7
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.4
13
+ Requires-Dist: pyuson>=0.7.5
14
14
  Requires-Python: >=3.12
15
15
  Description-Content-Type: text/markdown
16
16
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytdo"
3
- version = "0.2.6"
3
+ version = "0.2.7"
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.4",
17
+ "pyuson>=0.7.5",
18
18
  ]
19
19
 
20
20
  [project.gui-scripts]
@@ -1,5 +1,6 @@
1
1
  """Application for TDO analysis."""
2
2
 
3
+ import importlib.metadata
3
4
  from pathlib import Path
4
5
 
5
6
  from PyQt6 import QtWidgets
@@ -14,6 +15,7 @@ REGEXP_EXPID_SEPARATORS = r"[_-]"
14
15
  PROGRAM_NAME = "pytdo" # to get the relevant logger
15
16
  OUT_FORMAT = (".txt", ".csv", ".tsv", ".out")
16
17
  LOG_LEVEL = "INFO"
18
+ VERSION = importlib.metadata.version(PROGRAM_NAME)
17
19
 
18
20
 
19
21
  class MainWindow(gui.BaseMainWindow):
@@ -48,6 +50,8 @@ class MainWindow(gui.BaseMainWindow):
48
50
  self.setGeometry(300, 300, 900, 450)
49
51
  self.setWindowTitle("TDO Analyzer")
50
52
 
53
+ self.logger.info(f"Running pytdo v{VERSION}")
54
+
51
55
  def init_parameter_tree(self):
52
56
  super().init_parameter_tree()
53
57
 
@@ -57,8 +61,8 @@ class MainWindow(gui.BaseMainWindow):
57
61
  self.update_spectro_time_window
58
62
  )
59
63
  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)
64
+ self.wconfiguration.sig_fitdeg_changed.connect(self.fft)
65
+ self.wconfiguration.sig_npoints_interp_changed.connect(self.fft)
62
66
  self.wconfiguration.sig_curveoffset_changed.connect(self.plot_tdo_detrended)
63
67
 
64
68
  def init_buttons(self):
@@ -85,7 +89,7 @@ class MainWindow(gui.BaseMainWindow):
85
89
  ).sigValueChanged.connect(self.update_roi_from_fft)
86
90
 
87
91
  def init_log(self):
88
- super().init_log(PROGRAM_NAME, log_level=LOG_LEVEL)
92
+ super()._init_log(PROGRAM_NAME, log_level=LOG_LEVEL)
89
93
 
90
94
  def connect_worker(self):
91
95
  super().connect_worker()
@@ -1,7 +1,7 @@
1
1
  """The graphs area that holds all the plots."""
2
2
 
3
3
  import pyqtgraph as pg
4
- from PyQt6 import QtWidgets
4
+ from PyQt6 import QtCore, QtWidgets
5
5
  from PyQt6.QtCore import pyqtSignal, pyqtSlot
6
6
  from pyuson import gui
7
7
 
@@ -25,33 +25,46 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
25
25
  # Flags
26
26
  self._sync_roi = False
27
27
 
28
- # Create grid
29
- grid = QtWidgets.QGridLayout()
30
-
31
28
  # Create empty canvases in tabs
32
29
  field_tab = self.create_field_plot()
33
30
  signal_tab = self.create_signal_plot()
34
31
  tdo_tab = self.create_tdo_plot()
35
32
  fft_tab = self.create_fft_plot()
36
33
 
37
- self.init_coordinates_on_hover()
38
-
39
- # Add Tabs to the grid
40
- grid.addWidget(field_tab, 0, 0, 1, 1)
41
- grid.addWidget(signal_tab, 0, 1, 1, 3)
42
- grid.addWidget(tdo_tab, 1, 0, 1, 2)
43
- grid.addWidget(fft_tab, 1, 2, 1, 2)
34
+ self.customize_axis()
44
35
 
45
- # Force stretch factors
46
- grid.setColumnStretch(0, 1)
47
- grid.setColumnStretch(1, 1)
48
- grid.setColumnStretch(2, 1)
49
- grid.setColumnStretch(3, 1)
50
- grid.setRowStretch(0, 1)
51
- grid.setRowStretch(1, 1)
36
+ self.init_coordinates_on_hover()
52
37
 
53
- # Create widget
54
- self.setLayout(grid)
38
+ # Create a main splitter for rows (vertical)
39
+ main_splitter = QtWidgets.QSplitter(QtCore.Qt.Orientation.Vertical)
40
+
41
+ # Create a top splitter for the first row (horizontal)
42
+ top_splitter = QtWidgets.QSplitter(QtCore.Qt.Orientation.Horizontal)
43
+ top_splitter.addWidget(field_tab)
44
+ top_splitter.addWidget(signal_tab)
45
+ top_splitter.setStretchFactor(0, 1) # field_tab stretch factor
46
+ # signal_tab spans 3 columns
47
+ top_splitter.setStretchFactor(1, 3)
48
+
49
+ # Create a bottom splitter for the second row (horizontal)
50
+ bottom_splitter = QtWidgets.QSplitter(QtCore.Qt.Orientation.Horizontal)
51
+ bottom_splitter.addWidget(tdo_tab)
52
+ bottom_splitter.addWidget(fft_tab)
53
+ # tdo_tab spans 2 columns
54
+ bottom_splitter.setStretchFactor(0, 2)
55
+ # fft_tab spans 2 columns
56
+ bottom_splitter.setStretchFactor(1, 2)
57
+
58
+ # Add the top and bottom splitters to the main splitter
59
+ main_splitter.addWidget(top_splitter)
60
+ main_splitter.addWidget(bottom_splitter)
61
+ main_splitter.setStretchFactor(0, 1) # top row stretch factor
62
+ main_splitter.setStretchFactor(1, 1) # bottom row stretch factor
63
+
64
+ # Set the main splitter as the central widget
65
+ layout = QtWidgets.QVBoxLayout()
66
+ layout.addWidget(main_splitter)
67
+ self.setLayout(layout)
55
68
 
56
69
  def create_field_plot(self) -> QtWidgets.QTabWidget:
57
70
  tab = QtWidgets.QTabWidget(self)
@@ -60,14 +73,12 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
60
73
  self.field = pg.PlotWidget(title="Magnetic field")
61
74
  self.field.setLabel("bottom", "time (s)")
62
75
  self.field.setLabel("left", "field (T)")
63
- self.field.showGrid(y=True)
64
76
  self._plots_list.add(self.field)
65
77
 
66
78
  # pickup coil voltage (measured)
67
79
  self.dfield = pg.PlotWidget(title="Pickup")
68
80
  self.dfield.setLabel("bottom", "time (s)")
69
81
  self.dfield.setLabel("left", "pickup (V)")
70
- self.dfield.showGrid(y=True)
71
82
  self._plots_list.add(self.dfield)
72
83
 
73
84
  tab.addTab(self.field, "B(t)")
@@ -82,9 +93,8 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
82
93
  self.sig_field = pg.PlotWidget(title="Signal versus field")
83
94
  self.sig_field.setLabel("bottom", "field (T)")
84
95
  self.sig_field.setLabel("left", "TDO frequency (Hz)")
85
- self.sig_field.showGrid(y=True)
86
96
  # Field-window selector
87
- self.roi = pg.LinearRegionItem(brush=pg.mkBrush("#0000ff1a"))
97
+ self.roi = pg.LinearRegionItem(brush=pg.mkBrush("#0000ff1a"), pen=self.pen_fitbounds)
88
98
  self.roi.hoverEvent = lambda *args, **kwargs: None # disable mouse drag
89
99
  self.roi.mouseDragEvent = lambda *args, **kwargs: None # disable mouse drag
90
100
  self.sig_field.addItem(self.roi, ignoreBounds=True)
@@ -96,7 +106,6 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
96
106
  self.sig_time = pg.PlotWidget(title="Signal versus time")
97
107
  self.sig_time.setLabel("bottom", "time (s)")
98
108
  self.sig_time.setLabel("left", "TDO frequency (Hz)")
99
- self.sig_time.showGrid(y=True)
100
109
  self._plots_list.add(self.sig_time)
101
110
 
102
111
  tab.addTab(self.sig_field, "TDO(B)")
@@ -111,7 +120,6 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
111
120
  self.tdo_field = pg.PlotWidget(title="Oscillatory part versus field")
112
121
  self.tdo_field.setLabel("bottom", "field (T)")
113
122
  self.tdo_field.setLabel("left", "TDO detrended")
114
- self.tdo_field.showGrid(y=True)
115
123
  self.tdo_field.getPlotItem().addLegend()
116
124
  # Field-window selector for FFT range
117
125
  self.roi2 = pg.LinearRegionItem(brush=pg.mkBrush("#0000ff1a"))
@@ -130,7 +138,6 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
130
138
  self.tdo_inverse_field = pg.PlotWidget(title="Oscillatory part versus 1/B")
131
139
  self.tdo_inverse_field.setLabel("bottom", "1/B (T^-1)")
132
140
  self.tdo_inverse_field.setLabel("left", "TDO detrended")
133
- self.tdo_inverse_field.showGrid(y=True)
134
141
  self._plots_list.add(self.tdo_inverse_field)
135
142
 
136
143
  tab.addTab(self.tdo_field, "TDO detrended(B)")
@@ -145,7 +152,6 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
145
152
  self.fft = pg.PlotWidget(title="Fourier transform")
146
153
  self.fft.setLabel("bottom", "B-frequency (T)")
147
154
  self.fft.setLabel("left", "magnitude")
148
- self.fft.showGrid(y=True)
149
155
  self.fft.getPlotItem().addLegend()
150
156
  self._plots_list.add(self.fft)
151
157
 
@@ -153,6 +159,14 @@ class GraphsWidget(gui.widgets.BaseGraphsWidget):
153
159
 
154
160
  return tab
155
161
 
162
+ def customize_axis(self):
163
+ """Set a right axis and show the grid, for all the plots."""
164
+ for plot in self._plots_list:
165
+ plot.showAxis("right")
166
+ plot.getAxis("right").setTicks([])
167
+ plot.showGrid(y=True)
168
+
169
+
156
170
  def init_plot_style(self):
157
171
  """Set up PyQtGraph line styles."""
158
172
  w0 = 1
@@ -574,8 +574,8 @@ class TDOProcessor(tTDOProcessor, BaseProcessor):
574
574
 
575
575
  The resulting "frequencies" are therefore in units of B (teslas).
576
576
  """
577
- # Force oversample inverese field to update parameters
578
- self.oversample_inverse_field()
577
+ # Force detrend + oversample to make sure to use up-to-date data and parameters
578
+ self.remove_background()
579
579
 
580
580
  if not self._check_tdo_inverse():
581
581
  logger.error("Could not compute FFT because there is no signal in 1/B")
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