Skip to content

Commit

Permalink
Dramatic speed up when using minmax option
Browse files Browse the repository at this point in the history
  • Loading branch information
cultpenguin committed Oct 26, 2011
1 parent 8f17ce2 commit 4855cae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
4 changes: 2 additions & 2 deletions DOC/index.php
@@ -1,6 +1,6 @@
pd<?
require_once('magpierss/rss_fetch.inc');
$release="1.3";
$release="1.4";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
Expand All @@ -19,7 +19,7 @@

<H5>

M-files to read and write SEG-Y files from Matlab, implemented using the syntax of the SEG-Y format : SEG-Y revision 0 (1975) and revision 1 (May 2002) [<A HREF="http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf">pdf</A>,<A HREF="http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.doc">doc</A>].
M-files to read and write SEG-Y files from Matlab, implemented using the syntax of the SEG-Y format : SEG-Y revision 0 (1975) and revision 1 (May 2002) [<A HREF="http://www.seg.org/documents/10161/77915/seg_y_rev1.pdf">pdf</A>].
</H5>

<CENTER>This site is hosted by<BR>
Expand Down
47 changes: 35 additions & 12 deletions ReadSegy.m
Expand Up @@ -11,7 +11,7 @@
% [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(filename,'jump',5);
% Read data in a CDP header range : 5000<cdp<5800 :
% (change cdp to any other valid TraceHeader value)
% [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(filename,'minmax','cdp'5000,5800);
% [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(filename,'minmax','cdp',5000,5800);
% Read only the header values (Data will return empty)
% [Data,SegyTraceHeaders,SegyHeader]=ReadSegy(filename,'SkipData',1);
%
Expand Down Expand Up @@ -138,6 +138,7 @@


% TRANSFORM VARARGING INTO PARAMETERS
traces=[];
cargin=1;
while (cargin<ninput)
SegymatVerbose([mfilename,' - Converting varargin, ',num2str(cargin)],90)
Expand All @@ -152,8 +153,6 @@
cargin=cargin+1;
traces=varargin{cargin};
SegymatVerbose(['TRACES : Read only every ',num2str(jump),'th trace'])
else
traces=[];
end

if strcmp(varargin{cargin},'minmax')
Expand All @@ -164,6 +163,17 @@
cargin=cargin+1;
eval(['headermax=',num2str(varargin{cargin}),';']);
SegymatVerbose(['MIN MAX : Using header ',header,' from ',num2str(headermin),' to ',num2str(headermax)])

h=ReadSegyTraceHeaderValue(filename,'key',header);
minmax_traces=find(h>=headermin & h<=headermax);


if isempty(traces)
traces=minmax_traces;
else
traces=intersect(traces,minmax_traces);
end

end

if strcmp(varargin{cargin},'trange')
Expand Down Expand Up @@ -297,11 +307,12 @@

SegymatVerbose([mfilename,' : Reading Data'],90);

if ~isempty(traces)
[Data,SegyTraceHeaders,SegyHeader]=ReadSegyTrace(filename,traces,SegyHeader);
HeaderInfo=[];
return;
end
% MAKE USE OF ReadSegyTrace to quickly read specific traces
%if ~isempty(traces)
% [Data,SegyTraceHeaders,SegyHeader]=ReadSegyTrace(filename,traces,SegyHeader);
% HeaderInfo=[];
% return;
%end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -357,10 +368,21 @@

while (~(ftell(segyid)>=DataEnd))

traceinfile=traceinfile+1;

usetrace=1; % DEFAULT USING TRACE WHEN [1].

traceinfile=traceinfile+1;

if ~isempty(traces);
if (traceinfile>length(traces))
break
else
traceskip=240+(BPS/8)*SegyHeader.ns;
skip=DataStart+(traces(traceinfile)-1)*traceskip;
fseek(segyid,skip,'bof');
end
end


ishow=10000;
itime=1/(24*3600)*2; % Min time between verbose info to screen
if (((traceinfile/ishow)==round(traceinfile/ishow))&((now-tlast)>itime)),
Expand Down Expand Up @@ -418,12 +440,13 @@
if usetrace==1,
%% IF TIME RANGE IS SPECIFIED, THEN EXTRACT THIS
if (existTmin==1)&(existTmax==1)
% NEXT LINE SHOULD CONSIDER THAT ns in Trace and Segy Header could vary !!!
% NEXT LINE SHOULD CONSIDER THAT ns in Trace and Segy Header
% could vary !!!
origtrange=[1:1:SegyHeader.ns].*SegyHeader.dt.*1e-6+SingleSegyTraceHeaders.DelayRecordingTime.*1e-3;
gooddata=find(origtrange>tmin & origtrange<tmax);
SingleSegyData.data=SingleSegyData.data(gooddata);
% CHECK NEXT LINE TAHT DelatRec... is in micro seconds
SingleSegyTraceHeaders.DelayRecordingTime=tmin;
SingleSegyTraceHeaders.DelayRecordingTime=tmin.*1e+3;
SingleSegyTraceHeaders.ns=length(gooddata);
ns=length(gooddata); % for use below
end
Expand Down
2 changes: 1 addition & 1 deletion ReadSegyTraceHeaderValue.m
Expand Up @@ -67,7 +67,7 @@
hval=[];
return
end
disp(sprintf('key=%s, startpos=%d, precision=%s ',key,pos+1,precision))
SegymatVerbose(sprintf('key=%s, startpos=%d, precision=%s ',key,pos+1,precision))
end

cargin=cargin+1;
Expand Down

0 comments on commit 4855cae

Please sign in to comment.