def check_angle(self, name, expected, mu=-99, delta=99, nu=99,
                  eta=99, chi=99, phi=99):
     """All in degrees"""
     pos = YouPosition(mu, delta, nu, eta, chi, phi)
     pos.changeToRadians()
     calculated = self.calc._anglesToVirtualAngles(pos, None)[name] * TODEG
     assert_almost_equal(calculated, expected)
Exemplo n.º 2
0
 def check_angle(self,
                 name,
                 expected,
                 mu=-99,
                 delta=99,
                 nu=99,
                 eta=99,
                 chi=99,
                 phi=99):
     """All in degrees"""
     pos = YouPosition(mu, delta, nu, eta, chi, phi, unit='DEG')
     pos.changeToRadians()
     calculated = self.calc._anglesToVirtualAngles(pos, None)[name] * TODEG
     assert_almost_equal(calculated, expected)
Exemplo n.º 3
0
def decode_reflection(ref_dict, geometry):
    h, k, l = eval(ref_dict['hkl'])
    time = ref_dict['time'] and gt(ref_dict['time'])
    pos_tuple = eval(ref_dict['pos'])
    try:
        position = geometry.create_position(*pos_tuple)
    except AttributeError:
        position = YouPosition(*pos_tuple)
    return _Reflection(h, k, l, position, ref_dict['energy'], str(ref_dict['tag']), repr(time))
Exemplo n.º 4
0
 def physical_angles_to_internal_position(self, physical_angle_tuple):
     #    i16:   phi, chi, eta, mu, delta, gam
     # H. You:   mu, delta, nu, eta, chi, phi
     phi_phys, chi_phys, eta_phys, mu_phys, delta_phys, gam_phys = physical_angle_tuple
     return YouPosition(mu_phys,
                        delta_phys,
                        gam_phys,
                        eta_phys,
                        chi_phys,
                        phi_phys,
                        unit='DEG')
Exemplo n.º 5
0
 def edit_orientation(self, idx, h, k, l, x, y, z, position, tag, time):
     """num starts at 1"""
     try:
         num = self.get_tag_index(idx)
     except IndexError:
         raise DiffcalcException("There is no orientation " + repr(idx) +
                                 " to edit.")
     if type(position) in (list, tuple):
         position = YouPosition(*position)
     self._orientlist[num] = _Orientation(h, k, l, x, y, z, position, tag,
                                          time.__repr__())
Exemplo n.º 6
0
 def add_orientation(self, h, k, l, x, y, z, position, tag, time):
     """adds a crystal orientation
     """
     if type(position) in (list, tuple):
         try:
             position = self._geometry.create_position(*position)
         except AttributeError:
             position = YouPosition(*position)
     self._orientlist += [
         _Orientation(h, k, l, x, y, z, position, tag, time.__repr__())
     ]
Exemplo n.º 7
0
 def add_reflection(self, h, k, l, position, energy, tag, time):
     """adds a reflection, position in degrees
     """
     if type(position) in (list, tuple):
         try:
             position = self._geometry.create_position(*position)
         except AttributeError:
             position = YouPosition(*position)
     self._reflist += [
         _Reflection(h, k, l, position, energy, tag, time.__repr__())
     ]
Exemplo n.º 8
0
 def _create_position_pseudo_angles_pair(self, wavelength, mu, delta, nu, eta, chi, phi):
     # Create position
     position = YouPosition(mu, delta, nu, eta, chi, phi)
     position = _tidy_degenerate_solutions(position, self.constraints)
     if position.phi <= -pi + SMALL:
         position.phi += 2 * pi
     # pseudo angles calculated along the way were for the initial solution
     # and may be invalid for the chosen solution TODO: anglesToHkl need no
     # longer check the pseudo_angles as they will be generated with the
     # same function and it will prove nothing
     pseudo_angles = self._anglesToVirtualAngles(position, wavelength)
     return position, pseudo_angles
