An oil-water interface position recognition method based on total difference minimum

By using a method based on minimizing the total difference, an oil-water interface instrument is used to detect and filter the medium in the settling tank, solving the problem of boundary identification caused by the complexity of the medium in the settling tank, and achieving high-precision and low-cost boundary identification.

CN116263351BActive Publication Date: 2026-07-07CHINA PETROLEUM & CHEMICAL CORP +2

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA PETROLEUM & CHEMICAL CORP
Filing Date
2021-12-14
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing oil-water interface signal identification methods have simple algorithms, which cannot adapt to the complex media and emulsion layer in settling tanks, resulting in low identification accuracy and high manpower and material costs.

Method used

The identification method based on minimizing the total difference is adopted. Water, oil and air media are detected by an oil-water interface instrument. After filtering, the standard value and the measured difference are obtained. The total average difference is calculated by combining the standard value of air medium to determine the location of oil-water interface and oil-gas interface.

Benefits of technology

It enables real-time and accurate identification of the oil-water interface and oil-gas interface in the settling tank, simplifies equipment installation, improves identification accuracy, and saves costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116263351B_ABST
    Figure CN116263351B_ABST
Patent Text Reader

Abstract

The application discloses an oil-water interface position recognition method based on minimum total difference value, relates to the technical field of oil detection, and has the technical scheme that an oil-water interface instrument is used to detect three media of water, oil and air respectively, and oil gauge data are acquired; the collected data are filtered and taken as standard values; the standard values are combined with the standard value of the air medium to acquire a standard difference value; a to-be-detected medium is detected to serve as measured data; the acquired measured data are combined with the standard value of the air medium to acquire a measured difference value; a total average difference value is acquired according to the standard difference value and the measured difference value; and the positions of the oil-water interface position and the oil-gas interface position are determined according to the corresponding measurement point on the oil gauge of the total average difference value. The application has the beneficial effect that the application can accurately recognize the oil-water interface position and the oil-gas interface position in the current settling tank in real time according to the characteristics that the medium in the settling tank is complex and the oil-water interface is not clear and separable, and helps technical personnel to quickly master the production status of the settling tank.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of petroleum detection technology, and in particular to an oil-water interface identification method based on minimizing the total difference. Background Technology

[0002] Crude oil settling tanks utilize the density difference between crude oil and water to initially separate oil and water. The oil-water interface is a crucial factor affecting the operation of the settling tank. To understand the operating status of the settling tank, it is necessary to accurately determine the current oil-water interface and oil-gas interface. Currently, obtaining oil-water interface parameters is mainly done manually. Technicians place a measuring ruler into the settling tank and measure it based on the difference in conductivity between oil and water. This measurement method not only has low accuracy but also consumes a significant amount of manpower and resources. Installing an oil-water interface meter in the settling tank can not only provide timely and accurate information on the oil-water and oil-gas interfaces but also free up manpower, making it of great significance.

[0003] The core technology of oil-water interface instruments lies in identifying oil-water interface signals. In settling tanks, due to the presence of an emulsion layer between the oil and water layers, the medium is complex, and the oil-water interface is not clearly distinguishable, increasing the difficulty of identifying the interface signal. Existing oil-water interface signal identification methods are suitable for situations where the oil-water interface is clearly distinguishable, but they cannot adapt to the complex media conditions in settling tanks and are ineffective in identifying oil-water interface signals in settling tanks. For example:

[0004] Patent document (CN208765802U) discloses an oil-water interface sensor and system for a filter separator's water collection tank, relating to the field of oil-water interface detection technology in filter separators. The filter separator's water collection tank contains both water and oil layers, but no emulsion layer, and there is no need to measure the oil-gas interface. The oil-water interface identification algorithm is relatively simple, highly dependent on the measured capacitance value, and lacks a filtering algorithm, making it impossible to avoid errors in the measurement data.

[0005] Patent document (CN102564515A) relates to an electronic fusion measurement interface transmitter and its measurement method, belonging to the technical field of liquid mixed medium measurement equipment, and particularly to the interface measurement technology of oil-water mixed liquid in oil refining equipment. The invention calculates the oil-water interface based on the different relative permittivity of different media. The identification algorithm is simple, but it is not suitable for the situation where there is an emulsion layer in the settling tank. Summary of the Invention

