Skip to content

Commit

Permalink
EditFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderJuestel committed Dec 4, 2023
1 parent e403ead commit 12ee1fb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
56 changes: 45 additions & 11 deletions pyborehole/borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ def create_df(self):
df : pd.DataFrame
DataFrame containing the Borehole Metadata.
Examples
________
>>> borehole.create_df()
>>> borehole.df
Value
Name RWE EB1
Address Am Kraftwerk 17, 52249 Eschweiler, Germany
Location POINT (6.313031 50.835676)
X 6.313031
Y 50.835676
Coordinate Reference System EPSG:4326
Coordinate Reference System PyProj EPSG:4326
Altitude above sea level 136
Altitude above KB None
"""
# Create dict from attributes
df_dict = {'Name': self.name,
Expand Down Expand Up @@ -133,9 +148,12 @@ def update_df(self, data_dict: dict):
df])

def add_deviation(self,
path: str,
delimiter: str,
step: float):
path: Union[str, pd.DataFrame],
delimiter: str = '',
step: float = 1,
md_column: str = 'MD',
dip_column: str = 'DIP',
azimuth_column: str = 'AZI'):
"""Add deviation to the Borehole Object.
Parameters
Expand All @@ -153,7 +171,10 @@ def add_deviation(self,
self.deviation = Deviation(self,
path=path,
delimiter=delimiter,
step=step)
step=step,
md_column=md_column,
dip_column=dip_column,
azimuth_column=azimuth_column)

# Updating DataFrame
self.update_df(self.deviation.data_dict)
Expand Down Expand Up @@ -206,9 +227,12 @@ class Deviation(Borehole):

def __init__(self,
borehole,
path: str,
path: Union[str, pd.DataFrame],
delimiter: str,
step: float = 5):
step: float = 5,
md_column: str = 'MD',
dip_column: str = 'DIP',
azimuth_column: str = 'AZI'):

# Importing wellpathpy
try:
Expand All @@ -217,8 +241,16 @@ def __init__(self,
ModuleNotFoundError('wellpathpy package not installed')

# Opening deviation file
md, inc, azi = wp.read_csv(fname=path,
delimiter=delimiter)
if isinstance(path, str):
md, inc, azi = wp.read_csv(fname=path,
delimiter=delimiter)

# Opening Pandas DataFrame
if isinstance(path, pd.DataFrame):
md = path[md_column].values
inc = path[dip_column].values
azi = path[azimuth_column].values


# Creating deviation
dev = wp.deviation(
Expand Down Expand Up @@ -561,15 +593,15 @@ def plot_well_logs(self,
else:
j = 0

if not colors:
colors = [None] * len(tracks)

# Creating plot
fig, ax = plt.subplots(1,
len(tracks) + j,
figsize=(len(tracks) * 1.8, 8),
sharey=True)

if not colors:
colors = [None] * len(tracks)

# Helping variable for adding well tops
if add_well_tops:
for index, row in self.well_tops.df.iterrows():
Expand Down Expand Up @@ -607,6 +639,8 @@ def plot_well_logs(self,
ax[fill_between+j].fill_betweenx(df[depth_column], df[tracks[fill_between]], left_col_value, where=df[tracks[fill_between]] >= index,
color=color)

plt.tight_layout()

return fig, ax

def plot_well_log_along_path(self,
Expand Down
16 changes: 16 additions & 0 deletions test/test_borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ def test_borehole_class():
assert borehole.deviation is None
assert borehole.logs is None
assert isinstance(borehole.df, pd.DataFrame)
assert borehole.__str__() == 'Weisweiler R1'

borehole.update_df({'newname': 'Weisweiler R2'})
assert borehole.df.T['newname'].iloc[0] == 'Weisweiler R2'

data = {'MD': [0, 50, 100],
'DIP': [2, 2, 2],
'AZI': [5, 5, 5]}

df_dev = pd.DataFrame.from_dict(data)

borehole.add_deviation(path=df_dev,
step=25,
md_column='MD',
dip_column='DIP',
azimuth_column='AZI')


def test_borehole_class_error():
Expand Down

0 comments on commit 12ee1fb

Please sign in to comment.