def _table_to_workspace( input_workspace: Union[str, TableWorkspace], output_workspace: Optional[str] = None) -> MaskWorkspace: r""" @brief Convert a CORELLI calibration mask table to a MaskWorkspace :param input_workspace : the table containing the detector ID's for the masked detectors :param output_workspace : name of the output MaskWorkspace :return: handle to the MaskWorkspace """ table_handle = mtd[str(input_workspace)] detectors_masked = table_handle.column(0) # list of masked detectors if output_workspace is None: output_workspace = str(input_workspace) LoadEmptyInstrument(InstrumentName='CORELLI', OutputWorkspace=output_workspace) ClearMaskFlag(Workspace=output_workspace) # for good measure MaskDetectors( Workspace=output_workspace, DetectorList=detectors_masked) # output_workspace is a Workspace2D # output_workspace is converted to a MaskWorkspace, where the Y-values of the spectra are now either 0 or 1 ExtractMask(InputWorkspace=output_workspace, OutputWorkspace=output_workspace) return mtd[output_workspace]
def nominal_integrated_flux(self, name): """ Generate a flux independent of momentum :param name: Name of the output workspace :return: reference to flux workspace """ ws = LoadNexus(Filename=self._flux_ws_, OutputWorkspace=name) ClearMaskFlag(ws) MaskDetectors(ws, MaskedWorkspace=self._t_mask) return ws
def nominal_solid_angle(self, name): """ Generate an isotropic solid angle :param name: Name of the output workspace :return: reference to solid angle workspace """ ws = LoadNexus(Filename=self._solid_angle_ws_, OutputWorkspace=name) ClearMaskFlag(ws) MaskDetectors(ws, MaskedWorkspace=self._t_mask) for i in range(ws.getNumberHistograms()): ws.dataY(i)[0] = 0.0 if ws.getDetector(i).isMasked() else 1.0 ws.setX(i, self._momentum_range) return ws
def _elasticPeakDiagnostics(ws, peakSettings, wsNames, algorithmLogging): """Diagnose elastic peaks and return a mask workspace""" elasticPeakDiagnosticsWSName = wsNames.withSuffix('diagnostics_elastic_peak') elasticPeakDiagnostics, nFailures = \ MedianDetectorTest(InputWorkspace=ws, OutputWorkspace=elasticPeakDiagnosticsWSName, SignificanceTest=peakSettings.significanceTest, LowThreshold=peakSettings.lowThreshold, HighThreshold=peakSettings.highThreshold, EnableLogging=algorithmLogging) ClearMaskFlag(Workspace=elasticPeakDiagnostics, EnableLogging=algorithmLogging) return elasticPeakDiagnostics
def _bkgDiagnostics(bkgWS, noisyBkgSettings, wsNames, algorithmLogging): """Diagnose noisy flat backgrounds and return a mask workspace.""" noisyBkgWSName = wsNames.withSuffix('diagnostics_noisy_bkg') noisyBkgDiagnostics, nFailures = \ MedianDetectorTest(InputWorkspace=bkgWS, OutputWorkspace=noisyBkgWSName, SignificanceTest=noisyBkgSettings.significanceTest, LowThreshold=noisyBkgSettings.lowThreshold, HighThreshold=noisyBkgSettings.highThreshold, LowOutlier=0.0, EnableLogging=algorithmLogging) ClearMaskFlag(Workspace=noisyBkgDiagnostics, EnableLogging=algorithmLogging) return noisyBkgDiagnostics