[0006] To address the aforementioned technical problems, this invention provides an oil-water interface identification method based on minimizing the total difference, addressing the issue that existing oil-water interface signal identification methods are too simplistic and unsuitable for situations involving complex media or emulsion layers within settling tanks.

[0007] Its technical solution includes,

[0008] S1. The three media, water, oil and air, are detected by the oil-water interface meter to obtain the data fed back by the dipstick.

[0009] S2. Filter the data collected in S1;

[0010] S3. Record the data processed by S2 as the standard value;

[0011] S4. Combine the standard value obtained in S2 with the standard value of the air medium to obtain the standard deviation of the three media.

[0012] S5. Detect the medium to be tested, and perform the filtering process on the detected data to obtain the measured data.

[0013] S6. Combine the measured data obtained in S5 with the standard value of the air medium to obtain the measured difference;

[0014] S7. Obtain the total average difference based on the standard deviation of S4 and the measured difference of S6;

[0015] S8. Determine the location of the oil-water interface and the oil-gas interface based on the measurement points on the dipstick corresponding to the total average difference.

[0016] Preferably, the filtering process includes performing single-point lateral filtering on the measurement data using a mean-shift clustering algorithm, and performing longitudinal filtering on the measurement data using an arithmetic mean filtering algorithm.

[0017] Preferably, the single-point lateral filtering specifically involves setting a certain test point as C (1≤C≤N), where N is the total number of measurement points on the dipstick;

[0018] Ten recently measured data points of C were selected and clustered into three cluster centers. The three clusters were sorted from smallest to largest, and the measured value of point C was taken from the second cluster center. Single-point lateral filtering was then performed on each measurement point in turn.

[0019] Preferably, the longitudinal filtering is as follows: the length of the dipstick represented by a measurement point is 10mm. In order to preserve the characteristics of the data itself as much as possible, the length of the data template should be an odd number. The value of n (1≤n≤199) should be reasonably selected to ensure that the length of the data template is 2n+1. Since the position span of the interface usually does not exceed 60mm, in order to preserve the characteristics of the data itself, the length of the data template is usually selected as 9.

[0020] For a data template of length 2n+1, where n (1≤n≤199), calculate the mean of the data template and set a threshold m. For each data point in the template, the difference between data and mean is calculated. If the difference data-mean of a certain measurement point is greater than the threshold m, the data of this measurement point is considered to be an outlier, and the measurement value of the previous measurement point is used to replace the measurement value of this measurement point.

[0021] If the measured value of the first measurement point is an outlier, then the measured value of the second measurement point is used instead.

[0022] To ensure effective filtering, the threshold value *m* should be chosen appropriately. Since the data difference at the oil-water boundary is significant, if *m* is too small, the boundary data will be processed as incorrect parameters; if it is too large, smaller outliers will not be filtered out, negatively impacting the subsequent oil-water boundary calibration step. Based on experimental data, a value of 3000 for *m* is suitable here, as it avoids rejecting the oil-water boundary point while still removing larger outliers.

[0023] Preferably, in step S3, the data processed in step S2 is recorded as a standard value, specifically,

[0024] The standard value of the water medium is denoted as s_water;

[0025] The standard value of the oil medium is denoted as s_oil;

[0026] The standard value of the air medium is denoted as s_gas;

[0027] In step S4, the standard value obtained in S2 is combined with the standard value of the air medium to obtain the standard deviation of the three media. Specifically,

[0028] Subtracting the standard value of air from the standard values ​​of water, oil, and air respectively yields the following standard value differences:

[0029] d_water = s_water - s_gas

[0030] d_oil = s_oil - s_gas

[0031] d_gas = s_gas - s_gas = 0

[0032] Where d_water is the standard deviation of water medium, d_oil is the standard deviation of oil medium, and d_gas is the standard deviation of air medium.

[0033] Preferably, in step S6, the measured data obtained in step S5 is combined with the standard value of the air medium to obtain the measured difference. Specifically, the measured data is subtracted from the air standard value to obtain the measured difference, which is denoted as D. i(1≤i≤N), where N is the total number of measuring points on the dipstick.

[0034] Preferably, in step S7, the total average difference is obtained based on the standard deviation of step S4 and the measured difference of step S6, specifically as follows:

[0035] The measured difference D obtained according to S6 i (1≤i≤N), obtain the measured difference D. i (1≤i≤N) is the absolute value of the difference between itself and the standard deviation.

[0036] R i _water=|D i -d_water|

[0037] R i _oil=|D i -d_oil|

