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

📄 interpret_las3.m

📁 实现地震勘探中
💻 M
📖 第 1 页 / 共 2 页
字号:
function [wlog,aux]=interpret_las3(tlines,param)% Interpret the lines of a file in LAS 3.0 format and create a well-log% structure. Called by "read_las_file".%% Written by: E. R.: December 16, 2006% Last updated: January 31, 2007: Write parameters only if they are not empty%%          [wlog,aux]=interpret_las3(tlines)      % INPUT% tlines   non-blank lines of the LAS 3.0 file (except for the first two lines)% param    parameters passed on by the calling program "read_las_file"% OUTPUT% wlog     well log structure% aux      auxiliary information (nothing yet)global S4M L_WPLOG_REPEATaux=[];L_WPLOG_REPEAT=true;   % Used to avoid repeating a specific message%       Wrap infocomp=split_line(tlines{1});if strcmp(comp{1},'WRAP')   if ~strcmp(strtrim(comp{2}),'NO')      error('Line wrapping is not allowed in LAS 3.0')   endelse   error(['Line ',tlines{1},' should have wrap information.'])end%       Delimiter infocomp=split_line(tlines{2});if strcmp(comp{1},'DLM')   delim=strtrim(comp{2});   bool=ismember(delim,{'SPACE','COMMA','TAB'});  if ~any(bool)      error(['Unknown delimiter "',delim,'"'])   endelse   disp([' Line ',tlines{2}])   disp(' should have delimiter information.')   error('Abnormal termination')end[dummy,filename]=fileparts(S4M.filename);wlog=struct('type','well_log','tag','unspecified','name',filename, ...            'first',[],'last',[],'step',[],'units','','null',-999.25, ...            'from',fullfile(S4M.pathname,S4M.filename));%       Section-start linesindex=find(~cellfun(@isempty,strfind(tlines','~'))); % Requires Matlab version > 7.04% index=find(~cellfun('isempty',strfind(tlines','~')));index=[index,length(tlines)+1];for ii=1:length(index)-1   tline=tlines{index(ii)};   idx=strfind(tline,'|');   if isempty(idx)      temp=tokens(tline,' ');%      association=[];   else      temp1=tokens(tline,'|');      temp=tokens(temp1{1},' ');%      association=strtrim(temp1{2});   end%   temp=split_units_values(tlines{index(ii)});   switch_parameter=upper(temp{1});   switch switch_parameter   case '~WELL'      wlog=well_section_no1(wlog,tlines(index(ii)+1:index(ii+1)-1));   case '~PARAMETER'      wlog=parameter_section_no9(wlog,tlines(index(ii)+1:index(ii+1)-1));   case '~CURVE'      wlog=curve_section_no3(wlog,tlines(index(ii)+1:index(ii+1)-1));   case {'~ASCII','~LOG'}%      if ~isempty(association)  &&  strcmpi(association,'CURVE')       wlog=data_section_no4(wlog,tlines(index(ii)+1:index(ii+1)-1),delim);%      end    otherwise      wlog=section_analysis_no6(wlog,tlines(index(ii)+1:index(ii+1)-1), ...           delim,switch_parameter,param);         endendwlog=fix_las_file_log(wlog);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=well_section_no1(wlog,tlines)% Read well-section informationglobal S4M L_WPLOG_REPEATfor ii=1:length(tlines)   comp=split_line(tlines{ii});   comp{2}=strtrim(comp{2});   switch lower(comp{1})   case 'strt'      comp1=split_units_values(comp{2});      wlog.first=str2double(comp1{2});      units=unit_substitution(comp1{1});      if isempty(wlog.units)         wlog.units=units;      elseif ~strcmp(units,wlog.units)         error(['Depth units are incompatible: ',wlog.units,' and ',units])      end   case 'stop'      comp1=split_units_values(comp{2});      wlog.last=str2double(comp1{2});      units=unit_substitution(comp1{1});      if isempty(wlog.units)         wlog.units=units;      elseif ~strcmp(units,wlog.units)         error(['Depth units are incompatible: ',wlog.units,' and ',units])      end     case 'step'      comp1=split_units_values(comp{2});      wlog.step=str2double(comp1{2});      units=unit_substitution(comp1{1});      if isempty(wlog.units)         wlog.units=units;      elseif ~strcmp(units,wlog.units)         error(['Depth units are incompatible: ',wlog.units,' and ',units])      end   case 'null'       wlog.null=str2double(comp{2});     case 'comp'       if ~isempty(comp{2})          wlog.company=comp{2};       end   case 'well'       if ~isempty(comp{2})          wlog.wellname=comp{2};       end   case 'loc'       if ~isempty(comp{2})          wlog.location=comp{2};       end   case 'fld'       if ~isempty(comp{2})          wlog.field=comp{2};       end    case 'ctry'       if ~isempty(comp{2})          wlog.country=comp{2};       end%       For Canada   case 'prov'       if ~isempty(comp{2})          wlog.province=comp{2};       end   case 'uwi'       if ~isempty(comp{2})          wlog.wellid=comp{2};       end   case 'lic'       wlog.license_number=comp{2};%       For US   case 'stat'       if ~isempty(comp{2})          wlog.state=comp{2};       end   case 'cnty'       if ~isempty(comp{2})          wlog.county=comp{2};       end   case 'api'       if ~isempty(comp{2})          wlog.api=comp{2};       end%      end of "For US"      case 'srvc'       if ~isempty(comp{2})          wlog.service=comp{2};       end   case 'date'       if ~isempty(comp{2})          wlog.date=comp{2};       end  %      Either    case 'lat'       comp1=split_units_values(comp{2});       if ~isempty(comp{2}) ||  ~isempty(comp{2})          wlog.latitude=[comp1{2},' ',comp1{1}];       end   case 'long'       comp1=split_units_values(comp{2});       if ~isempty(comp{2}) ||  ~isempty(comp{2})          wlog.longitude=[comp1{2},' ',comp1{1}];       end   %     or    case 'x'       if ~isempty(comp{2})          wlog.x=comp{2};       end   case 'y'       if ~isempty(comp{2})          wlog.y=comp{2};       end   case 'hzcs'       if ~isempty(comp{2})          wlog.hor_coord_system=comp{2};       end   %    end of "or"     case 'gdat'       comp1=split_units_values(comp{2});       if ~isempty(comp{2}) ||  ~isempty(comp{2})          wlog.geodetic_datum=strtrim([comp1{2},' ',comp1{1}]);       end   case 'utm'       if ~isempty(comp{2})          wlog.utm=comp{2};       end    otherwise       % warning(['Unexpected parameter: ',comp{1}])      disp([' Unexpected keyword in ~WELL INFORMATION section: ',comp{1}])      if L_WPLOG_REPEAT         disp(' Assume that the ~PARAMETER INFORMATION line is missing.')         L_WPLOG_REPEAT=false;      end      wlog=parameter_section_no9(wlog,tlines(ii));   endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function [descr,fmt]=extract_format_no2(str)% Extract the format from the description sectionidx1=strfind(str,'{');if ~isempty(idx1)   idx2=strfind(str,'}');   if ~isempty(idx2)  &&  idx2 > idx1+1      fmt=strtrim(str(idx1+1:idx2-1));      descr=strtrim(str(1:idx1-1));   else      warning(warnid,['Error in description: ',str])      descr=strtrim(str);      fmt=[];     endelse   descr=strtrim(str);   fmt=[];end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=curve_section_no3(wlog,tlines)% Read curve-section informationnlines=length(tlines);wlog.curve_info=cell(nlines,5);for ii=1:nlines   comp=split_line(tlines{ii});   comp1=split_units_values(comp{2});   [descr,fmt]=extract_format_no2(comp{3});   %    If no format has been defined set it depending on the units of measurement   if isempty(fmt)      if isempty(comp1{1})         fmt='S';      else         fmt='F';      end   end   mnem=fix_mnem_no5(comp{1});  % Remove blanks and brackets from mnemonics   units=unit_substitution(comp1{1}); % Create standardized units of measurement   wlog.curve_info(ii,:)={mnem,units,descr,fmt,comp1{2}};end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=data_section_no4(wlog,tlines,delim)% Read data in data sectionfmt0=wlog.curve_info(:,4);[wlog,curves,bool,nlines,ncols]=data_section_no10(wlog,tlines,delim,fmt0);if all(bool)   % In case there are no strings   wlog.curves=cellfun(@str2double,curves);  % Requires Matlab version > 7.04   % wlog.curves=cellfun('str2double',curves);else           % In case there are strings   wlog.curves=zeros(nlines,ncols);   idx=find(bool);   lidx=length(idx);   wlog.row_label_info=wlog.curve_info(~bool,:);   %  Make mnemonics for string columns lower-case   wlog.row_label_info(:,1)=lower(wlog.row_label_info(:,1));    

⌨️ 快捷键说明

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