NeXpy 2.0.0b6__tar.gz → 2.0.0b8__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.
Files changed (112) hide show
  1. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/PKG-INFO +2 -2
  2. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/pyproject.toml +1 -1
  3. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/PKG-INFO +2 -2
  4. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/requires.txt +1 -1
  5. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/_version.py +2 -2
  6. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/dialogs.py +278 -27
  7. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/fitdialogs.py +14 -4
  8. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/mainwindow.py +47 -11
  9. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/treeview.py +21 -1
  10. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/utils.py +4 -10
  11. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/.gitattributes +0 -0
  12. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/.github/dependabot.yaml +0 -0
  13. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/.github/workflows/ci.yml +0 -0
  14. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/.gitignore +0 -0
  15. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/COPYING +0 -0
  16. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/README.md +0 -0
  17. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/README.rst +0 -0
  18. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/conda-recipe/bld.bat +0 -0
  19. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/conda-recipe/build.sh +0 -0
  20. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/conda-recipe/meta.yaml +0 -0
  21. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/Makefile +0 -0
  22. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/make.bat +0 -0
  23. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/_static/__ignore__.txt +0 -0
  24. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/conf.py +0 -0
  25. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/examples.rst +0 -0
  26. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/favicon.ico +0 -0
  27. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/axis-limits-bar.png +0 -0
  28. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/customize-panel.png +0 -0
  29. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/limits-panel.png +0 -0
  30. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/nexpy-fits.png +0 -0
  31. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/nexpy-gui.png +0 -0
  32. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/nexpy-logo.png +0 -0
  33. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/options-tab.png +0 -0
  34. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/projection-panel.png +0 -0
  35. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/projection-tab.png +0 -0
  36. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/scan-panel.png +0 -0
  37. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/signal-tab.png +0 -0
  38. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/simple-plot.png +0 -0
  39. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/skewed-axis.png +0 -0
  40. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/x-tab.png +0 -0
  41. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/y-tab.png +0 -0
  42. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/z-tab.png +0 -0
  43. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/images/z-toolbar.png +0 -0
  44. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/includeme.rst +0 -0
  45. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/index.rst +0 -0
  46. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/pythongui.rst +0 -0
  47. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/pythonshell.rst +0 -0
  48. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/readers.rst +0 -0
  49. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/doc/source/treeapi.rst +0 -0
  50. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/setup.cfg +0 -0
  51. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/SOURCES.txt +0 -0
  52. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/dependency_links.txt +0 -0
  53. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/entry_points.txt +0 -0
  54. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/pbr.json +0 -0
  55. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/NeXpy.egg-info/top_level.txt +0 -0
  56. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/__init__.py +0 -0
  57. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/README.rst +0 -0
  58. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/chopper.nxs +0 -0
  59. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/example.nxs +0 -0
  60. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/README.rst +0 -0
  61. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.py +0 -0
  62. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.pyc +0 -0
  63. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.py +0 -0
  64. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.pyc +0 -0
  65. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.py +0 -0
  66. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.pyc +0 -0
  67. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/plugins/chopper_plugin/pyproject.toml +0 -0
  68. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/scripts/README.rst +0 -0
  69. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/scripts/chopper_plot.py +0 -0
  70. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/examples/scripts/example.py +0 -0
  71. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/__init__.py +0 -0
  72. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/consoleapp.py +0 -0
  73. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/datadialogs.py +0 -0
  74. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/importdialog.py +0 -0
  75. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/plotview.py +0 -0
  76. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/pyqt.py +0 -0
  77. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/NeXpy.png +0 -0
  78. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/NeXpy.svg +0 -0
  79. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/back.png +0 -0
  80. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/backward-icon.png +0 -0
  81. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/customize.png +0 -0
  82. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/equal.png +0 -0
  83. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/export-data.png +0 -0
  84. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/export-figure.png +0 -0
  85. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/filesave.png +0 -0
  86. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/forward-icon.png +0 -0
  87. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/forward.png +0 -0
  88. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/hand.png +0 -0
  89. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/home.png +0 -0
  90. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/link-icon.png +0 -0
  91. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/lock-icon.png +0 -0
  92. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/lock-red-icon.png +0 -0
  93. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/modify-style.png +0 -0
  94. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/move.png +0 -0
  95. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/pause-icon.png +0 -0
  96. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/refresh-icon.png +0 -0
  97. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/unlock-icon.png +0 -0
  98. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/unlock-red-icon.png +0 -0
  99. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/resources/zoom_to_rect.png +0 -0
  100. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/scripteditor.py +0 -0
  101. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/gui/widgets.py +0 -0
  102. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/models/bose.py +0 -0
  103. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/models/critexp.py +0 -0
  104. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/models/op.py +0 -0
  105. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/models/pdfdecay.py +0 -0
  106. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/nexpygui.py +0 -0
  107. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/readers/readnpy.py +0 -0
  108. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/readers/readspec.py +0 -0
  109. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/readers/readstack.py +0 -0
  110. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/readers/readtiff.py +0 -0
  111. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/src/nexpy/readers/readtxt.py +0 -0
  112. {nexpy-2.0.0b6 → nexpy-2.0.0b8}/tests/test_imports.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeXpy
