xarray-graph 0.2.2__tar.gz → 0.2.4__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.
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/PKG-INFO +1 -1
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/pyproject.toml +1 -1
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/src/xarray_graph/XarrayGraph.py +63 -57
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/LICENSE +0 -0
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/README.md +0 -0
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/src/xarray_graph/__init__.py +0 -0
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/src/xarray_graph/__main__.py +0 -0
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/src/xarray_graph/tmp/RegionsManager.py +0 -0
- {xarray_graph-0.2.2 → xarray_graph-0.2.4}/tests/__init__.py +0 -0
|
@@ -153,7 +153,7 @@ class XarrayGraph(QMainWindow):
|
|
|
153
153
|
self._notes_edit.setPlainText(self.attrs.get('notes', ''))
|
|
154
154
|
|
|
155
155
|
# populate array math selections
|
|
156
|
-
|
|
156
|
+
self._update_array_math_comboboxes()
|
|
157
157
|
|
|
158
158
|
@property
|
|
159
159
|
def dims(self) -> list[str]:
|
|
@@ -905,8 +905,9 @@ class XarrayGraph(QMainWindow):
|
|
|
905
905
|
item.deleteLater()
|
|
906
906
|
self.add_region(region)
|
|
907
907
|
|
|
908
|
-
# stop drawing regions (draw one at a time)
|
|
909
|
-
self.
|
|
908
|
+
# stop drawing regions (draw one at a time)?
|
|
909
|
+
if self._draw_single_region_action.isChecked():
|
|
910
|
+
self._set_region_drawing_mode(False)
|
|
910
911
|
|
|
911
912
|
def _setup_ui(self) -> None:
|
|
912
913
|
self._setup_menubar()
|
|
@@ -916,11 +917,13 @@ class XarrayGraph(QMainWindow):
|
|
|
916
917
|
self._control_panel_toolbar.setStyleSheet("QToolBar{spacing:2px;}")
|
|
917
918
|
self._control_panel_toolbar.setIconSize(QSize(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE))
|
|
918
919
|
self._control_panel_toolbar.setMovable(False)
|
|
920
|
+
self._control_panel_toolbar.setContextMenuPolicy(Qt.ContextMenuPolicy.PreventContextMenu)
|
|
919
921
|
|
|
920
922
|
self._plot_grid_toolbar = QToolBar()
|
|
921
923
|
self._plot_grid_toolbar.setStyleSheet("QToolBar{spacing:2px;}")
|
|
922
924
|
self._plot_grid_toolbar.setIconSize(QSize(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE))
|
|
923
925
|
self._plot_grid_toolbar.setMovable(False)
|
|
926
|
+
self._plot_grid_toolbar.setContextMenuPolicy(Qt.ContextMenuPolicy.PreventContextMenu)
|
|
924
927
|
icon_button = QToolButton()
|
|
925
928
|
icon_button.setIcon(qta.icon('fa5s.cubes', options=[{'opacity': 0.5}]))
|
|
926
929
|
icon_button.pressed.connect(self.refresh)
|
|
@@ -991,6 +994,18 @@ class XarrayGraph(QMainWindow):
|
|
|
991
994
|
self._region_button.clicked.connect(self._set_region_drawing_mode)
|
|
992
995
|
self._action_after_dim_iter_things = self._plot_grid_toolbar.addWidget(self._region_button)
|
|
993
996
|
|
|
997
|
+
self._region_button_menu = QMenu()
|
|
998
|
+
self._draw_single_region_action = QAction('Draw single region', self._region_button_menu, checkable=True, checked=True)
|
|
999
|
+
self._draw_multiple_regions_action = QAction('Draw multiple regions', self._region_button_menu, checkable=True, checked=False)
|
|
1000
|
+
self._region_button_menu.addAction(self._draw_single_region_action)
|
|
1001
|
+
self._region_button_menu.addAction(self._draw_multiple_regions_action)
|
|
1002
|
+
group = QActionGroup(self._region_button_menu)
|
|
1003
|
+
group.addAction(self._draw_single_region_action)
|
|
1004
|
+
group.addAction(self._draw_multiple_regions_action)
|
|
1005
|
+
group.setExclusive(True)
|
|
1006
|
+
self._region_button.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
|
1007
|
+
self._region_button.customContextMenuRequested.connect(lambda pos: self._region_button_menu.exec_(self._region_button.mapToGlobal(pos)))
|
|
1008
|
+
|
|
994
1009
|
self._home_button = QToolButton()
|
|
995
1010
|
self._home_button.setIcon(qta.icon('mdi.home-outline', options=[{'opacity': 0.5}]))
|
|
996
1011
|
self._home_button.setToolTip('Autoscale all plots')
|
|
@@ -1176,7 +1191,7 @@ class XarrayGraph(QMainWindow):
|
|
|
1176
1191
|
self._math_operator_combobox.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
|
|
1177
1192
|
|
|
1178
1193
|
self._math_eval_button = QPushButton('Evaluate')
|
|
1179
|
-
|
|
1194
|
+
self._math_eval_button.pressed.connect(self.eval_array_math)
|
|
1180
1195
|
|
|
1181
1196
|
math_group = QGroupBox('Array math')
|
|
1182
1197
|
grid = QGridLayout(math_group)
|
|
@@ -1645,57 +1660,48 @@ class XarrayGraph(QMainWindow):
|
|
|
1645
1660
|
if isinstance(item, XAxisRegion):
|
|
1646
1661
|
item.setFontSize(self._textitem_fontsize_spinbox.value())
|
|
1647
1662
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
# self._math_lhs_combobox.addItems(var_items)
|
|
1658
|
-
# self._math_rhs_combobox.addItems(var_items)
|
|
1663
|
+
def _update_array_math_comboboxes(self) -> None:
|
|
1664
|
+
var_paths = [item.path for item in self._data_treeview.model().root().depth_first() if item.is_var()]
|
|
1665
|
+
for i in range(len(var_paths)):
|
|
1666
|
+
if len(var_paths[i]) > 100:
|
|
1667
|
+
var_paths[i] = '...' + var_paths[i][-97:]
|
|
1668
|
+
self._math_lhs_combobox.clear()
|
|
1669
|
+
self._math_rhs_combobox.clear()
|
|
1670
|
+
self._math_lhs_combobox.addItems(var_paths)
|
|
1671
|
+
self._math_rhs_combobox.addItems(var_paths)
|
|
1659
1672
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
# # append result as child of lhs_item
|
|
1682
|
-
# # TODO: handle result name collisions
|
|
1683
|
-
# result_name = self._math_result_name_edit.text().strip()
|
|
1684
|
-
# ds = xr.Dataset(data_vars={result.name: result})
|
|
1685
|
-
# result_node = XarrayTreeNode(name=result_name, dataset=ds, parent=lhs_item.node)
|
|
1673
|
+
def eval_array_math(self) -> None:
|
|
1674
|
+
var_items = [item for item in self._data_treeview.model().root().depth_first() if item.is_var()]
|
|
1675
|
+
lhs_item = var_items[self._math_lhs_combobox.currentIndex()]
|
|
1676
|
+
rhs_item = var_items[self._math_rhs_combobox.currentIndex()]
|
|
1677
|
+
lhs: xr.DataArray = lhs_item.node[lhs_item.key]
|
|
1678
|
+
rhs: xr.DataArray = rhs_item.node[rhs_item.key]
|
|
1679
|
+
op = self._math_operator_combobox.currentText()
|
|
1680
|
+
if op == '+':
|
|
1681
|
+
result = lhs + rhs
|
|
1682
|
+
elif op == '-':
|
|
1683
|
+
result = lhs - rhs
|
|
1684
|
+
elif op == '*':
|
|
1685
|
+
result = lhs * rhs
|
|
1686
|
+
elif op == '/':
|
|
1687
|
+
result = lhs / rhs
|
|
1688
|
+
# append result as child of lhs_item
|
|
1689
|
+
result_name = self._math_result_name_edit.text().strip()
|
|
1690
|
+
if result_name == '':
|
|
1691
|
+
result_name = self._math_result_name_edit.placeholderText()
|
|
1692
|
+
result_ds = xr.Dataset(data_vars={result.name: result})
|
|
1693
|
+
result_node = DataTree(name=result_name, data=result_ds, parent=lhs_item.node)
|
|
1686
1694
|
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
# self._data_treeview.setExpanded(model.parent(index), True)
|
|
1698
|
-
# item = item.next_depth_first()
|
|
1695
|
+
# update data tree
|
|
1696
|
+
self.data = self.data
|
|
1697
|
+
|
|
1698
|
+
# make sure newly added fit nodes are selected and expanded
|
|
1699
|
+
model: XarrayTreeModel = self._data_treeview.model()
|
|
1700
|
+
for item in model.root().depth_first():
|
|
1701
|
+
if item.node is result_node and item.is_var():
|
|
1702
|
+
index: QModelIndex = model.createIndex(item.sibling_index, 0, item)
|
|
1703
|
+
self._data_treeview.selectionModel().select(index, QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows)
|
|
1704
|
+
self._data_treeview.setExpanded(model.parent(index), True)
|
|
1699
1705
|
|
|
1700
1706
|
# # @Slot()
|
|
1701
1707
|
# # def on_axes_item_changed(self):
|
|
@@ -1725,7 +1731,7 @@ class XarrayGraph(QMainWindow):
|
|
|
1725
1731
|
i = np.argpartition(x, len(x) // 2)[len(x) // 2]
|
|
1726
1732
|
return x[i]
|
|
1727
1733
|
if measure_type in ['Min', 'Max', 'AbsMax', 'Peaks']:
|
|
1728
|
-
peak_width = self.
|
|
1734
|
+
peak_width = self._peak_half_width_spinbox.value()
|
|
1729
1735
|
if peak_width > 0:
|
|
1730
1736
|
def get_peak_index_range(mask, center_index):
|
|
1731
1737
|
start, stop = center_index, center_index + 1
|
|
@@ -2010,21 +2016,21 @@ class XarrayGraph(QMainWindow):
|
|
|
2010
2016
|
dims = yarr.dims
|
|
2011
2017
|
|
|
2012
2018
|
# region mask for fit optimization and/or evaluation
|
|
2013
|
-
if regions and (self.
|
|
2019
|
+
if regions and (self._curve_fit_optimize_in_regions_checkbox.isChecked() or self._curve_fit_evaluate_in_regions_checkbox.isChecked()):
|
|
2014
2020
|
# mask for combined regions
|
|
2015
2021
|
regions_mask = np.full(xdata.shape, False)
|
|
2016
2022
|
for region in regions:
|
|
2017
2023
|
xmin, xmax = region
|
|
2018
2024
|
regions_mask[(xdata >= xmin) & (xdata <= xmax)] = True
|
|
2019
2025
|
|
|
2020
|
-
if regions and self.
|
|
2026
|
+
if regions and self._curve_fit_optimize_in_regions_checkbox.isChecked():
|
|
2021
2027
|
xinput = xdata[regions_mask]
|
|
2022
2028
|
yinput = ydata[regions_mask]
|
|
2023
2029
|
else:
|
|
2024
2030
|
xinput = xdata
|
|
2025
2031
|
yinput = ydata
|
|
2026
2032
|
|
|
2027
|
-
if regions and self.
|
|
2033
|
+
if regions and self._curve_fit_evaluate_in_regions_checkbox.isChecked():
|
|
2028
2034
|
xoutput = xdata[regions_mask]
|
|
2029
2035
|
else:
|
|
2030
2036
|
xoutput = xdata
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|