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

📄 l_select.m

📁 地震、测井方面matlab代码,解释的比较详细
💻 M
字号:
function logout=l_select(login,varargin)
% Function retrieves subset of log from log structure
% An error message is printed if a column mnemonic is not found. 
% Column mnemonics are not case sensitive (corresponds to l_select1.m of folder Geophysics)
% Written by E. R., October 7, 2000;
% Last updated: March 4, 2003: Allow string with comma-separated curve mnemonics
%  
%                         logout=l_select(login,varargin)
% INPUT
% log		log structure
% varargin  same number of traces
% varargin     one or more cell arrays; the first element of each cell array is a keyword,
%              the other elements are parameters. Presently, keywords are:
%       'curves'  strings with curve mnemonics. Default: {'curves','*'} (implies all curves)
%              The depth (first column of "login.curves") is always included  
%       'depths'  start and end depth of log segment (two comma-separated numbers or a two-element
%                     vector)
%              Default: {'depths',login.first,login.last}
%       'rows'    string with logical expression involving one more of the curve mnemonics
%                 Default: {'rows',''} (implies all rows)
%               Both 'depths' and 'rows' may be given at the same time               
%
% OUTPUT
% logout	output log with curves defined in "curves"
%
% EXAMPLES  logout=l_select(login,{'curves','depth','twt'},{'rows','depth > 5000'})
%           logout=l_select(login,{'curves','depth','twt'},{'depths',2000,3000})
%           logout=l_select(login,{'rows','depth > 1000 & twt < 2000'})
%           logout=l_select(login,{'depths',4000,4500},{'rows','vclay < 0.35})

%    Set default values for input parameters
select.curves='*';
select.depths=[login.first,login.last];
select.rows='';

%       Decode and assign input arguments
select=assign_input(select,varargin);

if iscell(select.depths)
  select.depths=cat(2,select.depths{:});
end

[nrows,ncols]=size(login.curves);

%       Select curves
if strcmp(select.curves,'*')
  cindex=1:ncols;
else
%  [cindex,ier]=get_indices(login.curve_info(:,1),select.curves);
%  if ier
   cindex=curve_indices(login,select.curves);
   if ~isempty(find(cindex==0))
     error(' Abnormal termination')
  end
  if cindex(1) ~= 1
    cindex=[1,cindex];
  end
end

%       Select rows
select.depths=sort(select.depths);
dindex=find(login.curves(:,1) >= select.depths(1) & login.curves(:,1) <= select.depths(2));
if isempty(dindex)
  error([' Requested depth range (',num2str(select.depths(1)),', ',num2str(select.depths(2)), ...
        ') outside of range of log depths (',num2str(login.first),', ',num2str(login.last),')'])
end

if ~isempty(select.rows)

%       Find all the words in the logical expression
  words=lower(extract_words(select.rows));
  mnems=login.curve_info(find(ismember(lower(login.curve_info(:,1)),words)),1);  % Find curve mnemonics in logical expression   
%  index=unique(get_indices(login.curve_info(:,1),mnems));
  [index,ier]=curve_indices(login,mnems);
  index=unique(index);
  index=index(find(index > 0)); 
  if isempty(index)
    disp([' No colunm mnemonics in logical expression "',select.rows,'"'])
    error([' Available curve mnemonics are: ',cell2str(login.curve_info(:,1))])
  end

%       Create vectors whose names are the curve mnemonics in the logical expression
  for ii=1:length(index)
    eval([lower(char(login.curve_info(index(ii),1))),' = login.curves(dindex,index(ii));']);
  end

%       Modify expression to be valid for vectors
  expr=strrep(select.rows,'*','.*');
  expr=strrep(expr,'/','./');
  expr=strrep(expr,'^','.^');
  expr=lower(expr);

%       Evaluate modified expression
       	try
  rindex=eval(['find(',expr,')']);

     	catch
  disp([' Expression "',select.rows,'" appears to have errors'])
  disp([' curve mnemonics found in expression:',cell2str(login.curve_info(index,1))])
  disp([' curve mnemonics available:',cell2str(login.curve_info(:,1))])
  disp(' Misspelled curve mnemonics would be interpreted as variables')
  error(' Abnormal termination')
       	end

  if isempty(rindex)
     error([' No rows selected by condition "',select.rows,'"'])
  else
     dindex=dindex(rindex);
  end
end

logout.curve_info=login.curve_info(cindex,:);
logout.curves=login.curves(dindex,cindex);
logout.first=logout.curves(1,1);
logout.last=logout.curves(end,1);
dd=diff(logout.curves(:,1));

if ~isempty(dd)
  mad=max(dd);
  mid=min(dd);
  if mid*(1+1.0e6*eps) < mad
    logout.step=0;
  else
    logout.step=(logout.last-logout.first)/length(dd);
  end
else
  logout.step=1;
end

%       Copy rest of fields
logout=copy_fields(login,logout);

% 	Add null value if necessary
if ~isfield(logout,'null')
  if sum(isnan(logout.curves(:,2:end))) > 0
    logout.null=NaN;
  end
end
    

⌨️ 快捷键说明

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