xarray-graph 0.2.0__py3-none-any.whl → 0.2.1__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.
@@ -1034,6 +1034,17 @@ class XarrayGraph(QMainWindow):
1034
1034
  if i != index:
1035
1035
  button.setChecked(False)
1036
1036
 
1037
+ def _show_control_panel_at(self, index: int) -> None:
1038
+ actions = self._control_panel_toolbar.actions()
1039
+ widgets = [self._control_panel_toolbar.widgetForAction(action) for action in actions]
1040
+ buttons = [widget for widget in widgets if isinstance(widget, QToolButton)]
1041
+ buttons[index].setChecked(True)
1042
+ self._control_panel.setCurrentIndex(index)
1043
+ self._control_panel.setVisible(True)
1044
+ for i, button in enumerate(buttons):
1045
+ if i != index:
1046
+ button.setChecked(False)
1047
+
1037
1048
  def _setup_data_control_panel(self) -> None:
1038
1049
  button = QToolButton()
1039
1050
  button.setIcon(qta.icon('ph.eye', options=[{'opacity': 0.5}]))
xarray_graph/__main__.py CHANGED
@@ -1,14 +1,76 @@
1
1
  from xarray_graph.XarrayGraph import XarrayGraph
2
+ from qtpy.QtCore import QTimer
2
3
  from qtpy.QtWidgets import QApplication
3
4
 
4
5
 
5
6
  def main():
6
7
  app = QApplication()
7
8
  ui = XarrayGraph()
8
- ui.setWindowTitle(ui.__class__.__name__)
9
+ # ui.setWindowTitle(ui.__class__.__name__)
10
+ ui.setWindowTitle('xarray-graph')
9
11
  ui.show()
12
+ QTimer.singleShot(100, lambda: ask_for_example(ui))
10
13
  app.exec()
11
14
 
12
15
 
16
+ def ask_for_example(ui: XarrayGraph):
17
+ from qtpy.QtWidgets import QMessageBox
18
+
19
+ example = QMessageBox.question(ui, 'Example?', 'Load example data?')
20
+ if example == QMessageBox.StandardButton.Yes:
21
+ load_example(ui)
22
+
23
+
24
+ def load_example(ui: XarrayGraph):
25
+ import numpy as np
26
+ import xarray as xr
27
+ from datatree import DataTree
28
+
29
+ n = 100
30
+ raw_ds = xr.Dataset(
31
+ data_vars={
32
+ 'current': (['series', 'sweep', 'time'], np.random.rand(3, 10, n) * 1e-9, {'units': 'A'}),
33
+ 'voltage': (['series', 'sweep', 'time'], np.random.rand(3, 10, n) * 10000, {'units': 'V'}),
34
+ },
35
+ coords={
36
+ 'series': ('series', np.arange(3)),
37
+ 'sweep': ('sweep', np.arange(10)),
38
+ 'time': ('time', np.arange(n) * 0.01, {'units': 's'}),
39
+ },
40
+ )
41
+
42
+ baselined_ds = xr.Dataset(
43
+ data_vars={
44
+ 'current': (['series', 'sweep', 'time'], np.random.rand(3, 10, n) * 1e-9, {'units': 'A'}),
45
+ },
46
+ coords={
47
+ 'series': ('series', np.arange(3)),
48
+ 'sweep': ('sweep', np.arange(10)),
49
+ 'time': ('time', np.arange(n) * 0.01, {'units': 's'}),
50
+ },
51
+ )
52
+
53
+ scaled_ds = xr.Dataset(
54
+ data_vars={
55
+ 'current': (['series', 'sweep', 'time'], np.random.rand(1, 2, n) * 1e-9, {'units': 'A'}),
56
+ },
57
+ coords={
58
+ 'series': ('series', [1]),
59
+ 'sweep': ('sweep', [5,8]),
60
+ 'time': ('time', np.arange(n) * 0.01, {'units': 's'}),
61
+ },
62
+ )
63
+
64
+ root_node = DataTree()
65
+ raw_node = DataTree(name='raw', data=raw_ds, parent=root_node)
66
+ baselined_node = DataTree(name='baselined', data=baselined_ds, parent=raw_node)
67
+ scaled_node = DataTree(name='scaled', data=scaled_ds, parent=baselined_node)
68
+
69
+ ui.data = root_node
70
+
71
+ ui._show_control_panel_at(0)
72
+ ui._data_treeview.expandAll()
73
+
74
+
13
75
  if __name__ == '__main__':