[0038] R i _gas=|D i |

[0039] Where (1≤i≤N), N is the total number of measuring points on the dipstick;

[0040] x1 is the oil-water interface test point, x2 is the oil-gas interface test point, the segment (0, x1) represents the water medium, the segment (x1, x2) represents the oil medium, and the segment (x2, N) represents the air medium. A double-layer loop is defined, causing x1 and x2 to iterate from 1 to N respectively. The average value of R for each medium is calculated, where R is the absolute value of the difference. The three average values ​​are summed to obtain the overall average difference M.

[0041]

[0042]

[0043]

[0044] M = M_water + M_oil + M_gas

[0045] When M is at its minimum, x1 and x2 correspond to the locations of the oil-water interface and the oil-gas interface, respectively.

[0046] Preferably, the oil-water interface gauge is an oil-water interface gauge consisting of four oil dipsticks connected in series, with a length of approximately 4 meters and 400 measuring points, i.e., N=400.

[0047] The beneficial effects of the technical solution provided by the embodiments of the present invention are as follows: the present invention addresses the characteristics of complex media and indistinct oil-water interface in settling tanks, and can identify the oil-water interface and oil-gas interface in the settling tank in real time and accurately, helping technicians to quickly grasp the production status of the settling tank.

[0048] This invention is based on the principle of minimizing the sum of differences. The algorithm is simple and highly accurate. Compared with the traditional oil-water interface identification algorithm based on capacitive sensors, it is more suitable for the characteristics of the medium in settling tanks.

[0049] The algorithm used in this invention can be fully implemented in the host computer without the need to install additional equipment, microcontrollers, etc., thus saving equipment installation costs. Attached Figure Description

[0050] Figure 1 This is a flowchart of a method according to an embodiment of the present invention.

[0051] Figure 2 This is a flowchart of the filtering method according to an embodiment of the present invention.

[0052] Figure 3 This is a diagram of the original data from an embodiment of the present invention.

[0053] Figure 4 This is a data graph after filtering according to an embodiment of the present invention.

[0054] Figure 5 This is a measured difference graph from an embodiment of the present invention.

[0055] Figure 6 This is an emulsion layer identification diagram according to an embodiment of the present invention. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. Of course, the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0057] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0058] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0059] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "setting" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0060] Example 1

[0061] See Figures 1 to 5 This invention provides an oil-water interface identification method based on minimizing the total difference.

[0062] S1. The three media, water, oil and air, are detected by the oil-water interface meter to obtain the data fed back by the dipstick.

[0063] S2. Filter the data collected in S1;

[0064] S3. Record the data processed by S2 as the standard value;

[0065] S4. Combine the standard value obtained in S2 with the standard value of the air medium to obtain the standard deviation of the three media.

[0066] S5. Detect the medium to be tested, and perform the filtering process on the detected data to obtain the measured data.

[0067] S6. Combine the measured data obtained in S5 with the standard value of the air medium to obtain the measured difference;

[0068] S7. Obtain the total average difference based on the standard deviation of S4 and the measured difference of S6;

[0069] S8. Determine the location of the oil-water interface and the oil-gas interface based on the measurement points on the dipstick corresponding to the total average difference.

[0070] Preferably, the filtering process includes performing single-point lateral filtering on the measurement data using a mean-shift clustering algorithm, and performing longitudinal filtering on the measurement data using an arithmetic mean filtering algorithm.

[0071] Preferably, the single-point lateral filtering specifically involves setting a certain test point as C (1≤C≤N), where N is the total number of measurement points on the dipstick;

[0072] Ten recently measured data points of C were selected and clustered into three cluster centers. The three clusters were sorted from smallest to largest, and the measured value of point C was taken from the second cluster center. Single-point lateral filtering was then performed on each measurement point in turn.

[0073] Preferably, the longitudinal filtering is as follows: the length of the dipstick represented by a measurement point is 10mm. In order to preserve the characteristics of the data itself as much as possible, the length of the data template should be an odd number. The value of n (1≤n≤199) should be reasonably selected to ensure that the length of the data template is 2n+1. Since the position span of the interface usually does not exceed 60mm, in order to preserve the characteristics of the data itself, the length of the data template is usually selected as 9.

[0074] For a data template of length 2n+1, where n (1≤n≤199), calculate the mean of the data template and set a threshold m. For each data point in the template, the difference between data and mean is calculated. If the difference data-mean of a certain measurement point is greater than the threshold m, the data of this measurement point is considered to be an outlier, and the measurement value of the previous measurement point is used to replace the measurement value of this measurement point.

