📄 interpret_las3.m
字号:
wlog.curves(:,1:length(idx))=cellfun(@str2double,curves(:,idx)); % Requires Matlab version > 7.04 % wlog.curves(:,1:length(idx))=cellfun('str2double',curves(:,idx)); wlog.curve_info=[wlog.curve_info(bool,:);wlog.row_label_info]; wlog.row_labels=curves(:,~bool); for ii=1:size(wlog.row_label_info,1) temp=unique(wlog.row_labels(:,ii)); nlabels=length(temp); wlog.row_label_codes.(wlog.row_label_info{ii,1})= ... [temp,num2cell((1:nlabels)')]; for jj=1:nlabels bool1=~cellfun(@isempty,strfind(wlog.row_labels(:,ii),temp{jj})); % Requires Matlab version > 7.04 % bool1=~cellfun('isempty',strfind(wlog.row_labels(:,ii),temp{jj})); wlog.curves(bool1,lidx+ii)=jj; end end wlog.row_label_info=wlog.row_label_info(:,1:3);endwlog.curve_info=wlog.curve_info(:,1:3);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function mnem=fix_mnem_no5(mnem)% Remove blanks and bracketed indices from mnemonic of LAS file% e.g. mnemonic[3] ==> mnemonic_3% Find blanks and replace by underscoresmnem=strrep(mnem,' ','_');% Find bracketed indices and replace by underscores followed by indicesidx1=strfind(mnem,'[');if isempty(idx1) returnelse num=mnem(idx1+1:end-1); mnem=[mnem(1:idx1-1),'_',num];end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=section_analysis_no6(wlog,tlines,delim,switch_parameter,param)% Check selected less-conventional sectionscomp=tokens(switch_parameter,'_');section=lower(comp{1}(2:end));if (~isempty(param.section) && ismember({section},param.section)) || ... strcmpi(param.section,'all') switch upper(comp{2}) case 'PARAMETER' wlog=info4section_no7(wlog,tlines,section,'parameters'); case 'DEFINITION' wlog=info4section_no7(wlog,tlines,section,'info'); case 'DATA' wlog=data4section_no8(wlog,tlines,delim,section); otherwise % One should never get here end else if length(comp) == 1 || strcmp(upper(comp{2}),'DATA') disp([' Section "',section,'" ignored.']) keyboard endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=info4section_no7(wlog,tlines,first_name,last_name)% Read parameter-section informationfield=[first_name,'_',last_name];nlines=length(tlines);wlog.(field)=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.(field)(ii,:)={mnem,units,descr,fmt,comp1{2}};end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=data4section_no8(wlog,tlines,delim,first_name)% Read data in data section%label=[first_name,'_label']; % Field name for labeldata=[first_name,'_data']; % Field name for datalabel_info=[first_name,'_info']; % Field name for infofmt0=wlog.(label_info)(:,4);[wlog,curves,bool]=data_section_no10(wlog,tlines,delim,fmt0);%{nlines=length(tlines);ncols=length(fmt0);nerrors=0;% Convert cell vector of lines into cell array of matrix elementscurves=cell(nlines,ncols);% Set the delimiterswitch lower(delim)case 'blank' sep=' '; % Remove consecutive blanks so that they are not interpreted as % indicating missing data values tlines=remove_consecutive_blanks(tlines);case 'tab'; sep=sprintf('\t');case 'comma' sep=',';otherwise error([' Unknown delimiter :',delim])endfor ii=1:nlines temp=tokens(tlines{ii},sep); ltemp=length(temp); if ltemp == ncols curves(ii,:)=temp; elseif ltemp > ncols % Combine strings index=find(~cellfun(@isempty,strfind(temp,'"'))); % Requires Matlab version > 7.04 % index=find(~cellfun('isempty',strfind(temp,'"'))); if ~mod(length(index),2) == 0 nerrors=nerrors+1; if nerrors <= 10 disp([' Problem with a string in line ',num2str(ii),' of the data']) disp(' String is not enclosed in double quotes.') disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end else for jj=1:2:length(index) temp1=cell2str(temp(index(jj):index(jj+1)),', '); temp{index(jj)}=temp1(2:end-1); temp(index(jj)+1:index(jj+1))=[]; end end if length(temp) ~= ncols nerrors=nerrors+1; if nerrors <= 10 disp([' Problem with a string in data line ',num2str(ii)]) disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end else curves(ii,:)=temp; end else nerrors=nerrors+1; if nerrors <= 10 disp([' There are fewer than ',num2str(ncols),' data values in line ',num2str(ii)]) disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end endend% Find columns with stringsbool=true(1,ncols);for ii=1:ncols if strcmpi(fmt0{ii}(1),'S') || ... (length(fmt0{ii}) > 1 && strcmpi(fmt0{ii}(1:2),'AS')) bool(ii)=false; endend%}if all(bool) % In case there are no strings wlog.(data)=cellfun(@str2double,curves); % Requires Matlab version > 7.04 % wlog.(data)=cellfun('str2double',curves);else % In case there are strings wlog.(data)=[num2cell(cellfun(@str2double,curves(:,bool))),curves(:,~bool)]; % Requires Matlab version > 7.04 % wlog.(data)=[num2cell(cellfun('str2double',curves(:,bool))),curves(:,~bool)];endwlog.(label_info)=wlog.(label_info)(:,1:3);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function wlog=parameter_section_no9(wlog,tlines)% Read parameter-section information pf LAS 3.0 filenlines=length(tlines);wlog.parameter_info=cell(nlines,3);ik=0;for ii=1:nlines comp=split_line(tlines{ii}); if isempty(comp{4}) % No vertical bar comp1=split_units_values(comp{2}); values=str2num(comp1{2}); %#ok More than one numeric value is possible if ~isempty(values) [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=lower(fix_mnem_no5(comp{1})); % Remove blanks and brackets from mnemonics units=unit_substitution(comp1{1}); % Create standardized units of measurement if ~strcmpi(fmt(1),'S') ik=ik+1; wlog.parameter_info(ik,:)={mnem,units,descr}; wlog.(mnem)=values; else % Disregard parameters that have no numeric values end end else % Disregard parameter definitions that refer to different runs endendif ik > 0 wlog.parameter_info=wlog.parameter_info(1:ik,:);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function [wlog,curves,bool,nlines,ncols]=data_section_no10(wlog,tlines,delim,fmt0)% Used in "data_section_no4" and in "data4section_no8"nlines=length(tlines);ncols=length(fmt0);nerrors=0;% Convert cell vector of lines into cell array of matrix elementscurves=cell(nlines,ncols);% Set the delimiterswitch lower(delim)case 'blank' sep=' '; % Remove consecutive blanks so that they are not interpreted as % indicating missing data values tlines=remove_consecutive_blanks(tlines);case 'tab'; sep=sprintf('\t');case 'comma' sep=',';otherwise error([' Unknown delimiter :',delim])endfor ii=1:nlines temp=tokens(tlines{ii},sep); ltemp=length(temp); if ltemp == ncols curves(ii,:)=temp; elseif ltemp > ncols % Combine strings index=find(~cellfun(@isempty,strfind(temp,'"'))); % Requires Matlab version > 7.04% index=find(~cellfun('isempty',strfind(temp,'"'))); if ~mod(length(index),2) == 0 nerrors=nerrors+1; if nerrors <= 10 disp([' Problem with a string in line ',num2str(ii),' of the data']) disp(' String is not enclosed in double quotes.') disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end else for jj=1:2:length(index) temp1=cell2str(temp(index(jj):index(jj+1)),', '); temp{index(jj)}=temp1(2:end-1); temp(index(jj)+1:index(jj+1))=[]; end end if length(temp) ~= ncols nerrors=nerrors+1; if nerrors <= 10 disp([' Problem with a string in data line ',num2str(ii)]) disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end else curves(ii,:)=temp; end else nerrors=nerrors+1; if nerrors <= 10 disp([' There are fewer than ',num2str(ncols),' data values in line ',num2str(ii)]) disp(tlines{ii}) if nerrors == 10 disp(' Any additional errors are not displayed') end end endend% Find columns with stringsbool=true(1,ncols);for ii=1:ncols if strcmpi(fmt0{ii}(1),'S') || ... (length(fmt0{ii}) > 1 && strcmpi(fmt0{ii}(1:2),'AS')) bool(ii)=false; endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -