Example 01. Get the VLP calculations

This notebook runs the modified Hagedorn-Brown correlation calculated according to Brown’s book and procedure in Appendix C.

library(rNodal)
library(tibble)
# Example from Prosper oil well 01. Dry version

# roughness = 0.0006
input_example <-  setWellInput(field.name = "HAGBR.MOD", 
                               well.name = "Oilwell_01_Dry", 
                               depth.wh = 0, depth.bh = 9275, 
                               diam.in = 4.052, 
                               GLR = 800, liq.rt = 983, wcut = 0.0, 
                               thp = 100, tht = 60, bht = 210, 
                               API = 37, oil.visc = 5.0, 
                               gas.sg = 0.76, wat.sg = 1.07, if.tens = 30, 
                               salinity = 23000
                                 )

well_model <- setVLPmodel(vlp.model = "hagbr.mod", segments = 29, tol = 0.00001)

as.tibble(runVLP(well.input = input_example, well_model))
## Warning in get.well.slot(hFile, field.name, well.name): 
##  ./data folder does not exist. Creating a temporary file
## Warning in get.well.slot(hFile, field.name, well.name): Creating a local ./data folder is advised
## # A tibble: 30 x 45
##        i     depth       dL      temp     pres    p_avg     t_avg segment
##    <int>     <dbl>    <dbl>     <dbl>    <dbl>    <dbl>     <dbl>   <dbl>
##  1     1    0.0000   0.0000  60.00000 100.0000 100.0000  60.00000       0
##  2     2  319.8276 319.8276  65.17241 123.3668 111.6834  62.58621       1
##  3     3  639.6552 319.8276  70.34483 146.1362 134.7515  67.75862       2
##  4     4  959.4828 319.8276  75.51724 168.3186 157.2273  72.93103       3
##  5     5 1279.3103 319.8276  80.68966 190.0331 179.1758  78.10345       4
##  6     6 1599.1379 319.8276  85.86207 211.4121 200.7226  83.27586       5
##  7     7 1918.9655 319.8276  91.03448 232.5725 221.9923  88.44828       6
##  8     8 2238.7931 319.8276  96.20690 253.6108 243.0916  93.62069       7
##  9     9 2558.6207 319.8276 101.37931 274.5991 264.1042  98.79310       8
## 10    10 2878.4483 319.8276 106.55172 295.6000 285.0993 103.96552       9
## # ... with 20 more rows, and 37 more variables: GOR <dbl>, Rs <dbl>,
## #   gas.fvf <dbl>, gas.free <dbl>, liq.dens <dbl>, z <dbl>,
## #   gas.dens <dbl>, oil.visc <dbl>, wat.visc <dbl>, mixL.visc <dbl>,
## #   oil.fvf <dbl>, wat.fvf <dbl>, liq.svel <dbl>, gas.svel <dbl>,
## #   NL <dbl>, CNL <dbl>, NLV <dbl>, NGV <dbl>, A <dbl>, B <dbl>, BA <dbl>,
## #   ND <dbl>, X2 <dbl>, HL.psi <dbl>, X2.mod <dbl>, psi <dbl>, HL <dbl>,
## #   Re.TP <dbl>, ff <dbl>, mix.dens <dbl>, mixL.volume <dbl>,
## #   mixL.dens <dbl>, mixTP.dens <dbl>, mixTP.svel <dbl>, elev.grad <dbl>,
## #   fric.grad <dbl>, dp.dz <dbl>
p30 = 740.1965

p9

MD      TVD     Pres    Temp    Gradient
0   0   100.0   70.0        
250.0   250.0   116.7   74.0    0.066728    0.17564
500.0   500.0   133.7   78.0    0.068134    0.17885
750.0   750.0   151.1   82.1    0.069378    0.18161
1000.0  1000.0  168.7   86.1    0.070492    0.18399
1000.0  1000.0  168.7   86.1    0.01    
1243.4  1243.3  186.1   90.1    0.07149 0.18607
1486.8  1486.7  203.7   94.0    0.072389    0.18788
1730.1  1730.1  221.5   97.9    0.073217    0.18951
1973.5  1973.5  239.5   101.9   0.073984    0.19097
2216.9  2216.9  257.7   105.8   0.074696    0.19229
2460.3  2460.2  276.1   109.7   0.075361    0.19349
2703.7  2703.6  294.6   113.7   0.075984    0.19458
2947.0  2947.0  313.2   117.6   0.076568    0.19558
3190.4  3190.4  332.0   121.5   0.077188    0.1967
3433.8  3433.8  350.9   125.5   0.077845    0.19793
3677.2  3677.1  370.0   129.4   0.078473    0.1991
3920.6  3920.5  389.3   133.4   0.079073    0.20021
4164.0  4163.9  408.6   137.3   0.079649    0.20125
4407.3  4407.3  428.2   141.2   0.080201    0.20225
4650.7  4650.7  447.8   145.2   0.080732    0.20319
4894.1  4894.0  467.6   149.1   0.081241    0.2041
5137.5  5137.4  488.0   153.0   0.08366 0.21069
5380.9  5380.8  509.0   156.9   0.086341    0.2181
5624.2  5624.2  530.6   160.9   0.089066    0.22568
5867.6  5867.6  553.0   164.8   0.091835    0.23342
6111.0  6110.9  576.0   168.7   0.094647    0.24133
6354.4  6354.3  599.8   172.6   0.097499    0.24941
6597.8  6597.7  624.2   176.5   0.10039 0.25764
6841.1  6841.1  649.3   180.4   0.10332 0.26604
7084.5  7084.5  675.2   184.2   0.10629 0.27461
7327.9  7327.9  701.8   188.0   0.1093  0.28334
7571.3  7571.2  729.1   191.8   0.11234 0.29225
7814.7  7814.6  757.2   195.4   0.11544 0.30135
8058.0  8058.0  786.1   198.9   0.11858 0.31064
8301.4  8301.4  815.7   202.2   0.12179 0.32017
8544.8  8544.8  846.2   205.1   0.12508 0.32996
8788.2  8788.1  877.5   207.6   0.12848 0.3401
9031.6  9031.5  909.6   209.3   0.13204 0.35069
9275.0  9274.9  942.7   210.0   0.13584 0.36189

h5 temp

3 runs inst/extdata

Type        MD      ID(in)  Roughness(in) 
Xmas Tree   600                         
Tubing      1000    4.052   0.0006                      
SSSV                3.72                                
Tubing      9000    4.052   0.0006                      
Casing      9275    6.4     0.0006



     TVD     MD      FormTemp(deg F)
 1   0       0       60 
 2   600     600     40 
 3   9000    9275    210    



     Date        Comments   THP THT     WC      LIQRT    GDepth  GPres   ResPr      GOR      GOR Free
 1   03/16/2011  Test 1     230  143.8   0      9784.1   6250    1322.6  4042.19     800     0  
 2   05/21/2011  Test 2     521  134.2   0.5    7915.3   6250    1623.8  3910.16     800     0  
 3   10/07/2011  Test 3     765  118     1.9    5636.9   6250    1962.6  3778.13     800     0  