[0075] If the measured value of the first measurement point is an outlier, then the measured value of the second measurement point is used instead.

[0076] To ensure effective filtering, the threshold value *m* should be chosen appropriately. Since the data difference at the oil-water boundary is significant, if *m* is too small, the boundary data will be processed as incorrect parameters; if it is too large, smaller outliers will not be filtered out, negatively impacting the subsequent oil-water boundary calibration step. Based on experimental data, a value of 3000 for *m* is suitable here, as it avoids rejecting the oil-water boundary point while still removing larger outliers.

[0077] Preferably, in step S3, the data processed in step S2 is recorded as a standard value, specifically,

[0078] The standard value of the water medium is denoted as s_water;

[0079] The standard value of the oil medium is denoted as s_oil;

[0080] The standard value of the air medium is denoted as s_gas;

[0081] In step S4, the standard value obtained in S2 is combined with the standard value of the air medium to obtain the standard deviation of the three media. Specifically,

[0082] Subtracting the standard value of air from the standard values ​​of water, oil, and air respectively yields the following standard value differences:

[0083] d_water = s_water - s_gas

[0084] d_oil = s_oil - s_gas

[0085] d_gas = s_gas - s_gas = 0

[0086] Where d_water is the standard deviation of water medium, d_oil is the standard deviation of oil medium, and d_gas is the standard deviation of air medium.

[0087] Preferably, in step S6, the measured data obtained in step S5 is combined with the standard value of the air medium to obtain the measured difference. Specifically, the measured data is subtracted from the air standard value to obtain the measured difference, which is denoted as D. i (1≤i≤N), where N is the total number of measuring points on the dipstick.

[0088] Preferably, in step S7, the total average difference is obtained based on the standard deviation of step S4 and the measured difference of step S6, specifically as follows:

[0089] The measured difference D obtained according to S6 i (1≤i≤N), obtain the measured difference D. i (1≤i≤N) is the absolute value of the difference between itself and the standard deviation.

[0090] R i _water=|D i -d_water|

[0091] R i _oil=|D i -d_oil|

[0092] R i _gas=|D i |

[0093] Where (1≤i≤N), N is the total number of measuring points on the dipstick;

[0094] x1 is the oil-water interface test point, x2 is the oil-gas interface test point, the segment (0, x1) represents the water medium, the segment (x1, x2) represents the oil medium, and the segment (x2, N) represents the air medium. A double-layer loop is defined, causing x1 and x2 to iterate from 1 to N respectively. The average value of R for each medium is calculated, where R is the absolute value of the difference. The three average values ​​are summed to obtain the overall average difference M.

[0095]

[0096]

[0097]

[0098] M = M_water + M_oil + M_gas

[0099] When M is at its minimum, x1 and x2 correspond to the locations of the oil-water interface and the oil-gas interface, respectively.

[0100] Preferably, the oil-water interface gauge is an oil-water interface gauge consisting of four oil dipsticks connected in series, with a length of approximately 4 meters and 400 measuring points, i.e., N=400.

[0101] Example 2

[0102] Based on Example 1, this invention provides an oil-water interface identification method based on minimizing the total difference. The oil-water interface instrument is an oil-water interface instrument composed of four oil dipsticks connected in series, with a length of about 4 meters and 400 measurement points, i.e., N=400.

[0103] S1. The three media, water, oil and air, are detected by the oil-water interface meter to obtain the data fed back by the dipstick.

[0104] S2. Filter the data collected in S1; the filtering process includes using the mean-shift clustering algorithm to perform single-point lateral filtering on the measurement data, and using the arithmetic mean filtering algorithm to perform longitudinal filtering on the measurement data.

[0105] The single-point lateral filtering is specifically defined as follows: let a certain test point be C (1≤C≤N), where N is the total number of measurement points on the dipstick;

[0106] Ten recently measured data points of C were selected and clustered into three cluster centers. The three clusters were sorted from smallest to largest, and the measured value of point C was taken from the second cluster center. Single-point lateral filtering was then performed on each measurement point in turn.

