Clear Filters
Clear Filters

help changing subplot sequence in rdmseed

6 views (last 30 days)
Ancalagon8
Ancalagon8 on 10 May 2024
Edited: Ancalagon8 on 9 Jun 2024
How can i change the subplots sequence in rdmseed.m, while plotting a miniseed file with e.g. 5 stations?
function varargout = rdmseed(varargin)
if nargin > 6
error('Too many input arguments.')
end
% global variables shared with sub-functions
global f fid offset le ef wo rl forcebe verbose notc force
% default input arguments
makeplot = 0; % make plot flag
verbose = 0; % verbose flag/level
forcebe = 0; % force big-endian
ef = 10; % encoding format default
wo = 1; % word order default
rl = 2^12; % record length default
force = 0; % force input argument over blockette 1000 (UNDOCUMENTED)
notc = 0; % force no time correction (over ActivityFlags)
nullhead = 0; % allow null bytes before header
% sensible limits for multiplexed files
max_channels = 20; % absolute max number of channels to plot
max_channel_label = 6; % max. number of channels for y-labels
% file is opened in Big-Endian encoding (this is encouraged by SEED)
fid = fopen(f,'rb','ieee-be');
le = 0;
offset = 0;
% --- plots the data
if makeplot
figure
xlim = [min(cat(1,X.t)),max(cat(1,X.t))];
% test if all data records have the same length
rl = unique(cat(1,X.DataRecordSize));
if numel(rl) == 1
rl_text = sprintf('%d bytes',rl);
else
rl_text = sprintf('%d-%d bytes',min(rl),max(rl));
end
% test if all data records have the same sampling rate
sr = unique(cat(1,X.SampleRate));
if numel(sr) == 1
sr_text = sprintf('%g Hz',sr);
else
sr_text = sprintf('%d # samp. rates',numel(sr));
end
% test if all data records have the same encoding format
ef = unique(cellstr(cat(1,X.EncodingFormatName)));
if numel(ef) == 1
ef_text = sprintf('%s',ef{:});
else
ef_text = sprintf('%d different encod. formats',numel(ef));
end
if nc == 1
plot(cat(1,X.t),cat(1,X.d))
hold on
for i = 1:length(I.GapBlockIndex)
plot(I.GapTime(i),X(I.GapBlockIndex(i)).d(1),'*r')
end
for i = 1:length(I.OverlapBlockIndex)
plot(I.OverlapTime(i),X(I.OverlapBlockIndex(i)).d(1),'og')
end
hold off
set(gca,'XLim',xlim)
datetick('x','keeplimits')
grid on
xlabel(sprintf('Time\n(%s to %s)',datestr(xlim(1)),datestr(xlim(2))))
ylabel('Counts')
title(sprintf('mini-SEED file "%s"\n%s (%d rec. @ %s - %g samp. @ %s - %s)', ...
f,un{1},length(X),rl_text,numel(cat(1,X.d)),sr_text,ef_text),'Interpreter','none')
else
% plot is done only for real data channels...
if nc > max_channels
warning('Plot has been limited to %d channels (over %d). See help to manage multiplexed file.', ...
max_channels,nc);
nc = max_channels;
end
for i = 1:nc
subplot(nc*2,1,i*2 + (-1:0))
k = I(i).XBlockIndex;
if ~any(strcmp('ASCII',cellstr(cat(1,X(k).EncodingFormatName))))
plot(cat(1,X(k).t),cat(1,X(k).d))
hold on
for ii = 1:length(I(i).GapBlockIndex)
if ~isempty(X(I(i).GapBlockIndex(ii)).d)
D.BLOCKETTES.B1000.Reserved = fread(fid,1,'uint8');
end
  5 Comments
David Goodmanson
David Goodmanson on 16 May 2024
It didn't run because there were several end statements missing at the bottom. After those were supplied, it doesn't run because of the statement fid = fopen(f,'rb','ieee-be') and nobody has that file.
Ancalagon8
Ancalagon8 on 16 May 2024
Edited: Ancalagon8 on 9 Jun 2024
I attach an example .seed file. Please check it now and see if it runs correctly.

Sign in to comment.

Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!