def setup_method(self): dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f']) self.grp = ScannableGroup('grp', dummy) self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) self.energyhw = MockMotor() self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw)
class TestGdaHardwareMonitor(unittest.TestCase): def setUp(self): dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f']) self.grp = ScannableGroup('grp', dummy) self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) self.energyhw = MockMotor() self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw) def test__init__Andget_axes_names(self): self.assertEquals(self.hardware.get_axes_names(), ('a', 'b', 'c', 'd', 'e', 'f')) def testGetPosition(self): self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6)) self.assertEqual(self.hardware.get_position(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) def testGetEnergy(self): self.energyhw.asynchronousMoveTo(1.0) self.assertEqual(self.hardware.get_energy(), 1.0) def testGetWavelength(self): self.energyhw.asynchronousMoveTo(1.0) self.assertEqual(self.hardware.get_wavelength(), 12.39842 / 1.0)
def swithMotors(sax, say, saz, sath, sachi, saphi, diodedelta, specm5tth): import __main__ __main__.xyz_eta = ScannableGroup('xyz_eta', [sax, say, saz]) # @UndefinedVariable #update support for i21 non-concentric rotation motions __main__.sa = I21SampleStage('sa', sath, sachi, saphi,__main__.xyz_eta) # @UndefinedVariable __main__.tp_phi = sa.tp_phi_scannable __main__.tp_lab = I21TPLab('tp_lab', __main__.sa) # @UndefinedVariable __main__.tp_labx = __main__.tp_lab.tp_labx # @UndefinedVariable __main__.tp_laby = __main__.tp_lab.tp_laby # @UndefinedVariable __main__.tp_labz = __main__.tp_lab.tp_labz # @UndefinedVariable ### update Wrap i21 names to get diffcalc names _fourc = I21DiffractometerStage('_fourc', diodedelta, __main__.sa) # @UndefinedVariable __main__.delta = _fourc.delta __main__.eta = _fourc.eta __main__.chi = _fourc.chi __main__.phi = _fourc.phi #update diffcalc objects __main__.settings.hardware = ScannableHardwareAdapter(_fourc, __main__.en, ESMTGKeV) # @UndefinedVariable __main__.settings.geometry = FourCircleI21(beamline_axes_transform=beamline_axes_transform) # @UndefinedVariable __main__.settings.energy_scannable = __main__.en # @UndefinedVariable __main__.settings.axes_scannable_group= _fourc __main__.settings.energy_scannable_multiplier_to_get_KeV = ESMTGKeV __main__.fourc=DiffractometerScannableGroup('fourc', _dc, _fourc) __main__.hkl = Hkl('hkl', _fourc, _dc) __main__.h, __main__.k, __main__.l = hkl.h, hkl.k, hkl.l from diffcalc.gdasupport.you import _virtual_angles from diffcalc.gdasupport.scannable.simulation import SimulatedCrystalCounter from diffcalc.gdasupport.scannable.wavelength import Wavelength __main__.hklverbose = Hkl('hklverbose', _fourc, _dc, _virtual_angles) __main__.wl = Wavelength('wl',__main__.en,ESMTGKeV) # @UndefinedVariable __main__.ct = SimulatedCrystalCounter('ct', _fourc, __main__.settings.geometry,__main__.wl) # @UndefinedVariable #update scannales: fourc_vessel & hkl_vessel' _fourc_vessel = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_vessel', m5tth, sa) __main__.fourc_vessel = DiffractometerScannableGroup('fourc_vessel', _dc, _fourc_vessel) __main__.hkl_vessel = Hkl('hkl_vessel', _fourc_vessel, _dc) __main__.h_vessel, __main__.k_vessel, __main__.l_vessel = hkl_vessel.h, hkl_vessel.k, hkl_vessel.l #Update scannables: fourc_lowq & hkl_lowq' _fourc_lowq = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_lowq', m5tth, sa,delta_offset=LOWQ_OFFSET_ADDED_TO_DELTA_WHEN_READING) __main__.fourc_lowq = DiffractometerScannableGroup('fourc_lowq', _dc, _fourc_lowq) __main__.hkl_lowq = Hkl('hkl_lowq', _fourc_lowq, _dc) __main__.h_lowq, __main__.k_lowq, __main__.l_lowq = hkl_lowq.h, hkl_lowq.k, hkl_lowq.l #Update scannables: fourc_highq & hkl_highq' _fourc_highq = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_highq', m5tth, sa,delta_offset=highq_OFFSET_ADDED_TO_DELTA_WHEN_READING) __main__.fourc_highq = DiffractometerScannableGroup('fourc_highq', _dc, _fourc_highq) __main__.hkl_highq = Hkl('hkl_highq', _fourc_highq, _dc) __main__.h_highq, __main__.k_highq, __main__.l_highq = hkl_highq.h, hkl_highq.k, hkl_highq.l #Update scannables: fourc_diode & hkl_diode' _fourc_diode = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_diode', delta, sa) __main__.fourc_diode = DiffractometerScannableGroup('fourc_diode', _dc, _fourc_diode) __main__.hkl_diode = Hkl('hkl_diode', _fourc_diode, _dc) __main__.h_diode, __main__.k_diode, __main__.l_diode = hkl_diode.h, hkl_diode.k, hkl_diode.l
def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp)
def setup_method(self): class BadMockAngleCalculator: def angles_to_hkl(self, pos): raise Exception("Problem") dummy = createDummyAxes( ['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) self.group = ScannableGroup('grp', dummy) self.group.configure() self.sg = DiffractometerScannableGroup('sixc', BadMockAngleCalculator(), self.group)
class TestGdaHardwareMonitor(object): def setup_method(self): dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f']) self.grp = ScannableGroup('grp', dummy) self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) self.energyhw = MockMotor() self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw) def test__init__Andget_axes_names(self): assert self.hardware.get_axes_names() == ('a', 'b', 'c', 'd', 'e', 'f') def testGetPosition(self): self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6)) assert self.hardware.get_position() == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] def testGetEnergy(self): self.energyhw.asynchronousMoveTo(1.0) assert self.hardware.get_energy() == 1.0 def testGetWavelength(self): self.energyhw.asynchronousMoveTo(1.0) assert self.hardware.get_wavelength() == 12.39842 / 1.0 def testLowerLimitSetAndGet(self): self.hardware.set_lower_limit('a', -1) self.hardware.set_lower_limit('b', -2) self.hardware.set_lower_limit('c', -3) with pytest.raises(DiffcalcException): self.hardware.set_lower_limit('not an angle', 1) self.hardware.set_lower_limit('d', None) print "Should print WARNING:" self.hardware.set_lower_limit('d', None) assert self.hardware.get_lower_limit('a') == -1 assert self.hardware.get_lower_limit('c') == -3 def testUpperLimitSetAndGet(self): self.hardware.set_upper_limit('a', 1) self.hardware.set_upper_limit('b', 2) self.hardware.set_upper_limit('c', 3) with pytest.raises(DiffcalcException): self.hardware.set_upper_limit('not an angle', 1) self.hardware.set_upper_limit('d', None) print "Should print WARNING:" self.hardware.set_upper_limit('d', None) assert self.hardware.get_upper_limit('a') == 1 assert self.hardware.get_upper_limit('c') == 3
class TestDiffractometerScannableGroupWithFailingAngleCalculator(object): def setup_method(self): class BadMockAngleCalculator: def angles_to_hkl(self, pos): raise Exception("Problem") dummy = createDummyAxes(['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) self.group = ScannableGroup('grp', dummy) self.group.configure() self.sg = DiffractometerScannableGroup( 'sixc', BadMockAngleCalculator(), self.group) def testGetPosition(self): self.sg.getPosition() def testSimulateMoveTo(self): assert (self.sg.simulateMoveTo([1., 2., 3., 4., 5., 6.]) == "Error: Problem")
def setup_method(self): class BadMockAngleCalculator: def angles_to_hkl(self, pos): raise Exception("Problem") dummy = createDummyAxes(['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) self.group = ScannableGroup('grp', dummy) self.group.configure() self.sg = DiffractometerScannableGroup( 'sixc', BadMockAngleCalculator(), self.group)
class TestDiffractometerScannableGroupWithFailingAngleCalculator(object): def setup_method(self): class BadMockAngleCalculator: def angles_to_hkl(self, pos): raise Exception("Problem") dummy = createDummyAxes( ['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) self.group = ScannableGroup('grp', dummy) self.group.configure() self.sg = DiffractometerScannableGroup('sixc', BadMockAngleCalculator(), self.group) def testGetPosition(self): self.sg.getPosition() def testSimulateMoveTo(self): assert (self.sg.simulateMoveTo([1., 2., 3., 4., 5., 6.]) == "Error: Problem")
def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup( 'sixc', MockDiffcalc(6), self.grp)
def setup_method(self): class BadMockAngleCalculator: def angles_to_hkl(self, pos): raise Exception("Problem in angles_to_hkl") dummy = createDummyAxes(['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) self.group = ScannableGroup('grp', dummy) self.SixCircleGammaOnArmGeometry = DiffractometerScannableGroup( 'SixCircleGammaOnArmGeometry', MockDiffcalc(6), self.group) self.hkl = Hkl('hkl', self.SixCircleGammaOnArmGeometry, BadMockAngleCalculator())
class TestGdaHardwareMonitor(object): def setup_method(self): dummy = createDummyAxes(['a', 'b', 'c', 'd', 'e', 'f']) self.grp = ScannableGroup('grp', dummy) self.diffhw = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) self.energyhw = MockMotor() self.hardware = ScannableHardwareAdapter(self.diffhw, self.energyhw) def test__init__Andget_axes_names(self): assert self.hardware.get_axes_names() == ('a', 'b', 'c', 'd', 'e', 'f') def testGetPosition(self): self.diffhw.asynchronousMoveTo((1, 2, 3, 4, 5, 6)) assert self.hardware.get_position() == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] def testGetEnergy(self): self.energyhw.asynchronousMoveTo(1.0) assert self.hardware.get_energy() == 1.0 def testGetWavelength(self): self.energyhw.asynchronousMoveTo(1.0) assert self.hardware.get_wavelength() == 12.39842 / 1.0
def createDiffcalcAndScannables(self): self.en = DummyPD('en') dummy = createDummyAxes(['delta', 'omega', 'chi', 'phi']) scannableGroup = ScannableGroup('fourcgrp', dummy) self.fourc = DiffractometerScannableGroup('fourc', None, scannableGroup) settings.hardware = ScannableHardwareAdapter(self.fourc, self.en) settings.geometry = Fourc() settings.ubcalc_persister = UbCalculationNonPersister() from diffcalc.dc import dcvlieg as dc reload(dc) self.dc = dc self.fourc.diffcalc = self.dc self.hkl = Hkl('hkl', self.fourc, self.dc)
def testSimWithHklAndSixc(self): dummyAxes = createDummyAxes( ['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) dummySixcScannableGroup = ScannableGroup('sixcgrp', dummyAxes) sixcdevice = DiffractometerScannableGroup( 'SixCircleGammaOnArmGeometry', self.dc, dummySixcScannableGroup) hkldevice = Hkl('hkl', sixcdevice, self.dc) with pytest.raises(TypeError): sim() with pytest.raises(TypeError): sim(hkldevice) with pytest.raises(TypeError): sim(hkldevice, 1, 2, 3) with pytest.raises(TypeError): sim('not a proper scannable', 1) with pytest.raises(TypeError): sim(hkldevice, (1, 2, 'not a number')) with pytest.raises(TypeError): sim(hkldevice, 1) with pytest.raises(ValueError): sim(hkldevice, (1, 2, 3, 4)) s = self.sess c = self.calc # setup session info self.dc.newub(s.name) self.dc.setlat(s.name, *s.lattice) r = s.ref1 self.dc.addref([r.h, r.k, r.l], r.pos.totuple(), r.energy, r.tag) r = s.ref2 self.dc.addref([r.h, r.k, r.l], r.pos.totuple(), r.energy, r.tag) self.dc.calcub() # check the ubcalculation is okay before continuing # (useful to check for typos!) mneq_(self.dc.ubcalc.UB, (matrix(s.umatrix) * (matrix(s.bmatrix))), 4, note="wrong UB matrix after calculating U") self.hardware.energy = c.energy # Test each hkl/position pair for idx in range(len(c.hklList)): hkl = c.hklList[idx] pos = c.posList[idx].totuple() sim(sixcdevice, pos) sim(hkldevice, hkl)
def setup_method(self): self.en = DummyPD('en') dummy = createDummyAxes(['alpha', 'delta', 'omega', 'chi', 'phi']) group = ScannableGroup('fivecgrp', dummy) self.fivec = DiffractometerScannableGroup('fivec', None, group) settings.hardware = ScannableHardwareAdapter(self.fivec, self.en) settings.geometry = Fivec() settings.ubcalc_persister = UbCalculationNonPersister() from diffcalc.dc import dcvlieg as dc reload(dc) self.dc = dc self.fivec.diffcalc = self.dc self.hkl = Hkl('hkl', self.fivec, self.dc) self.hklverbose = Hkl('hkl', self.fivec, self.dc, ('theta', '2theta', 'Bin', 'Bout', 'azimuth')) self.orient()
def createDiffcalcAndScannables(self, geometryClass): self.en = DummyPD('en') dummy = createDummyAxes( ['alpha', 'delta', 'gamma', 'omega', 'chi', 'phi']) group = ScannableGroup('sixcgrp', dummy) self.sixc = DiffractometerScannableGroup('sixc', None, group) self.hardware = DummyHardwareAdapter( ('alpha', 'delta', 'gamma', 'omega', 'chi', 'phi')) settings.hardware = ScannableHardwareAdapter(self.sixc, self.en) settings.geometry = geometryClass() settings.ubcalc_persister = UbCalculationNonPersister() from diffcalc.dc import dcvlieg as dc reload(dc) self.dc = dc self.sixc.diffcalc = self.dc self.hkl = Hkl('hkl', self.sixc, self.dc)
def usesim(): # sample chamber print '- setting hkl ---> hkl_sim' print '- en ---> simenergy' global settings settings.hardware = _hw_sim settings.geometry = _tth_geometry settings.axes_scannable_group = _sc_sim setLimitsAndCuts(simdelta, simth, simchi, simphi) # Create diffractometer scannable import __main__ _diff_scn_name = _tth_geometry.name from diffcalc.dc import dcyou as _dc reload(_dc) lastub() _diff_scn = DiffractometerScannableGroup(_diff_scn_name, _dc, _sc_sim) __main__.hkl = hkl_sim __main__.h = hkl_sim.h __main__.k = hkl_sim.k __main__.l = hkl_sim.l __main__.fourc = _diff_scn from diffcalc.gdasupport.you import _virtual_angles __main__.hklverbose = Hkl('hklverbose', __main__.fourc, _dc, _virtual_angles) if GDA: __main__.en = simenergy __main__.wl = Wavelength('wl', __main__.en, ESMTGKeV) # @UndefinedVariable __main__.ct = SimulatedCrystalCounter( 'ct', __main__.fourc, settings.geometry, __main__.wl) # @UndefinedVariable # Custom scannables import startup.beamlinespecific.conic_scannables as _conic reload(_conic) __main__.conic_h = _conic.conic_h __main__.conic_k = _conic.conic_k __main__.conic_l = _conic.conic_l
def usedifftth(tp=None): # sample chamber print '- setting hkl ---> hkl_difftth' global settings if tp: settings.hardware = _hw_difftth_tp else: settings.hardware = _hw_difftth settings.geometry = _tth_geometry if tp: settings.axes_scannable_group = _sc_difftth_tp else: settings.axes_scannable_group = _sc_difftth # Create diffractometer scannable _diff_scn_name = _tth_geometry.name from diffcalc.dc import dcyou as _dc reload(_dc) lastub() if tp: _diff_scn = DiffractometerTPScannableGroup(_diff_scn_name, _dc, _sc_difftth_tp) else: _diff_scn = DiffractometerScannableGroup(_diff_scn_name, _dc, _sc_difftth) if tp: setLimitsAndCuts(difftth, th, ps_chi, ps_phi) elif GDA: setLimitsAndCuts(difftth, th, chi, phi) else: setLimitsAndCuts(delta, th, chi, phi) import __main__ if tp: __main__.hkl = hkl_difftth_tp __main__.h = hkl_difftth_tp.h __main__.k = hkl_difftth_tp.k __main__.l = hkl_difftth_tp.l else: __main__.hkl = hkl_difftth __main__.h = hkl_difftth.h __main__.k = hkl_difftth.k __main__.l = hkl_difftth.l __main__.fourc = _diff_scn from diffcalc.gdasupport.you import _virtual_angles __main__.hklverbose = Hkl('hklverbose', __main__.fourc, _dc, _virtual_angles) if GDA: __main__.en = energy __main__.wl = Wavelength('wl', __main__.en, ESMTGKeV) # @UndefinedVariable __main__.ct = SimulatedCrystalCounter( 'ct', __main__.fourc, settings.geometry, __main__.wl) # @UndefinedVariable # Custom scannables import startup.beamlinespecific.conic_scannables as _conic reload(_conic) __main__.conic_h = _conic.conic_h __main__.conic_k = _conic.conic_k __main__.conic_l = _conic.conic_l
class TestDiffractometerScannableGroup(object): def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup( 'sixc', MockDiffcalc(6), self.grp) def testInit(self): assert list(self.sg.getPosition()) == [0., 0., 0., 0., 0., 0.] def testAsynchronousMoveTo(self): self.sg.asynchronousMoveTo([1, 2.0, 3, 4, 5, 6]) assert list(self.sg.getPosition()) == [1., 2., 3., 4., 5., 6.] def testAsynchronousMoveToWithNones(self): self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) self.sg.asynchronousMoveTo([None, None, 3.2, None, 5.2, None]) assert list(self.sg.getPosition()) == [1., 2., 3.2, 4., 5.2, 6.] def testGetPosition(self): #implicitely tested above pass def testWhereMoveTo(self): # just check for exceptions print self.sg.simulateMoveTo((1.23, 2, 3, 4, 5, 6)) def testIsBusy(self): assert not self.sg.isBusy() self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4, 5, 6]) assert self.sg.isBusy() self.b.makeNotBusy() assert self.sg.isBusy() self.a.makeNotBusy() self.c.makeNotBusy() self.d.makeNotBusy() self.e.makeNotBusy() self.f.makeNotBusy() assert not self.sg.isBusy() def testRepr(self): print self.sg.__repr__()
setLimitsAndCuts(delta, chi, th, phi) ### Create i21 bespoke secondary hkl devices # Warning: this breaks the encapsulation provided by the diffcalc.dc.you public # interface, and may be prone to breakage in future. print 'Creating i21 bespoke scannables:' from diffcalc.dc import dcyou as _dc from diffcalc.gdasupport.scannable.diffractometer import DiffractometerScannableGroup from diffcalc.gdasupport.scannable.hkl import Hkl print '- fourc_vessel & hkl_vessel' _fourc_vessel = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_vessel', m5tth, sa) fourc_vessel = DiffractometerScannableGroup('fourc_vessel', _dc, _fourc_vessel) hkl_vessel = Hkl('hkl_vessel', _fourc_vessel, _dc) h_vessel, k_vessel, l_vessel = hkl_vessel.h, hkl_vessel.k, hkl_vessel.l print '- fourc_lowq & hkl_lowq' LOWQ_OFFSET_ADDED_TO_DELTA_WHEN_READING = -8 _fourc_lowq = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_lowq', m5tth, sa,delta_offset=LOWQ_OFFSET_ADDED_TO_DELTA_WHEN_READING) fourc_lowq = DiffractometerScannableGroup('fourc_lowq', _dc, _fourc_lowq) hkl_lowq = Hkl('hkl_lowq', _fourc_lowq, _dc) h_lowq, k_lowq, l_lowq = hkl_lowq.h, hkl_lowq.k, hkl_lowq.l print '- fourc_highq & hkl_highq' highq_OFFSET_ADDED_TO_DELTA_WHEN_READING = 0 _fourc_highq = ScannableGroup('_fourc', (delta, th, chi, phi)) #I21DiffractometerStage('_fourc_highq', m5tth, sa,delta_offset=highq_OFFSET_ADDED_TO_DELTA_WHEN_READING) fourc_highq = DiffractometerScannableGroup('fourc_highq', _dc, _fourc_highq) hkl_highq = Hkl('hkl_highq', _fourc_highq, _dc)
setcut(phi, -180) print "Current hardware limits set to:" hardware() ### Create i21 bespoke secondary hkl devices # Warning: this breaks the encapsulation provided by the diffcalc.dc.you public # interface, and may be prone to breakage in future. print 'Creating i21 bespoke scannables:' from diffcalc.dc import dcyou as _dc from diffcalc.gdasupport.scannable.diffractometer import DiffractometerScannableGroup from diffcalc.gdasupport.scannable.hkl import Hkl print '- fourc_vessel & hkl_vessel' _fourc_vessel = I21DiffractometerStage('_fourc_vessel', m5tth, sa, chi_offset = 90) fourc_vessel = DiffractometerScannableGroup('fourc_vessel', _dc, _fourc_vessel) fourc_vessel.hint_generator = _fourc_vessel.get_hints hkl_vessel = Hkl('hkl_vessel', _fourc_vessel, _dc) h_vessel, k_vessel, l_vessel = hkl_vessel.h, hkl_vessel.k, hkl_vessel.l print '- fourc_lowq & hkl_lowq' LOWQ_OFFSET_ADDED_TO_DELTA_WHEN_READING = -8 _fourc_lowq = I21DiffractometerStage( '_fourc_lowq', m5tth, sa, chi_offset=90, delta_offset=LOWQ_OFFSET_ADDED_TO_DELTA_WHEN_READING) fourc_lowq = DiffractometerScannableGroup('fourc_lowq', _dc, _fourc_lowq) fourc_lowq.hint_generator = _fourc_lowq.get_hints hkl_lowq = Hkl('hkl_lowq', _fourc_lowq, _dc) h_lowq, k_lowq, l_lowq = hkl_lowq.h, hkl_lowq.k, hkl_lowq.l print '- fourc_highq & hkl_highq'
def scan(*args): """ scan scn start stop step {scn {target}} {det t} """ return _scan(*args) from diffcalc.gdasupport.scannable.sim import sim # @UnusedImport _scn_group = settings.axes_scannable_group _diff_scn_name = settings.geometry.name # @UndefinedVariable _energy_scannable = settings.energy_scannable # Create diffractometer scannable _diff_scn = DiffractometerScannableGroup(_diff_scn_name, _dc, _scn_group) globals()[_diff_scn_name] = _diff_scn # Create hkl scannables hkl = Hkl('hkl', _scn_group, _dc) h = hkl.h k = hkl.k l = hkl.l hkloffset = HklOffset('hkloffset', _scn_group, _dc) h_offset = hkloffset.h k_offset = hkloffset.k l_offset = hkloffset.l pol_offset = hkloffset.polar az_offset = hkloffset.azimuthal
def test__init__(self): sg = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp, self.mock_driver) assert sg.slave_driver == self.mock_driver
class TestDiffractometerScannableGroup(object): def setup_method(self): self.a = MockMotor() self.b = MockMotor() self.c = MockMotor() self.d = MockMotor() self.e = MockMotor() self.f = MockMotor() self.grp = ScannableGroup( 'grp', [self.a, self.b, self.c, self.d, self.e, self.f]) self.grp.configure() self.sg = DiffractometerScannableGroup('sixc', MockDiffcalc(6), self.grp) def testInit(self): assert list(self.sg.getPosition()) == [0., 0., 0., 0., 0., 0.] def testAsynchronousMoveTo(self): self.sg.asynchronousMoveTo([1, 2.0, 3, 4, 5, 6]) assert list(self.sg.getPosition()) == [1., 2., 3., 4., 5., 6.] def testAsynchronousMoveToWithNones(self): self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) self.sg.asynchronousMoveTo([None, None, 3.2, None, 5.2, None]) assert list(self.sg.getPosition()) == [1., 2., 3.2, 4., 5.2, 6.] def testGetPosition(self): #implicitely tested above pass def testWhereMoveTo(self): # just check for exceptions print self.sg.simulateMoveTo((1.23, 2, 3, 4, 5, 6)) def testIsBusy(self): assert not self.sg.isBusy() self.sg.asynchronousMoveTo([1.0, 2.0, 3.0, 4, 5, 6]) assert self.sg.isBusy() self.b.makeNotBusy() assert self.sg.isBusy() self.a.makeNotBusy() self.c.makeNotBusy() self.d.makeNotBusy() self.e.makeNotBusy() self.f.makeNotBusy() assert not self.sg.isBusy() def testRepr(self): print self.sg.__repr__()