コード例 #1
0
    def runTest(self):
        HelperTestingClass.__init__(self)
        limits = (-10.0, 10.0, -9.0, 9.0)
        ws_nonrotho = CreateMDWorkspace(
            Dimensions=3,
            Extents=','.join([str(lim) for lim in limits]) + ',-8,8',
            Names='A,B,C',
            Units='r.l.u.,r.l.u.,r.l.u.',
            Frames='HKL,HKL,HKL')
        expt_info_nonortho = CreateSampleWorkspace()
        ws_nonrotho.addExperimentInfo(expt_info_nonortho)
        SetUB(ws_nonrotho, 1, 1, 2, 90, 90, 120)
        pres = SliceViewer(ws_nonrotho)

        # assert limits of orthog
        limits_orthog = pres.view.data_view.get_axes_limits()
        self.assertEqual(limits_orthog[0], limits[0:2])
        self.assertEqual(limits_orthog[1], limits[2:])

        # set nonorthog view and retrieve new limits
        pres.nonorthogonal_axes(True)
        limits_nonorthog = pres.view.data_view.get_axes_limits()
        self.assertAlmostEqual(limits_nonorthog[0][0], -19, delta=1e-5)
        self.assertAlmostEqual(limits_nonorthog[0][1], 19, delta=1e-5)
        self.assertEqual(limits_nonorthog[1], limits[2:])

        pres.view.close()
コード例 #2
0
    def test_model_MD(self):
        ws1 = LoadEventNexus("CNCS_7860", MetaDataOnly=True)
        ws2 = LoadEventNexus("VIS_19351", MetaDataOnly=True)
        md = CreateMDWorkspace(Dimensions=1, Extents='-1,1', Names='A', Units='U')
        md.addExperimentInfo(ws1)
        md.addExperimentInfo(ws2)
        model = SampleLogsModel(md)

        self.assertEqual(model.get_exp(), 0)
        self.assertEqual(model.get_name(), 'md')
        self.assertEqual(model.getNumExperimentInfo(), 2)

        values = model.get_log_display_values("duration")
        self.assertEqual(values[0], "duration")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], 148.0)
        self.assertEqual(values[3], "second")

        # Change exp
        model.set_exp(1)
        self.assertEqual(model.get_exp(), 1)
        values = model.get_log_display_values("duration")
        self.assertEqual(values[0], "duration")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], 4.616606712341309)
        self.assertEqual(values[3], "second")
コード例 #3
0
    def test_model_MD(self):
        ws1 = Load("ILL/D22/192068.nxs")
        ws2 = Load("ENGINX00228061")
        md = CreateMDWorkspace(Dimensions=1,
                               Extents='-1,1',
                               Names='A',
                               Units='U')
        md.addExperimentInfo(ws1)
        md.addExperimentInfo(ws2)
        model = SampleLogsModel(md)

        self.assertEqual(model.get_exp(), 0)
        self.assertEqual(model.get_name(), 'md')
        self.assertEqual(model.getNumExperimentInfo(), 2)

        values = model.get_log_display_values("duration")
        self.assertEqual(values[0], "duration")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], "120.0")
        self.assertEqual(values[3], "Sec")

        # Change exp
        model.set_exp(1)
        self.assertEqual(model.get_exp(), 1)
        values = model.get_log_display_values("rb_proposal")
        self.assertEqual(values[0], "rb_proposal")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], "1455001")
        self.assertEqual(values[3], "")
コード例 #4
0
    def test_model_MD(self):
        ws1 = LoadEventNexus("CNCS_7860", MetaDataOnly=True)
        ws2 = LoadEventNexus("VIS_19351", MetaDataOnly=True)
        md = CreateMDWorkspace(Dimensions=1,
                               Extents='-1,1',
                               Names='A',
                               Units='U')
        md.addExperimentInfo(ws1)
        md.addExperimentInfo(ws2)
        model = SampleLogsModel(md)

        self.assertEqual(model.get_exp(), 0)
        self.assertEqual(model.get_name(), 'md')
        self.assertEqual(model.getNumExperimentInfo(), 2)

        values = model.get_log_display_values("duration")
        self.assertEqual(values[0], "duration")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], 148.0)
        self.assertEqual(values[3], "second")

        # Change exp
        model.set_exp(1)
        self.assertEqual(model.get_exp(), 1)
        values = model.get_log_display_values("duration")
        self.assertEqual(values[0], "duration")
        self.assertEqual(values[1], "number")
        self.assertEqual(values[2], 4.616606712341309)
        self.assertEqual(values[3], "second")