[0107] The longitudinal filtering is specifically as follows: the length of the dipstick represented by a measurement point is 10mm. In order to preserve the characteristics of the data itself as much as possible, the length of the data template should be an odd number. The value of n (1≤n≤199) should be reasonably selected to ensure that the length of the data template is 2n+1. Since the position span of the interface usually does not exceed 60mm, in order to preserve the characteristics of the data itself, the length of the data template is usually selected as 9.

[0108] For a data template of length 2n+1, where n (1≤n≤199), calculate the mean of the data template and set a threshold m. For each data point in the template, the difference between data and mean is calculated. If the difference data-mean of a certain measurement point is greater than the threshold m, the data of this measurement point is considered to be an outlier, and the measurement value of the previous measurement point is used to replace the measurement value of this measurement point.

[0109] If the measured value of the first measurement point is an outlier, then the measured value of the second measurement point is used instead.

[0110] To ensure effective filtering, the threshold value *m* should be chosen appropriately. Since the data difference at the oil-water boundary is significant, if *m* is too small, the boundary data will be processed as incorrect parameters; if it is too large, smaller outliers will not be filtered out, negatively impacting the subsequent oil-water boundary calibration step. Based on experimental data, a value of 3000 for *m* is suitable here, as it avoids rejecting the oil-water boundary point while still removing larger outliers.

[0111] S3. Record the data processed by S2 as the standard value;

[0112] In step S3, the data processed by S2 is recorded as a standard value, specifically,

[0113] The standard value of the water medium is denoted as s_water;

[0114] The standard value of the oil medium is denoted as s_oil;

[0115] The standard value of the air medium is denoted as s_gas;

[0116] S4. Combine the standard value obtained in S2 with the standard value of the air medium to obtain the standard deviation of the three media.

[0117] By combining the standard value obtained from S2 with the standard value of air, the standard deviation for the three media is obtained.

[0118] Subtracting the standard value of air from the standard values ​​of water, oil, and air respectively yields the following standard value differences:

[0119] d_water = s_water - s_gas

[0120] d_oil = s_oil - s_gas

[0121] d_gas = s_gas - s_gas = 0

[0122] Where d_water is the standard deviation of water medium, d_oil is the standard deviation of oil medium, and d_gas is the standard deviation of air medium.

[0123] S5. Detect the medium to be tested, and perform the filtering process on the detected data to obtain the measured data.

[0124] S6. Combine the measured data obtained in S5 with the standard value of the air medium to obtain the measured difference;

[0125] The measured data obtained in S5 is combined with the standard value of the air medium to obtain the measured difference. Specifically, the measured data is subtracted from the air standard value to obtain the measured difference, which is denoted as D. i (1≤i≤N), where N is the total number of measuring points on the dipstick.

[0126] S7. Obtain the total average difference based on the standard deviation of S4 and the measured difference of S6;

[0127] Based on the standard deviation of S4 and the measured difference of S6, the overall average difference is obtained, specifically as follows:

[0128] The measured difference D obtained according to S6 i (1≤i≤N), obtain the measured difference D. i (1≤i≤N) is the absolute value of the difference between itself and the standard deviation.

[0129] R i _water=|D i -d_water|

[0130] R i _oil=|D i -d_oil|

[0131] R i _gas=|D i |

[0132] Where (1≤i≤N), N is the total number of measuring points on the dipstick;

[0133] Let x1 be the oil-water interface and x2 be the oil-gas interface. Define a double-layer loop, where x1 and x2 traverse from 1 to N respectively. Calculate the average value of R for different media, where R is the absolute value of the difference. Sum the three average values ​​to obtain the overall average difference M.

[0134]

[0135]

[0136]

[0137] M = M_water + M_oil + M_gas

[0138] When M is at its minimum, x1 and x2 correspond to the locations of the oil-water interface and the oil-gas interface, respectively.

[0139] S8. Determine the location of the oil-water interface and the oil-gas interface based on the measurement points on the dipstick corresponding to the total average difference.

[0140] See Figure 6 Emulsion layer identification:

[0141] 1. The emulsion layer in the settling tank fluctuates significantly, generally more than 100 mm. Ten measured values ​​near the oil-water interface x1 are selected and linearly fitted.

[0142] 2. Based on the identification results of oil-water and oil-gas interfaces, establish a coordinate system with the horizontal axis representing the position of the oil-water interface and the vertical axis representing the measured value. Fit the measured values ​​of the oil layer and water layer to obtain two horizontal straight lines, y_oil and y_water, respectively.

[0143] 3. The fitted line intersects with two horizontal lines respectively, and the intersection points are test point a and test point c.

