mantidproject / mslice

Source code for Mantid MSlice
http://mantidproject.github.io/mslice
1 stars 2 forks source link

Error when using a script generated by mslice #913

Closed MialLewis closed 11 months ago

MialLewis commented 1 year ago

Describe the bug When using scripts generated by mslice they often error (I've seen a few different messages).

To Reproduce Haven't had chance to replicate yet, but this was one script generated:

# Python Script Generated by Mslice on 2023-05-17 11:07:51
import mslice.cli as mc
import mslice.plotting.pyplot as plt
ws_MAR21335_Ei60meV = mc.Load(Filename='C:/Users/joy22959/Development/mantid/build/ExternalData/Testing/Data/UnitTest\MAR21335_Ei60meV.nxs', OutputWorkspace='MAR21335_Ei60meV')
fig = plt.gcf()
fig.clf()
ax = fig.add_subplot(111, projection="mslice")
cut_ws_0 = mc.Cut(ws_MAR21335_Ei60meV, CutAxis="|Q|,0.0,10.0,0.04671", IntegrationAxis="DeltaE,-5.0,5.0,0.0", NormToOne=False, IntensityCorrection=False, SampleTemperature=None)
ax.errorbar(cut_ws_0, label="MAR21335_Ei60meV -5.00<E<5.00", color="#1f77b4", marker="o", ls="-", lw=1.5)
from mslice.cli.helperfunctions import hide_a_line_and_errorbars, append_visible_handle_and_label
from mslice.util.compat import legend_set_draggable
# hide lines, errorbars, and legends
handles, labels = ax.get_legend_handles_labels()
visible_handles = []
visible_labels = []
append_visible_handle_and_label(visible_handles, handles, visible_labels, labels, 0)
legend_set_draggable(ax.legend(visible_handles, visible_labels, fontsize='medium'), True)
ax.set_title('', fontsize=12.0)
ax.set_ylabel(r'Signal/#Events', fontsize=10.0)
ax.set_ylim(bottom=-17.772422415630686, top=127.87112555418936)
ax.set_xlim(left=-0.17990654205607487, right=10.460280373831777)
ax.bragg(workspace='MAR21335_Ei60meV_cut(32.455,50.345)', element='Aluminium')
mc.Show()

This line clearly has wrong cut limits ax.bragg(workspace='MAR21335_Ei60meV_cut(32.455,50.345)', element='Aluminium')

mducle commented 1 year ago

I can reproduce this error on Linux (CentOS 7) nightly 6.6.20230413.1231 (sorry a bit old, but the latest on IDAaaS):

  1. Load any datafile (MAR21335_Ei60meV.nxs from the test data in this case).
  2. Go to "Workspace Manager / Slice" and click "Display".
  3. Click "Interactive Cuts" in the icon bar, and select a region.
  4. Click "Interactive Cuts" again to leave interactive mode.
  5. Go to "Workspace Manager / Cut" in the main control window (leaving the plot window open).
  6. Put in a cut along |Q| from 0 to 10 with steps of 0 (should auto change to the default value), integrating from -5 to 5 and click plot.
  7. In the plot window, go to "Information" -> "Bragg peaks" -> "Aluminium"
  8. In the plot window, go to "File" -> "Generate script to clipboard"
  9. Paste the script and see that it is plotting the wrong workspace in the last step.
  10. Close the plot window, then go back to the main "Workspace Manager" / "Cut" tab and click "Plot" again
  11. "Information" -> "Bragg peaks" -> "Aluminium"
  12. "File" -> "Generate script to clipboard"
  13. Check that the correct workspace is now used in the final step.
  14. Close the plot window and repeat steps 10-12. Check that the generated script now has an erroneous _(1) appended which will work in the current session but will error when reloaded in a new Mantid session.