def calc_tp_lab(tp_phi_tuple, eta, chi, phi, xyz_eta=[0, 0, 0]): tp_phi = matrix(tp_phi_tuple).T ETA = calcETA(eta * TORAD) CHI = calcCHI(chi * TORAD) PHI = calcPHI(phi * TORAD) xyz_eta = matrix(xyz_eta).T tp_lab = ETA * (xyz_eta + (CHI * PHI * tp_phi)) return list(tp_lab.T.tolist()[0])
def move_lab_origin_into_phi(chi, phi, xyz_eta_tuple): # the inverse of calc_tp_lab with tp_lab=0: CHI = calcCHI(chi * TORAD) PHI = calcPHI(phi * TORAD) xyz_eta = matrix(xyz_eta_tuple).T try: #work in IPython with numpy tp_phi = PHI.I * CHI.I * (-1.0 * xyz_eta) except: # work in GDA using jama_matrix_wrapper - definitely not nice tp_phi = PHI.I * CHI.I * (xyz_eta.__mul__(-1.0)) return list(tp_phi.T.tolist()[0])
def _calc_sample_angles_given_two_sample_and_reference( self, samp_constraints, psi, theta, q_phi, n_phi): """Available combinations: chi, phi, reference mu, eta, reference, chi=90, mu=0, reference """ N_phi = _calc_N(q_phi, n_phi) THETA = z_rotation(-theta) PSI = x_rotation(psi) if 'chi' in samp_constraints and 'phi' in samp_constraints: chi = samp_constraints['chi'] phi = samp_constraints['phi'] CHI = calcCHI(chi) PHI = calcPHI(phi) V = CHI * PHI * N_phi * PSI.T * THETA.T # (56) xi = atan2(-V[2, 0], V[2, 2]) eta = atan2(-V[0, 1], V[1, 1]) mu = atan2(-V[2, 1], sqrt(V[2, 2] ** 2 + V[2, 0] ** 2)) elif 'mu' in samp_constraints and 'eta' in samp_constraints: mu = samp_constraints['mu'] eta = samp_constraints['eta'] V = N_phi * PSI.T * THETA.T # (49) bot = sqrt(sin(eta) ** 2 * cos(mu) ** 2 + sin(mu) ** 2) chi_orig = (asin(-V[2, 1] / bot) - atan2(sin(mu), (sin(eta) * cos(mu)))) # (52) # Choose final chi solution here to obtain compatable xi and mu # TODO: This temporary solution works only for one case used on i07 # Return a list of possible solutions? if is_small(eta) and is_small(mu + pi / 2): for chi in _generate_transformed_values(chi_orig): if pi / 2 <= chi < pi: break else: chi = chi_orig a = sin(chi) * cos(eta) b = sin(chi) * sin(eta) * sin(mu) - cos(chi) * cos(mu) xi = atan2(V[2, 2] * a + V[2, 0] * b, V[2, 0] * a - V[2, 2] * b) # (54) a = sin(chi) * sin(mu) - cos(mu) * cos(chi) * sin(eta) b = cos(mu) * cos(eta) phi = atan2(V[1, 1] * a - V[0, 1] * b, V[0, 1] * a + V[1, 1] * b) # (55) # if is_small(mu+pi/2) and is_small(eta) and False: # phi_general = phi # # solved in extensions_to_yous_paper.wxm # phi = atan2(V[1, 1], V[0, 1]) # logger.info("phi = %.3f or %.3f (std)", # phi*TODEG, phi_general*TODEG ) elif 'chi' in samp_constraints and 'mu' in samp_constraints: # derived in extensions_to_yous_paper.wxm chi = samp_constraints['chi'] mu = samp_constraints['mu'] if not is_small(mu) and not is_small(chi - pi / 2): raise Exception('The fixed chi, mu, psi/alpha/beta modes only ' ' currently work with chi=90 and mu=0') V = N_phi * PSI.T * THETA.T eta = asin(-V[2, 1]) xi = atan2(V[2, 2], V[2, 0]) phi = -atan2(V[0, 1], V[1, 1]) else: raise DiffcalcException( 'No code yet to handle this combination of 2 sample ' 'constraints and one reference!:' + str(samp_constraints)) return xi, psi, mu, eta, chi, phi
def calcUB(self): CHI = calcCHI(self.chiMissmount * TORAD) PHI = calcPHI(self.phiMissmount * TORAD) self.UB = CHI * PHI * self.cut.B