Computing a trajectory¶
compute_trajectory() takes a survey, a
wellhead and a CRS, and returns a
WellTrajectory: every position along
the wellbore, with how it was arrived at.
TrajectoryInput.compute
calls it with everything an input holds, so what this page shows applies to
both; Building the input builds the input.
A first trajectory¶
from geodetic_engine.welltrajectory import Survey, compute_trajectory
survey = Survey(
md=[0, 500, 1500, 2500],
inclination=[0, 20, 60, 70],
azimuth=[10, 30, 45, 50],
md_unit="m",
)
trajectory = compute_trajectory(
survey,
wellhead=(500000.0, 6600000.0, 25.0),
crs="EPSG:32631",
north="GN",
method="AzimuthalEquidistant",
z_unit="m",
)
trajectory.to_dataframe()
| md | inclination | azimuth_true | azimuth_grid | east | north | tvd | x | y | z | dls | is_survey_station | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 10 | 10 | 0 | 0 | 0 | 500000 | 6600000 | 25 | 0 | True |
| 1 | 500 | 20 | 30 | 30 | 43.191979 | 74.810702 | 489.907768 | 500043.174702 | 6600074.780777 | -464.907768 | 1.2 | True |
| 2 | 1500 | 60 | 45 | 45 | 452.401845 | 549.414152 | 1241.949611 | 500452.220884 | 6600549.194387 | -1216.949611 | 1.226742 | True |
| 3 | 2500 | 70 | 50 | 50 | 1120.555349 | 1159.47817 | 1664.251663 | 501120.107127 | 6601159.014391 | -1639.251663 | 0.329244 | True |
to_dataframe() gives one
row per point. x and y are in the CRS, and z is the elevation, the
wellhead’s 25 m less the true vertical depth.
The arguments¶
Argument |
Meaning |
|---|---|
|
The |
|
The position of the first station, which TVD and the offsets count from: a |
|
The trajectory CRS: anything |
|
What the azimuths are measured from: |
|
How the offsets are georeferenced in the CRS; see Georeferencing methods. |
|
The unit of the wellhead elevation and of every depth, elevation and offset reported. Metres by default. |
|
If given, also a point every |
|
If given, also a point at each of these measured depths, in the survey’s MD unit. |
|
The well’s name, carried to the trajectory and used as its label in plots. |
The points md_step and md_points add come back among the survey stations,
in MD order, with is_survey_station False.
What a trajectory holds¶
One array entry per point, surveyed or interpolated:
Attribute |
Content |
|---|---|
|
Measured depth, in |
|
The hole’s direction, in degrees. |
|
Offsets from the wellhead against true north, TVD positive down, in |
|
Position in the CRS, in its own units. |
|
Elevation, the wellhead’s |
|
Dogleg per metre of MD, in radians; see |
|
True for a surveyed station, False for an interpolated point. |
and, once for the whole trajectory, how it was computed, and the well’s name
if the input gave one:
print("crs :", trajectory.crs.name)
print("method :", trajectory.method)
print("north_reference:", trajectory.north_reference)
print("units :", trajectory.md_unit, trajectory.z_unit)
print("local_crs :", trajectory.local_crs.name)
print()
print(*trajectory.operations, sep="\n")
crs : WGS 84 / UTM zone 31N
method : AzimuthalEquidistant
north_reference: GN
units : m m
local_crs : WGS 84 / Azimuthal Equidistant Lat=59.53834913 Lon=3.00000000
trajectory CRS EPSG:32631; wellhead at (500000, 6600000), elevation 25 m
grid convergence -0.000000000 deg and scale factor 0.999600000 at the wellhead
azimuths against grid north, turned onto true north by the grid convergence
minimum curvature over 4 survey stations
read offsets as WGS 84 / Azimuthal Equidistant Lat=59.53834913 Lon=3.00000000
converted from WGS 84 / Azimuthal Equidistant Lat=59.53834913 Lon=3.00000000 to WGS 84 / UTM zone 31N
operations says what
was done, in order. local_crs is the CRS the offsets were read in, here the
azimuthal equidistant projection centred on the wellhead; methods that read
the offsets in no CRS of their own leave it None.
Units of the results¶
MD stays in the survey’s unit. Depths, elevations and offsets are in z_unit,
which also applies to the wellhead’s elevation. A survey in metres can report
its depths in feet:
in_feet = compute_trajectory(
survey, (500000.0, 6600000.0, 82.0), "EPSG:32631", z_unit="ft"
)
in_feet.to_dataframe()[["md", "tvd", "z", "east", "north"]]
| md | tvd | z | east | north | |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 82 | 0 | 0 |
| 1 | 500 | 1607.30895 | -1525.30895 | 141.705967 | 245.441935 |
| 2 | 1500 | 4074.637832 | -3992.637832 | 1484.258022 | 1802.539868 |
| 3 | 2500 | 5460.14325 | -5378.14325 | 3676.362694 | 3804.062238 |
x and y are always in the CRS’s own units, whatever z_unit is.
Dogleg severity¶
dls() gives the dogleg
severity in degrees per a length of MD: per 30 m by default, or per 100 ft for
a survey in feet, which is
dls_length. Any other
length can be asked for:
print("per", trajectory.dls_length, trajectory.md_unit, ":", trajectory.dls().round(3))
print("per 10 m :", trajectory.dls(per_length=10).round(3))
print("rad per m :", trajectory.curvature.round(6))
per 30.0 m : [0. 1.2 1.227 0.329]
per 10 m : [0. 0.4 0.409 0.11 ]
rad per m : [0. 0.000698 0.000714 0.000192]
The value at a station is the curvature of the arc that ends there, and zero at the first station.
Points between stations¶
interpolate() gives the
trajectory at any measured depths inside the survey, on the minimum curvature
arcs:
trajectory.interpolate([1234.5, 2000]).to_dataframe()
| md | inclination | azimuth_true | azimuth_grid | east | north | tvd | x | y | z | dls | is_survey_station | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1234.5 | 49.256732 | 43.073512 | 43.073512 | 301.971419 | 394.187746 | 1088.473089 | 500301.85063 | 6600394.030071 | -1063.473089 | 1.226742 | False |
| 1 | 2000 | 64.979131 | 47.602056 | 47.602056 | 773.034085 | 855.490667 | 1472.863227 | 500772.72487 | 6600855.148475 | -1447.863227 | 0.329244 | False |
resample() gives a point
every given length of MD, keeping the surveyed stations unless told not to,
and always the last one:
every_250 = trajectory.resample(250)
every_250.to_dataframe()[["md", "inclination", "azimuth_true", "tvd", "is_survey_station"]]
| md | inclination | azimuth_true | tvd | is_survey_station | |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 10 | 0 | True |
| 1 | 250 | 10 | 30 | 248.732693 | False |
| 2 | 500 | 20 | 30 | 489.907768 | True |
| 3 | 750 | 29.802564 | 37.022932 | 716.438525 | False |
| 4 | 1000 | 39.803646 | 40.768381 | 921.481017 | False |
| 5 | 1250 | 49.883003 | 43.201618 | 1098.525106 | False |
| 6 | 1500 | 60 | 45 | 1241.949611 | True |
| 7 | 1750 | 62.483516 | 46.330493 | 1362.223069 | False |
| 8 | 2000 | 64.979131 | 47.602056 | 1472.863227 | False |
| 9 | 2250 | 67.48513 | 48.822816 | 1573.616424 | False |
| 10 | 2500 | 70 | 50 | 1664.251663 | True |
md_step does the same while the trajectory is computed. A depth outside the
survey raises InvalidSurveyError:
trajectory.interpolate([3000])
InvalidSurveyError: MD 3000 is outside the surveyed interval [0, 2500]
Minimum curvature explains how the points between stations are found.
Grid north and true north¶
Minimum curvature runs against true north. Azimuths against grid north are
turned onto true north first, by the grid convergence at the wellhead, from
projection_factors(). The wellhead above sits on
the central meridian, where the convergence is zero. Off it, the two readings
of the same survey part:
off_meridian = (666000.0, 6660000.0, 25.0)
as_grid = compute_trajectory(survey, off_meridian, "EPSG:32631", north="GN")
as_true = compute_trajectory(survey, off_meridian, "EPSG:32631", north="TN")
print("grid convergence at the wellhead:", as_grid.factors.grid_convergence)
print("scale factor at the wellhead :", as_grid.factors.scale_factor)
pd.DataFrame(
{
"md": as_grid.md,
"azimuth_grid (read as GN)": as_grid.azimuth_grid,
"azimuth_true (read as GN)": as_grid.azimuth_true,
"x (GN) - x (TN)": as_grid.x - as_true.x,
"y (GN) - y (TN)": as_grid.y - as_true.y,
}
)
grid convergence at the wellhead: [2.58306759]
scale factor at the wellhead : [0.9999377]
| md | azimuth_grid (read as GN) | azimuth_true (read as GN) | x (GN) - x (TN) | y (GN) - y (TN) | |
|---|---|---|---|---|---|
| 0 | 0 | 10 | 12.583068 | 0 | 0 |
| 1 | 500 | 30 | 32.583068 | 3.415225 | -1.870436 |
| 2 | 1500 | 45 | 47.583068 | 25.219058 | -19.82924 |
| 3 | 2500 | 50 | 52.583068 | 53.390799 | -49.319704 |
The convergence is taken at the wellhead and held for the whole well.
This calculation needs a projection that preserves angles at the wellhead;
otherwise azimuths against grid north raise
UnsupportedCRSError, while azimuths against
true north are placed, with no grid azimuths.
projection_factors()
shows how much it changes along the well:
along = as_grid.projection_factors()
along.grid_convergence - as_grid.factors.grid_convergence
array([9.92139704e-12, 7.40720489e-04, 7.54100659e-03, 1.84940969e-02])
A geographic CRS¶
In a geographic CRS the positions are longitude and latitude, in the CRS’s own unit, on its own ellipsoid. There is no grid, so the azimuths must be against true north:
geographic = compute_trajectory(survey, (4.0, 58.0, 25.0), "EPSG:4326", north="TN")
geographic.to_dataframe()[["md", "east", "north", "x", "y", "z"]]
| md | east | north | x | y | z | |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 4 | 58 | 25 |
| 1 | 500 | 43.191979 | 74.810702 | 4.00073 | 58.000672 | -464.907768 |
| 2 | 1500 | 452.401845 | 549.414152 | 4.007652 | 58.004933 | -1216.949611 |
| 3 | 2500 | 1120.555349 | 1159.47817 | 4.018955 | 58.010409 | -1639.251663 |
compute_trajectory(survey, (4.0, 58.0, 25.0), "EPSG:4326", north="GN")
UnsupportedCRSError: azimuths are given against grid north, but WGS 84 is geographic and has no grid; give them against true north
Moving to another CRS¶
to_geographic() gives the
horizontal positions in another CRS, WGS 84 by default, as a
TransformationResult with its provenance.
From WGS 84 / UTM zone 31N that needs no datum change:
trajectory.to_geographic().coordinates.to_numpy()
array([[ 3. , 59.53834913],
[ 3.00076345, 59.53902065],
[ 3.00799758, 59.54328059],
[ 3.01981245, 59.54875545]])
From ED50 it does, and a datum change has to be named, exactly as for
Transformation:
ed50 = compute_trajectory(survey, (500000.0, 6600000.0, 25.0), "EPSG:23031")
ed50.to_geographic()
AmbiguousOperationError: EPSG:23031 to EPSG:4326 involves a datum change; every datum operation must be named explicitly. allow_any_operation no longer permits automatic selection or ballpark results
wgs84 = ed50.to_geographic(operation="EPSG:1133")
print(wgs84.operation.name)
wgs84.coordinates.to_numpy()
ED50 to WGS 84 (1)
array([[ 2.99835076, 59.53641567],
[ 2.99911413, 59.53708719],
[ 3.00634761, 59.54134721],
[ 3.01816147, 59.54682219]])
A bound CRS names its own datum shift, so a trajectory computed in one moves without an operation:
from pyproj import CRS
from pyproj.crs import BoundCRS, CoordinateOperation
bound = BoundCRS(
CRS("EPSG:23031"), CRS("EPSG:4326"), CoordinateOperation.from_epsg(1133)
)
in_bound = compute_trajectory(survey, (500000.0, 6600000.0, 25.0), bound)
print(in_bound.to_geographic().operation.name)
ED50 to WGS 84 (1)
The positions in the bound CRS are the same as in its base, ED50 / UTM zone 31N: the binding only matters when the positions leave the CRS. See Results and provenance for what a transformation result records. The same applies when the horizontal component of a compound CRS is bound: demotion to horizontal coordinates preserves its datum operation.