Zabamund / wellpathpy

Well deviation import
GNU Lesser General Public License v3.0
78 stars 28 forks source link

Unable to generate a deviation log without already having the deviation log #62

Open ICWallis opened 2 years ago

ICWallis commented 2 years ago

I'm not sure if this should be raised as an issue or enhancement.

I would like to be able to generate a deviation log (md, az, inc) when I only have positional data (tvd, n, e).

I tested wp against case study data and it works well. But when I use an empty src to make the minimum_curvature class and pass in the case study positional log as lists, I get a slightly different deviation survey result. Not sure why.

The testing method is below and case study data are attached.

#
# Comparision to case study data shows the method works :-)
# It perfectly replicates the case study data
# I passed in the dev log, made a pos log, and then used the pos log to generate a dev log
#

md, inc, azi = wp.read_csv('Case_study_dev_data.csv')

dev = wp.deviation(
    md = md,
    inc = inc,
    azi = azi
)

pos = dev.minimum_curvature()
pos.to_csv('Case_study_T1_pos_log_wp_calculated.csv')
# results perfectly match the case study data :-)

dls = [0] * 21 # 21 values in pos.northing etc

min_curv = wp.minimum_curvature(
    dev, # src
    pos.depth, # TVD
    pos.northing,
    pos.easting,
    dls, 
    )

new_dev = min_curv.deviation()
new_dev.to_csv('Case_study_T2_dev_data_wp_calculated.csv')
# results perfect match the case study data :-)

#
# However, I would like to make a dev log when we only have pos data
# so can not follow the method above in its entirety
# It appeared that min_curve.deviation() only uses tvd, n, e to make the dev log
# but using the approach below did not perfectly replicate the case study data
#

with open ('Case_study_pos_data.csv', encoding='utf-8-sig') as csv_file:
    dict_reader_object = csv.DictReader(csv_file)
    tvd_from_csv = []
    nth_from_csv = []
    est_from_csv = []
    for col in dict_reader_object:
        tvd_from_csv.append(float(col['tvd']))
        nth_from_csv.append(float(col['nth']))
        est_from_csv.append(float(col['est']))

empty_dev = wp.deviation(np.array([]),np.array([]),np.array([]))

min_curv = wp.minimum_curvature(
    empty_dev,
    tvd_from_csv,
    nth_from_csv,
    est_from_csv,
    zeros_dls,
    )

new_dev = min_curv.deviation()
new_dev.to_csv('Case_study_T3_dev_data_wp_calculated.csv')
# inclnation is off by around 1 dp and azumuth is off by 0 - 4 degrees :-(

Case_study_pos_data.csv Case_study_dev_data.csv

Zabamund commented 2 years ago

Thank you for this issue @ICWallis , now I've had time to look at it, a couple of things that would make it easier to help:

  1. please include all required imports in your example, in this case:
    import csv
    import numpy as np
  2. you've not defined zeros_dls, but I assume perhaps you mean the dls that you created? Thank you for including your example files and this code.

I think what you're trying to achieve is not currently supported by wellpathpy, in our position_log Class, we currently require an existing deviation, I know that this is not your use case.

Currently we can resample a position log (that is based on a deviation), onto a new sample interval using minimum curvature but again, this does not match what you need.

I've marked this issue as an enhancement as this is functionality I think we probably should support in a future release. I'll leave this issue open for now until we get a chance to address it.

ICWallis commented 2 years ago

Thanks. I did wonder if this was out-of-scope for the current wellpathpy.

Sorry for missing those bits in the example:

I went back and re-read the source code and now see where the method uses the deviation survey to make the deviation survey. Sorry I missed that the first time around.

jokva commented 2 years ago

You don't need it for the minimum curvature per se, the (presumed source) deviation is kept for resampling. If all you want to do is compute a deviation survey from a position log you can even use None.

If this is a sufficiently common operation we could consider making it a free function and pull the implementation out of minimum_curvature.