Ejemplo n.º 1
0
def _generate_calibration_workspace(instrument, ws_name='__calib'):
    simulation_workspace = CreateSimulationWorkspace(Instrument=instrument,
                                                     BinParams='0,1,2')
    number_of_histograms = simulation_workspace.getNumberHistograms()

    calib_workspace = CreateWorkspace(OutputWorkspace=ws_name,
                                      DataX=np.ones(1),
                                      DataY=np.ones(number_of_histograms),
                                      NSpec=number_of_histograms,
                                      ParentWorkspace=simulation_workspace)

    DeleteWorkspace(simulation_workspace)

    return calib_workspace
def _generate_calibration_workspace(instrument, ws_name='__calib'):
    simulation_workspace = CreateSimulationWorkspace(Instrument=instrument,
                                                     BinParams='0,1,2')
    number_of_histograms = simulation_workspace.getNumberHistograms()

    calib_workspace = CreateWorkspace(OutputWorkspace=ws_name,
                                      DataX=np.ones(1),
                                      DataY=np.ones(number_of_histograms),
                                      NSpec=number_of_histograms,
                                      ParentWorkspace=simulation_workspace)

    DeleteWorkspace(simulation_workspace)

    return calib_workspace
Ejemplo n.º 3
0
    def setUpClass(cls):
        x = np.linspace(0, 99, 100)
        y = x * 1
        e = y * 0 + 2
        cls.m_workspace = wrap_workspace(
            CreateWorkspace(x, y, e, OutputWorkspace="m_ws"), 'm_ws')

        sim_workspace = CreateSimulationWorkspace(Instrument='MAR',
                                                  BinParams=[-10, 1, 10],
                                                  UnitX='DeltaE',
                                                  OutputWorkspace='ws1')
        AddSampleLog(sim_workspace,
                     LogName='Ei',
                     LogText='3.',
                     LogType='Number')
        cls.px_workspace = ConvertToMD(InputWorkspace=sim_workspace,
                                       OutputWorkspace="ws1",
                                       QDimensions='|Q|',
                                       dEAnalysisMode='Direct',
                                       MinValues='-10,0,0',
                                       MaxValues='10,6,500',
                                       SplitInto='50,50')
        cls.px_workspace_clone = CloneWorkspace(
            InputWorkspace=cls.px_workspace,
            OutputWorkspace='ws2',
            StoreInADS=False)
        cls.px_workspace = wrap_workspace(cls.px_workspace, 'ws1')
        cls.px_workspace_clone = wrap_workspace(cls.px_workspace_clone, 'ws2')
Ejemplo n.º 4
0
    def setUp(self):
        # IPeak cannot currently be instatiated so this is a quick way
        # getting a handle to a peak object
        ws = CreateSimulationWorkspace("SXD", BinParams="1,1,10")
        peaks = CreatePeaksWorkspace(ws, 1)
        self._peak = peaks.getPeak(0)

        # tolerance for differences in q vectors that a recomputed
        # on every call.
        self._tolerance = 1e-2
    def get_tof_factors(self):
        ws = CreateSimulationWorkspace(Instrument=self._instrument_definition_file,
                                       BinParams='0.0,0.1,0.2')

        instrument = ws.getInstrument()
        sample = instrument.getSample()
        source_sample_distance = (sample.getPos() - instrument.getSource().getPos()).norm()

        # Get the detectors of the instrument
        detectors = [ws.getDetector(x) for x in range(ws.getNumberHistograms())]

        # Calculate sin(theta)...
        sin_theta = [np.sin(ws.detectorTwoTheta(x) / 2.0) for x in detectors]

        # ...and the total flight paths for each detector.
        distances = [source_sample_distance + (x.getPos() - sample.getPos()).norm() for x in detectors]

        # Multiplying a d-value in Angstrom with a value in this list gives the TOF in microseconds
        return [2.0 * m_n * s * st / h * 1e-4 for s, st in zip(distances, sin_theta)]
Ejemplo n.º 6
0
    def test_get_hkls(self):
        ws = CreateSimulationWorkspace("IRIS", BinParams="1,5,10")
        peaks = CreatePeaksWorkspace(ws, 2)
        reference = np.array([
            [1, 1, 2],
            [2, 1, 4],
        ])

        peak = peaks.getPeak(0)
        peak.setHKL(1, 1, 2)
        peak = peaks.getPeak(1)
        peak.setHKL(2, 1, 4)

        hkl = indexing.get_hkls(peaks)
        npt.assert_array_equal(hkl, reference)
Ejemplo n.º 7
0
 def create_pixel_workspace(self, name):
     sim_workspace = CreateSimulationWorkspace(Instrument='MAR', BinParams=[-10, 1, 10],
                                               UnitX='DeltaE', OutputWorkspace=name)
     AddSampleLog(sim_workspace, LogName='Ei', LogText='3.', LogType='Number')
     sim_workspace = ConvertToMD(InputWorkspace=sim_workspace, OutputWorkspace=name, QDimensions='|Q|',
                                 dEAnalysisMode='Direct', MinValues='-10,0,0', MaxValues='10,6,500',
                                 SplitInto='50,50')
     workspace = wrap_workspace(sim_workspace, name)
     workspace.is_PSD = True
     workspace.limits['MomentumTransfer'] = [0.1, 3.1, 0.1]
     workspace.limits['|Q|'] = [0.1, 3.1, 0.1]
     workspace.limits['DeltaE'] = [-10, 15, 1]
     workspace.e_fixed = 10
     workspace.ef_defined = True
     return workspace
Ejemplo n.º 8
0
 def setUpClass(cls):  # create (non-zero) test data
     sim_workspace = CreateSimulationWorkspace(Instrument='MAR',
                                               BinParams=[-10, 1, 10],
                                               UnitX='DeltaE',
                                               OutputWorkspace='simws')
     AddSampleLog(sim_workspace,
                  LogName='Ei',
                  LogText='3.',
                  LogType='Number')
     cls.workspace = ConvertToMD(InputWorkspace=sim_workspace,
                                 OutputWorkspace="convert_ws",
                                 QDimensions='|Q|',
                                 dEAnalysisMode='Direct',
                                 MinValues='-10,0,0',
                                 MaxValues='10,6,500',
                                 SplitInto='50,50')
     cls.workspace = PixelWorkspace(cls.workspace, 'convert_ws')