def isorthogonal(self): deg90 = np.pi / 2 EPS_deg = 1e-5 if not FT.equal(self.alpha, deg90, EPS_deg): return False if not FT.equal(self.beta, deg90, EPS_deg): return False if not FT.equal(self.gamma, deg90, EPS_deg): return False return True
def iscubic(self): EPS_a = 1e-4 if not self.isorthogonal(): return False if not FT.equal(self.a, self.b, EPS_a): return False if not FT.equal(self.b, self.c, EPS_a): return False return True
def ishcp(self): deg90 = np.pi / 2 deg120 = np.deg2rad(120) EPS_deg = 1e-5 EPS_a = 1e-4 if not FT.equal(self.alpha, deg90, EPS_deg): return False if not FT.equal(self.beta, deg90, EPS_deg): return False if not FT.equal(self.gamma, deg120, EPS_deg): return False if not FT.equal(self.a, self.b, EPS_a): return False return True
def isdeplicate(peak, peaks, EPS=np.deg2rad(0.05)): if len(peaks) == 0: return False tth, gamma = peak.tth, peak.gamma for i, p in enumerate(peaks): if FT.equal(p.tth, tth, EPS) and FT.equal(p.gamma, gamma, EPS): if peak.intn > p.intn: logging.debug('%s is excluded because of %s' % (peak.index.str, p.index.str)) # print('%s is excluded because of %s'%(p.index.str, peak.index.str)) del peaks[i] else: logging.debug('%s is excluded because of %s' % (peak.index.str, p.index.str)) # print('%s is excluded because of %s'%(peak.index.str, p.index.str)) return True return False
def Gen_hklfamilies(hklrange=(10, 10, 10), lattice=None): ''' give an array of hklfamilies from given range of index NOTE: This is a GENERATOR ''' if lattice is None: hkls = Gen_hkls(hklrange=hklrange) for hkl in hkls: hklfamily = Familyindex(hkl) hklfamily.add_sons(hkl) yield hklfamily else: if lattice.LP.iscubic(): for h in range(hklrange[0] + 1): for k in range(min(h, hklrange[1]) + 1): for l in range(min(k, hklrange[2]) + 1): if h == 0 and k == 0 and l == 0: continue hklfamily = Familyindex((h, k, l), symmetry='cubic') if not lattice.isextinct(hklfamily): yield hklfamily elif lattice.LP.ishcp(): for h in range(hklrange[0] + 1): for k in range(min(h, hklrange[1]) + 1): for l in range(hklrange[2] + 1): if h == 0 and k == 0 and l == 0: continue hklfamily = Familyindex((h, k, l), symmetry='hcp') if not lattice.isextinct(hklfamily): yield hklfamily else: hkls = FT.tolist(Gen_hkls(hklrange=hklrange, lattice=None)) d_spacing = lattice.D_spacing(hkls) d_spacing_0 = 0 EPS_d = 1e-5 for hkl, d_spacing in sorted(zip(hkls, d_spacing), key=lambda x: x[1], reverse=True): if FT.equal(d_spacing, d_spacing_0, EPS_d): hklfamily.add_sons(hkl) else: yield hklfamily hklfamily = Familyindex(hkl) hklfamily.add_sons(hkl) yield hklfamily