[0144] 4. The area between test points a and c is determined to be the emulsion layer.

[0145] Example 3

[0146] Based on the above embodiments, an experiment was conducted using Tank No. 8 of the Guerlian Oilfield in the Gudao Oil Production Plant of Shengli Oilfield. After the equipment installation and power and communication line installation were completed, field data was collected through the 485 communication interface. The test data was subjected to single-point horizontal and vertical filtering, and the measured difference obtained after subtracting the air standard value is as follows: Figure 4 As shown in the figure, the horizontal axis represents the test points of the oil-water interface instrument, from channel 1 to channel 400, and the vertical axis represents the measured difference. As shown in the figure, the measured difference is approximately 0 in air, approximately 2000 in oil, and approximately 8000 in water. The oil-water interface and the oil-gas interface are clearly visible. The identification results are shown in the table below.

[0147] The experimental results show that the oil-water interface meter can accurately identify the oil-water interface. The test data demonstrates that the meter's identification is stable, without significant fluctuations, and provides monitoring personnel with accurate oil-water and oil-gas interface data.

[0148]

[0149]

[0150] Therefore, it can be seen that the method proposed in this scheme has a high accuracy rate.

[0151] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for identifying oil-water interfaces based on minimizing the total difference, characterized in that, include: S1. The three media, water, oil and air, are detected by the oil-water interface meter to obtain the data fed back by the dipstick. S2. Filter the data collected in S1; S3. Record the data processed in S2 as the standard value. The standard values ​​for water, oil, and air media are respectively recorded as follows: , , ; S4. Combine the standard value obtained in S2 with the standard value of air to obtain the standard deviation for the three media; subtract the standard value of air from the standard values ​​of water, oil, and air respectively to obtain the standard deviations for the three media. , , ; S5. Detect the medium to be tested, and perform the filtering process on the detected data to obtain the measured data. S6. Combine the measured data obtained in S5 with the standard value of the air medium to obtain the measured difference; specifically, subtract the air standard value from the measured data to obtain the measured difference, which is denoted as . , This represents the total number of measuring points on the dipstick. S7. Obtain the total average difference based on the standard deviation of S4 and the measured difference of S6; Specifically, based on the measured difference obtained in step S6 Obtain the measured difference The absolute value of the difference from the standard deviation. ; ; ; in , This represents the total number of measuring points on the dipstick. For oil-water interface test points, For oil-gas interface test points, The section is a water medium. The section is for oil medium. The segment is an air medium; a two-layer loop is defined to make... and Traverse from 1 to For different media Find the average value. The total average difference is obtained by summing the three averages to find the absolute value of the difference. , ; ; ; ; The minimum corresponding and These refer to the locations of the oil-water interface and the oil-gas interface, respectively. S8. Determine the location of the oil-water interface and the oil-gas interface based on the measurement points on the dipstick corresponding to the total average difference.

2. The oil-water interface identification method based on minimizing total difference according to claim 1, characterized in that, The filtering process includes using a mean-shift clustering algorithm to perform single-point lateral filtering on the measurement data, and using an arithmetic mean filtering algorithm to perform longitudinal filtering on the measurement data.

3. The oil-water interface identification method based on minimizing total difference according to claim 2, characterized in that, The single-point transverse filtering specifically refers to setting a test point as follows: , This represents the total number of measuring points on the dipstick. Select the measured The 10 data points were clustered into three cluster centers. The three clusters were then sorted from smallest to largest, and the second cluster center was selected as the center. The measured values ​​of each point are used to perform single-point lateral filtering on each measurement point in turn.

4. The oil-water interface identification method based on minimizing total difference according to claim 2, characterized in that, The longitudinal filtering specifically involves selecting an odd number of data templates with a length of 10mm for each measurement point on the dipstick. For a length of The data template, in which Find the average value of the data template. Set a threshold Each data in the template and Subtraction; if the difference at a certain measurement point Greater than the threshold If the value is not found, the data at this measurement point is considered an outlier, and the measurement value of the previous measurement point is used to replace the measurement value of this measurement point. If the measured value of the first measurement point is an outlier, then the measured value of the second measurement point is used instead.

5. The oil-water interface identification method based on minimizing the total difference according to any one of claims 1-4, characterized in that, The oil-water interface gauge is a 4-meter-long instrument consisting of four oil dipsticks connected in series, with 400 measuring points. .