Calculate the angle for the original deviation survey

     MD      TVD     CumDisp(ft) Angle(deg)
 1   0       0       0           0  
 2   600     600     0           0  
 3   1005    1000    63.4429     9.01245    
 4   4075    4000    715.286     12.2587    
 5   7700    7500    1659.02     15.0902    
 6   9275    9000    2139.25     17.7528

Set deviation survey and compute angle

# in Prosper the angle is measured againt the vertical
library(rNodal)

md_tvd_01 <- "
MD      TVD 
0        0   
600     600
1005     1000
4075     4000
7700     7500
9275     9000
"

md_tvd <- set_deviation_survey(md_tvd_01)
md_tvd
##     MD  TVD
## 1    0    0
## 2  600  600
## 3 1005 1000
## 4 4075 4000
## 5 7700 7500
## 6 9275 9000
deviation_survey <- compute_angle_deviation_survey(md_tvd, reference = "vertical")
dataFrame <- deviation_survey
dataFrame
##     MD  TVD delta.md delta.tvd   radians    disp cum_disp   degrees
## 1    0    0        0         0 0.0000000   0.000    0.000  0.000000
## 2  600  600      600       600 0.0000000   0.000    0.000  0.000000
## 3 1005 1000      405       400 0.1572970  63.443   63.443  9.012451
## 4 4075 4000     3070      3000 0.2139555 651.844  715.287 12.258749
## 5 7700 7500     3625      3500 0.2633734 943.729 1659.016 15.090185
## 6 9275 9000     1575      1500 0.3098446 480.234 2139.250 17.752790

Split the well in deltas

by interval steps

# split deviated well in two ways: by and length.out
library(rNodal)

md <- deviation_survey[["MD"]]   # get MD vector

add_md_by <- rNodal:::split_well_in_deltas(md, by = 50)
add_md_by
##   [1]    0   50  100  150  200  250  300  350  400  450  500  550  600  650
##  [15]  700  750  800  850  900  950 1000 1005 1050 1100 1150 1200 1250 1300
##  [29] 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 1900 1950 2000
##  [43] 2050 2100 2150 2200 2250 2300 2350 2400 2450 2500 2550 2600 2650 2700
##  [57] 2750 2800 2850 2900 2950 3000 3050 3100 3150 3200 3250 3300 3350 3400
##  [71] 3450 3500 3550 3600 3650 3700 3750 3800 3850 3900 3950 4000 4050 4075
##  [85] 4100 4150 4200 4250 4300 4350 4400 4450 4500 4550 4600 4650 4700 4750
##  [99] 4800 4850 4900 4950 5000 5050 5100 5150 5200 5250 5300 5350 5400 5450
## [113] 5500 5550 5600 5650 5700 5750 5800 5850 5900 5950 6000 6050 6100 6150
## [127] 6200 6250 6300 6350 6400 6450 6500 6550 6600 6650 6700 6750 6800 6850
## [141] 6900 6950 7000 7050 7100 7150 7200 7250 7300 7350 7400 7450 7500 7550
## [155] 7600 7650 7700 7750 7800 7850 7900 7950 8000 8050 8100 8150 8200 8250
## [169] 8300 8350 8400 8450 8500 8550 8600 8650 8700 8750 8800 8850 8900 8950
## [183] 9000 9050 9100 9150 9200 9250 9275

by total size of the sample or rows

# split deviated well in two ways: by and length.out
library(rNodal)

md <- deviation_survey[["MD"]]   # get MD vector