3
- Version: 2.0.0b6
3
+ Version: 2.0.0b8
4
4
  Summary: Python GUI to analyze NeXus data
5
5
  Author-email: Raymond Osborn <rayosborn@mac.com>
6
6
  License: Licensing Terms for NeXpy
@@ -88,7 +88,7 @@ Requires-Dist: ipython
88
88
  Requires-Dist: lmfit
89
89
  Requires-Dist: matplotlib
90
90
  Requires-Dist: mplcursors
91
- Requires-Dist: nexusformat>=2.0.0b4
91
+ Requires-Dist: nexusformat>=2.0.0b6
92
92
  Requires-Dist: numpy
93
93
  Requires-Dist: packaging
94
94
  Requires-Dist: pillow
@@ -40,7 +40,7 @@ dependencies = [
40
40
  "lmfit",
41
41
  "matplotlib",
42
42
  "mplcursors",
43
- "nexusformat >= 2.0.0b4",
43
+ "nexusformat >= 2.0.0b6",
44
44
  "numpy",
45
45
  "packaging",
46
46
  "pillow",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeXpy
3
- Version: 2.0.0b6
3
+ Version: 2.0.0b8
4
4
  Summary: Python GUI to analyze NeXus data
5
5
  Author-email: Raymond Osborn <rayosborn@mac.com>
6
6
  License: Licensing Terms for NeXpy
@@ -88,7 +88,7 @@ Requires-Dist: ipython
88
88
  Requires-Dist: lmfit
89
89
  Requires-Dist: matplotlib
90
90
  Requires-Dist: mplcursors
91
- Requires-Dist: nexusformat>=2.0.0b4
91
+ Requires-Dist: nexusformat>=2.0.0b6
92
92
  Requires-Dist: numpy
93
93
  Requires-Dist: packaging
94
94
  Requires-Dist: pillow
@@ -5,7 +5,7 @@ ipython
5
5
  lmfit
6
6
  matplotlib
7
7
  mplcursors
8
- nexusformat>=2.0.0b4
8
+ nexusformat>=2.0.0b6
9
9
  numpy
10
10
  packaging
11
11
  pillow
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.0.0b6'
21
- __version_tuple__ = version_tuple = (2, 0, 0, 'b6')
20
+ __version__ = version = '2.0.0b8'
21
+ __version_tuple__ = version_tuple = (2, 0, 0, 'b8')
@@ -2614,12 +2614,12 @@ class ProjectionTab(NXTab):
2614
2614
 
2615
2615
  def get_rectangle(self):
2616
2616
  """
2617
- Return the coordinates of the rectangle defining the projection limits.
2617
+ Return the coordinates of the projection limits rectangle.
2618
2618
 
2619
- The coordinates are returned as a list of four tuples, each tuple
2620
- containing the x and y coordinates of a vertex of the rectangle.
2621
- If the plot is skewed, the coordinates are transformed to the
2622
- skewed coordinates.
2619
+ The coordinates are returned as a list of four tuples, each
2620
+ tuple containing the x and y coordinates of a vertex of the
2621
+ rectangle. If the plot is skewed, the coordinates are
2622
+ transformed to the skewed coordinates.
2623
2623
  """
2624
2624
  xp = self.plotview.xaxis.dim
2625
2625
  yp = self.plotview.yaxis.dim
@@ -3378,26 +3378,72 @@ class ScanTab(NXTab):
3378
3378
  """
3379
3379
  super().__init__(label, parent=parent)
3380
3380
 
3381
+ grid = QtWidgets.QGridLayout()
3382
+ grid.setSpacing(10)
3383
+ headers = ['Axis', 'Minimum', 'Maximum']
3384
+ width = [50, 100, 100]
3385
+ column = 0
3386
+ for header in headers:
3387
+ label = NXLabel(header, bold=True, align='center')
3388
+ grid.addWidget(label, 0, column)
3389
+ grid.setColumnMinimumWidth(column, width[column])
3390
+ column += 1
3391
+ row = 0
3392
+ self.minbox = {}
3393
+ self.maxbox = {}
3394
+ for axis in range(self.plotview.ndim):
3395
+ row += 1
3396
+ self.minbox[axis] = NXSpinBox(self.set_limits)
3397
+ self.maxbox[axis] = NXSpinBox(self.set_limits)
3398
+ grid.addWidget(self.label(self.plotview.axis[axis].name), row, 0)
3399
+ grid.addWidget(self.minbox[axis], row, 1)
3400
+ grid.addWidget(self.maxbox[axis], row, 2)
3401
+
3381
3402
  self.set_layout(
3403
+ grid, self.checkboxes(("hide", "Hide Limits", False)),
3382
3404
  self.textboxes(('Scan', '')),
3383
3405
  self.action_buttons(('Select Scan', self.select_scan),
3384
3406
  ('Select Files', self.select_files)),
3385
3407
  self.action_buttons(('Plot', self.plot_scan),
3386
3408
  ('Copy', self.copy_scan),
3387
3409
  ('Save', self.save_scan)))
3410
+ self.checkbox["hide"].stateChanged.connect(self.hide_rectangle)
3388
3411
  self.file_box = None
3389
3412
  self.scan_files = None
3390
3413
  self.scan_values = None
3391
3414
  self.scan_data = None
3415
+ self.scan_root = None
3392
3416
  self.files = None
3417
+ self.initialize()
3418
+ self._rectangle = None
3419
+
3420
+ def initialize(self):
3421
+ """
3422
+ Initialize the projection limits and copy widgets.
3423
+
3424
+ This function is called when the dialog is first created and
3425
+ after the data has been changed. It sets the minimum and maximum
3426
+ limits to the centers of the data and sets the current limits to
3427
+ the current limits of the plot. The copy widgets are also
3428
+ updated to reflect the current state of the other tabs.
3429
+ """
3430
+ for axis in range(self.plotview.ndim):
3431
+ self.minbox[axis].data = self.maxbox[axis].data = \
3432
+ self.plotview.axis[axis].centers
3433
+ self.minbox[axis].setMaximum(self.minbox[axis].data.size-1)
3434
+ self.maxbox[axis].setMaximum(self.maxbox[axis].data.size-1)
3435
+ self.block_signals(True)
3436
+ self.minbox[axis].setValue(self.plotview.axis[axis].lo)
3437
+ self.maxbox[axis].setValue(self.plotview.axis[axis].hi)
3438
+ self.block_signals(False)
3393
3439
 
3394
3440
  def select_scan(self):
3395
3441
  """
3396
3442
  Set the scan axis of the dialog to the currently selected node.
3397
3443
 
3398
3444
  The currently selected node must be a scalar NXfield. If the
3399
- selected node is not a scalar NXfield, a NeXusError is raised and
3400
- reported.
3445
+ selected node is not a scalar NXfield, a NeXusError is raised
3446
+ and reported.
3401
3447
  """
3402
3448
  scan_axis = self.treeview.node
3403
3449
  if not isinstance(scan_axis, NXfield):
@@ -3411,13 +3457,14 @@ class ScanTab(NXTab):
3411
3457
  """
3412
3458
  Create a dialog to select files to plot.
3413
3459
 
3414
- The dialog will show a list of files with checkboxes. The list of
3415
- files is determined by the data_path argument passed to the
3460
+ The dialog will show a list of files with checkboxes. The list
3461
+ of files is determined by the data_path argument passed to the
3416
3462
  constructor. The list of files is filtered to only include files
3417
- that have a scan axis with the scan_path argument. If no scan_path
3418
- argument is provided, all files are included. The dialog also
3419
- allows the user to select a prefix for the files. The selected
3420
- files are returned as a list of (file name, scan value) tuples.
3463
+ that have a scan axis with the scan_path argument. If no
3464
+ scan_path argument is provided, all files are included. The
3465
+ dialog also allows the user to select a prefix for the files.
3466
+ The selected files are returned as a list of (file name, scan
3467
+ value) tuples.
3421
3468
  """
3422
3469
  if self.file_box in self.mainwindow.dialogs:
3423
3470
  try:
@@ -3496,6 +3543,58 @@ class ScanTab(NXTab):
3496
3543
  else:
3497
3544
  self.files[f].value = ''
3498
3545
 
3546
+ def get_axes(self):
3547
+ """Return a list of NXfields containing the data axes."""
3548
+ return self.plotview.xtab.get_axes()
3549
+
3550
+ def set_limits(self):
3551
+ """Plot the limits rectangle when the axis limits change."""
3552
+ self.scan_data = None
3553
+ self.draw_rectangle()
3554
+
3555
+ def get_limits(self, axis=None):
3556
+ """
3557
+ Return the limits of the plot for the given axis.
3558
+
3559
+ Parameters
3560
+ ----------
3561
+ axis : int or None
3562
+ The axis for which to return the limits. If None, return the
3563
+ limits for all axes.
3564
+
3565
+ Returns
3566
+ -------
3567
+ limits : list of tuples of int
3568
+ The limits of the plot for the given axis or axes. Each
3569
+ tuple is a pair of start and stop indices.
3570
+ """
3571
+ def get_indices(minbox, maxbox):
3572
+ start, stop = minbox.index, maxbox.index+1
3573
+ if minbox.reversed:
3574
+ start, stop = len(maxbox.data)-stop, len(minbox.data)-start
3575
+ return start, stop
3576
+ if axis:
3577
+ return get_indices(self.minbox[axis], self.maxbox[axis])
3578
+ else:
3579
+ return [get_indices(self.minbox[axis], self.maxbox[axis])
3580
+ for axis in range(self.plotview.ndim)]
3581
+
3582
+ def get_slice(self):
3583
+ """
3584
+ Return a tuple of slice objects for the axes of the data.
3585
+
3586
+ The slice objects are generated from the limits boxes. The
3587
+ start and stop indices of each slice are the start and stop
3588
+ values of the corresponding limits box, respectively.
3589
+
3590
+ Returns
3591
+ -------
3592
+ slice : tuple of slice objects
3593
+ A tuple of slice objects for the axes of the data.
3594
+ """
3595
+ idx = self.get_limits()
3596
+ return tuple(slice(start, stop) for (start, stop) in idx)
3597
+
3499
3598
  @property
3500
3599
  def data_path(self):
3501
3600
  """Return the path to the data to be plotted."""
@@ -3537,10 +3636,23 @@ class ScanTab(NXTab):
3537
3636
  for f in self.files if self.files[f].vary]
3538
3637
  self.scan_values = [self.files[f].value for f in self.files
3539
3638
  if self.files[f].vary]
3540
- self.scan_data = nxconsolidate(self.scan_files, self.data_path,
3541
- self.scan_path)
3639
+ self.create_scan_data()
3542
3640
  except Exception:
3543
- raise NeXusError("Files not selected")
3641
+ report_error("Choosing Scan Files", "Files not selected")
3642
+
3643
+ def create_scan_data(self):
3644
+ """Create the consolidated scan data."""
3645
+ self.scan_data = nxconsolidate(self.scan_files, self.data_path,
3646
+ self.scan_path, idx=self.get_slice())
3647
+ try:
3648
+ if Path(self.scan_root.nxfilename).exists():
3649
+ Path(self.scan_root.nxfilename).unlink()
3650
+ except Exception:
3651
+ pass
3652
+ import tempfile
3653
+ with nxload(tempfile.mkstemp(suffix='.nxs')[1], mode='w') as root:
3654
+ root['data'] = self.scan_data
3655
+ self.scan_root = root
3544
3656
 
3545
3657
  def plot_scan(self):
3546
3658
  """
@@ -3554,6 +3666,8 @@ class ScanTab(NXTab):
3554
3666
  NeXusError
3555
3667
  If the data cannot be plotted.
3556
3668
  """
3669
+ if self.scan_data is None:
3670
+ self.create_scan_data()
3557
3671
  try:
3558
3672
  self.scanview.plot(self.scan_data)
3559
3673
  self.scanview.make_active()
@@ -3573,6 +3687,8 @@ class ScanTab(NXTab):
3573
3687
  NeXusError
3574
3688
  If the data cannot be copied.
3575
3689
  """
3690
+ if self.scan_data is None:
3691
+ self.create_scan_data()
3576
3692
  try:
3577
3693
  self.mainwindow.copied_node = self.mainwindow.copy_node(
3578
3694
  self.scan_data)
@@ -3591,6 +3707,8 @@ class ScanTab(NXTab):
3591
3707
  NeXusError
3592
3708
  If the data cannot be saved.
3593
3709
  """
3710
+ if self.scan_data is None:
3711
+ self.create_scan_data()
3594
3712
  try:
3595
3713
  keep_data(self.scan_data)
3596
3714
  except NeXusError as error:
@@ -3605,6 +3723,116 @@ class ScanTab(NXTab):
3605
3723
  from .plotview import NXPlotView
3606
3724
  return NXPlotView('Scan')
3607
3725
 
3726
+ def block_signals(self, block=True):
3727
+ """
3728
+ Block signals from the limits boxes.
3729
+
3730
+ Parameters
3731
+ ----------
3732
+ block : bool
3733
+ True to block signals, False to unblock signals
3734
+ """
3735
+ for axis in range(self.plotview.ndim):
3736
+ self.minbox[axis].blockSignals(block)
3737
+ self.maxbox[axis].blockSignals(block)
3738
+
3739
+ @property
3740
+ def rectangle(self):
3741
+ """The rectangle defining the projection limits."""
3742
+ if self._rectangle not in self.plotview.ax.patches:
3743
+ self._rectangle = NXpolygon(self.get_rectangle(), closed=True,
3744
+ plotview=self.plotview).shape
3745
+ self._rectangle.set_edgecolor(self.plotview._gridcolor)
3746
+ self._rectangle.set_facecolor('none')
3747
+ self._rectangle.set_linestyle('dashed')
3748
+ self._rectangle.set_linewidth(2)
3749
+ return self._rectangle
3750
+
3751
+ def get_rectangle(self):
3752
+ """
3753
+ Return the coordinates of the rectangle.
3754
+
3755
+ The coordinates are returned as a list of four tuples, each
3756
+ tuple containing the x and y coordinates of a vertex of the
3757
+ rectangle. If the plot is skewed, the coordinates are
3758
+ transformed to the skewed coordinates.
3759
+ """
3760
+ xp = self.plotview.xaxis.dim
3761
+ yp = self.plotview.yaxis.dim
3762
+ x0 = self.minbox[xp].minBoundaryValue(self.minbox[xp].index)
3763
+ x1 = self.maxbox[xp].maxBoundaryValue(self.maxbox[xp].index)
3764
+ y0 = self.minbox[yp].minBoundaryValue(self.minbox[yp].index)
3765
+ y1 = self.maxbox[yp].maxBoundaryValue(self.maxbox[yp].index)
3766
+ xy = [(x0, y0), (x0, y1), (x1, y1), (x1, y0)]
3767
+ if self.plotview.skew is not None:
3768
+ return [self.plotview.transform(_x, _y) for _x, _y in xy]
3769
+ else:
3770
+ return xy
3771
+
3772
+ def draw_rectangle(self):
3773
+ """
3774
+ Redraw the rectangle in the plot based on the current limits.
3775
+
3776
+ Notes
3777
+ -----
3778
+ The coordinates of the rectangle are obtained from the limits of
3779
+ the x and y axes. If the plot is skewed, the coordinates are
3780
+ transformed to the skewed coordinates.
3781
+ """
3782
+ self.rectangle.set_xy(self.get_rectangle())
3783
+ self.plotview.draw()
3784
+
3785
+ def rectangle_visible(self):
3786
+ """
3787
+ Return True if the rectangle defining the projection limits
3788
+ should be visible.
3789
+
3790
+ The rectangle is visible unless the 'Hide Limits' checkbox is
3791
+ checked.
3792
+ """
3793
+ return not self.checkbox["hide"].isChecked()
3794
+
3795
+ def hide_rectangle(self):
3796
+ """
3797
+ Hide or show the rectangle defining the projection limits based
3798
+ on the 'Hide Limits' checkbox.
3799
+
3800
+ If the checkbox is checked, hide the rectangle. Otherwise, show
3801
+ it.
3802
+ """
3803
+ if self.checkbox["hide"].isChecked():
3804
+ self.rectangle.set_visible(False)
3805
+ else:
3806
+ self.rectangle.set_visible(True)
3807
+ self.plotview.draw()
3808
+
3809
+ def update(self):
3810
+ """
3811
+ Update the limits boxes and the rectangle in the plot based on
3812
+ the current limits of the axes.
3813
+
3814
+ Notes
3815
+ -----
3816
+ If the limits of the x or y axes have changed, the limits boxes
3817
+ are updated to reflect the new limits. The rectangle is then
3818
+ redrawn based on the updated limits.
3819
+ """
3820
+ self.block_signals(True)
3821
+ for axis in range(self.plotview.ndim):
3822
+ lo, hi = self.plotview.axis[axis].get_limits()
3823
+ minbox, maxbox = self.minbox[axis], self.maxbox[axis]
3824
+ ilo, ihi = minbox.indexFromValue(lo), maxbox.indexFromValue(hi)
3825
+ if (self.plotview.axis[axis] is self.plotview.xaxis or
3826
+ self.plotview.axis[axis] is self.plotview.yaxis):
3827
+ ilo = ilo + 1
3828
+ ihi = max(ilo, ihi-1)
3829
+ if lo > minbox.value():
3830
+ minbox.setValue(minbox.valueFromIndex(ilo))
3831
+ if hi < maxbox.value():
3832
+ maxbox.setValue(maxbox.valueFromIndex(ihi))
3833
+ self.block_signals(False)
3834
+ self.draw_rectangle()
3835
+
3608
3836
  def close(self):
3609
3837
  """
3610
3838
  Close the dialog.
@@ -3612,10 +3840,21 @@ class ScanTab(NXTab):
3612
3840
  This will close the dialog and remove it from the list of
3613
3841
  dialogs. It will also close the file dialog if it is open.
3614
3842
  """
3843
+ try:
3844
+ if Path(self.scan_root.nxfilename).exists():
3845
+ Path(self.scan_root.nxfilename).unlink()
3846
+ except Exception:
3847
+ pass
3615
3848
  try:
3616
3849
  self.file_box.close()
3617
3850
  except Exception:
3618
3851
  pass
3852
+ try:
3853
+ if self._rectangle:
3854
+ self._rectangle.remove()
3855
+ self.plotview.draw()
3856
+ except Exception:
3857
+ pass
3619
3858
  super().close()
3620
3859
 
3621
3860
 
@@ -5589,9 +5828,10 @@ class ManagePluginsDialog(NXDialog):
5589
5828
  if p not in self.plugins]:
5590
5829
  try:
5591
5830
  self.plugins[plugin] = load_plugin(plugin)
5592
- except Exception as error:
5831
+ except Exception:
5593
5832
  self.plugins[plugin] = {'package': plugin,
5594
5833
  'menu': 'unavailable',
5834
+ 'actions': [],
5595
5835
  'order': 'Disabled'}
5596
5836
 
5597
5837
  self.grid = QtWidgets.QGridLayout()
@@ -5618,19 +5858,30 @@ class ManagePluginsDialog(NXDialog):
5618
5858
 
5619
5859
  def update_plugins(self):
5620
5860
  """
5621
- Set the order of plugins in the settings from the current dialog
5622
- box layout. Check that the order is unique and sequential,
5623
- otherwise raise a NeXusError.
5861
+ Update the plugin order.
5862
+
5863
+ The order of the plugins is updated by reading the values from
5864
+ the grid of widgets. The order is checked to ensure that it is
5865
+ unique and sequential, and an error is raised if it is not. If a
5866
+ plugin is unavailable, the order is set to 'Disabled' and the
5867
+ selection is reset.
5624
5868
  """
5625
5869
  for row, plugin in enumerate(self.plugins):
5626
- p = self.plugins[plugin]
5627
- order = self.grid.itemAtPosition(row+1, 2).widget().currentText()
5628
- if order != 'Disabled' and p['menu'] == 'unavailable':
5629
- p['order'] = 'Disabled'
5630
- self.grid.itemAtPosition(row+1, 2).widget().select('Disabled')
5631
- raise NeXusError(f"Plugin '{p['package']}' is unavailable")
5870
+ order_combo = self.grid.itemAtPosition(row+1, 2).widget()
5871
+ order = order_combo.selected
5872
+ if order == 'Disabled':
5873
+ self.plugins[plugin]['order'] = 'Disabled'
5632
5874
  else:
5633
- p['order'] = order
5875
+ if self.plugins[plugin]['menu'] == 'unavailable':
5876
+ try:
5877
+ self.plugins[plugin] = load_plugin(plugin)
5878
+ except Exception as error:
5879
+ self.plugins[plugin]['order'] = 'Disabled'
5880
+ order_combo.select('Disabled')
5881
+ raise NeXusError(
5882
+ f"Plugin '{plugin}' could not be loaded\n{error}")
5883
+ else:
5884
+ self.plugins[plugin]['order'] = order
5634
5885
  order_set = [int(p['order']) for p in self.plugins.values()
5635
5886
  if p['order'] != 'Disabled']
5636
5887
  if sorted(order_set) != list(range(1, len(order_set)+1)):
@@ -286,8 +286,10 @@ class FitTab(NXTab):
286
286
  self.form_combo = NXComboBox()
287
287
  self.compose_button = NXPushButton(
288
288
  "Compose Models", self.compose_model)
289
+ self.import_button = NXPushButton("Import Model", self.import_fit)
289
290
  model_layout = self.make_layout(add_button, self.model_combo,
290
291
  self.form_combo, 'stretch',
292
+ self.import_button,
291
293
  self.compose_button, align='justified')
292
294
 
293
295
  self.parameter_layout = self.initialize_parameter_grid()
@@ -499,6 +501,7 @@ class FitTab(NXTab):
499
501
  Set to True if the data have been fitted.
500
502
  """
501
503
  if len(self.models) == 0:
504
+ self.import_button.setVisible(True)
502
505
  self.compose_button.setVisible(False)
503
506
  self.remove_button.setVisible(False)
504
507
  self.remove_combo.setVisible(False)
@@ -514,6 +517,7 @@ class FitTab(NXTab):
514
517
  self.plot_combo.setVisible(False)
515
518
  self.plot_checkbox.setVisible(False)
516
519
  else:
520
+ self.import_button.setVisible(False)
517
521
  if len(self.models) > 1:
518
522
  self.compose_button.setVisible(True)
519
523
  self.remove_button.setVisible(True)
@@ -790,9 +794,18 @@ class FitTab(NXTab):
790
794
  except Exception:
791
795
  return None, None
792
796
 
797
+ def import_fit(self):
798
+ """Select the NXprocess group containing the fit."""
799
+ group = self.treeview.node
800
+ if not isinstance(group, NXprocess):
801
+ display_message("Import Fit",
802
+ "Select a valid NXprocess group in the tree")
803
+ else:
804
+ self.load_fit(group)
805
+
793
806
  def load_fit(self, group):
794
807
  """
795
- Loads a fit from a NeXus NXprocess group.
808
+ Load a fit from a NeXus NXprocess group.
796
809
 
797
810
  Parameters
798
811
  ----------
@@ -840,9 +853,6 @@ class FitTab(NXTab):
840
853
  if error:
841
854
  parameter.stderr = float(
842
855
  saved_parameters[p].attrs['error'])
843
- parameter.vary = True
844
- else:
845
- parameter.vary = False
846
856
  self.models.append({'name': model_name,
847
857
  'class': model_class,
848
858
  'model': model,
@@ -1497,7 +1497,7 @@ class MainWindow(QtWidgets.QMainWindow):
1497
1497
  except NeXusError as error:
1498
1498
  report_error("Managing Plugins", error)
1499
1499
 
1500
- def plot_data(self):
1500
+ def plot_data(self, new_plot=False):
1501
1501
  """
1502
1502
  Plot the selected data.
1503
1503
 
@@ -1513,6 +1513,8 @@ class MainWindow(QtWidgets.QMainWindow):
1513
1513
  self.treeview.status_message(node)
1514
1514
  if isinstance(node, NXgroup) and node.plottable_data:
1515
1515
  try:
1516
+ if new_plot:
1517
+ self.new_plot_window()
1516
1518
  node.plot()
1517
1519
  self.plotview.make_active()
1518
1520
  return
@@ -2160,6 +2162,12 @@ class MainWindow(QtWidgets.QMainWindow):
2160
2162
  triggered=lambda: self.plotviews[label].make_active(),
2161
2163
  checkable=False)
