def _extractPos(self, hkle): ki = self._attached_mono.read(0) kf = self._attached_ana.read(0) if self.inelastic: if self.emode == 'FKI': kf = ki - hkle[3] else: ki = kf + hkle[3] ki = to_k(ki, self._attached_mono.unit) kf = to_k(kf, self._attached_ana.unit) qepos = tasQEPosition(ki, kf, hkle[0], hkle[1], hkle[2], 0) ub = session.experiment.sample.getUB() try: angpos = calcTasQAngles(ub, np.array(self.plane_normal), self.scattering_sense, 0, qepos) except RuntimeError as xx: raise InvalidValueError(xx) from None poslist = [('a3', angpos.a3), ('a4', angpos.sample_two_theta)] if self.inelastic: poslist.append(('mono', from_k(ki, self._attached_mono.unit))) poslist.append(('ana', from_k(kf, self._attached_ana.unit))) if self.out_of_plane: poslist.append(('sgu', angpos.sgu)) poslist.append(('sgl', angpos.sgl)) return poslist
def doUpdateUnit(self, value): if 'unit' not in self._params: # this is the initial update return if self._mode not in (MASTER, SIMULATION): # change limits only from the master copy, or in simulation mode return new_absmin = from_k(to_k(self.abslimits[0], self.unit), value) new_absmax = from_k(to_k(self.abslimits[1], self.unit), value) if new_absmin > new_absmax: new_absmin, new_absmax = new_absmax, new_absmin self._setROParam('abslimits', (new_absmin, new_absmax)) if self.userlimits != (0, 0): new_umin = from_k(to_k(self.userlimits[0], self.unit), value) new_umax = from_k(to_k(self.userlimits[1], self.unit), value) if new_umin > new_umax: new_umin, new_umax = new_umax, new_umin new_umin = max(new_umin, new_absmin) new_umax = min(new_umax, new_absmax) self.userlimits = (new_umin, new_umax) if 'target' in self._params and self.target and self.target != 'unknown': # this should be still within the limits self._setROParam('target', from_k(to_k(self.target, self.unit), value)) self.read(0)
def _convertPos(self, pos, wavelength=None): ki = pos[0] kf = pos[1] a = tasAngles(0, pos[2], pos[3], pos[5], pos[4], 0) ub = session.experiment.sample.getUB() q = calcTasQH(ub, a, ki, kf) en = from_k(ki, 'meV') - from_k(kf, 'meV') return q[0], q[1], q[2], en
def _movefoci(self, focmode, hfocuspars, vfocuspars): lam = from_k(to_k(self.target, self.unit), 'A') # get goalposition in A focusv, focush = self._attached_focusv, self._attached_focush if focmode == 'flat': if focusv: focusv.move(self.vfocusflat) if focush: focush.move(self.hfocusflat) elif focmode == 'horizontal': if focusv: focusv.move(self.vfocusflat) if focush: focush.move(self._calfocus(lam, hfocuspars)) elif focmode == 'vertical': if focusv: focusv.move(self._calfocus(lam, vfocuspars)) if focush: focush.move(self.hfocusflat) elif focmode == 'double': if focusv: focusv.move(self._calfocus(lam, vfocuspars)) if focush: focush.move(self._calfocus(lam, hfocuspars)) else: if self._focwarnings and (focusv or focush): self.log.warning('focus is in manual mode') self._focwarnings -= 1
def doReadPrecision(self): if not hasattr(self, 'scatteringsense'): # object not yet intialized return 0 # the precision depends on the angular precision of theta and twotheta val = self.read() if val == 0.0: return 0.0 lam = from_k(to_k(val, self.unit), 'A') dtheta = self._attached_theta.precision + \ self._attached_twotheta.precision dlambda = abs(2.0 * self.dvalue * cos(self._attached_twotheta.read() * pi / 360) * dtheta / 180 * pi) if self.unit == 'A-1': return 2 * pi / lam**2 * dlambda elif self.unit == 'meV': return 2 * ANG2MEV / lam**3 * dlambda elif self.unit == 'THz': return 2 * ANG2MEV / THZ2MEV / lam**3 * dlambda return dlambda
def doRead(self, maxage=0): # the scattering angle is deciding tt = self.scatteringsense * self._attached_twotheta.read(maxage) if tt == 0.0: return 0.0 return from_k(wavevector(self.dvalue, self.order, tt / 2.0), self.unit)
def _movefoci(self, focmode, hfocuspars, vfocuspars): focusv = self._attached_focusv if focusv: focusv.move( self._calfocus(from_k(to_k(self.target, self.unit), 'A'), vfocuspars))