Skip to content

Commit

Permalink
feat: added ntgs converter
Browse files Browse the repository at this point in the history
  • Loading branch information
rabii-chaarani committed Jul 3, 2024
1 parent 0f851ea commit 90f2a2b
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions LoopDataConverter/converters/ntgs_converter.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 90f2a2b

Please sign in to comment.