From 90f2a2b41467e9b1f3a7e8a90e4bb7523e24f4ca Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Wed, 3 Jul 2024 16:02:04 +0930 Subject: [PATCH] feat: added ntgs converter --- .../converters/ntgs_converter.py | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/LoopDataConverter/converters/ntgs_converter.py b/LoopDataConverter/converters/ntgs_converter.py index 95c2ed8..b36cd9e 100644 --- a/LoopDataConverter/converters/ntgs_converter.py +++ b/LoopDataConverter/converters/ntgs_converter.py @@ -1,35 +1,69 @@ +# internal imports from .base_converter import BaseConverter +from ..utils import ( + convert_dipdir_terms, + convert_dip_terms, + convert_tightness_terms, + convert_displacement_terms, +) + +# external imports import pandas import numpy class NTGSConverter(BaseConverter): def __init__(self, data: pandas.DataFrame): - self.data = data + self.raw_data = data.copy() self._type_label = "NTGSConverter" + self._data = None def type(self): return self._type_label def convert_fold_map(self): - pass + # convert dip direction terms to degrees + self.raw_data["AxialPlaneDipDir"] = self.raw_data["AxialPlaneDipDir"].apply( + lambda x: convert_dipdir_terms(x) + ) + # convert dip terms to degrees + self.raw_data["AxialPlaneDip"] = self.raw_data["AxialPlaneDip"].apply( + lambda x: convert_dip_terms(x, type="fold") + ) + # convert tightness terms to degrees + self.raw_data["InterlimbAngle"] = self.raw_data["InterlimbAngle"].apply( + lambda x: convert_tightness_terms(x) + ) def convert_fault_map(self): - pass - - def convert_geology_map(self): - pass + # convert dip direction terms to degrees + self.raw_data["DipDirection"] = self.raw_data["DipDirection"].apply( + lambda x: convert_dipdir_terms(x) + ) + # convert dip terms to degrees + self.raw_data["Dip"] = self.raw_data["Dip"].apply( + lambda x: convert_dip_terms(x, type="fault") + ) + self.raw_data["Displacement"] = self.raw_data["Displacement"].apply( + lambda x: convert_displacement_terms(x) + ) def convert_structure_map(self): # discard any rows that has a dip value of -99 and does not have any esimated dip value - condition = (self.data["Dip"] != -99) & (self.data["DipEstimate"] != numpy.nan) - self.data = self.data[condition] + condition = (self.raw_data["Dip"] != -99) & ( + self.raw_data["DipEstimate"] != numpy.nan + ) + self.raw_data = self.raw_data[condition] # convert dip estimate to float (average of the range) - condition = self.data["Dip"] == -99 - self.data.loc[condition, "DipEstimate"] = self.data.loc[ + condition = self.raw_data["Dip"] == -99 + self.raw_data.loc[condition, "DipEstimate"] = self.raw_data.loc[ condition, "DipEstimate" ].apply(lambda x: sum(map(float, x.split("-"))) / 2) - self.data[condition, "Dip"] = self.data[condition, "DipEstimate"] + self.raw_data[condition, "Dip"] = self.raw_data[condition, "DipEstimate"] def convert(self): - pass + self.convert_fold_map() + self.convert_fault_map() + self.convert_structure_map() + + self._data = self.raw_data.copy()