From 002b7e0e963755fe6cbad7c105628e348def7444 Mon Sep 17 00:00:00 2001 From: Jerritt Collord Date: Fri, 8 Mar 2024 17:01:16 -0500 Subject: [PATCH 1/2] support for wellpathpy --- geoh5py/objects/drillhole.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/geoh5py/objects/drillhole.py b/geoh5py/objects/drillhole.py index 56d581ae9..b7153ffe0 100644 --- a/geoh5py/objects/drillhole.py +++ b/geoh5py/objects/drillhole.py @@ -456,9 +456,39 @@ def desurvey(self, depths): if isinstance(depths, list): depths = np.asarray(depths) + surveys = self.surveys.copy() + # Repeat first survey point at surface for de-survey interpolation - surveys = np.vstack([self.surveys[0, :], self.surveys]) - surveys[0, 0] = 0.0 + # (only if needed) + if surveys[0,0] != 0.0: + surveys = np.vstack([surveys[0, :], surveys]) + surveys[0, 0] = 0.0 + + try: + import wellpathpy as wp + + # Repeat last survey point at bottom depth of desurvey request + # TODO there is a mathematically more correct way to do this. + if surveys[-1, 0] < depths[-1]: + surveys = np.vstack([surveys, surveys[-1, :] ]) + surveys[-1, 0] = depths[-1] + + # geoh5py dips range from -90 to 0 + # wellpathpy expects inclination inc | 0 <= inc < 180 + # where 180 = 90 degree dip (vertical), so never truly vertical? + surveys[:,2] = surveys[:,2] + 90.00000000001 + + dev = wp.deviation( md=surveys[:,0], azi=surveys[:,1], inc=surveys[:,2]) + pos = dev.minimum_curvature( ).resample( depths ) + + return np.c_[ [ self.locations[0, 0] + pos.easting , + self.locations[0, 1] + pos.northing , + self.locations[0, 2] - pos.depth]].T + except Exception as e: + print('cannot do wellpathpy') + print( e ) + + pass ind_loc = np.maximum( np.searchsorted(surveys[:, 0], depths, side="left") - 1, From b9f7710fcfcdcb1b89c259df42d16e1237c71c1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 23:08:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- geoh5py/objects/drillhole.py | 41 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/geoh5py/objects/drillhole.py b/geoh5py/objects/drillhole.py index b7153ffe0..784653483 100644 --- a/geoh5py/objects/drillhole.py +++ b/geoh5py/objects/drillhole.py @@ -457,38 +457,41 @@ def desurvey(self, depths): depths = np.asarray(depths) surveys = self.surveys.copy() - + # Repeat first survey point at surface for de-survey interpolation # (only if needed) - if surveys[0,0] != 0.0: + if surveys[0, 0] != 0.0: surveys = np.vstack([surveys[0, :], surveys]) surveys[0, 0] = 0.0 try: import wellpathpy as wp - # Repeat last survey point at bottom depth of desurvey request - # TODO there is a mathematically more correct way to do this. + # Repeat last survey point at bottom depth of desurvey request + # TODO there is a mathematically more correct way to do this. if surveys[-1, 0] < depths[-1]: - surveys = np.vstack([surveys, surveys[-1, :] ]) + surveys = np.vstack([surveys, surveys[-1, :]]) surveys[-1, 0] = depths[-1] - + # geoh5py dips range from -90 to 0 - # wellpathpy expects inclination inc | 0 <= inc < 180 + # wellpathpy expects inclination inc | 0 <= inc < 180 # where 180 = 90 degree dip (vertical), so never truly vertical? - surveys[:,2] = surveys[:,2] + 90.00000000001 - - dev = wp.deviation( md=surveys[:,0], azi=surveys[:,1], inc=surveys[:,2]) - pos = dev.minimum_curvature( ).resample( depths ) - - return np.c_[ [ self.locations[0, 0] + pos.easting , - self.locations[0, 1] + pos.northing , - self.locations[0, 2] - pos.depth]].T + surveys[:, 2] = surveys[:, 2] + 90.00000000001 + + dev = wp.deviation(md=surveys[:, 0], azi=surveys[:, 1], inc=surveys[:, 2]) + pos = dev.minimum_curvature().resample(depths) + + return np.c_[ + [ + self.locations[0, 0] + pos.easting, + self.locations[0, 1] + pos.northing, + self.locations[0, 2] - pos.depth, + ] + ].T except Exception as e: - print('cannot do wellpathpy') - print( e ) - - pass + print("cannot do wellpathpy") + print(e) + ind_loc = np.maximum( np.searchsorted(surveys[:, 0], depths, side="left") - 1,