jonnymaserati / welleng

A collection of Wells/Drilling Engineering tools, focused on well trajectory planning for the time being.
Apache License 2.0
113 stars 31 forks source link

Interpolation error #142

Closed mohsenminaei closed 1 year ago

mohsenminaei commented 1 year ago

I have the following data:

md = [0.0, 4004.0, 4050.0, 4100.0, 4150.0, 4200.0, 4250.0, 4300.0, 4350.0, 4400.0, 4500.0, 4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0, 5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0, 6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0, 7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0, 8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0, 9100.0, 9200.0, 9300.0, 9400.0, 9500.0, 9540.0, 9571.0, 9664.0, 9757.0, 9850.0, 9942.0, 10034.0, 10130.0, 10222.0, 10316.0, 10407.0, 10499.0, 10592.0, 10685.0, 10775.0, 10868.0, 10968.0, 11060.0, 11153.0, 11246.0, 11338.0, 11432.0, 11525.0, 11623.0, 11717.0, 11811.0, 11905.0, 11999.0, 12079.0, 12177.0, 12265.0, 12364.0, 12453.0, 12548.0, 12645.0, 12739.0, 12833.0, 12924.0, 13021.0, 13115.0, 13211.0, 13302.0, 13395.0, 13492.0, 13581.0, 13642.0, 13726.0, 13766.0, 13796.0, 13873.6904296875, 14065.0, 14158.2998046875, 14337.0, 14526.0, 14895.0, 15367.0, 16479.0, 16575.0, 16667.0, 16854.0, 17041.0, 17666.5, 17763.470703125, 17853.4609375, 18224.5703125, 18319.6796875, 18412.490234375, 18504.2890625, 18599.150390625, 18695.349609375, 18785.55078125, 18881.740234375, 18972.740234375, 19067.30078125, 19161.990234375, 19341.419921875, 19442.599609375, 19533.0, 19629.0, 19717.9609375, 19818.060546875, 19914.009765625, 20501.0]

inc = [0.0, 0.0, 1.75, 2.0, 2.25, 1.75, 1.75, 1.0, 0.75, 0.75, 0.5, 0.75, 0.5, 0.5, 0.5, 0.75, 0.75, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.0, 0.25, 0.5, 0.0, 0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.0, 0.25, 0.5, 0.25, 0.5, 0.25, 0.5, 0.75, 0.5, 0.5, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25, 0.0, 0.25, 0.25, 0.25, 0.5199999809265137, 0.4699999988079071, 0.4000000059604645, 0.49000000953674316, 0.550000011920929, 0.4399999976158142, 0.49000000953674316, 0.5600000023841858, 0.6600000262260437, 0.5899999737739563, 0.3799999952316284, 0.4699999988079071, 0.6899999976158142, 0.7699999809265137, 0.75, 0.3799999952316284, 0.7900000214576721, 0.9800000190734863, 0.8199999928474426, 0.9599999785423279, 1.0399999618530273, 0.8899999856948853, 0.9399999976158142, 0.8199999928474426, 0.9900000095367432, 0.9700000286102295, 0.7099999785423279, 0.8500000238418579, 0.6399999856948853, 0.8199999928474426, 0.9399999976158142, 0.9399999976158142, 1.0800000429153442, 0.9700000286102295, 1.0499999523162842, 0.9599999785423279, 1.2300000190734863, 1.0800000429153442, 0.8500000238418579, 0.7599999904632568, 0.44999998807907104, 0.36000001430511475, 0.18000000715255737, 0.14000000059604645, 0.5, 0.5, 0.029999999329447746, 0.33000001311302185, 0.33000001311302185, 0.05999999865889549, 0.27000001072883606, 0.25999999046325684, 0.25999999046325684, 0.5400000214576721, 0.7699999809265137, 0.8899999856948853, 0.8899999856948853, 0.949999988079071, 0.9800000190734863, 0.7599999904632568, 0.9200000166893005, 0.9100000262260437, 0.8299999833106995, 0.9399999976158142, 0.9800000190734863, 0.8399999737739563, 0.9599999785423279, 1.1299999952316284, 1.3799999952316284, 1.409999966621399, 1.5099999904632568, 1.4600000381469727, 1.6200000047683716, 1.7100000381469727, 2.0999999046325684, 0.8999999761581421, 1.7999999523162842, 1.7000000476837158, 1.899999976158142, 2.200000047683716, 2.200000047683716, 2.200000047683716]

