def setUp(self):
     input_ws = CreateSampleWorkspace(
         Function="User Defined",
         UserDefinedFunction="name=LinearBackground, " +
         "A0=0.3;name=Gaussian, PeakCentre=5, Height=10, Sigma=0.3",
         NumBanks=2,
         BankPixelWidth=1,
         XMin=0,
         XMax=10,
         BinWidth=0.1,
         BankDistanceFromSample=4.0)
     self._input_ws = input_ws
     self._table = FindEPP(input_ws, OutputWorkspace="table")
     AddSampleLog(self._input_ws,
                  LogName='wavelength',
                  LogText='4.0',
                  LogType='Number',
                  LogUnit='Angstrom')
     for i in range(input_ws.getNumberHistograms()):
         y = input_ws.dataY(i)
         y.fill(0.)
         y[51] = 100.
         e = input_ws.dataE(i)
         e.fill(0.)
         e[51] = 10.
Esempio n. 2
0
    def test_calculation_fitsample(self):
        OutputWorkspaceName = "outputws"
        # generate EPP table
        table = FindEPP(self._input_ws)

        alg_test = run_algorithm("TOFTOFConvertTofToDeltaE",
                                 InputWorkspace=self._input_ws,
                                 EPPTable=table,
                                 OutputWorkspace=OutputWorkspaceName)
        self.assertTrue(alg_test.isExecuted())
        wsoutput = AnalysisDataService.retrieve(OutputWorkspaceName)

        # create reference data for X axis
        dataX = np.linspace(4005.75, 7995.75, 381)
        tel = 6005.25
        factor = m_n * 1e+15 / eV
        newX = 0.5 * factor * 16.0 * (1 / tel**2 - 1 / dataX**2)
        # compare
        self.assertTrue(np.allclose(newX, wsoutput.readX(0)))  # sdd = 4.0
        self.assertTrue(np.allclose(4.0 * newX,
                                    wsoutput.readX(1)))  # sdd = 8.0

        # create reference data for Y axis and compare to the output
        tof = dataX[:-1] + 5.25
        newY = self._input_ws.readY(0) * tof**3 / (factor * 10.5 * 16.0)
        self.assertTrue(np.allclose(newY, wsoutput.readY(0)))  # sdd = 4.0
        self.assertTrue(np.allclose(newY / 4.0,
                                    wsoutput.readY(1)))  # sdd = 8.0

        DeleteWorkspace(wsoutput)
        DeleteWorkspace(table)
 def setUp(self):
     input_ws = CreateSampleWorkspace(Function="User Defined",
                                      UserDefinedFunction="name=LinearBackground, A0=0.3;name=Gaussian, \
                                      PeakCentre=5, Height=10, Sigma=0.3", NumBanks=2, BankPixelWidth=1,
                                      XMin=0, XMax=10, BinWidth=0.1, BankDistanceFromSample=4.0)
     self._input_ws = input_ws
     self._table = FindEPP(input_ws, OutputWorkspace="table")
     AddSampleLog(self._input_ws, LogName='wavelength', LogText='4.0', LogType='Number', LogUnit='Angstrom')
Esempio n. 4
0
def _fitEPP(ws, wsType, wsNames, algorithmLogging):
    """Return a fitted EPP table for a workspace."""
    if wsType == common.WS_CONTENT_DETS:
        eppWSName = wsNames.withSuffix('epp_detectors')
    else:
        eppWSName = wsNames.withSuffix('epp_monitors')
    eppWS = FindEPP(InputWorkspace=ws,
                    OutputWorkspace=eppWSName,
                    EnableLogging=algorithmLogging)
    return eppWS
 def setUp(self):
     input_ws = CreateSampleWorkspace(
         Function="User Defined",
         UserDefinedFunction="name=LinearBackground, " +
         "A0=0.3;name=Gaussian, PeakCentre=5, Height=10, Sigma=0.3",
         NumBanks=2, BankPixelWidth=1, XMin=0, XMax=10, BinWidth=0.1,
         BankDistanceFromSample=4.0)
     self._input_ws = input_ws
     self._table = FindEPP(input_ws, OutputWorkspace="table")
     AddSampleLog(self._input_ws, LogName='wavelength', LogText='4.0',
                  LogType='Number', LogUnit='Angstrom')
     # These ranges correspond to 6*FWHM of the gaussian above,
     # the integration ranges of ComputeCalibrationCoefVan.
     self._lowerBoundRange = slice(28, 73)
     self._upperBoundRange = slice(27, 74)
Esempio n. 6
0
def _fitElasticChannel(ys, wsNames, wsCleanup, algorithmLogging):
    """Return index to the peak position of ys."""
    xs = np.array([i for i in range(len(ys))])
    l2SumWSName = wsNames.withSuffix('summed_detectors_at_l2')
    l2SumWS = CreateWorkspace(OutputWorkspace=l2SumWSName,
                              DataX=xs,
                              DataY=ys,
                              EnableLogging=algorithmLogging)
    fitWSName = wsNames.withSuffix('summed_detectors_at_l2_fit_results')
    fitWS = FindEPP(InputWorkspace=l2SumWS,
                    OutputWorkspace=fitWSName,
                    EnableLogging=algorithmLogging)
    peakCentre = float(fitWS.cell('PeakCentre', 0))
    wsCleanup.cleanup(l2SumWS)
    wsCleanup.cleanup(fitWS)
    return peakCentre
 def _EPPTable(self, ws, eppWSName):
     eppWS = FindEPP(InputWorkspace=ws,
                     OutputWorkspace=eppWSName,
                     EnableLogging=False)
     return eppWS