コード例 #5
0
def create_hkl_ws():
    hkl_ws = CreateMDWorkspace(Dimensions=3,
                               Extents='-10,10,-9,9,-8,8',
                               Names='A,B,C',
                               Units='r.l.u.,r.l.u.,r.l.u.',
                               Frames='HKL,HKL,HKL',
                               OutputWorkspace='hkl_ws')
    expt_info = CreateSampleWorkspace()
    hkl_ws.addExperimentInfo(expt_info)
    SetUB(hkl_ws, 1, 1, 1, 90, 90, 90)
    return hkl_ws
コード例 #6
0
    def runTest(self):
        HelperTestingClass.__init__(self)
        ws_4D = CreateMDWorkspace(Dimensions=4, Extents=[-1, 1, -1, 1, -1, 1, -1, 1], Names="E,H,K,L",
                                  Frames='General Frame,HKL,HKL,HKL', Units='meV,r.l.u.,r.l.u.,r.l.u.')
        expt_info_4D = CreateSampleWorkspace()
        ws_4D.addExperimentInfo(expt_info_4D)
        SetUB(ws_4D, 1, 1, 2, 90, 90, 120)
        pres = SliceViewer(ws_4D)
        self._qapp.sendPostedEvents()

        non_ortho_action = toolbar_actions(pres, [ToolItemText.NONORTHOGONAL_AXES])[0]
        self.assertFalse(non_ortho_action.isEnabled())

        pres.view.close()
コード例 #7
0
    def runTest(self):
        HelperTestingClass.__init__(self)
        ws_non_ortho = CreateMDWorkspace(Dimensions='3', Extents='-6,6,-4,4,-0.5,0.5',
                                         Names='H,K,L', Units='r.l.u.,r.l.u.,r.l.u.',
                                         Frames='HKL,HKL,HKL',
                                         SplitInto='2', SplitThreshold='50')
        expt_info_nonortho = CreateSampleWorkspace()
        ws_non_ortho.addExperimentInfo(expt_info_nonortho)
        SetUB(ws_non_ortho, 1, 1, 2, 90, 90, 120)
        pres = SliceViewer(ws_non_ortho)
        ClearUB(ws_non_ortho)

        self._qapp.sendPostedEvents()

        self.assert_no_toplevel_widgets()
        self.assertEqual(pres.ads_observer, None)