2162
2164
  self.window_menu.addAction(self.active_action[number])
2165
+ elif label.startswith('Rotation'):
2166
+ self.active_action[number] = QtWidgets.QAction(
2167
+ label, self,
2168
+ triggered=lambda: self.plotviews[label].make_active(),
2169
+ checkable=False)
2170
+ self.window_menu.addAction(self.active_action[number])
2163
2171
  else:
2164
2172
  numbers = [num for num in sorted(self.active_action) if num < 100]
2165
2173
  if number > numbers[-1]:
@@ -2221,16 +2229,19 @@ class MainWindow(QtWidgets.QMainWindow):
2221
2229
 
2222
2230
  def cascade_plots(self):
2223
2231
  """Cascade plot windows across the available screen."""
2224
- pvs = [self.plotviews[pv] for pv in self.plotviews]
2232
+ pvs = sorted([self.plotviews[pv] for pv in self.plotviews
2233
+ if self.plotviews[pv].number < 100],
2234
+ key=lambda obj: obj.number)
2235
+ self.tile_panels()
2236
+ available_geometry = self.app.app.primaryScreen().availableGeometry()
2237
+ left, top = available_geometry.left(), available_geometry.top()
2238
+ self.move(left, top)
2225
2239
  if len(pvs) <= 1:
