def runTest(self): flood = CreateFloodWorkspace('OFFSPEC00035946.nxs', StartSpectrum=250, EndSpectrum=600, ExcludeSpectra=[260, 261, 262, 516, 517, 518], OutputWorkspace='flood') data = Load('OFFSPEC00044998.nxs') data = Rebin(data, [0,1000,100000], PreserveEvents=False) data = ConvertUnits(data, 'Wavelength') ApplyFloodWorkspace(InputWorkspace=data, FloodWorkspace=flood, OutputWorkspace=self.out_ws_name)
def plot_specular_pixel_check(input_workspace: EventWorkspace, flood_workspace: EventWorkspace, ax): flooded_ws = ApplyFloodWorkspace(input_workspace, flood_workspace) integrated = Integration(flooded_ws, RangeLower=9000, RangeUpper=88000, StartWorkspaceIndex=70, EndWorkspaceIndex=95) integrated_transposed = Transpose(integrated) def _1gaussian(x, ampl, cent, sigma): return ampl * (1 / sigma * (np.sqrt(2 * np.pi))) * (np.exp(-((x - cent)**2) / (2 * sigma)**2)) xval = integrated_transposed.readX(0) yval = integrated_transposed.readY(0) popt_gauss, pcov_gauss = optimize.curve_fit(_1gaussian, xval, yval, p0=[56000, 86, 0.8]) perr_gauss = np.sqrt(np.diag(pcov_gauss)) fit_yvals = _1gaussian(xval, *popt_gauss) ax.plot(xval, yval, "rx") ax.plot(xval, fit_yvals, 'k--') ax.axvline(x=86.0, color='b', linestyle='--') ax.set_xlabel("Spectrum") ax.set_ylabel("Counts") max_pos = fit_yvals.argmax() annot_y = fit_yvals[max_pos] annot_x = xval[max_pos] ax.annotate(f"X:{annot_x}, Y:{annot_y}", xy=(annot_x, annot_y), xytext=(annot_x * 1.02, annot_y)) ax.minorticks_on() ax.grid(True, which="both") ax.set_title("Specular pixel") # make interactive plotly figure fig = go.Figure() fig.add_trace( go.Scatter(x=xval, y=yval, name="Data", mode="markers", marker_symbol=4)) fig.add_trace(go.Scatter(x=xval, y=fit_yvals, mode="lines", name="Fit")) fig.add_vline(x=86, line_dash="dash", line_color="blue") fig.update_layout(xaxis_title="Spectrum", yaxis_title="Counts", width=600, title_text="Specular pixel", title_x=0.5) return fig
def runTest(self): flood = CreateFloodWorkspace( 'OFFSPEC00035946.nxs', StartSpectrum=250, EndSpectrum=600, ExcludeSpectra=[260, 261, 262, 516, 517, 518], OutputWorkspace='flood') data = Load('OFFSPEC00044998.nxs') ApplyFloodWorkspace(InputWorkspace=data, FloodWorkspace=flood, OutputWorkspace=self.out_ws_name)