コード例 #8
0
ファイル: HB3AWorkflowTests.py プロジェクト: durong24/mantid
    def runTest(self):
        # Na Mn Cl3
        # R -3 H (148)
        # 6.592 6.592 18.585177 90 90 120

        # UB/wavelength from /HFIR/HB3A/IPTS-25470/shared/autoreduce/HB3A_exp0769_scan0040.nxs

        ub = np.array([[1.20297e-01, 1.70416e-01, 1.43000e-04],
                       [8.16000e-04, -8.16000e-04, 5.38040e-02],
                       [1.27324e-01, -4.05110e-02, -4.81000e-04]])

        wavelength = 1.553

        # create fake MDEventWorkspace, similar to what is expected from exp769 after loading with HB3AAdjustSampleNorm
        MD_Q_sample = CreateMDWorkspace(
            Dimensions='3',
            Extents='-5,5,-5,5,-5,5',
            Names='Q_sample_x,Q_sample_y,Q_sample_z',
            Units='rlu,rlu,rlu',
            Frames='QSample,QSample,QSample')

        inst = LoadEmptyInstrument(InstrumentName='HB3A')
        AddTimeSeriesLog(inst, 'omega', '2010-01-01T00:00:00', 0.)
        AddTimeSeriesLog(inst, 'phi', '2010-01-01T00:00:00', 0.)
        AddTimeSeriesLog(inst, 'chi', '2010-01-01T00:00:00', 0.)
        MD_Q_sample.addExperimentInfo(inst)
        SetUB(MD_Q_sample, UB=ub)

        ol = OrientedLattice()
        ol.setUB(ub)

        sg = SpaceGroupFactory.createSpaceGroup("R -3")

        hkl = []
        sat_hkl = []

        for h in range(0, 6):
            for k in range(0, 6):
                for l in range(0, 11):
                    if sg.isAllowedReflection([h, k, l]):
                        if h == k == l == 0:
                            continue
                        q = V3D(h, k, l)
                        q_sample = ol.qFromHKL(q)
                        if not np.any(np.array(q_sample) > 5):
                            hkl.append(q)
                            FakeMDEventData(
                                MD_Q_sample,
                                PeakParams='1000,{},{},{},0.05'.format(
                                    *q_sample))
                        # satellite peaks at 0,0,+1.5
                        q = V3D(h, k, l + 1.5)
                        q_sample = ol.qFromHKL(q)
                        if not np.any(np.array(q_sample) > 5):
                            sat_hkl.append(q)
                            FakeMDEventData(
                                MD_Q_sample,
                                PeakParams='100,{},{},{},0.02'.format(
                                    *q_sample))
                        # satellite peaks at 0,0,-1.5
                        q = V3D(h, k, l - 1.5)
                        q_sample = ol.qFromHKL(q)
                        if not np.any(np.array(q_sample) > 5):
                            sat_hkl.append(q)
                            FakeMDEventData(
                                MD_Q_sample,
                                PeakParams='100,{},{},{},0.02'.format(
                                    *q_sample))

        # Check that this fake workpsace gives us the expected UB
        peaks = FindPeaksMD(MD_Q_sample,
                            PeakDistanceThreshold=1,
                            OutputType='LeanElasticPeak')
        FindUBUsingFFT(peaks, MinD=5, MaxD=20)
        ShowPossibleCells(peaks)
        SelectCellOfType(peaks,
                         CellType='Rhombohedral',
                         Centering='R',
                         Apply=True)
        OptimizeLatticeForCellType(peaks, CellType='Hexagonal', Apply=True)
        found_ol = peaks.sample().getOrientedLattice()
        self.assertAlmostEqual(found_ol.a(), 6.592, places=2)
        self.assertAlmostEqual(found_ol.b(), 6.592, places=2)
        self.assertAlmostEqual(found_ol.c(), 18.585177, places=2)
        self.assertAlmostEqual(found_ol.alpha(), 90)
        self.assertAlmostEqual(found_ol.beta(), 90)
        self.assertAlmostEqual(found_ol.gamma(), 120)

        # nuclear peaks
        predict = HB3APredictPeaks(
            MD_Q_sample,
            Wavelength=wavelength,
            ReflectionCondition='Rhombohedrally centred, obverse',
            SatellitePeaks=True,
            IncludeIntegerHKL=True)
        predict = HB3AIntegratePeaks(MD_Q_sample, predict, 0.25)

        self.assertEqual(predict.getNumberPeaks(), 66)
        # check that the found peaks are expected
        for n in range(predict.getNumberPeaks()):
            HKL = predict.getPeak(n).getHKL()
            self.assertTrue(HKL in hkl, msg=f"Peak {n} with HKL={HKL}")

        # magnetic peaks
        satellites = HB3APredictPeaks(
            MD_Q_sample,
            Wavelength=wavelength,
            ReflectionCondition='Rhombohedrally centred, obverse',
            SatellitePeaks=True,
            ModVector1='0,0,1.5',
            MaxOrder=1,
            IncludeIntegerHKL=False)
        satellites = HB3AIntegratePeaks(MD_Q_sample, satellites, 0.1)

        self.assertEqual(satellites.getNumberPeaks(), 80)
        # check that the found peaks are expected
        for n in range(satellites.getNumberPeaks()):
            HKL = satellites.getPeak(n).getHKL()
            self.assertTrue(HKL in sat_hkl, msg=f"Peak {n} with HKL={HKL}")
コード例 #9
0
 def test_add_experiment_info(self):
     ws1 = CreateSampleWorkspace()
     md = CreateMDWorkspace(Dimensions=1, Extents='-1,1', Names='A', Units='U')
     md.addExperimentInfo(ws1)