def group(self, struct, **kwargs): """Method to retrieve data from SDB database to apsg.Group Args: struct: name of structure to retrieve Keyword Args: sites: name or list of names of sites to retrieve from units: name or list of names of units to retrieve from tags: tag or list of tags to retrieve Example: >>> g = db.group('L2', units=['HG', 'MG'], tags='bos') """ dtsel = self._make_select(structs=struct, **kwargs) sel = self.execsql(dtsel) if sel: if self.is_planar(struct): res = Group( [Fol(el["azimuth"], el["inclination"]) for el in sel], name=struct, ) else: res = Group( [Lin(el["azimuth"], el["inclination"]) for el in sel], name=struct, ) return res else: raise ValueError("No structures found using provided criteria.")
def eigenvects(self): """ Returns Group of three eigenvectors represented as ``Vec3`` """ return Group([Vec3(self.vects.T[0]), Vec3(self.vects.T[1]), Vec3(self.vects.T[2])])
def eigenvects(self): """ Return ```Group``` of principal eigenvectors as ``Vec3`` objects. """ U, _, _ = np.linalg.svd(self) return Group([Vec3(U.T[0]), Vec3(U.T[1]), Vec3(U.T[2])])
def pca(self, kind='geo', origin=False): data = getattr(self, kind) if origin: data.append(Vec3([0, 0, 0])) r = data.R / len(data) dv = Group([v - r for v in data]) ot = dv.ortensor pca = ot.eigenvects[0] if pca.angle(r) > 90: pca = -pca mad = np.degrees(np.arctan(np.sqrt((ot.E2 + ot.E3) / ot.E1))) return pca, mad
def eigenvects(self) -> Group: """ Return the group of eigenvectors. If scaled property is `True` their length is scaled by eigenvalues, otherwise unit length. """ if self.scaled: e1, e2, e3 = self.E1, self.E2, self.E3 else: e1 = e2 = e3 = 1.0 return Group([ e1 * Vec3(self._evects[0]), e2 * Vec3(self._evects[1]), e3 * Vec3(self._evects[2]), ])
def group(self, structs, **kwargs): """Method to retrieve data from SDB database to apsg.Group Args: structs: structure or list of structures to retrieve Keyword Args: sites: name or list of names of sites to retrieve from units: name or list of names of units to retrieve from tags: tag or list of tags to retrieve labels: if True return also list of sites. Default False """ labels = kwargs.pop('labels', False) dtsel = self._make_select(structs=structs, **kwargs) sel = self.execsql(dtsel) if sel: if isinstance(structs, str): name = structs else: name = ' '.join(structs) if self.is_planar(structs): res = Group( [Fol(el["azimuth"], el["inclination"]) for el in sel], name=name, ) else: res = Group( [Lin(el["azimuth"], el["inclination"]) for el in sel], name=name, ) if labels: return res, [el["name"] for el in sel] else: return res else: raise ValueError("No structures found using provided criteria.")
def getfols(self): """get Group of Fol by mouse""" pts = plt.ginput(0, mouse_add=1, mouse_pop=2, mouse_stop=3) return Group([Fol(*getfdd(x, y)) for x, y in pts])
def getlins(self): """get Group of Lin by mouse""" pts = plt.ginput(0, mouse_add=1, mouse_pop=2, mouse_stop=3) return Group([Lin(*getldd(x, y)) for x, y in pts])
def V(self): "Returns `Group` of vectors in sample (or core) coordinates system" return Group([v / self.volume for v in self._vectors], name=self.name)