⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l_sonic2time.m

📁 地震、测井方面matlab代码,解释的比较详细
💻 M
字号:
function wlog=l_sonic2time(wlog,varargin)
% Function computes two-way time by integrating sonic log and adds it to the input log structure.
% By default, the function assumes that interval transit time and/or compressional velocity
% have the standard mnemonics. This can be changed by temporarily redefining the standard
% mnemonics, e.g. {'DTp','DTCO'} specifies that the mnemonic of the sonic log is 'DTCO' rather
% 'DTp'. Standard mnemonics are defined in function "presets". Likewise, the output curve has
% the standard mnemonic "TWT" (or "OWT", depending on the choice made via keyword "output').
% This too can be changed be temporarily redefining the standard mnemonics.
% Written by: E. R., February 16, 2001
% Last updated: May 2, 2005: Retrn after error in interactive mode
%
%          wlog=l_sonic2time(wlog,varargin)
% INPUT
% wlog     log structure with sonic log (DTp) and/or velocity (Vp);
%          if both are available, the interval transit time is used
% 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:
%          'depth_time'  depth value and the corresponding time to establish time to top of log
%                 the depth value must satisfy wlog.first <= depth_time{1} <= wlog.last
%                 Default:{'depth_time',first,0} : "first" is the depth of the first non-NaN 
%                      sample of the sonic or velocity log; thus first >= wlog.first
%          'action' describes how to handle new curve. Possible values are:
%                'add'     gives an error message if a curve with this mnemonic already exists
%                'replace' gives an error message if a curve with this mnemonic does not exist
%                'add_ne'  (add --- no error) adds a new curve or replaces an existing one
%                'Default: {'action','add_ne'}
%          'output'  Type of output, possible values are: 'twt' (two-way time) or 'owt' (one-way
%                time. Default: {'output','twt'}  
%          'description'  string with curve description.
%                 Default: {'description','Two-way time'}  if 'output' is 'twt'
%                          {'description','One-way time'}  if 'output' is 'owt'  
% OUTPUT
% wlog     input log structure with curve TWT (or OWT) appended (time units are "ms")

global ABORTED

ABORTED=logical(0);

%       Set defaults for input parameters
param.depth_time=[];
param.action='add_ne';
param.output='twt';
param.description='';

%       Decode and assign input arguments
[param,cm]=l_assign_input(param,varargin);

if strcmpi(param.output,'twt')
   fact=2;
   mnem_out=cm.twt;
   if isempty(param.description)
      param.description='Two-way time';
   end
else
   fact=1;
   mnem_out=cm.owt;
   if isempty(param.description)
      param.description='One-way time';
   end
end

dunits=wlog.curve_info{1,2};     % Depth units
% depth=wlog.curves(:,1);
if ~strcmpi(dunits,'m') & ~strcmpi(dunits,'ft')
   myerror([' Depth units are "',dunits,'"; must be "m" or "ft"'])
   return
end

[idx,ier]=curve_index1(wlog,cm.dtp);
if ier
   if length(idx) > 0
       myerror([' More than one curve with mnemonic "',cm.dtp,'"'])
       return
   end
   [idx,ier]=curve_index1(wlog,cm.vp);
   if ier
      if length(idx) > 0
         myerror([' More than one curve with mnemonic "',cm.vp,'"'])
      else
         myerror([' No curve with mnemonic "',cm.vp,'" found'])
      end
      return
   end

   vel=wlog.curves(:,idx);
   index=find(~isnan(vel));
   if isempty(index)
      myerror(' Velocity log consists of nothing but null values')
      return
   end
   if isempty(param.depth_time)
      param.depth_time={wlog.curves(index(1),1),0};
   end
 
   units=wlog.curve_info{idx,2};
   if strcmp(dunits,'m')
      if strcmp(units,'ft/s')
         time=cumquad((fact*1000/0.3048)./vel(index),wlog.curves(index,1));
      elseif strcmp(units,'m/s')
         time=cumquad((fact*1000)./vel(index),wlog.curves(index,1));
      else
         myerror([' Unknown velocity units "',units,'"'])
         return
      end
   else
      if strcmp(units,'m/s')
         time=cumquad((fact*304.8)./vel(index),wlog.curves(index,1));
         elseif strcmp(units,'ft/s')
         time=cumquad(fact*1000./vel(index),wlog.curves(index,1));
      else
         myerror([' Unknown velocity units "',units,'"'])
         return
      end
   end

else    % Sonic log available
   itt=wlog.curves(:,idx);
   index=find(~isnan(itt));
   if isempty(index)
      myerror(' Sonic log consists of nothing but null values')
      return
   end
   if isempty(param.depth_time)
      param.depth_time={wlog.curves(index(1),1),0};
   end
   units=wlog.curve_info{idx,2};
   if strcmp(dunits,'m')
      if strcmp(units,'us/ft')
         time=cumquad((fact/304.8)*itt(index),wlog.curves(index,1));
      elseif strcmp(units,'us/m')
         time=cumquad((fact*0.001)*itt(index),wlog.curves(index,1));
      else
         myerror([' Unknown velocity units "',units,'"'])
         return
      end
   else           % dunits is "ft"
      if strcmp(units,'us/m')
         time=cumquad((fact*0.0003048)*itt(index),wlog.curves(index,1));
      elseif strcmp(units,'us/ft')
         time=cumquad((fact*0.001)*itt(index),wlog.curves(index,1));
      else
         myerror([' Unknown velocity units "',units,'"'])
         return
      end
   end
end


%       Find time to top of log
temp=interp1(wlog.curves(index,1),time,param.depth_time{1},'*linear');

if isnan(temp)
   myerror([' Depth defined via keyword ''depth_time'' (', ...
      num2str(param.depth_time{1}),') must be between ', ...
      num2str(wlog.curves(index(1),1)),' and ', ...
      num2str(wlog.curves(index(end),1)),' ',wlog.curve_info{1,2}])
   return
end

time=time-temp+param.depth_time{2};
temp=NaN*zeros(size(wlog.curves,1),1);
temp(index)=time;
wlog=l_curve(wlog,param.action,mnem_out,temp,'ms',param.description);

if strcmpi(param.output,'twt')
   wlog=add_curve_type(wlog,{mnem_out,'twt','two-way time'});
else
   wlog=add_curve_type(wlog,{mnem_out,'owt','one-way time'});
end  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -