-
Notifications
You must be signed in to change notification settings - Fork 0
/
l_depth2wb_depth.m
119 lines (104 loc) · 3.36 KB
/
l_depth2wb_depth.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function wlog=l_depth2wb_depth(wlog,varargin)
% Change the depth coordinate to depth from water bottom; the function assumes
% the water depth and possibly the Kelly bushing are available as parameters
% ('wd' and 'ekb', respectively) of the well log. There must also be a field
% 'parameter_info'. If these parameters were already in the LAS file they would
% have be automatically transferred to the log structure.
%
% Written by: E. R.: April 1, 2005
% Last updated:
%
% wlog=l_depth2wb_depth(wlog,varargin)
% INPUT
% wlog well log
% varargin one or more cell arrays; the first element of each cell array is a keyword,
% the other elements are parameters. Presently, keywords are:
% 'wd' either mnemonic of the water-depth parameter or actual water depth
% in the depth units of the log
% Default: {'wd','wd'}
% 'ekb' either mnemonic of the Kelly bushing parameter or actual Kelly
% bushing elevation in the depth units of the log
% Default: {'ekb','ekb'}
% OUTPUT
% wlog well log
% Default parameters
param.wd='wd';
param.ekb='ekb';
% Decode and assign input arguments
[param,cm]=l_assign_input(param,varargin);
dunits=wlog.curve_info{1,2}; % Depth units of the log
if ischar(param.wd)
try
wd=getfield(wlog,param.wd);
catch
disp([' Well log has no parameter "',param.wd,'".'])
error('Abnormal termination')
end
units=getParameterUnits(wlog,param.wd);
if ~strcmpi(units,dunits)
if strcmpi(units,'ft') & strcmpi(dunits,'m')
wd=wd*0.3048;
elseif strcmpi(units,'m') & strcmpi(dunits,'ft')
wd=wd/0.3048;
else
error(['Incompatible units: ',dunits,', ',units])
end
end
else
wd=param.wd;
end
if ischar(param.ekb)
try
ekb=getfield(wlog,param.ekb);
catch
disp([' Well log has no parameter "',param.ekb,'".'])
error('Abnormal termination')
end
units=getParameterUnits(wlog,param.ekb);
if ~strcmpi(units,dunits)
if strcmpi(units,'ft') & strcmpi(dunits,'m')
ekb=ekb*0.3048;
elseif strcmpi(units,'m') & strcmpi(dunits,'ft')
ekb=ekb/0.3048;
else
error(['Incompatible units: ',dunits,', ',units])
end
end
else
ekb=param.ekb;
end
if wlog.step > 0
total=round((wd+ekb)/wlog.step)*wlog.step;
else
total=wd+ekb;
end
wlog.curves(:,1)=wlog.curves(:,1)-total;
wlog.first=wlog.curves(1,1);
wlog.last=wlog.curves(end,1);
wlog.curve_info{1,3}=[wlog.curve_info{1,3},' (from water bottom)'];
% Check if there is a curve OWT and/or TWT and change it as well
if strcmp(dunits,'ft')
wt1=wd/4888;
else
wt1=wd/1490;
end
idx=find(ismember(wlog.curve_info,cm.twt));
if length(idx) == 1
if strcmp(wlog.curve_info{idx,2},'ms')
wlog.curves(:,idx)=wlog.curves(:,idx)-wt1*2000;
elseif strcmp(wlog.curve_info{idx,2},'s')
wlog.curves(:,idx)=wlog.curves(:,idx)-wt1*2;
else
error(['Well log has unknown two-way time units: "',wlog.curve_info{idx,2}])
end
end
idx=find(ismember(wlog.curve_info,cm.owt));
if length(idx) == 1
if strcmp(wlog.curve_info{idx,2},'ms')
wlog.curves(:,idx)=wlog.curves(:,idx)-wt1*1000;
elseif strcmp(wlog.curve_info{idx,2},'s')
wlog.curves(:,idx)=wlog.curves(:,idx)-wt1;
else
error(['Well log has unknown one-way time units: "',wlog.curve_info{idx,2}])
end
end