Exemplo n.º 9
0
    def _filter_valid_sample_solutions(
        self, delta, nu, possible_mu_eta_chi_phi_tuples, wavelength, hkl,
        ref_constraint_name, ref_constraint_value):
        mu_eta_chi_phi_tuples = []

        if logger.isEnabledFor(logging.DEBUG):
            msg = 'Checking all sample solutions (found to be within limits)\n'

        for mu, eta, chi, phi in possible_mu_eta_chi_phi_tuples:
            pos = YouPosition(mu, delta, nu, eta, chi, phi)
            hkl_actual = self._anglesToHkl(pos, wavelength)
            hkl_okay = sequence_ne(hkl, hkl_actual)

            if hkl_okay:
                virtual_angles = self._anglesToVirtualAngles(pos, wavelength)
                if not ref_constraint_name:
                    virtual_okay = True;
                elif ref_constraint_name == 'a_eq_b':
                    virtual_okay = ne(virtual_angles['alpha'],
                                      virtual_angles['beta'])
                else:
                    virtual_okay = ne(ref_constraint_value,
                                      virtual_angles[ref_constraint_name])
            else:
                virtual_okay = False
            if hkl_okay and virtual_okay:
                mu_eta_chi_phi_tuples.append((mu, eta, chi, phi))

            if logger.isEnabledFor(logging.DEBUG):
                msg += '*' if virtual_okay else '.'
                msg += '*' if hkl_okay else '.'
                msg += ('mu=% 7.10f, eta=% 7.10f, chi=% 7.10f, phi=% 7.10f' %
                        (mu * TODEG, eta * TODEG, chi * TODEG, phi * TODEG))
                if hkl_okay:
                    virtual_angles_in_deg = {}
                    for k in virtual_angles:
                        virtual_angles_in_deg[k] = virtual_angles[k] * TODEG
                    msg += (' --- psi=%(psi) 7.3f, tau=%(tau) 7.3f, '
                            'naz=%(naz) 7.3f, qaz=%(qaz) 7.3f, alpha=%(alpha) '
                            '7.3f, beta=%(beta) 7.3f' % virtual_angles_in_deg)
                msg += 'hkl= ' + str(hkl_actual)
                msg += '\n'
        if logger.isEnabledFor(logging.DEBUG):
            logger.debug(msg)
        return mu_eta_chi_phi_tuples
Exemplo n.º 10
0
 def physical_angles_to_internal_position(self, physical_angle_tuple):
     # mu, delta, nu, eta, chi, phi
     delta_phys, gam_phys, eta_phys, chi_phys, phi_phys = physical_angle_tuple
     return YouPosition(0, delta_phys, gam_phys, -eta_phys, -chi_phys,
                        -phi_phys, 'DEG')
Exemplo n.º 11
0
 def physical_angles_to_internal_position(self, physical_angle_tuple):
     delta_phys, gam_phys, eta_phys, phi_phys = physical_angle_tuple
     return YouPosition(0, delta_phys, gam_phys, eta_phys, -90, phi_phys,
                        'DEG')
def posFromI16sEuler(phi, chi, eta, mu, delta, gamma):
    return YouPosition(mu, delta, gamma, eta, chi, phi, unit='DEG')
 def test_psi5(self):
     #self.check_angle('psi', 0, mu=10, delta=.00000001,
     #nu=0, eta=0, chi=90, phi=0)
     pos = YouPosition(0, .00000001, 0, 0, 90, 0)
     pos.changeToRadians()
     assert isnan(self.calc._anglesToVirtualAngles(pos, None)['psi'])
Exemplo n.º 14
0
 def test_psi5(self):
     #self.check_angle('psi', 0, mu=10, delta=.00000001,
     #nu=0, eta=0, chi=90, phi=0)
     pos = YouPosition(0, 0, 0, 0, 90, 0, 'DEG')
     pos.changeToRadians()
     assert isnan(self.calc._anglesToVirtualAngles(pos, None)['psi'])
Exemplo n.º 15
0
 def test_psi0(self):
     pos = YouPosition(0, 0, 0, 0, 0, 0, 'DEG')
     assert isnan(self.calc._anglesToVirtualAngles(pos, None)['psi'])
Exemplo n.º 16
0
 def physical_angles_to_internal_position(self, physical_angle_tuple):
     #    i16:   phi, chi, eta, mu, delta, gam
     # H. You:   mu, delta, nu, eta, chi, phi
     phi, chi, eta, mu, delta, gam = physical_angle_tuple
     return YouPosition(mu, delta, gam, eta, chi, phi)