add_md_lo <- rNodal:::split_well_in_deltas(md, length.out = 40)
add_md_lo
##  [1]    0.0000  237.8205  475.6410  600.0000  713.4615  951.2821 1005.0000
##  [8] 1189.1026 1426.9231 1664.7436 1902.5641 2140.3846 2378.2051 2616.0256
## [15] 2853.8462 3091.6667 3329.4872 3567.3077 3805.1282 4042.9487 4075.0000
## [22] 4280.7692 4518.5897 4756.4103 4994.2308 5232.0513 5469.8718 5707.6923
## [29] 5945.5128 6183.3333 6421.1538 6658.9744 6896.7949 7134.6154 7372.4359
## [36] 7610.2564 7700.0000 7848.0769 8085.8974 8323.7179 8561.5385 8799.3590
## [43] 9037.1795 9275.0000
rNodal:::build_survey_with_deltas(deviation_survey, add_md_by)
##       md seg delta.md   radians   degrees delta.tvd       tvd
## 1      0   1        0 0.0000000  0.000000  0.000000    0.0000
## 2     50   2       50 0.0000000  0.000000 50.000000   50.0000
## 3    100   2       50 0.0000000  0.000000 50.000000  100.0000
## 4    150   2       50 0.0000000  0.000000 50.000000  150.0000
## 5    200   2       50 0.0000000  0.000000 50.000000  200.0000
## 6    250   2       50 0.0000000  0.000000 50.000000  250.0000
## 7    300   2       50 0.0000000  0.000000 50.000000  300.0000
## 8    350   2       50 0.0000000  0.000000 50.000000  350.0000
## 9    400   2       50 0.0000000  0.000000 50.000000  400.0000
## 10   450   2       50 0.0000000  0.000000 50.000000  450.0000
## 11   500   2       50 0.0000000  0.000000 50.000000  500.0000
## 12   550   2       50 0.0000000  0.000000 50.000000  550.0000
## 13   600   2       50 0.0000000  0.000000 50.000000  600.0000
## 14   650   3       50 0.1572970  9.012451 49.382716  649.3827
## 15   700   3       50 0.1572970  9.012451 49.382716  698.7654
## 16   750   3       50 0.1572970  9.012451 49.382716  748.1481
## 17   800   3       50 0.1572970  9.012451 49.382716  797.5309
## 18   850   3       50 0.1572970  9.012451 49.382716  846.9136
## 19   900   3       50 0.1572970  9.012451 49.382716  896.2963
## 20   950   3       50 0.1572970  9.012451 49.382716  945.6790
## 21  1000   3       50 0.1572970  9.012451 49.382716  995.0617
## 22  1005   3        5 0.1572970  9.012451  4.938272 1000.0000
## 23  1050   4       45 0.2139555 12.258749 43.973941 1043.9739
## 24  1100   4       50 0.2139555 12.258749 48.859935 1092.8339
## 25  1150   4       50 0.2139555 12.258749 48.859935 1141.6938
## 26  1200   4       50 0.2139555 12.258749 48.859935 1190.5537
## 27  1250   4       50 0.2139555 12.258749 48.859935 1239.4137
## 28  1300   4       50 0.2139555 12.258749 48.859935 1288.2736
## 29  1350   4       50 0.2139555 12.258749 48.859935 1337.1336
## 30  1400   4       50 0.2139555 12.258749 48.859935 1385.9935
## 31  1450   4       50 0.2139555 12.258749 48.859935 1434.8534
## 32  1500   4       50 0.2139555 12.258749 48.859935 1483.7134
## 33  1550   4       50 0.2139555 12.258749 48.859935 1532.5733
## 34  1600   4       50 0.2139555 12.258749 48.859935 1581.4332
## 35  1650   4       50 0.2139555 12.258749 48.859935 1630.2932
## 36  1700   4       50 0.2139555 12.258749 48.859935 1679.1531
## 37  1750   4       50 0.2139555 12.258749 48.859935 1728.0130
## 38  1800   4       50 0.2139555 12.258749 48.859935 1776.8730
## 39  1850   4       50 0.2139555 12.258749 48.859935 1825.7329
## 40  1900   4       50 0.2139555 12.258749 48.859935 1874.5928
## 41  1950   4       50 0.2139555 12.258749 48.859935 1923.4528
## 42  2000   4       50 0.2139555 12.258749 48.859935 1972.3127
## 43  2050   4       50 0.2139555 12.258749 48.859935 2021.1726
## 44  2100   4       50 0.2139555 12.258749 48.859935 2070.0326
## 45  2150   4       50 0.2139555 12.258749 48.859935 2118.8925
## 46  2200   4       50 0.2139555 12.258749 48.859935 2167.7524
## 47  2250   4       50 0.2139555 12.258749 48.859935 2216.6124
## 48  2300   4       50 0.2139555 12.258749 48.859935 2265.4723
## 49  2350   4       50 0.2139555 12.258749 48.859935 2314.3322
## 50  2400   4       50 0.2139555 12.258749 48.859935 2363.1922
## 51  2450   4       50 0.2139555 12.258749 48.859935 2412.0521
## 52  2500   4       50 0.2139555 12.258749 48.859935 2460.9121
## 53  2550   4       50 0.2139555 12.258749 48.859935 2509.7720
## 54  2600   4       50 0.2139555 12.258749 48.859935 2558.6319
## 55  2650   4       50 0.2139555 12.258749 48.859935 2607.4919
## 56  2700   4       50 0.2139555 12.258749 48.859935 2656.3518
## 57  2750   4       50 0.2139555 12.258749 48.859935 2705.2117
## 58  2800   4       50 0.2139555 12.258749 48.859935 2754.0717
## 59  2850   4       50 0.2139555 12.258749 48.859935 2802.9316
## 60  2900   4       50 0.2139555 12.258749 48.859935 2851.7915
## 61  2950   4       50 0.2139555 12.258749 48.859935 2900.6515
## 62  3000   4       50 0.2139555 12.258749 48.859935 2949.5114
## 63  3050   4       50 0.2139555 12.258749 48.859935 2998.3713
## 64  3100   4       50 0.2139555 12.258749 48.859935 3047.2313
## 65  3150   4       50 0.2139555 12.258749 48.859935 3096.0912
## 66  3200   4       50 0.2139555 12.258749 48.859935 3144.9511
## 67  3250   4       50 0.2139555 12.258749 48.859935 3193.8111
## 68  3300   4       50 0.2139555 12.258749 48.859935 3242.6710
## 69  3350   4       50 0.2139555 12.258749 48.859935 3291.5309
## 70  3400   4       50 0.2139555 12.258749 48.859935 3340.3909
## 71  3450   4       50 0.2139555 12.258749 48.859935 3389.2508
## 72  3500   4       50 0.2139555 12.258749 48.859935 3438.1107
## 73  3550   4       50 0.2139555 12.258749 48.859935 3486.9707
## 74  3600   4       50 0.2139555 12.258749 48.859935 3535.8306
## 75  3650   4       50 0.2139555 12.258749 48.859935 3584.6906
## 76  3700   4       50 0.2139555 12.258749 48.859935 3633.5505
## 77  3750   4       50 0.2139555 12.258749 48.859935 3682.4104
## 78  3800   4       50 0.2139555 12.258749 48.859935 3731.2704
## 79  3850   4       50 0.2139555 12.258749 48.859935 3780.1303
## 80  3900   4       50 0.2139555 12.258749 48.859935 3828.9902
## 81  3950   4       50 0.2139555 12.258749 48.859935 3877.8502
## 82  4000   4       50 0.2139555 12.258749 48.859935 3926.7101
## 83  4050   4       50 0.2139555 12.258749 48.859935 3975.5700
## 84  4075   4       25 0.2139555 12.258749 24.429967 4000.0000
## 85  4100   5       25 0.2633734 15.090185 24.137931 4024.1379
## 86  4150   5       50 0.2633734 15.090185 48.275862 4072.4138
## 87  4200   5       50 0.2633734 15.090185 48.275862 4120.6897
## 88  4250   5       50 0.2633734 15.090185 48.275862 4168.9655
## 89  4300   5       50 0.2633734 15.090185 48.275862 4217.2414
## 90  4350   5       50 0.2633734 15.090185 48.275862 4265.5172
## 91  4400   5       50 0.2633734 15.090185 48.275862 4313.7931
## 92  4450   5       50 0.2633734 15.090185 48.275862 4362.0690
## 93  4500   5       50 0.2633734 15.090185 48.275862 4410.3448
## 94  4550   5       50 0.2633734 15.090185 48.275862 4458.6207
## 95  4600   5       50 0.2633734 15.090185 48.275862 4506.8966
## 96  4650   5       50 0.2633734 15.090185 48.275862 4555.1724
## 97  4700   5       50 0.2633734 15.090185 48.275862 4603.4483
## 98  4750   5       50 0.2633734 15.090185 48.275862 4651.7241
## 99  4800   5       50 0.2633734 15.090185 48.275862 4700.0000
## 100 4850   5       50 0.2633734 15.090185 48.275862 4748.2759
## 101 4900   5       50 0.2633734 15.090185 48.275862 4796.5517
## 102 4950   5       50 0.2633734 15.090185 48.275862 4844.8276
## 103 5000   5       50 0.2633734 15.090185 48.275862 4893.1034
## 104 5050   5       50 0.2633734 15.090185 48.275862 4941.3793
## 105 5100   5       50 0.2633734 15.090185 48.275862 4989.6552
## 106 5150   5       50 0.2633734 15.090185 48.275862 5037.9310
## 107 5200   5       50 0.2633734 15.090185 48.275862 5086.2069
## 108 5250   5       50 0.2633734 15.090185 48.275862 5134.4828
## 109 5300   5       50 0.2633734 15.090185 48.275862 5182.7586
## 110 5350   5       50 0.2633734 15.090185 48.275862 5231.0345
## 111 5400   5       50 0.2633734 15.090185 48.275862 5279.3103
## 112 5450   5       50 0.2633734 15.090185 48.275862 5327.5862
## 113 5500   5       50 0.2633734 15.090185 48.275862 5375.8621
## 114 5550   5       50 0.2633734 15.090185 48.275862 5424.1379
## 115 5600   5       50 0.2633734 15.090185 48.275862 5472.4138
## 116 5650   5       50 0.2633734 15.090185 48.275862 5520.6897
## 117 5700   5       50 0.2633734 15.090185 48.275862 5568.9655
## 118 5750   5       50 0.2633734 15.090185 48.275862 5617.2414
## 119 5800   5       50 0.2633734 15.090185 48.275862 5665.5172
## 120 5850   5       50 0.2633734 15.090185 48.275862 5713.7931
## 121 5900   5       50 0.2633734 15.090185 48.275862 5762.0690
## 122 5950   5       50 0.2633734 15.090185 48.275862 5810.3448
## 123 6000   5       50 0.2633734 15.090185 48.275862 5858.6207
## 124 6050   5       50 0.2633734 15.090185 48.275862 5906.8966
## 125 6100   5       50 0.2633734 15.090185 48.275862 5955.1724
## 126 6150   5       50 0.2633734 15.090185 48.275862 6003.4483
## 127 6200   5       50 0.2633734 15.090185 48.275862 6051.7241
## 128 6250   5       50 0.2633734 15.090185 48.275862 6100.0000
## 129 6300   5       50 0.2633734 15.090185 48.275862 6148.2759
## 130 6350   5       50 0.2633734 15.090185 48.275862 6196.5517
## 131 6400   5       50 0.2633734 15.090185 48.275862 6244.8276
## 132 6450   5       50 0.2633734 15.090185 48.275862 6293.1034
## 133 6500   5       50 0.2633734 15.090185 48.275862 6341.3793
## 134 6550   5       50 0.2633734 15.090185 48.275862 6389.6552
## 135 6600   5       50 0.2633734 15.090185 48.275862 6437.9310
## 136 6650   5       50 0.2633734 15.090185 48.275862 6486.2069
## 137 6700   5       50 0.2633734 15.090185 48.275862 6534.4828
## 138 6750   5       50 0.2633734 15.090185 48.275862 6582.7586
## 139 6800   5       50 0.2633734 15.090185 48.275862 6631.0345
## 140 6850   5       50 0.2633734 15.090185 48.275862 6679.3103
## 141 6900   5       50 0.2633734 15.090185 48.275862 6727.5862
## 142 6950   5       50 0.2633734 15.090185 48.275862 6775.8621
## 143 7000   5       50 0.2633734 15.090185 48.275862 6824.1379
## 144 7050   5       50 0.2633734 15.090185 48.275862 6872.4138
## 145 7100   5       50 0.2633734 15.090185 48.275862 6920.6897
## 146 7150   5       50 0.2633734 15.090185 48.275862 6968.9655
## 147 7200   5       50 0.2633734 15.090185 48.275862 7017.2414
## 148 7250   5       50 0.2633734 15.090185 48.275862 7065.5172
## 149 7300   5       50 0.2633734 15.090185 48.275862 7113.7931
## 150 7350   5       50 0.2633734 15.090185 48.275862 7162.0690
## 151 7400   5       50 0.2633734 15.090185 48.275862 7210.3448
## 152 7450   5       50 0.2633734 15.090185 48.275862 7258.6207
## 153 7500   5       50 0.2633734 15.090185 48.275862 7306.8966
## 154 7550   5       50 0.2633734 15.090185 48.275862 7355.1724
## 155 7600   5       50 0.2633734 15.090185 48.275862 7403.4483
## 156 7650   5       50 0.2633734 15.090185 48.275862 7451.7241
## 157 7700   5       50 0.2633734 15.090185 48.275862 7500.0000
## 158 7750   6       50 0.3098446 17.752790 47.619048 7547.6190
## 159 7800   6       50 0.3098446 17.752790 47.619048 7595.2381
## 160 7850   6       50 0.3098446 17.752790 47.619048 7642.8571
## 161 7900   6       50 0.3098446 17.752790 47.619048 7690.4762
## 162 7950   6       50 0.3098446 17.752790 47.619048 7738.0952
## 163 8000   6       50 0.3098446 17.752790 47.619048 7785.7143
## 164 8050   6       50 0.3098446 17.752790 47.619048 7833.3333
## 165 8100   6       50 0.3098446 17.752790 47.619048 7880.9524
## 166 8150   6       50 0.3098446 17.752790 47.619048 7928.5714
## 167 8200   6       50 0.3098446 17.752790 47.619048 7976.1905
## 168 8250   6       50 0.3098446 17.752790 47.619048 8023.8095
## 169 8300   6       50 0.3098446 17.752790 47.619048 8071.4286
## 170 8350   6       50 0.3098446 17.752790 47.619048 8119.0476
## 171 8400   6       50 0.3098446 17.752790 47.619048 8166.6667
## 172 8450   6       50 0.3098446 17.752790 47.619048 8214.2857
## 173 8500   6       50 0.3098446 17.752790 47.619048 8261.9048
## 174 8550   6       50 0.3098446 17.752790 47.619048 8309.5238
## 175 8600   6       50 0.3098446 17.752790 47.619048 8357.1429
## 176 8650   6       50 0.3098446 17.752790 47.619048 8404.7619
## 177 8700   6       50 0.3098446 17.752790 47.619048 8452.3810
## 178 8750   6       50 0.3098446 17.752790 47.619048 8500.0000
## 179 8800   6       50 0.3098446 17.752790 47.619048 8547.6190
## 180 8850   6       50 0.3098446 17.752790 47.619048 8595.2381
## 181 8900   6       50 0.3098446 17.752790 47.619048 8642.8571
## 182 8950   6       50 0.3098446 17.752790 47.619048 8690.4762
## 183 9000   6       50 0.3098446 17.752790 47.619048 8738.0952
## 184 9050   6       50 0.3098446 17.752790 47.619048 8785.7143
## 185 9100   6       50 0.3098446 17.752790 47.619048 8833.3333
## 186 9150   6       50 0.3098446 17.752790 47.619048 8880.9524
## 187 9200   6       50 0.3098446 17.752790 47.619048 8928.5714
## 188 9250   6       50 0.3098446 17.752790 47.619048 8976.1905
## 189 9275   6       25 0.3098446 17.752790 23.809524 9000.0000
rNodal:::build_survey_with_deltas(deviation_survey, add_md_lo)
##           md seg  delta.md   radians   degrees delta.tvd       tvd
## 1     0.0000   1   0.00000 0.0000000  0.000000   0.00000    0.0000
## 2   237.8205   2 237.82051 0.0000000  0.000000 237.82051  237.8205
## 3   475.6410   2 237.82051 0.0000000  0.000000 237.82051  475.6410
## 4   600.0000   2 124.35897 0.0000000  0.000000 124.35897  600.0000
## 5   713.4615   3 113.46154 0.1572970  9.012451 112.06078  712.0608
## 6   951.2821   3 237.82051 0.1572970  9.012451 234.88446  946.9452
## 7  1005.0000   3  53.71795 0.1572970  9.012451  53.05476 1000.0000
## 8  1189.1026   4 184.10256 0.2139555 12.258749 179.90479 1179.9048
## 9  1426.9231   4 237.82051 0.2139555 12.258749 232.39790 1412.3027
## 10 1664.7436   4 237.82051 0.2139555 12.258749 232.39790 1644.7006
## 11 1902.5641   4 237.82051 0.2139555 12.258749 232.39790 1877.0985
## 12 2140.3846   4 237.82051 0.2139555 12.258749 232.39790 2109.4964
## 13 2378.2051   4 237.82051 0.2139555 12.258749 232.39790 2341.8943
## 14 2616.0256   4 237.82051 0.2139555 12.258749 232.39790 2574.2922
## 15 2853.8462   4 237.82051 0.2139555 12.258749 232.39790 2806.6901
## 16 3091.6667   4 237.82051 0.2139555 12.258749 232.39790 3039.0879
## 17 3329.4872   4 237.82051 0.2139555 12.258749 232.39790 3271.4858
## 18 3567.3077   4 237.82051 0.2139555 12.258749 232.39790 3503.8837
## 19 3805.1282   4 237.82051 0.2139555 12.258749 232.39790 3736.2816
## 20 4042.9487   4 237.82051 0.2139555 12.258749 232.39790 3968.6795
## 21 4075.0000   4  32.05128 0.2139555 12.258749  31.32047 4000.0000
## 22 4280.7692   5 205.76923 0.2633734 15.090185 198.67374 4198.6737
## 23 4518.5897   5 237.82051 0.2633734 15.090185 229.61981 4428.2935
## 24 4756.4103   5 237.82051 0.2633734 15.090185 229.61981 4657.9134
## 25 4994.2308   5 237.82051 0.2633734 15.090185 229.61981 4887.5332
## 26 5232.0513   5 237.82051 0.2633734 15.090185 229.61981 5117.1530
## 27 5469.8718   5 237.82051 0.2633734 15.090185 229.61981 5346.7728
## 28 5707.6923   5 237.82051 0.2633734 15.090185 229.61981 5576.3926
## 29 5945.5128   5 237.82051 0.2633734 15.090185 229.61981 5806.0124
## 30 6183.3333   5 237.82051 0.2633734 15.090185 229.61981 6035.6322
## 31 6421.1538   5 237.82051 0.2633734 15.090185 229.61981 6265.2520
## 32 6658.9744   5 237.82051 0.2633734 15.090185 229.61981 6494.8718
## 33 6896.7949   5 237.82051 0.2633734 15.090185 229.61981 6724.4916
## 34 7134.6154   5 237.82051 0.2633734 15.090185 229.61981 6954.1114
## 35 7372.4359   5 237.82051 0.2633734 15.090185 229.61981 7183.7312
## 36 7610.2564   5 237.82051 0.2633734 15.090185 229.61981 7413.3510
## 37 7700.0000   5  89.74359 0.2633734 15.090185  86.64898 7500.0000
## 38 7848.0769   6 148.07692 0.3098446 17.752790 141.02564 7641.0256
## 39 8085.8974   6 237.82051 0.3098446 17.752790 226.49573 7867.5214
## 40 8323.7179   6 237.82051 0.3098446 17.752790 226.49573 8094.0171
## 41 8561.5385   6 237.82051 0.3098446 17.752790 226.49573 8320.5128
## 42 8799.3590   6 237.82051 0.3098446 17.752790 226.49573 8547.0085
## 43 9037.1795   6 237.82051 0.3098446 17.752790 226.49573 8773.5043
## 44 9275.0000   6 237.82051 0.3098446 17.752790 226.49573 9000.0000
# split the MD of the well in equal parts but a total of "n" segments
split <- seq.int(deviation_survey[1, "MD"], deviation_survey[nrow(deviation_survey), "MD"], 
                 length.out = 100)

