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

📄 l_interpolate.m

📁 matlab源代码
💻 M
字号:
function wlog=l_interpolate(wlog,mnemonics)
% Function interpolates null values of all curves specified by an optional list 
% of mnemonics. The function assumes that null values are represented by NaNs.
% Date April 29, 2000;  written by E. R.
% Last update: June 8, 2004: use "wlog" instead of "log" and "log_out"
% INPUT
% wlog         log structure
% mnemonics   mnemonic or cell array of mnemonics to interpolate
%             if mnemonic is not given or empty all curves are interpolated
% OUTPUT
% wlog     log with interpolated curves; curves not in the list of mnemonics are
%             copied unchanged
%     wlog=l_interpolate(wlog,mnemonics)

if ~isfield(wlog,'null')       % If there are no null values in the log curves ...
   return
end

[n,m]=size(wlog.curves);

if nargin < 2 | isempty(mnemonics)
   idx=2:m;
else
   if ischar(mnemonics)
      mnemonics={mnemonics};
   elseif ~iscell(mnemonics)
      error(' Input parameter mnemonics must be a string or a cell array of strings')
   end
   nm=length(mnemonics);
   idx=find(ismember(lower(wlog.curve_info(:,1)),lower(mnemonics)));
   if length(idx) ~= nm
      disp(' Curves_requested:')
      disp(mnemonics)
      disp(' Curves_found:')
      disp(wlog.curve_info(:,1)')
      error('Number of curves found differs from number requested')
   end
end

if ~isnan(wlog.null)
   idx=find(wlog.curves == wlog.null);
   wlog.curves(idx)=NaN;
   wlog.null=NaN;   
end

% wlog.curves=wlog.curves;

for ii=idx(:)'
  index=find(~isnan(wlog.curves(:,ii)));
  if ~isempty(index) & length(index) ~= n 
     wlog.curves(index(1):index(end),ii)=fill_gaps(wlog.curves(index(1):index(end),1), ...
                  wlog.curves(index(1):index(end),ii),index-index(1)+1);
  end
end
 
%       Copy rest of fields
% wlog=copy_fields(wlog,wlog);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function curve=fill_gaps(depth,curve,index)
% Function fills gaps in log curve.
% INPUT
% depth     uniform depth values
% curve     corresponding values of the curve
% index     index vector of non-NaN values (i.e. curve(index) is not NaN)
% OUTPUT
% curve     input curve with the NaNs replaced by interpolated values

idx=find(diff(index) > 1);
if isempty(idx)
   return
end
nidx=length(idx);
for ii=1:nidx
  ia=index(idx(ii));
  ie=index(idx(ii)+1);
  curve(ia+1:ie-1)=interp1q(depth([ia,ie]),curve([ia,ie]),depth(ia+1:ie-1));
end



⌨️ 快捷键说明

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