Open jclarkeSTFC opened 1 week ago
Describe the bug
If you run the script below in the script editor in Workbench then it will hang. If you run the script at a terminal it will run no problem.
To Reproduce Open Workbench, adjust script file location, run script
Expected behavior
No hanging
Platform/Version (please complete the following information):
Additional context
Reported by Richard W
Script:
# import mantid algorithms, numpy and matplotlib from mantid.simpleapi import * import matplotlib.pyplot as plt import numpy as np from mantid.kernel import UnitConversion, DeltaEModeType, UnitParams, UnitParametersMap from os import path data_dir = r"C:\Temp\POLDI_script" ws = LoadNexus(Filename=path.join(data_dir, "poldi_workspace.nxs")) xmax = ws.readX(0)[-1] bin_width = ws.readX(0)[1] - ws.readX(0)[0] inst = ws.getInstrument() source = inst.getSource() sample = inst.getSample() chopper = inst.getComponentByName("chopper") l_chop = (chopper.getPos() - source.getPos()).norm() t0 = chopper.getNumberParameter("t0")[0] t0_const = chopper.getNumberParameter("t0_const")[0] chopper_speed = ws.run().getPropertyAsSingleValue("chopperspeed") chopper_phase = ws.run().getPropertyAsSingleValue("ChopperPhase") cycle_time = 60.0 / (4.0 * chopper_speed) * 1.0e6; zero_offset = t0*cycle_time + t0_const nslits = chopper.nelements() slit_offsets = [chopper[islit].getPos()[0]*cycle_time + t0 for islit in range(nslits)] # get d-spacing array lambda_min, lambda_max = 1, 6 tth_min, tth_max = 68, 112 dspac_min = lambda_min/(2*np.sin(np.radians(tth_max)/2)) dspac_max = lambda_max/(2*np.sin(np.radians(tth_min)/2)) dspacs = np.linspace(dspac_min, dspac_max, 1000) # actual is 5531 # get npulses duration = ws.run().getPropertyAsSingleValue("DetTime") # Doesn't appear to be used? npulses = int(duration // cycle_time) # evaluate intermeidate corellation spectrum (Eq. 7 in POLDI concept paper) inter_corr = np.full((len(dspacs), npulses*nslits), np.nan, dtype=float) # sum over all spectra si = ws.spectrumInfo() blocksize = ws.blocksize() for ispec in range(ws.getNumberHistograms()): print(ispec, ispec/ws.getNumberHistograms()) params = UnitParametersMap() params[UnitParams.l2] = si.l2(ispec) params[UnitParams.twoTheta] = si.twoTheta(ispec) tof_d1Ang = UnitConversion.run("dSpacing", "TOF", 1.0, si.l1() - l_chop, DeltaEModeType.Elastic, params) for idspac, dspac in enumerate(dspacs): iopen = 0 for ipulse in range(npulses): for islit in range(nslits): # calc tof offset for this lambda time_offset = ipulse*cycle_time + slit_offsets[islit] time = (tof_d1Ang*dspac + time_offset + t0_const) % cycle_time if time < xmax - 0.5*bin_width: itime = time/bin_width ibin = int(itime) # ws.yindexOfX(time) # k in paper if ibin < blocksize - 1: inter_corr[idspac, iopen] += (ibin + 1 - itime)*ws.readY(ispec)[ibin] + (itime - ibin)*ws.readY(ispec)[ibin+1] iopen += 1
poldi_workspace.nxs.txt
Describe the bug
If you run the script below in the script editor in Workbench then it will hang. If you run the script at a terminal it will run no problem.
To Reproduce Open Workbench, adjust script file location, run script
Expected behavior
No hanging
Platform/Version (please complete the following information):
Additional context
Reported by Richard W
Script:
poldi_workspace.nxs.txt