# add the known MD values to the sequence. Now the length is little bit longer
md <- deviation_survey[["MD"]]
add_md <- sort(unique(c(md, split)))
add_md
##   [1]    0.00000   93.68687  187.37374  281.06061  374.74747  468.43434
##   [7]  562.12121  600.00000  655.80808  749.49495  843.18182  936.86869
##  [13] 1005.00000 1030.55556 1124.24242 1217.92929 1311.61616 1405.30303
##  [19] 1498.98990 1592.67677 1686.36364 1780.05051 1873.73737 1967.42424
##  [25] 2061.11111 2154.79798 2248.48485 2342.17172 2435.85859 2529.54545
##  [31] 2623.23232 2716.91919 2810.60606 2904.29293 2997.97980 3091.66667
##  [37] 3185.35354 3279.04040 3372.72727 3466.41414 3560.10101 3653.78788
##  [43] 3747.47475 3841.16162 3934.84848 4028.53535 4075.00000 4122.22222
##  [49] 4215.90909 4309.59596 4403.28283 4496.96970 4590.65657 4684.34343
##  [55] 4778.03030 4871.71717 4965.40404 5059.09091 5152.77778 5246.46465
##  [61] 5340.15152 5433.83838 5527.52525 5621.21212 5714.89899 5808.58586
##  [67] 5902.27273 5995.95960 6089.64646 6183.33333 6277.02020 6370.70707
##  [73] 6464.39394 6558.08081 6651.76768 6745.45455 6839.14141 6932.82828
##  [79] 7026.51515 7120.20202 7213.88889 7307.57576 7401.26263 7494.94949
##  [85] 7588.63636 7682.32323 7700.00000 7776.01010 7869.69697 7963.38384
##  [91] 8057.07071 8150.75758 8244.44444 8338.13131 8431.81818 8525.50505
##  [97] 8619.19192 8712.87879 8806.56566 8900.25253 8993.93939 9087.62626
## [103] 9181.31313 9275.00000
# reconstruct MD v TVD but for the partitioned well in delta-x
df <- data.frame()     # new long dataframe
index <- 1             # index the small dataframe
tvd <- 0 
for (j in 1:length(add_md)) {  # iterate through the sequence
    row = dataFrame[index, ]   # get a row of the deviation survey
    # cat(index)
    df[j, "md"]  <- add_md[j]  # assign MD in sequence to md in long dataframe
    df[j, "seg"] <- index      # assign 
    if (j == 1)                 # if it is the first row
        df[j, "delta.md"] <- add_md[j]
    else
        df[j, "delta.md"] <- add_md[j] - df[j-1, "md"]
    
    df[j, "radians"] <- row[["radians"]]
    df[j, "degrees"] <- row[["degrees"]]
    df[j, "delta.tvd"] <- cos(row[["radians"]]) * df[j, "delta.md"] # calculate delta TVD
    tvd <- tvd + df[j, "delta.tvd"]        # add delta.tvd
    df[j, "tvd"] <- tvd                    # tvd column
    if (add_md[j] >= row[["MD"]]) {        # switch to next deviation branch
        index <- index + 1
    }
}
df
##             md seg delta.md   radians   degrees delta.tvd        tvd
## 1      0.00000   1  0.00000 0.0000000  0.000000   0.00000    0.00000
## 2     93.68687   2 93.68687 0.0000000  0.000000  93.68687   93.68687
## 3    187.37374   2 93.68687 0.0000000  0.000000  93.68687  187.37374
## 4    281.06061   2 93.68687 0.0000000  0.000000  93.68687  281.06061
## 5    374.74747   2 93.68687 0.0000000  0.000000  93.68687  374.74747
## 6    468.43434   2 93.68687 0.0000000  0.000000  93.68687  468.43434
## 7    562.12121   2 93.68687 0.0000000  0.000000  93.68687  562.12121
## 8    600.00000   2 37.87879 0.0000000  0.000000  37.87879  600.00000
## 9    655.80808   3 55.80808 0.1572970  9.012451  55.11909  655.11909
## 10   749.49495   3 93.68687 0.1572970  9.012451  92.53024  747.64933
## 11   843.18182   3 93.68687 0.1572970  9.012451  92.53024  840.17957
## 12   936.86869   3 93.68687 0.1572970  9.012451  92.53024  932.70981
## 13  1005.00000   3 68.13131 0.1572970  9.012451  67.29019 1000.00000
## 14  1030.55556   4 25.55556 0.2139555 12.258749  24.97286 1024.97286
## 15  1124.24242   4 93.68687 0.2139555 12.258749  91.55069 1116.52354
## 16  1217.92929   4 93.68687 0.2139555 12.258749  91.55069 1208.07423
## 17  1311.61616   4 93.68687 0.2139555 12.258749  91.55069 1299.62491
## 18  1405.30303   4 93.68687 0.2139555 12.258749  91.55069 1391.17560
## 19  1498.98990   4 93.68687 0.2139555 12.258749  91.55069 1482.72629
## 20  1592.67677   4 93.68687 0.2139555 12.258749  91.55069 1574.27697
## 21  1686.36364   4 93.68687 0.2139555 12.258749  91.55069 1665.82766
## 22  1780.05051   4 93.68687 0.2139555 12.258749  91.55069 1757.37834
## 23  1873.73737   4 93.68687 0.2139555 12.258749  91.55069 1848.92903
## 24  1967.42424   4 93.68687 0.2139555 12.258749  91.55069 1940.47972
## 25  2061.11111   4 93.68687 0.2139555 12.258749  91.55069 2032.03040
## 26  2154.79798   4 93.68687 0.2139555 12.258749  91.55069 2123.58109
## 27  2248.48485   4 93.68687 0.2139555 12.258749  91.55069 2215.13177
## 28  2342.17172   4 93.68687 0.2139555 12.258749  91.55069 2306.68246
## 29  2435.85859   4 93.68687 0.2139555 12.258749  91.55069 2398.23315
## 30  2529.54545   4 93.68687 0.2139555 12.258749  91.55069 2489.78383
## 31  2623.23232   4 93.68687 0.2139555 12.258749  91.55069 2581.33452
## 32  2716.91919   4 93.68687 0.2139555 12.258749  91.55069 2672.88520
## 33  2810.60606   4 93.68687 0.2139555 12.258749  91.55069 2764.43589
## 34  2904.29293   4 93.68687 0.2139555 12.258749  91.55069 2855.98658
## 35  2997.97980   4 93.68687 0.2139555 12.258749  91.55069 2947.53726
## 36  3091.66667   4 93.68687 0.2139555 12.258749  91.55069 3039.08795
## 37  3185.35354   4 93.68687 0.2139555 12.258749  91.55069 3130.63863
## 38  3279.04040   4 93.68687 0.2139555 12.258749  91.55069 3222.18932
## 39  3372.72727   4 93.68687 0.2139555 12.258749  91.55069 3313.74001
## 40  3466.41414   4 93.68687 0.2139555 12.258749  91.55069 3405.29069
## 41  3560.10101   4 93.68687 0.2139555 12.258749  91.55069 3496.84138
## 42  3653.78788   4 93.68687 0.2139555 12.258749  91.55069 3588.39206
## 43  3747.47475   4 93.68687 0.2139555 12.258749  91.55069 3679.94275
## 44  3841.16162   4 93.68687 0.2139555 12.258749  91.55069 3771.49344
## 45  3934.84848   4 93.68687 0.2139555 12.258749  91.55069 3863.04412
## 46  4028.53535   4 93.68687 0.2139555 12.258749  91.55069 3954.59481
## 47  4075.00000   4 46.46465 0.2139555 12.258749  45.40519 4000.00000
## 48  4122.22222   5 47.22222 0.2633734 15.090185  45.59387 4045.59387
## 49  4215.90909   5 93.68687 0.2633734 15.090185  90.45629 4136.05016
## 50  4309.59596   5 93.68687 0.2633734 15.090185  90.45629 4226.50644
## 51  4403.28283   5 93.68687 0.2633734 15.090185  90.45629 4316.96273
## 52  4496.96970   5 93.68687 0.2633734 15.090185  90.45629 4407.41902
## 53  4590.65657   5 93.68687 0.2633734 15.090185  90.45629 4497.87530
## 54  4684.34343   5 93.68687 0.2633734 15.090185  90.45629 4588.33159
## 55  4778.03030   5 93.68687 0.2633734 15.090185  90.45629 4678.78788
## 56  4871.71717   5 93.68687 0.2633734 15.090185  90.45629 4769.24417
## 57  4965.40404   5 93.68687 0.2633734 15.090185  90.45629 4859.70045
## 58  5059.09091   5 93.68687 0.2633734 15.090185  90.45629 4950.15674
## 59  5152.77778   5 93.68687 0.2633734 15.090185  90.45629 5040.61303
## 60  5246.46465   5 93.68687 0.2633734 15.090185  90.45629 5131.06931
## 61  5340.15152   5 93.68687 0.2633734 15.090185  90.45629 5221.52560
## 62  5433.83838   5 93.68687 0.2633734 15.090185  90.45629 5311.98189
## 63  5527.52525   5 93.68687 0.2633734 15.090185  90.45629 5402.43817
## 64  5621.21212   5 93.68687 0.2633734 15.090185  90.45629 5492.89446
## 65  5714.89899   5 93.68687 0.2633734 15.090185  90.45629 5583.35075
## 66  5808.58586   5 93.68687 0.2633734 15.090185  90.45629 5673.80704
## 67  5902.27273   5 93.68687 0.2633734 15.090185  90.45629 5764.26332
## 68  5995.95960   5 93.68687 0.2633734 15.090185  90.45629 5854.71961
## 69  6089.64646   5 93.68687 0.2633734 15.090185  90.45629 5945.17590
## 70  6183.33333   5 93.68687 0.2633734 15.090185  90.45629 6035.63218
## 71  6277.02020   5 93.68687 0.2633734 15.090185  90.45629 6126.08847
## 72  6370.70707   5 93.68687 0.2633734 15.090185  90.45629 6216.54476
## 73  6464.39394   5 93.68687 0.2633734 15.090185  90.45629 6307.00104
## 74  6558.08081   5 93.68687 0.2633734 15.090185  90.45629 6397.45733
## 75  6651.76768   5 93.68687 0.2633734 15.090185  90.45629 6487.91362
## 76  6745.45455   5 93.68687 0.2633734 15.090185  90.45629 6578.36991
## 77  6839.14141   5 93.68687 0.2633734 15.090185  90.45629 6668.82619
## 78  6932.82828   5 93.68687 0.2633734 15.090185  90.45629 6759.28248
## 79  7026.51515   5 93.68687 0.2633734 15.090185  90.45629 6849.73877
## 80  7120.20202   5 93.68687 0.2633734 15.090185  90.45629 6940.19505
## 81  7213.88889   5 93.68687 0.2633734 15.090185  90.45629 7030.65134
## 82  7307.57576   5 93.68687 0.2633734 15.090185  90.45629 7121.10763
## 83  7401.26263   5 93.68687 0.2633734 15.090185  90.45629 7211.56392
## 84  7494.94949   5 93.68687 0.2633734 15.090185  90.45629 7302.02020
## 85  7588.63636   5 93.68687 0.2633734 15.090185  90.45629 7392.47649
## 86  7682.32323   5 93.68687 0.2633734 15.090185  90.45629 7482.93278
## 87  7700.00000   5 17.67677 0.2633734 15.090185  17.06722 7500.00000
## 88  7776.01010   6 76.01010 0.3098446 17.752790  72.39057 7572.39057
## 89  7869.69697   6 93.68687 0.3098446 17.752790  89.22559 7661.61616
## 90  7963.38384   6 93.68687 0.3098446 17.752790  89.22559 7750.84175
## 91  8057.07071   6 93.68687 0.3098446 17.752790  89.22559 7840.06734
## 92  8150.75758   6 93.68687 0.3098446 17.752790  89.22559 7929.29293
## 93  8244.44444   6 93.68687 0.3098446 17.752790  89.22559 8018.51852
## 94  8338.13131   6 93.68687 0.3098446 17.752790  89.22559 8107.74411
## 95  8431.81818   6 93.68687 0.3098446 17.752790  89.22559 8196.96970
## 96  8525.50505   6 93.68687 0.3098446 17.752790  89.22559 8286.19529
## 97  8619.19192   6 93.68687 0.3098446 17.752790  89.22559 8375.42088
## 98  8712.87879   6 93.68687 0.3098446 17.752790  89.22559 8464.64646
## 99  8806.56566   6 93.68687 0.3098446 17.752790  89.22559 8553.87205
## 100 8900.25253   6 93.68687 0.3098446 17.752790  89.22559 8643.09764
## 101 8993.93939   6 93.68687 0.3098446 17.752790  89.22559 8732.32323
## 102 9087.62626   6 93.68687 0.3098446 17.752790  89.22559 8821.54882
## 103 9181.31313   6 93.68687 0.3098446 17.752790  89.22559 8910.77441
## 104 9275.00000   6 93.68687 0.3098446 17.752790  89.22559 9000.00000
# iterate through dataframe
 for (index in 1:nrow(dataFrame)) { 
     row = dataFrame[index, ] 
     # do stuff with the row 
     # print(row[["MD"]])
     cat(row[["MD"]], "\n")
 } 
