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", [])
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)