def from_lattice(cls, lattice: OrientedLattice, x_proj: Sequence, y_proj: Sequence): """ :param lattice: An OrientedLattice object defining the unit cell :param x_proj: Projection vector of dimension associated with X coordinate :param y_proj: Projection vector of dimension associated with Y coordinate """ return cls(np.radians(lattice.recAngle(*x_proj, *y_proj)))
def test_create_nonorthogonal_transform_with_nonorthogonal_lattice_and_nonorthogonal_projections( self): lattice = OrientedLattice(1, 1, 2, 90, 90, 120.) x_proj, y_proj = (1, 0, 0), (1, 1, 0) transform = NonOrthogonalTransform.from_lattice( lattice, x_proj, y_proj) self.assertAlmostEqual(transform.angle, np.radians(lattice.recAngle(*x_proj, *y_proj)))
class Scisoft(): def __init__(self, point): # input : qe # output : qe+tas self.point = point self.qe_para() self.qe_limit() if self.limit_qe == 1: self.scisoft() if tp.ModeChoice.mode == 3: # add sample stick rotation s0 self.scisoft_premium() self.tas = tl.TasLimit(self.tas).point else: self.tas = tl.TasLimit(self.tas).point else: self.tas = pd.Series(data=None, index=tp.TasStatus.tas_status.index.drop( ['mts', 'sta', 'dtx']).copy()) self.tas['s1s2_limit'] = 1 self.tas['soft_limit'] = 1 self.tas['qe_limit'] = self.limit_qe # raise Exception as def qe_para(self): self.orien = OrientedLattice(*Alignment.para) self.para = Alignment.para self.hkl = [self.point.h, self.point.k, self.point.l] self.len = self.orien.qFromHKL(self.hkl).norm() self.mono = Monochromator(en=self.point.ei) self.ana = Monochromator(en=self.point.ef) def qe_limit(self): if self.mono.k + self.ana.k < self.len: self.limit_qe = tp.LimitNumb.Modenumb[tp.LimitNumb.mode] else: self.limit_qe = 1 def angdif(self): # angle between point and refa p0 = self.hkl p1 = Alignment.refa p2 = Alignment.refb theta1 = self.orien.recAngle(p0[0], p0[1], p0[2], p1.h, p1.k, p1.l) valcos1 = math.cos(math.radians(theta1)) theta2 = self.orien.recAngle(p0[0], p0[1], p0[2], p2.h, p2.k, p2.l) valcos2 = math.cos(math.radians(theta2)) if valcos1 * valcos2 == 0: self.angdiff = theta1 * (valcos1 + valcos2) else: self.angdiff = theta1 * abs(valcos2) / valcos2 def scisoft(self): s2_value = (self.mono.k**2 + self.ana.k**2 - self.len**2) / 2.0 / self.mono.k / self.ana.k self.tth = math.degrees(math.acos(s2_value)) self.angdif() s2 = self.tth * tp.TasConfig.tas_config.s s1dif = (self.mono.k**2 - self.ana.k**2 + self.len**2) / 2.0 / self.mono.k / self.len s1dif = math.acos(s1dif) s1dif = s1dif * 180 / math.pi s1 = -1 * Alignment.delta - self.angdiff - s1dif * tp.TasConfig.tas_config.s index = ['m1', 'm2', 's1', 's2', 'a1', 'a2'] self.tas = pd.Series(data=[ self.mono.tth / 2, self.mono.tth, s1, s2, self.ana.tth / 2, self.ana.tth ], index=index) def s1p_split(self): # s0 first : magnet # s1 first : crystat s1p = self.tas.s1 delta_s1p = s1p - (tp.TasStatus.tas_status.s1 + tp.TasStatus.tas_status.s0) if tp.SplitMode.mode == 0: s0 = tp.TasStatus.tas_status.s0 + delta_s1p s1 = tp.TasStatus.tas_status.s1 elif tp.SplitMode.mode == 1: s1 = tp.TasStatus.tas_status.s1 + delta_s1p s0 = tp.TasStatus.tas_status.s0 return pd.Series(data=[s0, s1], index=['s0', 's1']) def scisoft_premium(self): junk = self.tas addition = self.s1p_split() junk.pop('s1') self.tas = junk.append(addition)