2226
2240
  return
2227
- available_geometry = self.app.app.primaryScreen().availableGeometry()
2228
2241
  last_left = available_geometry.right() - pvs[-1].width()
2229
2242
  last_top = available_geometry.bottom() - pvs[-1].height()
2230
2243
  offset_x = int((last_left - available_geometry.left()) / (len(pvs)-1))
2231
2244
  offset_y = int((last_top - available_geometry.top()) / (len(pvs)-1))
2232
- left, top = available_geometry.left(), available_geometry.top()
2233
- self.move(left, top)
2234
2245
  for pv in pvs[1:]:
2235
2246
  left += offset_x
2236
2247
  top += offset_y
@@ -2239,24 +2250,49 @@ class MainWindow(QtWidgets.QMainWindow):
2239
2250
 
2240
2251
  def tile_plots(self):
2241
2252
  """Tile plot windows across the available screen."""
2242
- pvs = [self.plotviews[pv] for pv in self.plotviews if pv != 'Main']
2243
- if len(pvs) <= 1:
2244
- return
2253
+ pvs = sorted([self.plotviews[pv] for pv in self.plotviews
2254
+ if pv != 'Main' and self.plotviews[pv].number < 100],
2255
+ key=lambda obj: obj.number)
2256
+ self.tile_panels()
2245
2257
  available_geometry = self.app.app.primaryScreen().availableGeometry()
