Code covered by the BSD License  

Highlights from
Seis_Pick

image thumbnail

Seis_Pick

by

 

06 Feb 2012 (Updated )

Seis_Pick provides an interactive picking environment for processing seismic data.

[tr,nt,nr,nc]=read_sac_event(stringarg)
function [tr,nt,nr,nc]=read_sac_event(stringarg)
% [tr,nt,nr,nc] = read_sac_event(stringarg)
%
%  e.g. [tr,nt,nr,nc]=read_sac_event('stem=event_1. nums=1:8 components=xyz')
%
% Read in a set of sac files from an event, which has files in the format
% specified in the input string
%
% INPUT STRING VARIABLES:
%
%         stem= filename stem for sac events (e.g. event1.)
%         numbers= the numbers appending the event names (e.g. event1.1)
%         components= the component names appending the files (e.g. xyz)
%         ncomps= number of components per station
%         zeros= pad the number extensions with zeros
%         
%         if components is not specified, the user must instead specify the
%         number of components per geophone.
%
%         where nr is greater than 0, sometimes padding of zeros is
%         required
%
%         As an e.g.: A set of sac files with names event1.1.x, event1.1.y,
%         event1.1.z; event1.2.x (y,z); through to event1.8.x(y,z) would be
%         read using:
%
%         sac_string_argument='event1.1.x would be 'stem=event1.
%         numbers=1:8 components=xyz'
%
%         A set of 3-component sac files with names event1.01 ... event1.24
%         would be read using:
%   
%         sac_string_argument='event1. numbers=1:24 ncomps=3 zeros=1'
% 
%         A simmilar set but without padding zeros, i.e., event1.1 ...
%         event1.24 would be read with:
%         
%         sac_string_argument='event1. numbers=1:24 ncomps=3'
%
%
% J.P. Verdon, UoB, 2011
%

[stem,istem]=get_string(stringarg,'stem');

[nums,inums]=get_numbers(stringarg);

[comps,icomps]=get_string(stringarg,'components');

if icomps~=1
    [ncomps,incomps]=get_integer(stringarg,'ncomps');
end
    
% Find if padded zeros are present when n < 10
[dummy,izeros]=get_integer(stringarg,'zeros');
if dummy == 0 && izeros == 1
    izeros=0;
end



if icomps == 1
    nr=length(nums);
    nt=length(nums)*length(comps);
    nc=length(comps);
else
    nt=length(nums);
    nr=nt/ncomps;
    nc=ncomps;
end

if icomps == 1
    c=0;
    for i=1:nr
        for j=1:nc
            c=c+1;
            if izeros == 1 && nums(i) < 10
                name=[stem,'0',num2str(nums(i)),'.',comps(j)];
            else
                name=[stem,num2str(nums(i)),'.',comps(j)];
            end
            tr(c)=msac_read(name);
        end
    end
else
    c=0;
    for i=1:nt
        c=c+1;
        if izeros == 1 && nums(i) < 10    
            name=[stem,'.0',num2str(i)];
        else
            name=[stem,'.',num2str(i)];
        end
        tr(c)=msac_read(name);
    end
end


Contact us