14
76
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xarray-graph
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: PyQt/PySide UI for graphing (x,y) slices of Xarray datasets.
5
5
  Keywords: PyQt,PySide,xarray,graph
6
6
  Home-page: https://github.com/marcel-goldschen-ohm/xarray-graph
@@ -20,11 +20,11 @@ Project-URL: Repository, https://github.com/marcel-goldschen-ohm/xarray-graph
20
20
  Requires-Python: >=3.9
21
21
  Requires-Dist: numpy>=1.26.2
22
22
  Requires-Dist: xarray>=2023.12.0
23
- Requires-Dist: xarray-tree>=0.1.0
24
23
  Requires-Dist: qtpy>=2.4.1
25
24
  Requires-Dist: qtawesome>=1.3.0
26
- Requires-Dist: pyqt-ext>=1.1.0
27
- Requires-Dist: pyqtgraph-ext>=1.0.0
25
+ Requires-Dist: pyqt-ext>=1.2.0
26
+ Requires-Dist: pyqtgraph-ext>=1.2.0
27
+ Requires-Dist: xarray-treeview>=1.2.0
28
28
  Requires-Dist: scipy>=1.11.4
29
29
  Requires-Dist: lmfit>=1.2.2
30
30
  Description-Content-Type: text/markdown
@@ -38,6 +38,11 @@ Should work with PySide6, PyQt6, or PyQt5.
38
38
  pip install PySide6 xarray-graph
39
39
  ```
40
40
 
41
+ # Run
42
+ ```shell
43
+ xarray-graph
44
+ ```
45
+
41
46
  # TODO
42
47
  - i/o
43
48
  - tests
@@ -0,0 +1,9 @@
1
+ xarray_graph-0.2.1.dist-info/METADATA,sha256=C5TY1bM_h-A7wYuh3bC-vjrL2XZSW1jeyZCIGqn6PTw,1488
2
+ xarray_graph-0.2.1.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
3
+ xarray_graph-0.2.1.dist-info/entry_points.txt,sha256=aW9CKuCZREtN_3Mtg4dKrysPMmHc-tQdUCNmzQYE_vA,61
4
+ xarray_graph-0.2.1.dist-info/licenses/LICENSE,sha256=OE7VkhwkLeFeY8LXi86O-nMXC9B3WsBSILLfPmYGd-8,1077
5
+ xarray_graph/XarrayGraph.py,sha256=KyiQ2oOgvffe1DpQw5fIUVhAtLP0gj2s99eVGVBg6FU,101127
6
+ xarray_graph/__init__.py,sha256=1aAM-Fcno60-ou3AnSqt5HKm6UmZrtULGzg2LF34IJE,48
7
+ xarray_graph/__main__.py,sha256=8c74k8lpaqOuMeKlcBahOKfgo08O7xmJs_htvKKKpck,2274
8
+ xarray_graph/tmp/RegionsManager.py,sha256=0nnrO1e1mqvrs88doO51SJ3JvMNW5wXBKOp2nLQcUFs,1841
9
+ xarray_graph-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ xarray-graph = xarray_graph.__main__:main
3
+
@@ -1,9 +0,0 @@
1
- xarray_graph-0.2.0.dist-info/METADATA,sha256=PlV0f9GGnKYWLqFqs13wQBL1mZsBHs93TztzG4tRhPo,1451
2
- xarray_graph-0.2.0.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
3
- xarray_graph-0.2.0.dist-info/entry_points.txt,sha256=8qLdEjfVtm86FytoAItpsjvgDEUDj2e7Z2ekiTkUsQs,52
4
- xarray_graph-0.2.0.dist-info/licenses/LICENSE,sha256=OE7VkhwkLeFeY8LXi86O-nMXC9B3WsBSILLfPmYGd-8,1077
5
- xarray_graph/RegionsManager.py,sha256=0nnrO1e1mqvrs88doO51SJ3JvMNW5wXBKOp2nLQcUFs,1841
6
- xarray_graph/XarrayGraph.py,sha256=7hAiKNx0UcLT9rQfGX-vvfeVz0FcjCMVw5o7PL2fRvU,100581
7
- xarray_graph/__init__.py,sha256=1aAM-Fcno60-ou3AnSqt5HKm6UmZrtULGzg2LF34IJE,48
8
- xarray_graph/__main__.py,sha256=TMeudufLyynSMYS3WuLpHxUjr0ijfb_-a3vnZgEomgQ,265
9
- xarray_graph-0.2.0.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- xrg = xarray_graph.__main__:main
3
-