azi = [0.0, 358.8590393066406, 133.85903930664062, 135.85903930664062, 127.85903930664062, 138.85903930664062, 115.85903930664062, 112.85903930664062, 98.85903930664062, 113.85903930664062, 89.85903930664062, 99.85903930664062, 119.85903930664062, 66.85903930664062, 103.85903930664062, 79.85903930664062, 36.85904312133789, 38.85904312133789, 38.85904312133789, 34.85904312133789, 22.859041213989258, 6.859041690826416, 325.8590393066406, 325.8590393066406, 328.8590393066406, 358.8590393066406, 284.8590393066406, 302.8590393066406, 358.8590393066406, 321.8590393066406, 292.8590393066406, 301.8590393066406, 351.8590393066406, 322.8590393066406, 301.8590393066406, 3.859041690826416, 315.8590393066406, 339.8590393066406, 23.859041213989258, 330.8590393066406, 323.8590393066406, 6.859041690826416, 358.8590393066406, 351.8590393066406, 323.8590393066406, 346.8590393066406, 33.85904312133789, 16.859041213989258, 49.85904312133789, 14.859041213989258, 10.859041213989258, 27.859041213989258, 358.8590393066406, 22.859041213989258, 28.859041213989258, 25.859041213989258, 56.85904312133789, 29.859041213989258, 358.8590393066406, 57.85904312133789, 51.85904312133789, 68.85903930664062, 59.41904067993164, 67.71903991699219, 73.26904296875, 88.97904205322266, 64.21903991699219, 64.89904022216797, 25.749042510986328, 33.66904067993164, 359.2390441894531, 0.7190417051315308, 3.7790417671203613, 347.2290344238281, 316.8890380859375, 324.58905029296875, 323.57904052734375, 293.9390563964844, 301.9890441894531, 290.32904052734375, 304.96905517578125, 297.33905029296875, 289.279052734375, 283.0990295410156, 273.8590393066406, 270.26904296875, 247.4390411376953, 244.54904174804688, 228.50904846191406, 209.22903442382812, 209.32904052734375, 210.77903747558594, 201.54904174804688, 200.6390380859375, 200.62904357910156, 209.11904907226562, 195.49903869628906, 178.6390380859375, 179.50904846191406, 177.36904907226562, 159.16903686523438, 147.3190460205078, 165.4690399169922, 194.12904357910156, 133.6890411376953, 90.79904174804688, 197.72903442382812, 207.0590362548828, 97.04904174804688, 54.049041748046875, 89.76904296875, 251.8190460205078, 281.6190490722656, 297.8690490722656, 268.8690490722656, 257.8590393066406, 243.35903930664062, 217.23904418945312, 193.15904235839844, 198.5590362548828, 193.53904724121094, 196.25904846191406, 199.45904541015625, 212.42904663085938, 199.12904357910156, 199.1490478515625, 197.8490447998047, 187.6490478515625, 186.62904357910156, 182.54904174804688, 196.8990478515625, 208.69903564453125, 198.62904357910156, 198.48904418945312, 191.92904663085938, 187.77903747558594, 173.65904235839844, 174.35903930664062, 185.75904846191406, 187.15904235839844, 195.75904846191406, 195.02903747558594, 205.92904663085938, 205.92904663085938]

I create a survey using

survey=we.survey.Survey(md, inc, azi)

My goal is to have the well path with 10 ft step. So I do this:

survey = survey.interpolate_survey(step=10)

Since the last value of md is 20501, I expect to get 2051 values, but I get 2131 values. There are some random points between two valid md points, such as below:

19160.0 19161.990234375 19170.0

Is this a known issue? Is there a workaround for it? Thanks for your help in advance.

mohsenminaei commented 1 year ago

I am using welleng 0.5.1 on Windows.

jonnymaserati commented 1 year ago

Hi @mohsenminaei and thanks for the question!

When interpolating, the original stations are maintained, so your count is the sum of the original survey stations plus the interpolated ones. There's a few reasons for doing this... if you only use the interpolated stations and then fit a path through these, you'll get a slightly different trajectory since the original points will no longer be on the minimum curvature path.

To see which stations are interpolated, you can use the interpolated property.

>>> survey_interpolated = survey.interpolate_survey(step=10)
>>> survey_interpolated.interpolated

This will return a List[bool] indicating which stations have been interpolated (True).

If you want to extract only the stations where the md is divisible by the step interval, you could make a sort of index mask with a modulo operator and apply that to the properties you're after:

mask = survey_interpolated.md % 10 == 0

If I apply this to your example:

>>> len(survey_interpolated.md[mask])
... 2051

Hope this helps?

BTW: note that the survey module uses meters... this won't impact the survey calculations since they're dimensionless, but stuff like dls won't be correct in feet.

mohsenminaei commented 1 year ago

Thanks so much @jonnymaserati for your super quick response. It makes sense now, your explanation was very helpful.