2246
2258
  left, top = available_geometry.left(), available_geometry.top()
2247
2259
  self.move(left, top)
2248
- left += self.treeview.minimumWidth()
2260
+ if len(pvs) <= 1:
2261
+ return
2262
+ left_min = self.treeview.minimumWidth()
2263
+ left += left_min
2264
+ if sys.platform == 'darwin':
2265
+ top_min = 0
2266
+ else:
2267
+ top_min = (self.frameGeometry().height() - self.geometry().height()
2268
+ + self.menuBar().height())
2269
+ top += top_min
2249
2270
  pvs[0].move(left, top)
2271
+ pvs[0].make_active()
2250
2272
  for pv in pvs[1:]:
2251
2273
  left += pv.canvas.width()
2252
2274
  if left + pv.canvas.width() > available_geometry.right():
2253
- left = available_geometry.left() + self.treeview.minimumWidth()
2275
+ left = available_geometry.left() + left_min
2254
2276
  top += pv.canvas.height()
2255
2277
  if top + pv.canvas.height() > available_geometry.bottom():
2256
- top = available_geometry.top()
2278
+ top = available_geometry.top() + top_min
2257
2279
  pv.move(left, top)
2258
2280
  pv.make_active()
2259
2281
 
2282
+ def tile_panels(self):
2283
+ """Tile panels along the bottom of the available screen."""
2284
+ available_geometry = self.app.app.primaryScreen().availableGeometry()
2285
+ left, bottom = available_geometry.left(), available_geometry.bottom()
2286
+ for p in self.panels:
2287
+ panel = self.panels[p]
2288
+ height = panel.frameGeometry().height()
2289
+ width = panel.frameGeometry().width()
2290
+ if panel.isVisible():
2291
+ if left + width > available_geometry.right():
2292
+ left = available_geometry.left()
2293
+ panel.move(left, bottom - height)
2294
+ left += width
2295
+
2260
2296
  def update_active(self, number):
