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

📄 read_las_file.m

📁 基于Matlab的地震数据处理显示和测井数据显示于处理的小程序
💻 M
📖 第 1 页 / 共 2 页
字号:
      end      wlog.first = sscanf(buffer(ia+nu:ind),'%f',1);    end    if strcmpi(kw,'STOP')      if ~strcmp(buffer(ia),' ')%      if buffer(ia) ~= ' '        temp=sscanf(buffer(ia:ind),'%s',1);        nu=length(temp);      else        nu=0;      end      wlog.last = sscanf(buffer(ia+nu:ind), '%f',1);    end     if strcmpi(kw,'STEP')%      if buffer(ia) ~= ' '      if ~strcmp(buffer(ia),' ')        nu=length(temp);      else        nu=0;      end      wlog.step = sscanf(buffer(ia+nu:ind), '%f');      wlog.units='';	% Place holder    end           if strcmpi(kw,'NULL')      wlog.null = sscanf(buffer(ia:ind), '%f');      end    if strcmpi(kw,'COMP')      wlog.company = strim(buffer(ia:ind));      end		          if strcmpi(kw,'WELL')      wlog.wellname = strim(buffer(ia:ind));    end    if strcmpi(kw,'FLD')      wlog.field = strim(buffer(ia:ind));      end		          if strcmpi(kw,'LOC')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.location = temp; end     end	    if strcmpi(kw,'PROV')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.province = temp; end     end		      		          if strcmpi(kw,'CTRY')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.country = temp; end;    end    if strcmpi(kw,'CNTY')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.county = temp; end;    end    if strcmpi(kw,'STAT')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.state = temp; end;    end    if strcmpi(kw,'UWI')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.wellid = temp; end    end    if strcmpi(kw,'API')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.api = temp; end    end    if strcmpi(kw,'SRVC')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.service = temp; end    end    if strcmpi(kw,'DATE')      temp=strim(buffer(ia:ind));      if ~isempty(temp), wlog.date = temp; end     end		          buffer=get_buffer(fid);  end  if iprint ~= 0, disp('... finished reading well info'); endend% 	Parameter information blockif strcmpi(buffer(1:2),'~p')   unknown_block=0;  nhead=nhead+1;  lb=min([length(buffer),nchar]);  bmax=max([lb,bmax]);  las_header(nhead,1:lb)=buffer(1:lb);    if iprint ~= 0, disp('... reading parameter info'); end  buffer=get_buffer(fid);	     while buffer(1:1) ~= '~'     nhead=nhead+1;     lb=min([length(buffer),nchar]);    bmax=max([lb,bmax]);    las_header(nhead,1:lb)=buffer(1:lb);    if ~strcmpi(buffer(1),'#')       ind=find(buffer(1:min([lb-1,21])) == '.')-1;       ind=ind(1);      parameter=lower(strim(buffer(1:ind)));      ind1=find(buffer == ':');      if ~strcmpi(buffer(ind+2),' ') & ~strcmpi(buffer(ind+2),':')         unit=sscanf(buffer(ind+2:ind1-1),'%s',1);         nu=length(unit);         unit=char(unit_substitution(unit));%  Change abbreviations for units of measurement      else         unit='UNDEFINED';         nu=0;      end      value=strim(buffer(ind+nu+2:ind1-1));      temp=strim(buffer(ind1+1:end));      if ~isempty(temp)	     n=min([60 length(temp)]);	     descr=temp(1:n);      else         descr='UNDEFINED';      end      if isnumber(value)         if str2double(value) ~= wlog.null            if ~isfield(wlog,'parameter_info')	           wlog.parameter_info={parameter,unit,descr};             else	           wlog.parameter_info=[wlog.parameter_info;	                           {parameter,unit,descr}];            end %           wlog.parameter_info=setfield(wlog.parameter_info,parameter,{unit,descr});            wlog=setfield(wlog,parameter,str2double(value)); %           wlog.(parameter)=str2num(value);         end      end    end    buffer=get_buffer(fid);  end%   if isempty(wlog.parameter_info), wlog=rmfield(wlog,'parameter_info'); end  if iprint ~= 0, disp('... finished reading parameter info'); endend  % 	Curve information blockif strcmpi(buffer(1:2),'~c')   unknown_block=0;  nhead=nhead+1;  lb=min([length(buffer),nchar]);  bmax=max([lb,bmax]);  las_header(nhead,1:lb)=buffer(1:lb);    if iprint ~= 0, disp('... reading curve info'); end  buffer=get_buffer(fid);  nlogs=0;	     while isempty(buffer) | buffer(1:1) ~= '~'    nhead=nhead+1;     lb=min([length(buffer),nchar]);    bmax=max([lb,bmax]);    las_header(nhead,1:lb)=buffer(1:lb);    if  ~strcmp(buffer(1),'#')      nlogs=nlogs+1;      ind=find(buffer(1:min(length(buffer),mnem_length+1)) == '.')-1;      if isempty(ind)        disp(' No period (dot) found.')        disp([' Curve mnemonic could be longer than ',num2str(mnem_length),' characters:'])        disp(buffer)        fclose(fid);        error(' Abnormal termination')      end%		Get units of measurement      ind1=find(buffer == ':');      if ~strcmp(buffer(ind+2),' ')%       curve_info(2,nlogs)={sscanf(buffer(ind+2:ind1-1),'%s',1)};        temp=strim(buffer(ind+2:ind1-1));        idx=findstr(temp,'  ');        if ~isempty(idx)  % Are there blanks in the unit description?          idx1=find(diff(idx)==1);          if isempty(idx1)             curve_info{2,nlogs}=temp;          else             curve_info{2,nlogs}=temp(1:idx(idx1(1))-1);          end        else          curve_info{2,nlogs}=temp;        end      else        curve_info{2,nlogs}='UNDEFINED';      end%		Get description      ind2=find(buffer(ind1+1:end) > 64);      if ~isempty(ind2)        curve_info{3,nlogs}=buffer(ind1+ind2(1):end);      else        curve_info{3,nlogs}='UNDEFINED';      end      curve_info{1,nlogs}=deblank(buffer(1:ind(1)));    end    buffer=get_buffer(fid);  end  if iprint ~= 0, disp('... finished reading curve info'); endend  % 	Other information blockif strcmpi(buffer(1:2),'~o')   unknown_block=0;  nhead=nhead+1;  lb=min([length(buffer),nchar]);  bmax=max([lb,bmax]);  las_header(nhead,1:lb)=buffer(1:lb);  if iprint ~= 0, disp('... reading other information'); end  buffer=deblank(fgetl(fid));  nhead=nhead+1;  lb=min([length(buffer),nchar]);  bmax=max([lb,bmax]);  las_header(nhead,1:lb)=buffer(1:lb);  while isempty(buffer) | buffer(1:1) ~= '~'     nhead=nhead+1;    lb=min([length(buffer),nchar]);    bmax=max([lb,bmax]);    las_header(nhead,1:lb)=buffer(1:lb);     buffer=deblank(fgetl(fid));   end  if iprint ~= 0, disp('... finished reading other information'); endend       if unknown_block == 1     	% Unknown block encountered: 				% Write it to header  nhead=nhead+1;  lb=min([length(buffer)-1,nchar]);  bmax=max([lb,bmax]);  las_header(nhead,1:lb)=buffer(1:lb);   buffer=deblank(fgetl(fid));   while  ~isempty(buffer) & buffer(1:1) ~= '~'    nhead=nhead+1;    lb=min([length(buffer),nchar]);    bmax=max([lb,bmax]);    las_header(nhead,1:lb)=buffer(1:lb);     buffer=get_buffer(fid);   endend                        		end      % Last block (log curves) reachednhead=nhead+1;lb=min([length(buffer),nchar]);% bmax=max([lb,bmax]);las_header(nhead,1:lb)=buffer(1:lb);las_header=deblank(char(las_header(1:nhead,:)));%	ASCI log curves% nhead=nhead+1;% lb=min([length(buffer),nchar]);% bmax=max([lb,bmax]);if iprint ~= 0, disp('... reading ASCII curve values'); endwlog.curves=fscanf(fid,'%g',[nlogs,inf])';if iprint ~= 0, disp('... finished reading ASCII curve values'); endfclose(fid);wlog.curve_info=curve_info';if strcmpi(curve_info{1,1},'dept')   wlog.curve_info{1,1}='DEPTH';end%	Change abbreviations for units of measurementfor ii=1:nlogs  wlog.curve_info(ii,2)=unit_substitution(wlog.curve_info(ii,2));end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function buffer=get_buffer(fid)% Get next line in file% INPUT% fid     file identifier% OUTPUT% buffer  line of textbuffer=strim(fgetl(fid));while isempty(buffer)   buffer=strim(fgetl(fid));endif length(buffer == 1)   buffer=[buffer,' '];end

⌨️ 快捷键说明

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