Automate the Boring Stuff with Python—An Innovative Solution to Borehole Salinity Estimation
Authors: Dutta M. , Das A. , Hati S. , Das B. 
Published: May 2023

Abstract
Most field engineers and geoscientists find the estimation of borehole salinity using multiple mud reports to be a tedious task. The existing process involves using spreadsheets with multiple charts for conversion and requires the user to juggle from charts to reports to calculators at the same time. Depending on the mud vendor, the standard of estimation and equations change, making the process more user intensive. However, these equations can be strategically used in a programming language to automate this exhaustive and manual process of estimation. Any open-source code editor can be used to run the codes and generate borehole salinity at any depth desired. Borehole salinity is an important parameter as it influences the correction of neutron porosity and associated measurements to be used for petrophysical evaluation.
In this study we first outline the current industrywide used methodology of estimating borehole salinity using mud reports supplied by vendors. The input parameters, calculation standards, and equations vary based on mud type and vendor. We also outline the increased complexity and decreased efficiency of the existing estimation process by focusing on two factors: first, equations are mostly embedded in a spreadsheet, which still requires manual interventions such as copying and editing values from large numbers of mud reports. Second, it can be time consuming, and the user needs hours-long training to comprehend the process. We then discuss the novel automated process where a suite of scripts written in open-source Python language runs via any open-source code editor. By using the popular Python library and DataFrame, tabular data from mud reports can be detected and pertinent values can be used as input for necessary calculation using the equations and charts already embedded in the scripts, which eventually generates salinity values in less than a minute.
This project aims to deliver an automated solution to estimate borehole salinity. This methodology can be adopted by engineers on the rig and geoscientists in the office to calculate salinity values instantaneously without using any conversion chart or complicated equations whatsoever. In a case study using 20 samples from a typical mud vendor, we show that the new process is time saving and produces accurate borehole salinity values that are the same as values calculated using a manual technique. It is also a zero-cost process as open-source yet licensed software is used for estimation and needs little training for operation.
The key innovative aspect of this project is to create a stepping-stone towards automation of day-to-day routine tasks that are being executed manually in the office and at the rig site. Existing salinity estimation has remained unchanged since early 2000 and calls for an update as the industry is taking aggressive steps towards automation. Borehole salinity automation is a first of its kind and its successful establishment will encourage more automation of similar calculation-based workflows.