Skip to content

Commit

Permalink
Updated the survey.survey_to_df function and added a convenience meth…
Browse files Browse the repository at this point in the history
…od. Added some export to MS Excel functions/methods.
  • Loading branch information
jonnymaserati committed Jul 7, 2024
1 parent f49a4fd commit e641f38
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions welleng/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,16 @@ def maximum_curvature(self, dls_noise=1.0):
survey.interpolated[::2] = self.interpolated

return survey

def to_df(self) -> pd.DataFrame:
"""Returns a ``pandas.DataFrame`` of useful survey parameters."""
return survey_to_df(self)

def to_excel(self, filename: str) -> None:
"""Exports a survey listing to an MS Excel file."""
df = self.survey_to_df()
with pd.ExcelWriter(f'{filename}.xlsx') as writer:
df.to_excel(writer, sheet_name="pilot", index=False)


def modified_tortuosity_index(
Expand Down Expand Up @@ -1861,6 +1871,20 @@ def _ensure_int_or_float(val, required_type) -> int | float:
return required_type(val)


def surveys_to_excel(surveys: list, filename: str) -> None:
"""Exports a list of surveys to sheets in an MS Excel file, using the
name of the well in the ``survey.header.name`` variable as the sheet name if
available and saving the file at the provided filename.
Useful for saving several iterations of a design or sidetrack surveys in a
single file.
"""
with pd.ExcelWriter(f'{filename}.xlsx') as writer:
for survey in surveys:
df = survey.to_df()
df.to_excel(writer, sheet_name=survey.header.name, index=False)


class SplitSurvey:
def __init__(
self,
Expand Down

0 comments on commit e641f38

Please sign in to comment.