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.

write_sac_event(stringarg,tr)
function write_sac_event(stringarg,tr)
% write_sac_event(stringarg,tr)
%
%  e.g. write_sac_event('stem=event_1. nums=1:8 comps=xyz',tr)
%
% Writes sac trace structures to the files specified in the input string
%
% See read_sac_event for full explanation of the string_argument
%
% 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
            msac_write(name,tr(c));
        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
        msac_write(name,tr(c));
    end
end


Contact us