## 0 
## 600 
## 1005 
## 4075 
## 7700 
## 9275
for (index in 1:nrow(dataFrame)) { 
    row = dataFrame[index, ] 
    # cat(row, "\n")
    for (j in add_md) {
        if (j <= row[["MD"]]) {
            cat(sprintf("%12f %12f \n", j, row[["MD"]]))
            # print(row[["MD"]][index] * sin(row[["radians"]][index]))
        }
    }
}
##     0.000000     0.000000 
##     0.000000   600.000000 
##    93.686869   600.000000 
##   187.373737   600.000000 
##   281.060606   600.000000 
##   374.747475   600.000000 
##   468.434343   600.000000 
##   562.121212   600.000000 
##   600.000000   600.000000 
##     0.000000  1005.000000 
##    93.686869  1005.000000 
##   187.373737  1005.000000 
##   281.060606  1005.000000 
##   374.747475  1005.000000 
##   468.434343  1005.000000 
##   562.121212  1005.000000 
##   600.000000  1005.000000 
##   655.808081  1005.000000 
##   749.494949  1005.000000 
##   843.181818  1005.000000 
##   936.868687  1005.000000 
##  1005.000000  1005.000000 
##     0.000000  4075.000000 
##    93.686869  4075.000000 
##   187.373737  4075.000000 
##   281.060606  4075.000000 
##   374.747475  4075.000000 
##   468.434343  4075.000000 
##   562.121212  4075.000000 
##   600.000000  4075.000000 
##   655.808081  4075.000000 
##   749.494949  4075.000000 
##   843.181818  4075.000000 
##   936.868687  4075.000000 
##  1005.000000  4075.000000 
##  1030.555556  4075.000000 
##  1124.242424  4075.000000 
##  1217.929293  4075.000000 
##  1311.616162  4075.000000 
##  1405.303030  4075.000000 
##  1498.989899  4075.000000 
##  1592.676768  4075.000000 
##  1686.363636  4075.000000 
##  1780.050505  4075.000000 
##  1873.737374  4075.000000 
##  1967.424242  4075.000000 
##  2061.111111  4075.000000 
##  2154.797980  4075.000000 
##  2248.484848  4075.000000 
##  2342.171717  4075.000000 
##  2435.858586  4075.000000 
##  2529.545455  4075.000000 
##  2623.232323  4075.000000 
##  2716.919192  4075.000000 
##  2810.606061  4075.000000 
##  2904.292929  4075.000000 
##  2997.979798  4075.000000 
##  3091.666667  4075.000000 
##  3185.353535  4075.000000 
##  3279.040404  4075.000000 
##  3372.727273  4075.000000 
##  3466.414141  4075.000000 
##  3560.101010  4075.000000 
##  3653.787879  4075.000000 
##  3747.474747  4075.000000 
##  3841.161616  4075.000000 
##  3934.848485  4075.000000 
##  4028.535354  4075.000000 
##  4075.000000  4075.000000 
##     0.000000  7700.000000 
##    93.686869  7700.000000 
##   187.373737  7700.000000 
##   281.060606  7700.000000 
##   374.747475  7700.000000 
##   468.434343  7700.000000 
##   562.121212  7700.000000 
##   600.000000  7700.000000 
##   655.808081  7700.000000 
##   749.494949  7700.000000 
##   843.181818  7700.000000 
##   936.868687  7700.000000 
##  1005.000000  7700.000000 
##  1030.555556  7700.000000 
##  1124.242424  7700.000000 
##  1217.929293  7700.000000 
##  1311.616162  7700.000000 
##  1405.303030  7700.000000 
##  1498.989899  7700.000000 
##  1592.676768  7700.000000 
##  1686.363636  7700.000000 
##  1780.050505  7700.000000 
##  1873.737374  7700.000000 
##  1967.424242  7700.000000 
##  2061.111111  7700.000000 
##  2154.797980  7700.000000 
##  2248.484848  7700.000000 
##  2342.171717  7700.000000 
##  2435.858586  7700.000000 
##  2529.545455  7700.000000 
##  2623.232323  7700.000000 
##  2716.919192  7700.000000 
##  2810.606061  7700.000000 
##  2904.292929  7700.000000 
##  2997.979798  7700.000000 
##  3091.666667  7700.000000 
##  3185.353535  7700.000000 
##  3279.040404  7700.000000 
##  3372.727273  7700.000000 
##  3466.414141  7700.000000 
##  3560.101010  7700.000000 
##  3653.787879  7700.000000 
##  3747.474747  7700.000000 
##  3841.161616  7700.000000 
##  3934.848485  7700.000000 
##  4028.535354  7700.000000 
##  4075.000000  7700.000000 
##  4122.222222  7700.000000 
##  4215.909091  7700.000000 
##  4309.595960  7700.000000 
##  4403.282828  7700.000000 
##  4496.969697  7700.000000 
##  4590.656566  7700.000000 
##  4684.343434  7700.000000 
##  4778.030303  7700.000000 
##  4871.717172  7700.000000 
##  4965.404040  7700.000000 
##  5059.090909  7700.000000 
##  5152.777778  7700.000000 
##  5246.464646  7700.000000 
##  5340.151515  7700.000000 
##  5433.838384  7700.000000 
##  5527.525253  7700.000000 
##  5621.212121  7700.000000 
##  5714.898990  7700.000000 
##  5808.585859  7700.000000 
##  5902.272727  7700.000000 
##  5995.959596  7700.000000 
##  6089.646465  7700.000000 
##  6183.333333  7700.000000 
##  6277.020202  7700.000000 
##  6370.707071  7700.000000 
##  6464.393939  7700.000000 
##  6558.080808  7700.000000 
##  6651.767677  7700.000000 
##  6745.454545  7700.000000 
##  6839.141414  7700.000000 
##  6932.828283  7700.000000 
##  7026.515152  7700.000000 
##  7120.202020  7700.000000 
##  7213.888889  7700.000000 
##  7307.575758  7700.000000 
##  7401.262626  7700.000000 
##  7494.949495  7700.000000 
##  7588.636364  7700.000000 
##  7682.323232  7700.000000 
##  7700.000000  7700.000000 
##     0.000000  9275.000000 
##    93.686869  9275.000000 
##   187.373737  9275.000000 
##   281.060606  9275.000000 
##   374.747475  9275.000000 
##   468.434343  9275.000000 
##   562.121212  9275.000000 
##   600.000000  9275.000000 
##   655.808081  9275.000000 
##   749.494949  9275.000000 
##   843.181818  9275.000000 
##   936.868687  9275.000000 
##  1005.000000  9275.000000 
##  1030.555556  9275.000000 
##  1124.242424  9275.000000 
##  1217.929293  9275.000000 
##  1311.616162  9275.000000 
##  1405.303030  9275.000000 
##  1498.989899  9275.000000 
##  1592.676768  9275.000000 
##  1686.363636  9275.000000 
##  1780.050505  9275.000000 
##  1873.737374  9275.000000 
##  1967.424242  9275.000000 
##  2061.111111  9275.000000 
##  2154.797980  9275.000000 
##  2248.484848  9275.000000 
##  2342.171717  9275.000000 
##  2435.858586  9275.000000 
##  2529.545455  9275.000000 
##  2623.232323  9275.000000 
##  2716.919192  9275.000000 
##  2810.606061  9275.000000 
##  2904.292929  9275.000000 
##  2997.979798  9275.000000 
##  3091.666667  9275.000000 
##  3185.353535  9275.000000 
##  3279.040404  9275.000000 
##  3372.727273  9275.000000 
##  3466.414141  9275.000000 
##  3560.101010  9275.000000 
##  3653.787879  9275.000000 
##  3747.474747  9275.000000 
##  3841.161616  9275.000000 
##  3934.848485  9275.000000 
##  4028.535354  9275.000000 
##  4075.000000  9275.000000 
##  4122.222222  9275.000000 
##  4215.909091  9275.000000 
##  4309.595960  9275.000000 
##  4403.282828  9275.000000 
##  4496.969697  9275.000000 
##  4590.656566  9275.000000 
##  4684.343434  9275.000000 
##  4778.030303  9275.000000 
##  4871.717172  9275.000000 
##  4965.404040  9275.000000 
##  5059.090909  9275.000000 
##  5152.777778  9275.000000 
##  5246.464646  9275.000000 
##  5340.151515  9275.000000 
##  5433.838384  9275.000000 
##  5527.525253  9275.000000 
##  5621.212121  9275.000000 
##  5714.898990  9275.000000 
##  5808.585859  9275.000000 
##  5902.272727  9275.000000 
##  5995.959596  9275.000000 
##  6089.646465  9275.000000 
##  6183.333333  9275.000000 
##  6277.020202  9275.000000 
##  6370.707071  9275.000000 
##  6464.393939  9275.000000 
##  6558.080808  9275.000000 
##  6651.767677  9275.000000 
##  6745.454545  9275.000000 
##  6839.141414  9275.000000 
##  6932.828283  9275.000000 
##  7026.515152  9275.000000 
##  7120.202020  9275.000000 
##  7213.888889  9275.000000 
##  7307.575758  9275.000000 
##  7401.262626  9275.000000 
##  7494.949495  9275.000000 
##  7588.636364  9275.000000 
##  7682.323232  9275.000000 
##  7700.000000  9275.000000 
##  7776.010101  9275.000000 
##  7869.696970  9275.000000 
##  7963.383838  9275.000000 
##  8057.070707  9275.000000 
##  8150.757576  9275.000000 
##  8244.444444  9275.000000 
##  8338.131313  9275.000000 
##  8431.818182  9275.000000 
##  8525.505051  9275.000000 
##  8619.191919  9275.000000 
##  8712.878788  9275.000000 
##  8806.565657  9275.000000 
##  8900.252525  9275.000000 
##  8993.939394  9275.000000 
##  9087.626263  9275.000000 
##  9181.313131  9275.000000 
##  9275.000000  9275.000000
# split the tubing in dx pieces
apply(deviation_survey, 1, function(x) x["MD"] 
)
## [1]    0  600 1005 4075 7700 9275