2261
2297
  """
2262
2298
  Update the active window in 'Window' menu.
@@ -470,7 +470,6 @@ class NXTreeView(QtWidgets.QTreeView):
470
470
 
471
471
  self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
472
472
  self.setExpandsOnDoubleClick(False)
473
- self.doubleClicked.connect(self.mainwindow.plot_data)
474
473
  self.selectionModel().selectionChanged.connect(self.selection_changed)
475
474
  self.expanded.connect(self.expand_node)
476
475
 
@@ -902,3 +901,24 @@ class NXTreeView(QtWidgets.QTreeView):
902
901
  node = self.get_node()
903
902
  if node is not None:
904
903
  self.popMenu(self.get_node()).exec(self.mapToGlobal(point))
904
+
905
+ def mouseDoubleClickEvent(self, event):
906
+ """
907
+ Called when the user double-clicks in the treeview.
908
+
909
+ If a node is double-clicked, it is plotted in a new plot window
910
+ if the Shift key is held down. Otherwise, it is plotted in the
911
+ current default plot window.
912
+
913
+ Parameters
914
+ ----------
915
+ event : QMouseEvent
916
+ The double-click event in the treeview.
917
+ """
918
+ index = self.indexAt(event.pos())
919
+ if index.isValid():
920
+ if event.modifiers() & QtCore.Qt.ShiftModifier:
921
+ self.mainwindow.plot_data(new_plot=True)
922
+ else:
923
+ self.mainwindow.plot_data()
924
+ super().mouseDoubleClickEvent(event)
@@ -795,19 +795,13 @@ def load_plugin(plugin, order=None):
795
795
  package = plugin_path.stem
796
796
  module = import_plugin(plugin_path)
797
797
  menu, actions = module.plugin_menu()
798
- return {'package': package, 'menu': menu, 'actions': actions,
799
- 'order': order}
800
798
  else:
801
799
  eps = entry_points().select(group='nexpy.plugins')
802
800
  entry = next((e for e in eps if e.module == plugin), None)
803
- try:
804
- package = entry.dist.name
805
- menu, actions = entry.load()()
806
- return {'package': package, 'menu': menu, 'actions': actions,
807
- 'order': order}
808
- except Exception:
809
- return {'package': plugin, 'menu': 'unavailable', 'actions': [],
810
- 'order': 'Disabled'}
801
+ package = entry.dist.name
802
+ menu, actions = entry.load()()
803
+ return {'package': package, 'menu': menu, 'actions': actions,
804
+ 'order': order}
811
805
 
812
806
 
813
807
  def load_readers():
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes