Пример #1
0
    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.")
Пример #2
0
 def __init__(self, **kwargs):
     self.site = kwargs.get("site", "Default")
     self.name = kwargs.get("name", "Default")
     self.filename = kwargs.get("filename", None)
     self.latitude = kwargs.get("latitude", None)
     self.longitude = kwargs.get("longitude", None)
     self.height = kwargs.get("height", None)
     self.rock = kwargs.get("rock", None)
     self.age = kwargs.get("age", None)
     self.formation = kwargs.get("formation", None)
     self.sref = kwargs.get("sref", Pair(180, 0, 180, 0))
     self.gref = kwargs.get("gref", Pair(180, 0, 180, 0))
     self.bedding = kwargs.get("bedding", Fol(0, 0))
     self.foldaxis = kwargs.get("foldaxis", Lin(0, 0))
     self.volume = kwargs.get("volume", 1.0)
     self.date = kwargs.get("date", datetime.now())
     self.steps = kwargs.get("steps", [])
     self.a95 = kwargs.get("a95", [])
     self.comments = kwargs.get("comments", [])
     self._vectors = kwargs.get("vectors", [])
Пример #3
0
    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.")
Пример #4
0
 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])
Пример #5
0
 def getfol(self):
     """get Fol by mouse click"""
     x, y = plt.ginput(1)[0]
     return Fol(*getfdd(x, y))
Пример #6
0
    def from_rs3(cls, filename):
        """Return ``Core`` instance generated from PMD file.

        Args:
          filename: Remasoft rs3 file

        """
        with open(filename, encoding="latin1") as f:
            d = f.read().splitlines()

        import io

        headspec = [
            [0, 9],
            [10, 19],
            [20, 29],
            [30, 40],
            [41, 50],
            [51, 65],
            [66, 70],
            [71, 73],
            [74, 79],
            [80, 85],
            [86, 91],
            [92, 97],
            [98, 103],
            [104, 109],
            [110, 112],
            [113, 115],
            [116, 118],
            [119, 121],
            [122, 126],
        ]
        bodyspec = [
            [0, 2],
            [3, 13],
            [14, 27],
            [28, 33],
            [34, 39],
            [40, 45],
            [46, 51],
            [52, 57],
            [58, 63],
            [64, 69],
            [70, 75],
            [76, 81],
            [82, 95],
            [96, 105],
            [106, 115],
            [116, 126],
        ]

        head = pd.read_fwf(io.StringIO('\n'.join(d[:2])), colspecs=headspec)
        body = pd.read_fwf(io.StringIO('\n'.join(d[2:])), colspecs=bodyspec)

        data = {}
        vline = d[1]
        data["site"] = head['Site'][0] if not pd.isna(head['Site'][0]) else ''
        data["filename"] = filename
        data["name"] = head['Name'][0] if not pd.isna(head['Name'][0]) else ''
        data["longitude"] = (float(head['Longitude'][0])
                             if not pd.isna(head['Longitude'][0]) else None)
        data["latitude"] = (float(head['Latitude'][0])
                            if not pd.isna(head['Latitude'][0]) else None)
        data["height"] = (float(head['Height'][0])
                          if not pd.isna(head['Height'][0]) else None)
        data["rock"] = head['Rock'][0] if not pd.isna(head['Rock'][0]) else ''
        data["age"] = head['Age'][0] if not pd.isna(head['Age'][0]) else ''
        data["formation"] = head['Fm'][0] if not pd.isna(head['Fm'][0]) else ''
        data["sref"] = Pair(180, 0, 180, 0)
        data["gref"] = Pair(
            float(head['SDec'][0]),
            float(head['SInc'][0]),
            float(head['SDec'][0]),
            float(head['SInc'][0]),
        )
        data["bedding"] = (Fol(float(head['BDec'][0]), float(head['BInc'][0]))
                           if not pd.isna(head['BDec'][0])
                           and not pd.isna(head['BInc'][0]) else None)
        data["foldaxis"] = (Lin(float(head['FDec'][0]), float(head['FInc'][0]))
                            if not pd.isna(head['FDec'][0])
                            and not pd.isna(head['FInc'][0]) else None)
        data["date"] = datetime.now()
        #ix = (body.iloc[:, 0] == 'T') | (body.iloc[:, 0] == 'N')
        ix = body.iloc[:, 0] != 'C'
        data["steps"] = body[ix].iloc[:, 1].to_list()
        data["comments"] = body[ix]['Note'].to_list()
        data["a95"] = body[ix]['Prec'].to_list()
        data["vectors"] = []
        for n, r in body[ix].iterrows():
            data["vectors"].append(r['M[A/m]'] * Vec3(r['Dsp'], r['Isp']))
        return cls(**data)
Пример #7
0
 def bedding(self):
     return Fol(self.strike + 90, self.dip)
Пример #8
0
 def getfol(self):
     """Get Fol instance by mouse click."""
     x, y = plt.ginput(1)[0]
     return Fol(*getfdd(x, y))