-
Notifications
You must be signed in to change notification settings - Fork 0
/
l_trend_removal.m
59 lines (52 loc) · 2 KB
/
l_trend_removal.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [wlog,aux]=l_trend_removal(wlog,mnem,refdepth,varargin)
% Correct values of a particular curve to a particular depth, called
% reference depth (remove a linear trend of the form a+b*depth)
% new_curve = (old_curve/trend)*trend_at_reference_depth
%
% Written by: E. R.: August 8, 2003
% Last updated:
%
% [wlog,aux]=l_trend_removal(wlog,mnem,refdepth,varargin)
% INPUT
% wlog well log
% mnem mnemonic of curve whose trend should be removed
% refdepth reference depth
% varargin one or more cell arrays; the first element of each cell array
% is a keyword string, the following arguments contains a parameter(s).
% Accepted keywords are:
% 'mnemonic' mnemonic of the new curve;
% Default: {'mnemonic',[mnem,'_normal']
% 'depths' first and last depth of the interval over which the
% trend should be computed; it is then applied to the whole log,
% not just that interval
% Default: {'depths',wlog.first,wlog.last}
% OUTPUT
% wlog input well log with new curve.
% aux structure with intercept "a" and slope "b" of the trend
% Defaults of input arguments
param.alpha=0.45;
param.mnemonic=[mnem,'_normal'];
param.depths=[wlog.first,wlog.last];
% Use input parameters to change defaults
param=assign_input(param,varargin);
if iscell(param.depths)
param.depths=cell2mat(param.depths);
end
% dummy=l_select(wlog,[{'depth'},param.depths]);
[curve,info]=l_gc(wlog,mnem);
depth=wlog.curves(:,1);
idx=find(depth >= param.depths(1) & depth <= param.depths(2));
if isempty(idx)
disp(' No log values in depth range requested')
error('Abnormal termination')
end
[a,b]=l1_slope_intercept(depth(idx),curve(idx),param.alpha);
trend=a+b*depth;
curve=(curve./trend)*(a+b*refdepth);
wlog=l_curve(wlog,'add_ne',param.mnemonic,curve,info{2},[info{3}, ...
' (corrected for depth of ',num2str(refdepth),' ', ...
wlog.curve_info{1,2},')']);
if nargout > 1;
aux.a=a;
aux.b=b;
end