Category: News
Where do I use a Copilot I created and Published using Copilot Studio?
Hello,
My understanding was that Copilot for Microsoft 365 Customers can create their own custom copilots.
I created a Copilot using Copilot StudioInside Copilot Studio, when I go to “Channels”, I choose “Microsoft Copilot” as the Channel and click “Go to Publish”That takes me to the Publish page from where I completed the PublishShown a Message indicating Publish was successful
But where would an end user go to actually use this Custom Copilot??
Right now I only know how to use it inside Copilot Studio (which is obviously not very useful).
I know exactly how to use a CustomGPT I create in ChatGPT. This is similar, but I can’t figure it out for Copilot. Please help.
Power On! / Avi
https://www.linkedin.com/in/PowerBIPro
Hello, My understanding was that Copilot for Microsoft 365 Customers can create their own custom copilots. I created a Copilot using Copilot StudioInside Copilot Studio, when I go to “Channels”, I choose “Microsoft Copilot” as the Channel and click “Go to Publish”That takes me to the Publish page from where I completed the PublishShown a Message indicating Publish was successfulBut where would an end user go to actually use this Custom Copilot??Right now I only know how to use it inside Copilot Studio (which is obviously not very useful).I know exactly how to use a CustomGPT I create in ChatGPT. This is similar, but I can’t figure it out for Copilot. Please help. Power On! / Avihttps://www.linkedin.com/in/PowerBIPro Read More
help changing subplot sequence in rdmseed
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
if nargin < 1
[filename,pathname] = uigetfile(‘*’,’Please select a miniSEED file…’);
f = fullfile(pathname,filename);
else
f = varargin{1};
end
if ~ischar(f) || ~exist(f,’file’)
error(‘File %s does not exist.’,f);
end
if nargin > 1
verbose = any(strcmpi(varargin,’v’)) + 2*any(strcmpi(varargin,’vv’)) …
+ 3*any(strcmpi(varargin,’vvv’));
makeplot = any(strcmpi(varargin,’plot’));
forcebe = any(strcmpi(varargin,’be’));
notc = any(strcmpi(varargin,’notc’));
force = any(strcmpi(varargin,’force’));
nullhead = any(strcmpi(varargin,’nullhead’));
end
nargs = (makeplot>0) + (verbose>0) + (forcebe>0) + (notc>0) + (force>0) …
+ (nullhead>0);
if nargin > (1 + nargs)
ef = varargin{2};
if ~isnumeric(ef) || ~any(ef==[0:5,10:19,30:33])
error(‘Argument ENCODINGFORMAT must be a valid FDSN code value.’);
end
end
if nargin > (2 + nargs)
wo = varargin{3};
if ~isnumeric(wo) || (wo ~= 0 && wo ~= 1)
error(‘Argument WORDORDER must be 0 or 1.’);
end
end
if nargin > (3 + nargs)
rl = varargin{4};
if ~isnumeric(rl) || rl < 256 || rem(log(rl)/log(2),1) ~= 0
error(‘Argument RECORDLENGTH must be a power of 2 and greater or equal to 256.’);
end
end
if nargout == 0
makeplot = 1;
end
% 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;
% — tests if the header is mini-SEED
% the 7th character must be one of the "data header/quality indicator", usually ‘D’
header = fread(fid,20,’*char’);
if ~ismember(header(7),’DRMQ’)
if ismember(header(7),’VAST’)
error(‘File seems to be a SEED Volume. Cannot read it.’);
else
if header(1)==0
if nullhead
if verbose
fprintf(‘Null header option: bypassing…’);
end
c = 0;
fseek(fid,0,’bof’);
while c==0
c = fread(fid,1,’*char’);
offset = offset + 1;
end
if verbose
fprintf(‘ %d null bytes.n’,offset);
end
header = fread(fid,6,’*char’);
if ~ismember(header(6),’DRMQ’)
error(‘File is not in mini-SEED format. Cannot read it.’);
else
offset = offset – 1;
end
else
error(‘File starts with null bytes… if you believe it is still a miniseed file, try the ”nullhead” option.’);
end
else
error(‘File is not in mini-SEED format. Cannot read it.’);
end
end
end
i = 1;
while offset >= 0
X(i) = read_data_record;
i = i + 1;
end
fclose(fid);
if nargout > 0
varargout{1} = X;
end
% — analyses data
if makeplot || nargout > 1
% test if the file is multiplexed or a single channel
un = unique(cellstr(char(X.ChannelFullName)));
nc = numel(un);
for i = 1:nc
k = find(strcmp(cellstr(char(X.ChannelFullName)),un{i}));
I(i).ChannelFullName = X(k(1)).ChannelFullName;
I(i).XBlockIndex = k;
I(i).ClockDrift = ([diff(cat(1,X(k).RecordStartTimeMATLAB));NaN]*86400 – cat(1,X(k).NumberSamples)./cat(1,X(k).SampleRate))./cat(1,X(k).NumberSamples);
I(i).OverlapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) < -.5) + 1);
I(i).OverlapTime = cat(1,X(I(i).OverlapBlockIndex).RecordStartTimeMATLAB);
I(i).GapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) > .5) + 1);
I(i).GapTime = cat(1,X(I(i).GapBlockIndex).RecordStartTimeMATLAB);
end
end
if nargout > 1
varargout{2} = I;
end
% — 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(‘Timen(%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)
plot(I(i).GapTime(ii),X(I(i).GapBlockIndex(ii)).d,’r’)
else
plot(repmat(I(i).GapTime(ii),1,2),ylim,’r’)
end
end
for ii = 1:length(I(i).OverlapBlockIndex)
if ~isempty(X(I(i).OverlapBlockIndex(ii)).d)
plot(I(i).OverlapTime(ii),X(I(i).OverlapBlockIndex(ii)).d,’g’)
else
plot(repmat(I(i).OverlapTime(ii),1,2),ylim,’g’)
end
end
hold off
end
set(gca,’XLim’,xlim,’FontSize’,8)
h = ylabel(un{i},’Interpreter’,’none’);
if nc > max_channel_label
set(gca,’YTick’,[])
set(h,’Rotation’,0,’HorizontalAlignment’,’right’,’FontSize’,8)
end
datetick(‘x’,’keeplimits’)
set(gca,’XTickLabel’,[])
grid on
if i == 1
title(sprintf(‘mini-SEED file "%s"n%d channels (%d rec. @ %s – %g data – %s – %s)’, …
f,length(un),length(X),rl_text,numel(cat(1,X(k).d)),sr_text,ef_text),’Interpreter’,’none’)
end
if i == nc
datetick(‘x’,’keeplimits’)
xlabel(sprintf(‘Timen(%s to %s)’,datestr(xlim(1)),datestr(xlim(2))))
end
end
v = version;
if str2double(v(1))>=7
linkaxes(findobj(gcf,’type’,’axes’),’x’)
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function D = read_data_record
% read_data_record uses global variables f, fid, offset, le, ef, wo, rl,
% and verbose. It reads a data record and returns a structure D.
global f fid offset le ef wo rl verbose notc force
fseek(fid,offset,’bof’);
% — read fixed section of Data Header (48 bytes)
D.SequenceNumber = fread(fid,6,’*char’)’;
D.DataQualityIndicator = fread(fid,1,’*char’);
D.ReservedByte = fread(fid,1,’*char’);
D.StationIdentifierCode = fread(fid,5,’*char’)’;
D.LocationIdentifier = fread(fid,2,’*char’)’;
D.ChannelIdentifier = fread(fid,3,’*char’)’;
D.NetworkCode = fread(fid,2,’*char’)’;
D.ChannelFullName = sprintf(‘%s:%s:%s:%s’,deblank(D.NetworkCode), …
deblank(D.StationIdentifierCode),deblank(D.LocationIdentifier), …
deblank(D.ChannelIdentifier));
% Start Time decoding
[D.RecordStartTime,swapflag] = readbtime;
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
if swapflag
if le
machinefmt = ‘ieee-be’;
le = 0;
else
machinefmt = ‘ieee-le’;
le = 1;
end
position = ftell(fid);
fclose(fid);
fid = fopen(f,’rb’,machinefmt);
fseek(fid,position,’bof’);
if verbose > 0
warning(‘RDMSEED:DataIntegrity’, …
‘Sequence # %s: need to switch file encoding to %s…n’, …
D.SequenceNumber,machinefmt);
end
end
D.NumberSamples = fread(fid,1,’uint16′);
% Sample Rate decoding
SampleRateFactor = fread(fid,1,’int16′);
SampleRateMultiplier = fread(fid,1,’int16′);
if SampleRateFactor > 0
if SampleRateMultiplier >= 0
D.SampleRate = SampleRateFactor*SampleRateMultiplier;
else
D.SampleRate = -1*SampleRateFactor/SampleRateMultiplier;
end
else
if SampleRateMultiplier >= 0
D.SampleRate = -1*SampleRateMultiplier/SampleRateFactor;
else
D.SampleRate = 1/(SampleRateFactor*SampleRateMultiplier);
end
end
D.ActivityFlags = fread(fid,1,’uint8′);
D.IOFlags = fread(fid,1,’uint8′);
D.DataQualityFlags = fread(fid,1,’uint8′);
D.NumberBlockettesFollow = fread(fid,1,’uint8′);
D.TimeCorrection = fread(fid,1,’int32′); % Time correction in 0.0001 s
D.OffsetBeginData = fread(fid,1,’uint16′);
D.OffsetFirstBlockette = fread(fid,1,’uint16′);
% — read the blockettes
OffsetNextBlockette = D.OffsetFirstBlockette;
D.BLOCKETTES = [];
b2000 = 0; % Number of Blockette 2000
for i = 1:D.NumberBlockettesFollow
fseek(fid,offset + OffsetNextBlockette,’bof’);
BlocketteType = fread(fid,1,’uint16′);
switch BlocketteType
case 1000
% BLOCKETTE 1000 = Data Only SEED (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1000.EncodingFormat = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.WordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.DataRecordLength = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.Reserved = fread(fid,1,’uint8′);
case 1001
% BLOCKETTE 1001 = Data Extension (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1001.TimingQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.Micro_sec = fread(fid,1,’int8′);
D.BLOCKETTES.B1001.Reserved = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.FrameCount = fread(fid,1,’uint8′);
case 100
% BLOCKETTE 100 = Sample Rate (12 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B100.ActualSampleRate = fread(fid,1,’float32′);
D.BLOCKETTES.B100.Flags = fread(fid,1,’uint8′);
D.BLOCKETTES.B100.Reserved = fread(fid,1,’uint8′);
case 500
% BLOCKETTE 500 = Timing (200 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.VCOCorrection = fread(fid,1,’float32′);
D.BLOCKETTES.B500.TimeOfException = readbtime;
D.BLOCKETTES.B500.MicroSec = fread(fid,1,’int8′);
D.BLOCKETTES.B500.ReceptionQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B500.ExceptionCount = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.ExceptionType = fread(fid,16,’*char’)’;
D.BLOCKETTES.B500.ClockModel = fread(fid,32,’*char’)’;
D.BLOCKETTES.B500.ClockStatus = fread(fid,128,’*char’)’;
case 2000
% BLOCKETTE 2000 = Opaque Data (variable length)
b2000 = b2000 + 1;
OffsetNextBlockette = fread(fid,1,’uint16′);
BlocketteLength = fread(fid,1,’uint16′);
OffsetOpaqueData = fread(fid,1,’uint16′);
D.BLOCKETTES.B2000(b2000).RecordNumber = fread(fid,1,’uint32′);
D.BLOCKETTES.B2000(b2000).DataWordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B2000(b2000).Flags = fread(fid,1,’uint8′);
NumberHeaderFields = fread(fid,1,’uint8′);
HeaderFields = splitfield(fread(fid,OffsetOpaqueData-15,’*char’)’,’~’);
D.BLOCKETTES.B2000(b2000).HeaderFields = HeaderFields(1:NumberHeaderFields);
% Opaque data are stored as a single char string, but must be
% decoded using appropriate format (e.g., Quanterra Q330)
D.BLOCKETTES.B2000(b2000).OpaqueData = fread(fid,BlocketteLength-OffsetOpaqueData,’*char’)’;
otherwise
OffsetNextBlockette = fread(fid,1,’uint16′);
if verbose > 0
warning(‘RDMSEED:UnknownBlockette’, …
‘Unknown Blockette number %d (%s)!n’, …
BlocketteType,D.ChannelFullName);
end
end
end
% — read the data stream
fseek(fid,offset + D.OffsetBeginData,’bof’);
if ~force && isfield(D.BLOCKETTES,’B1000′)
EncodingFormat = D.BLOCKETTES.B1000.EncodingFormat;
WordOrder = D.BLOCKETTES.B1000.WordOrder;
D.DataRecordSize = 2^D.BLOCKETTES.B1000.DataRecordLength;
else
EncodingFormat = ef;
WordOrder = wo;
D.DataRecordSize = rl;
end
uncoded = 0;
D.d = NaN;
D.t = NaN;
switch EncodingFormat
case 0
% — decoding format: ASCII text
D.EncodingFormatName = {‘ASCII’};
D.d = fread(fid,D.DataRecordSize – D.OffsetBeginData,’*char’)’;
case 1
% — decoding format: 16-bit integers
D.EncodingFormatName = {‘INT16’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/2),’*int16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 2
% — decoding format: 24-bit integers
D.EncodingFormatName = {‘INT24’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/3),’bit24=>int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 3
% — decoding format: 32-bit integers
D.EncodingFormatName = {‘INT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 4
% — decoding format: IEEE floating point
D.EncodingFormatName = {‘FLOAT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*float’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 5
% — decoding format: IEEE double precision floating point
D.EncodingFormatName = {‘FLOAT64’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/8),’*double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {10,11,19}
% — decoding formats: STEIM-1 and STEIM-2 compression
% (c) Joseph M. Steim, Quanterra Inc., 1994
steim = find(EncodingFormat==[10,11,19]);
D.EncodingFormatName = {sprintf(‘STEIM%d’,steim)};
% Steim compression decoding strategy optimized for Matlab
% — by F. Beauducel, October 2010 —
%
% 1. loads all data into a single 16xM uint32 array
% 2. gets all nibbles from the first row splitted into 2-bit values
% 3. for each possible nibble value, selects (find) and decodes
% (bitsplit) all the corresponding words, and stores results
% in a 4xN (STEIM1) or 7xN (STEIM2) array previously filled with
% NaN’s. For STEIM2 with nibbles 2 or 3, decodes also dnib values
% (first 2-bit of the word)
% 5. reduces this array with non-NaN values only
% 6. integrates with cumsum
%
% This method is about 30 times faster than a ‘C-like’ loops coding…
frame32 = fread(fid,[16,(D.DataRecordSize – D.OffsetBeginData)/64],’*uint32′);
if xor(~WordOrder,le)
frame32 = swapbytes(frame32);
end
% specific processes for STEIM-3
if steim == 3
% first bit = 1 means second differences
SecondDiff = bitshift(frame32(1,:),-31);
% checks for "squeezed flag"… and replaces frame32(1,:)
squeezed = bitand(bitshift(frame32(1,:),-24),127);
k = find(bitget(squeezed,7));
if ~isempty(k)
moredata24 = bitand(frame32(1,k),16777215);
k = find(squeezed == 80); % upper nibble 8-bit = 0x50
if ~isempty(k)
frame32(1,k) = hex2dec(‘15555555’);
end
k = find(squeezed == 96); % upper nibble 8-bit = 0x60
if ~isempty(k)
frame32(1,k) = hex2dec(‘2aaaaaaa’);
end
k = find(squeezed == 112); % upper nibble 8-bit = 0x70
if ~isempty(k)
frame32(1,k) = hex2dec(‘3fffffff’);
end
end
end
% nibbles is an array of the same size as frame32…
nibbles = bitand(bitshift(repmat(frame32(1,:),16,1),repmat(-30:2:0,size(frame32,2),1)’),3);
x0 = bitsign(frame32(2,1),32); % forward integration constant
xn = bitsign(frame32(3,1),32); % reverse integration constant
switch steim
case 1
% STEIM-1: 3 cases following the nibbles
ddd = NaN*ones(4,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 3); % nibble = 3 : one 32-bit difference
if ~isempty(k)
ddd(1,k) = bitsign(frame32(k),32);
end
case 2
% STEIM-2: 7 cases following the nibbles and dnib
ddd = NaN*ones(7,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 1); % dnib = 1 : one 30-bit difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),30);
end
kk = k(dnib == 2); % dnib = 2 : two 15-bit differences
if ~isempty(kk)
ddd(1:2,kk) = bitsplit(frame32(kk),30,15);
end
kk = k(dnib == 3); % dnib = 3 : three 10-bit differences
if ~isempty(kk)
ddd(1:3,kk) = bitsplit(frame32(kk),30,10);
end
end
k = find(nibbles == 3); % nibble = 3 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 0); % dnib = 0 : five 6-bit difference
if ~isempty(kk)
ddd(1:5,kk) = bitsplit(frame32(kk),30,6);
end
kk = k(dnib == 1); % dnib = 1 : six 5-bit differences
if ~isempty(kk)
ddd(1:6,kk) = bitsplit(frame32(kk),30,5);
end
kk = k(dnib == 2); % dnib = 2 : seven 4-bit differences (28 bits!)
if ~isempty(kk)
ddd(1:7,kk) = bitsplit(frame32(kk),28,4);
end
end
case 3 % *** STEIM-3 DECODING IS ALPHA AND UNTESTED ***
% STEIM-3: 7 cases following the nibbles
ddd = NaN*ones(9,numel(frame32)); % initiates array with NaN
k = find(nibbles == 0); % nibble = 0 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look even dnib
if ~isempty(k)
dnib2 = bitshift(frame32(k(2:2:end)),-30);
w60 = bitand(frame32(k(2:2:end)),1073741823) …
+ bitshift(bitand(frame32(k(1:2:end)),1073741823),30); % concatenates two 30-bit words
kk = find(dnib2 == 0); % dnib = 0: five 12-bit differences (60 bits)
if ~isempty(kk)
ddd(1:5,k(2*kk)) = bitsplit(w60,60,12);
end
kk = find(dnib2 == 1); % dnib = 1: three 20-bit differences (60 bits)
if ~isempty(kk)
ddd(1:3,k(2*kk)) = bitsplit(w60,60,20);
end
end
k = find(nibbles == 3); % nibble = 3 : must look 3rd bit
if ~isempty(k)
dnib = bitshift(frame32(k),-27);
kk = k(dnib == 24); % dnib = 11000 : nine 3-bit differences (27 bits)
if ~isempty(kk)
ddd(1:9,kk) = bitsplit(frame32(kk),27,3);
end
kk = k(dnib == 25); % dnib = 11001 : Not A Difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),27);
end
kk = k(dnib > 27); % dnib = 111.. : 29-bit sample (29 bits)
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),29);
end
end
end
% Little-endian coding: needs to swap bytes
if ~WordOrder
ddd = flipud(ddd);
end
dd = ddd(~isnan(ddd)); % reduces initial array ddd: dd is non-NaN values of ddd
% controls the number of samples
if numel(dd) ~= D.NumberSamples
if verbose > 1
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%d-%03d %02d:%02d:%07.4f]: number of samples in header (%d) does not equal data (%d).n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.NumberSamples,numel(dd));
end
if numel(dd) < D.NumberSamples
D.NumberSamples = numel(dd);
end
end
% rebuilds the data vector by integrating the differences
D.d = cumsum([x0;dd(2:D.NumberSamples)]);
% controls data integrity…
if D.d(end) ~= xn
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%s]: data integrity check failed, last_data=%d, Xn=%d.n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.d(end),xn);
end
if D.NumberSamples == 0
D.d = nan(0,1);
end
% for debug purpose…
if verbose > 2
D.dd = dd;
D.nibbles = nibbles;
D.x0 = x0;
D.xn = xn;
end
case 12
% — decoding format: GEOSCOPE multiplexed 24-bit integer
D.EncodingFormatName = {‘GEOSCOPE24’};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/3,’bit24=>double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {13,14}
% — decoding format: GEOSCOPE multiplexed 16/3 and 16/4 bit gain ranged
% (13): 16/3-bit (bit 15 is unused)
% (14): 16/4-bit
% bits 15-12 = 3 or 4-bit gain exponent (positive)
% bits 11-0 = 12-bit mantissa (positive)
% => data = (mantissa – 2048) / 2^gain
geoscope = 7 + 8*(EncodingFormat==14); % mask for gain exponent
D.EncodingFormatName = {sprintf(‘GEOSCOPE16-%d’,EncodingFormat-10)};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/2,’*uint16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
dd = (double(bitand(dd,2^12-1))-2^11)./2.^double(bitand(bitshift(dd,-12),geoscope));
D.d = dd(1:D.NumberSamples);
case 15
% — decoding format: US National Network compression
D.EncodingFormatName = {‘USNN’};
uncoded = 1;
case 16
% — decoding format: CDSN 16-bit gain ranged
D.EncodingFormatName = {‘CDSN’};
uncoded = 1;
case 17
% — decoding format: Graefenberg 16-bit gain ranged
D.EncodingFormatName = {‘GRAEFENBERG’};
uncoded = 1;
case 18
% — decoding format: IPG – Strasbourg 16-bit gain ranged
D.EncodingFormatName = {‘IPGS’};
uncoded = 1;
case 30
% — decoding format: SRO format
D.EncodingFormatName = {‘SRO’};
uncoded = 1;
case 31
% — decoding format: HGLP format
D.EncodingFormatName = {‘HGLP’};
uncoded = 1;
case 32
% — decoding format: DWWSSN gain ranged format
D.EncodingFormatName = {‘DWWSSN’};
uncoded = 1;
case 33
% — decoding format: RSTN 16-bit gain ranged
D.EncodingFormatName = {‘RSTN’};
uncoded = 1;
otherwise
D.EncodingFormatName = {sprintf(‘** Unknown (%d) **’,EncodingFormat)};
uncoded = 1;
end
if uncoded
error(‘Sorry, the encoding format "%s" is not yet implemented.’,D.EncodingFormatName);
end
% Applies time correction (if needed)
D.RecordStartTimeMATLAB = datenum(double([D.RecordStartTime(1),0,D.RecordStartTime(2:5)])) …
+ (~notc & bitand(D.ActivityFlags,2) == 0)*D.TimeCorrection/1e4/86400;
tv = datevec(D.RecordStartTimeMATLAB);
doy = datenum(tv(1:3)) – datenum(tv(1),1,0);
D.RecordStartTime = [tv(1),doy,tv(4:5),round(tv(6)*1e4)/1e4];
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
D.t = D.RecordStartTimeMATLAB;
% makes the time vector and applies time correction (if needed)
if EncodingFormat > 0
D.t = D.t + (0:(D.NumberSamples-1))’/(D.SampleRate*86400);
end
offset = ftell(fid);
fread(fid,1,’char’); % this is to force EOF=1 on last record.
if feof(fid)
offset = -1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c = splitfield(s,d)
% splitfield(S) splits string S of D-character separated field names
C = textscan(s,’%s’,’Delimiter’,d);
c = C{1};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [d,swapflag] = readbtime
% readbtime reads BTIME structure from current opened file and returns
% D = [YEAR,DAY,HOUR,MINUTE,SECONDS]
global fid forcebe
Year = fread(fid,1,’*uint16′);
DayOfYear = fread(fid,1,’*uint16′);
Hours = fread(fid,1,’uint8′);
Minutes = fread(fid,1,’uint8′);
Seconds = fread(fid,1,’uint8′);
fseek(fid,1,0); % skip 1 byte (unused)
Seconds0001 = fread(fid,1,’*uint16′);
% Automatic detection of little/big-endian encoding
% — by F. Beauducel, March 2014 —
%
% If the 2-byte day is >= 512, the file is not opened in the correct
% endianness. If the day is 1 or 256, there is a possible byte-swap and we
% need to check also the year; but we need to consider what is a valid year:
% – years from 1801 to 2047 are OK (swapbytes >= 2312)
% – years from 2048 to 2055 are OK (swapbytes <= 1800)
% – year 2056 is ambiguous (swapbytes = 2056)
% – years from 2057 to 2311 are OK (swapbytes >= 2312)
% – year 1799 is ambiguous (swapbytes = 1799)
% – year 1800 is suspicious (swapbytes = 2055)
%
% Thus, the only cases for which we are ‘sure’ there is a byte-swap, are:
% – day >= 512
% – (day == 1 or day == 256) and (year < 1799 or year > 2311)
%
% Note: in IRIS libmseed, the test is only year>2050 or year<1920.
if ~forcebe && (DayOfYear >= 512 || (ismember(DayOfYear,[1,256]) && (Year > 2311 || Year < 1799)))
swapflag = 1;
Year = swapbytes(Year);
DayOfYear = swapbytes(DayOfYear);
Seconds0001 = swapbytes(Seconds0001);
else
swapflag = 0;
end
d = [double(Year),double(DayOfYear),Hours,Minutes,Seconds + double(Seconds0001)/1e4];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsplit(x,b,n)
% bitsplit(X,B,N) splits the B-bit number X into signed N-bit array
% X must be unsigned integer class
% N ranges from 1 to B
% B is a multiple of N
sign = repmat((b:-n:n)’,1,size(x,1));
x = repmat(x’,b/n,1);
d = double(bitand(bitshift(x,flipud(sign-b)),2^n-1)) …
– double(bitget(x,sign))*2^n;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsign(x,n)
% bitsign(X,N) returns signed double value from unsigned N-bit number X.
% This is equivalent to bitsplit(X,N,N), but the formula is simplified so
% it is much more efficient
d = double(bitand(x,2^n-1)) – double(bitget(x,n)).*2^n;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
if nargin < 1
[filename,pathname] = uigetfile(‘*’,’Please select a miniSEED file…’);
f = fullfile(pathname,filename);
else
f = varargin{1};
end
if ~ischar(f) || ~exist(f,’file’)
error(‘File %s does not exist.’,f);
end
if nargin > 1
verbose = any(strcmpi(varargin,’v’)) + 2*any(strcmpi(varargin,’vv’)) …
+ 3*any(strcmpi(varargin,’vvv’));
makeplot = any(strcmpi(varargin,’plot’));
forcebe = any(strcmpi(varargin,’be’));
notc = any(strcmpi(varargin,’notc’));
force = any(strcmpi(varargin,’force’));
nullhead = any(strcmpi(varargin,’nullhead’));
end
nargs = (makeplot>0) + (verbose>0) + (forcebe>0) + (notc>0) + (force>0) …
+ (nullhead>0);
if nargin > (1 + nargs)
ef = varargin{2};
if ~isnumeric(ef) || ~any(ef==[0:5,10:19,30:33])
error(‘Argument ENCODINGFORMAT must be a valid FDSN code value.’);
end
end
if nargin > (2 + nargs)
wo = varargin{3};
if ~isnumeric(wo) || (wo ~= 0 && wo ~= 1)
error(‘Argument WORDORDER must be 0 or 1.’);
end
end
if nargin > (3 + nargs)
rl = varargin{4};
if ~isnumeric(rl) || rl < 256 || rem(log(rl)/log(2),1) ~= 0
error(‘Argument RECORDLENGTH must be a power of 2 and greater or equal to 256.’);
end
end
if nargout == 0
makeplot = 1;
end
% 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;
% — tests if the header is mini-SEED
% the 7th character must be one of the "data header/quality indicator", usually ‘D’
header = fread(fid,20,’*char’);
if ~ismember(header(7),’DRMQ’)
if ismember(header(7),’VAST’)
error(‘File seems to be a SEED Volume. Cannot read it.’);
else
if header(1)==0
if nullhead
if verbose
fprintf(‘Null header option: bypassing…’);
end
c = 0;
fseek(fid,0,’bof’);
while c==0
c = fread(fid,1,’*char’);
offset = offset + 1;
end
if verbose
fprintf(‘ %d null bytes.n’,offset);
end
header = fread(fid,6,’*char’);
if ~ismember(header(6),’DRMQ’)
error(‘File is not in mini-SEED format. Cannot read it.’);
else
offset = offset – 1;
end
else
error(‘File starts with null bytes… if you believe it is still a miniseed file, try the ”nullhead” option.’);
end
else
error(‘File is not in mini-SEED format. Cannot read it.’);
end
end
end
i = 1;
while offset >= 0
X(i) = read_data_record;
i = i + 1;
end
fclose(fid);
if nargout > 0
varargout{1} = X;
end
% — analyses data
if makeplot || nargout > 1
% test if the file is multiplexed or a single channel
un = unique(cellstr(char(X.ChannelFullName)));
nc = numel(un);
for i = 1:nc
k = find(strcmp(cellstr(char(X.ChannelFullName)),un{i}));
I(i).ChannelFullName = X(k(1)).ChannelFullName;
I(i).XBlockIndex = k;
I(i).ClockDrift = ([diff(cat(1,X(k).RecordStartTimeMATLAB));NaN]*86400 – cat(1,X(k).NumberSamples)./cat(1,X(k).SampleRate))./cat(1,X(k).NumberSamples);
I(i).OverlapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) < -.5) + 1);
I(i).OverlapTime = cat(1,X(I(i).OverlapBlockIndex).RecordStartTimeMATLAB);
I(i).GapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) > .5) + 1);
I(i).GapTime = cat(1,X(I(i).GapBlockIndex).RecordStartTimeMATLAB);
end
end
if nargout > 1
varargout{2} = I;
end
% — 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(‘Timen(%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)
plot(I(i).GapTime(ii),X(I(i).GapBlockIndex(ii)).d,’r’)
else
plot(repmat(I(i).GapTime(ii),1,2),ylim,’r’)
end
end
for ii = 1:length(I(i).OverlapBlockIndex)
if ~isempty(X(I(i).OverlapBlockIndex(ii)).d)
plot(I(i).OverlapTime(ii),X(I(i).OverlapBlockIndex(ii)).d,’g’)
else
plot(repmat(I(i).OverlapTime(ii),1,2),ylim,’g’)
end
end
hold off
end
set(gca,’XLim’,xlim,’FontSize’,8)
h = ylabel(un{i},’Interpreter’,’none’);
if nc > max_channel_label
set(gca,’YTick’,[])
set(h,’Rotation’,0,’HorizontalAlignment’,’right’,’FontSize’,8)
end
datetick(‘x’,’keeplimits’)
set(gca,’XTickLabel’,[])
grid on
if i == 1
title(sprintf(‘mini-SEED file "%s"n%d channels (%d rec. @ %s – %g data – %s – %s)’, …
f,length(un),length(X),rl_text,numel(cat(1,X(k).d)),sr_text,ef_text),’Interpreter’,’none’)
end
if i == nc
datetick(‘x’,’keeplimits’)
xlabel(sprintf(‘Timen(%s to %s)’,datestr(xlim(1)),datestr(xlim(2))))
end
end
v = version;
if str2double(v(1))>=7
linkaxes(findobj(gcf,’type’,’axes’),’x’)
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function D = read_data_record
% read_data_record uses global variables f, fid, offset, le, ef, wo, rl,
% and verbose. It reads a data record and returns a structure D.
global f fid offset le ef wo rl verbose notc force
fseek(fid,offset,’bof’);
% — read fixed section of Data Header (48 bytes)
D.SequenceNumber = fread(fid,6,’*char’)’;
D.DataQualityIndicator = fread(fid,1,’*char’);
D.ReservedByte = fread(fid,1,’*char’);
D.StationIdentifierCode = fread(fid,5,’*char’)’;
D.LocationIdentifier = fread(fid,2,’*char’)’;
D.ChannelIdentifier = fread(fid,3,’*char’)’;
D.NetworkCode = fread(fid,2,’*char’)’;
D.ChannelFullName = sprintf(‘%s:%s:%s:%s’,deblank(D.NetworkCode), …
deblank(D.StationIdentifierCode),deblank(D.LocationIdentifier), …
deblank(D.ChannelIdentifier));
% Start Time decoding
[D.RecordStartTime,swapflag] = readbtime;
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
if swapflag
if le
machinefmt = ‘ieee-be’;
le = 0;
else
machinefmt = ‘ieee-le’;
le = 1;
end
position = ftell(fid);
fclose(fid);
fid = fopen(f,’rb’,machinefmt);
fseek(fid,position,’bof’);
if verbose > 0
warning(‘RDMSEED:DataIntegrity’, …
‘Sequence # %s: need to switch file encoding to %s…n’, …
D.SequenceNumber,machinefmt);
end
end
D.NumberSamples = fread(fid,1,’uint16′);
% Sample Rate decoding
SampleRateFactor = fread(fid,1,’int16′);
SampleRateMultiplier = fread(fid,1,’int16′);
if SampleRateFactor > 0
if SampleRateMultiplier >= 0
D.SampleRate = SampleRateFactor*SampleRateMultiplier;
else
D.SampleRate = -1*SampleRateFactor/SampleRateMultiplier;
end
else
if SampleRateMultiplier >= 0
D.SampleRate = -1*SampleRateMultiplier/SampleRateFactor;
else
D.SampleRate = 1/(SampleRateFactor*SampleRateMultiplier);
end
end
D.ActivityFlags = fread(fid,1,’uint8′);
D.IOFlags = fread(fid,1,’uint8′);
D.DataQualityFlags = fread(fid,1,’uint8′);
D.NumberBlockettesFollow = fread(fid,1,’uint8′);
D.TimeCorrection = fread(fid,1,’int32′); % Time correction in 0.0001 s
D.OffsetBeginData = fread(fid,1,’uint16′);
D.OffsetFirstBlockette = fread(fid,1,’uint16′);
% — read the blockettes
OffsetNextBlockette = D.OffsetFirstBlockette;
D.BLOCKETTES = [];
b2000 = 0; % Number of Blockette 2000
for i = 1:D.NumberBlockettesFollow
fseek(fid,offset + OffsetNextBlockette,’bof’);
BlocketteType = fread(fid,1,’uint16′);
switch BlocketteType
case 1000
% BLOCKETTE 1000 = Data Only SEED (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1000.EncodingFormat = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.WordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.DataRecordLength = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.Reserved = fread(fid,1,’uint8′);
case 1001
% BLOCKETTE 1001 = Data Extension (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1001.TimingQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.Micro_sec = fread(fid,1,’int8′);
D.BLOCKETTES.B1001.Reserved = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.FrameCount = fread(fid,1,’uint8′);
case 100
% BLOCKETTE 100 = Sample Rate (12 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B100.ActualSampleRate = fread(fid,1,’float32′);
D.BLOCKETTES.B100.Flags = fread(fid,1,’uint8′);
D.BLOCKETTES.B100.Reserved = fread(fid,1,’uint8′);
case 500
% BLOCKETTE 500 = Timing (200 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.VCOCorrection = fread(fid,1,’float32′);
D.BLOCKETTES.B500.TimeOfException = readbtime;
D.BLOCKETTES.B500.MicroSec = fread(fid,1,’int8′);
D.BLOCKETTES.B500.ReceptionQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B500.ExceptionCount = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.ExceptionType = fread(fid,16,’*char’)’;
D.BLOCKETTES.B500.ClockModel = fread(fid,32,’*char’)’;
D.BLOCKETTES.B500.ClockStatus = fread(fid,128,’*char’)’;
case 2000
% BLOCKETTE 2000 = Opaque Data (variable length)
b2000 = b2000 + 1;
OffsetNextBlockette = fread(fid,1,’uint16′);
BlocketteLength = fread(fid,1,’uint16′);
OffsetOpaqueData = fread(fid,1,’uint16′);
D.BLOCKETTES.B2000(b2000).RecordNumber = fread(fid,1,’uint32′);
D.BLOCKETTES.B2000(b2000).DataWordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B2000(b2000).Flags = fread(fid,1,’uint8′);
NumberHeaderFields = fread(fid,1,’uint8′);
HeaderFields = splitfield(fread(fid,OffsetOpaqueData-15,’*char’)’,’~’);
D.BLOCKETTES.B2000(b2000).HeaderFields = HeaderFields(1:NumberHeaderFields);
% Opaque data are stored as a single char string, but must be
% decoded using appropriate format (e.g., Quanterra Q330)
D.BLOCKETTES.B2000(b2000).OpaqueData = fread(fid,BlocketteLength-OffsetOpaqueData,’*char’)’;
otherwise
OffsetNextBlockette = fread(fid,1,’uint16′);
if verbose > 0
warning(‘RDMSEED:UnknownBlockette’, …
‘Unknown Blockette number %d (%s)!n’, …
BlocketteType,D.ChannelFullName);
end
end
end
% — read the data stream
fseek(fid,offset + D.OffsetBeginData,’bof’);
if ~force && isfield(D.BLOCKETTES,’B1000′)
EncodingFormat = D.BLOCKETTES.B1000.EncodingFormat;
WordOrder = D.BLOCKETTES.B1000.WordOrder;
D.DataRecordSize = 2^D.BLOCKETTES.B1000.DataRecordLength;
else
EncodingFormat = ef;
WordOrder = wo;
D.DataRecordSize = rl;
end
uncoded = 0;
D.d = NaN;
D.t = NaN;
switch EncodingFormat
case 0
% — decoding format: ASCII text
D.EncodingFormatName = {‘ASCII’};
D.d = fread(fid,D.DataRecordSize – D.OffsetBeginData,’*char’)’;
case 1
% — decoding format: 16-bit integers
D.EncodingFormatName = {‘INT16’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/2),’*int16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 2
% — decoding format: 24-bit integers
D.EncodingFormatName = {‘INT24’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/3),’bit24=>int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 3
% — decoding format: 32-bit integers
D.EncodingFormatName = {‘INT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 4
% — decoding format: IEEE floating point
D.EncodingFormatName = {‘FLOAT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*float’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 5
% — decoding format: IEEE double precision floating point
D.EncodingFormatName = {‘FLOAT64’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/8),’*double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {10,11,19}
% — decoding formats: STEIM-1 and STEIM-2 compression
% (c) Joseph M. Steim, Quanterra Inc., 1994
steim = find(EncodingFormat==[10,11,19]);
D.EncodingFormatName = {sprintf(‘STEIM%d’,steim)};
% Steim compression decoding strategy optimized for Matlab
% — by F. Beauducel, October 2010 —
%
% 1. loads all data into a single 16xM uint32 array
% 2. gets all nibbles from the first row splitted into 2-bit values
% 3. for each possible nibble value, selects (find) and decodes
% (bitsplit) all the corresponding words, and stores results
% in a 4xN (STEIM1) or 7xN (STEIM2) array previously filled with
% NaN’s. For STEIM2 with nibbles 2 or 3, decodes also dnib values
% (first 2-bit of the word)
% 5. reduces this array with non-NaN values only
% 6. integrates with cumsum
%
% This method is about 30 times faster than a ‘C-like’ loops coding…
frame32 = fread(fid,[16,(D.DataRecordSize – D.OffsetBeginData)/64],’*uint32′);
if xor(~WordOrder,le)
frame32 = swapbytes(frame32);
end
% specific processes for STEIM-3
if steim == 3
% first bit = 1 means second differences
SecondDiff = bitshift(frame32(1,:),-31);
% checks for "squeezed flag"… and replaces frame32(1,:)
squeezed = bitand(bitshift(frame32(1,:),-24),127);
k = find(bitget(squeezed,7));
if ~isempty(k)
moredata24 = bitand(frame32(1,k),16777215);
k = find(squeezed == 80); % upper nibble 8-bit = 0x50
if ~isempty(k)
frame32(1,k) = hex2dec(‘15555555’);
end
k = find(squeezed == 96); % upper nibble 8-bit = 0x60
if ~isempty(k)
frame32(1,k) = hex2dec(‘2aaaaaaa’);
end
k = find(squeezed == 112); % upper nibble 8-bit = 0x70
if ~isempty(k)
frame32(1,k) = hex2dec(‘3fffffff’);
end
end
end
% nibbles is an array of the same size as frame32…
nibbles = bitand(bitshift(repmat(frame32(1,:),16,1),repmat(-30:2:0,size(frame32,2),1)’),3);
x0 = bitsign(frame32(2,1),32); % forward integration constant
xn = bitsign(frame32(3,1),32); % reverse integration constant
switch steim
case 1
% STEIM-1: 3 cases following the nibbles
ddd = NaN*ones(4,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 3); % nibble = 3 : one 32-bit difference
if ~isempty(k)
ddd(1,k) = bitsign(frame32(k),32);
end
case 2
% STEIM-2: 7 cases following the nibbles and dnib
ddd = NaN*ones(7,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 1); % dnib = 1 : one 30-bit difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),30);
end
kk = k(dnib == 2); % dnib = 2 : two 15-bit differences
if ~isempty(kk)
ddd(1:2,kk) = bitsplit(frame32(kk),30,15);
end
kk = k(dnib == 3); % dnib = 3 : three 10-bit differences
if ~isempty(kk)
ddd(1:3,kk) = bitsplit(frame32(kk),30,10);
end
end
k = find(nibbles == 3); % nibble = 3 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 0); % dnib = 0 : five 6-bit difference
if ~isempty(kk)
ddd(1:5,kk) = bitsplit(frame32(kk),30,6);
end
kk = k(dnib == 1); % dnib = 1 : six 5-bit differences
if ~isempty(kk)
ddd(1:6,kk) = bitsplit(frame32(kk),30,5);
end
kk = k(dnib == 2); % dnib = 2 : seven 4-bit differences (28 bits!)
if ~isempty(kk)
ddd(1:7,kk) = bitsplit(frame32(kk),28,4);
end
end
case 3 % *** STEIM-3 DECODING IS ALPHA AND UNTESTED ***
% STEIM-3: 7 cases following the nibbles
ddd = NaN*ones(9,numel(frame32)); % initiates array with NaN
k = find(nibbles == 0); % nibble = 0 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look even dnib
if ~isempty(k)
dnib2 = bitshift(frame32(k(2:2:end)),-30);
w60 = bitand(frame32(k(2:2:end)),1073741823) …
+ bitshift(bitand(frame32(k(1:2:end)),1073741823),30); % concatenates two 30-bit words
kk = find(dnib2 == 0); % dnib = 0: five 12-bit differences (60 bits)
if ~isempty(kk)
ddd(1:5,k(2*kk)) = bitsplit(w60,60,12);
end
kk = find(dnib2 == 1); % dnib = 1: three 20-bit differences (60 bits)
if ~isempty(kk)
ddd(1:3,k(2*kk)) = bitsplit(w60,60,20);
end
end
k = find(nibbles == 3); % nibble = 3 : must look 3rd bit
if ~isempty(k)
dnib = bitshift(frame32(k),-27);
kk = k(dnib == 24); % dnib = 11000 : nine 3-bit differences (27 bits)
if ~isempty(kk)
ddd(1:9,kk) = bitsplit(frame32(kk),27,3);
end
kk = k(dnib == 25); % dnib = 11001 : Not A Difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),27);
end
kk = k(dnib > 27); % dnib = 111.. : 29-bit sample (29 bits)
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),29);
end
end
end
% Little-endian coding: needs to swap bytes
if ~WordOrder
ddd = flipud(ddd);
end
dd = ddd(~isnan(ddd)); % reduces initial array ddd: dd is non-NaN values of ddd
% controls the number of samples
if numel(dd) ~= D.NumberSamples
if verbose > 1
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%d-%03d %02d:%02d:%07.4f]: number of samples in header (%d) does not equal data (%d).n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.NumberSamples,numel(dd));
end
if numel(dd) < D.NumberSamples
D.NumberSamples = numel(dd);
end
end
% rebuilds the data vector by integrating the differences
D.d = cumsum([x0;dd(2:D.NumberSamples)]);
% controls data integrity…
if D.d(end) ~= xn
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%s]: data integrity check failed, last_data=%d, Xn=%d.n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.d(end),xn);
end
if D.NumberSamples == 0
D.d = nan(0,1);
end
% for debug purpose…
if verbose > 2
D.dd = dd;
D.nibbles = nibbles;
D.x0 = x0;
D.xn = xn;
end
case 12
% — decoding format: GEOSCOPE multiplexed 24-bit integer
D.EncodingFormatName = {‘GEOSCOPE24’};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/3,’bit24=>double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {13,14}
% — decoding format: GEOSCOPE multiplexed 16/3 and 16/4 bit gain ranged
% (13): 16/3-bit (bit 15 is unused)
% (14): 16/4-bit
% bits 15-12 = 3 or 4-bit gain exponent (positive)
% bits 11-0 = 12-bit mantissa (positive)
% => data = (mantissa – 2048) / 2^gain
geoscope = 7 + 8*(EncodingFormat==14); % mask for gain exponent
D.EncodingFormatName = {sprintf(‘GEOSCOPE16-%d’,EncodingFormat-10)};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/2,’*uint16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
dd = (double(bitand(dd,2^12-1))-2^11)./2.^double(bitand(bitshift(dd,-12),geoscope));
D.d = dd(1:D.NumberSamples);
case 15
% — decoding format: US National Network compression
D.EncodingFormatName = {‘USNN’};
uncoded = 1;
case 16
% — decoding format: CDSN 16-bit gain ranged
D.EncodingFormatName = {‘CDSN’};
uncoded = 1;
case 17
% — decoding format: Graefenberg 16-bit gain ranged
D.EncodingFormatName = {‘GRAEFENBERG’};
uncoded = 1;
case 18
% — decoding format: IPG – Strasbourg 16-bit gain ranged
D.EncodingFormatName = {‘IPGS’};
uncoded = 1;
case 30
% — decoding format: SRO format
D.EncodingFormatName = {‘SRO’};
uncoded = 1;
case 31
% — decoding format: HGLP format
D.EncodingFormatName = {‘HGLP’};
uncoded = 1;
case 32
% — decoding format: DWWSSN gain ranged format
D.EncodingFormatName = {‘DWWSSN’};
uncoded = 1;
case 33
% — decoding format: RSTN 16-bit gain ranged
D.EncodingFormatName = {‘RSTN’};
uncoded = 1;
otherwise
D.EncodingFormatName = {sprintf(‘** Unknown (%d) **’,EncodingFormat)};
uncoded = 1;
end
if uncoded
error(‘Sorry, the encoding format "%s" is not yet implemented.’,D.EncodingFormatName);
end
% Applies time correction (if needed)
D.RecordStartTimeMATLAB = datenum(double([D.RecordStartTime(1),0,D.RecordStartTime(2:5)])) …
+ (~notc & bitand(D.ActivityFlags,2) == 0)*D.TimeCorrection/1e4/86400;
tv = datevec(D.RecordStartTimeMATLAB);
doy = datenum(tv(1:3)) – datenum(tv(1),1,0);
D.RecordStartTime = [tv(1),doy,tv(4:5),round(tv(6)*1e4)/1e4];
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
D.t = D.RecordStartTimeMATLAB;
% makes the time vector and applies time correction (if needed)
if EncodingFormat > 0
D.t = D.t + (0:(D.NumberSamples-1))’/(D.SampleRate*86400);
end
offset = ftell(fid);
fread(fid,1,’char’); % this is to force EOF=1 on last record.
if feof(fid)
offset = -1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c = splitfield(s,d)
% splitfield(S) splits string S of D-character separated field names
C = textscan(s,’%s’,’Delimiter’,d);
c = C{1};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [d,swapflag] = readbtime
% readbtime reads BTIME structure from current opened file and returns
% D = [YEAR,DAY,HOUR,MINUTE,SECONDS]
global fid forcebe
Year = fread(fid,1,’*uint16′);
DayOfYear = fread(fid,1,’*uint16′);
Hours = fread(fid,1,’uint8′);
Minutes = fread(fid,1,’uint8′);
Seconds = fread(fid,1,’uint8′);
fseek(fid,1,0); % skip 1 byte (unused)
Seconds0001 = fread(fid,1,’*uint16′);
% Automatic detection of little/big-endian encoding
% — by F. Beauducel, March 2014 —
%
% If the 2-byte day is >= 512, the file is not opened in the correct
% endianness. If the day is 1 or 256, there is a possible byte-swap and we
% need to check also the year; but we need to consider what is a valid year:
% – years from 1801 to 2047 are OK (swapbytes >= 2312)
% – years from 2048 to 2055 are OK (swapbytes <= 1800)
% – year 2056 is ambiguous (swapbytes = 2056)
% – years from 2057 to 2311 are OK (swapbytes >= 2312)
% – year 1799 is ambiguous (swapbytes = 1799)
% – year 1800 is suspicious (swapbytes = 2055)
%
% Thus, the only cases for which we are ‘sure’ there is a byte-swap, are:
% – day >= 512
% – (day == 1 or day == 256) and (year < 1799 or year > 2311)
%
% Note: in IRIS libmseed, the test is only year>2050 or year<1920.
if ~forcebe && (DayOfYear >= 512 || (ismember(DayOfYear,[1,256]) && (Year > 2311 || Year < 1799)))
swapflag = 1;
Year = swapbytes(Year);
DayOfYear = swapbytes(DayOfYear);
Seconds0001 = swapbytes(Seconds0001);
else
swapflag = 0;
end
d = [double(Year),double(DayOfYear),Hours,Minutes,Seconds + double(Seconds0001)/1e4];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsplit(x,b,n)
% bitsplit(X,B,N) splits the B-bit number X into signed N-bit array
% X must be unsigned integer class
% N ranges from 1 to B
% B is a multiple of N
sign = repmat((b:-n:n)’,1,size(x,1));
x = repmat(x’,b/n,1);
d = double(bitand(bitshift(x,flipud(sign-b)),2^n-1)) …
– double(bitget(x,sign))*2^n;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsign(x,n)
% bitsign(X,N) returns signed double value from unsigned N-bit number X.
% This is equivalent to bitsplit(X,N,N), but the formula is simplified so
% it is much more efficient
d = double(bitand(x,2^n-1)) – double(bitget(x,n)).*2^n; 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
if nargin < 1
[filename,pathname] = uigetfile(‘*’,’Please select a miniSEED file…’);
f = fullfile(pathname,filename);
else
f = varargin{1};
end
if ~ischar(f) || ~exist(f,’file’)
error(‘File %s does not exist.’,f);
end
if nargin > 1
verbose = any(strcmpi(varargin,’v’)) + 2*any(strcmpi(varargin,’vv’)) …
+ 3*any(strcmpi(varargin,’vvv’));
makeplot = any(strcmpi(varargin,’plot’));
forcebe = any(strcmpi(varargin,’be’));
notc = any(strcmpi(varargin,’notc’));
force = any(strcmpi(varargin,’force’));
nullhead = any(strcmpi(varargin,’nullhead’));
end
nargs = (makeplot>0) + (verbose>0) + (forcebe>0) + (notc>0) + (force>0) …
+ (nullhead>0);
if nargin > (1 + nargs)
ef = varargin{2};
if ~isnumeric(ef) || ~any(ef==[0:5,10:19,30:33])
error(‘Argument ENCODINGFORMAT must be a valid FDSN code value.’);
end
end
if nargin > (2 + nargs)
wo = varargin{3};
if ~isnumeric(wo) || (wo ~= 0 && wo ~= 1)
error(‘Argument WORDORDER must be 0 or 1.’);
end
end
if nargin > (3 + nargs)
rl = varargin{4};
if ~isnumeric(rl) || rl < 256 || rem(log(rl)/log(2),1) ~= 0
error(‘Argument RECORDLENGTH must be a power of 2 and greater or equal to 256.’);
end
end
if nargout == 0
makeplot = 1;
end
% 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;
% — tests if the header is mini-SEED
% the 7th character must be one of the "data header/quality indicator", usually ‘D’
header = fread(fid,20,’*char’);
if ~ismember(header(7),’DRMQ’)
if ismember(header(7),’VAST’)
error(‘File seems to be a SEED Volume. Cannot read it.’);
else
if header(1)==0
if nullhead
if verbose
fprintf(‘Null header option: bypassing…’);
end
c = 0;
fseek(fid,0,’bof’);
while c==0
c = fread(fid,1,’*char’);
offset = offset + 1;
end
if verbose
fprintf(‘ %d null bytes.n’,offset);
end
header = fread(fid,6,’*char’);
if ~ismember(header(6),’DRMQ’)
error(‘File is not in mini-SEED format. Cannot read it.’);
else
offset = offset – 1;
end
else
error(‘File starts with null bytes… if you believe it is still a miniseed file, try the ”nullhead” option.’);
end
else
error(‘File is not in mini-SEED format. Cannot read it.’);
end
end
end
i = 1;
while offset >= 0
X(i) = read_data_record;
i = i + 1;
end
fclose(fid);
if nargout > 0
varargout{1} = X;
end
% — analyses data
if makeplot || nargout > 1
% test if the file is multiplexed or a single channel
un = unique(cellstr(char(X.ChannelFullName)));
nc = numel(un);
for i = 1:nc
k = find(strcmp(cellstr(char(X.ChannelFullName)),un{i}));
I(i).ChannelFullName = X(k(1)).ChannelFullName;
I(i).XBlockIndex = k;
I(i).ClockDrift = ([diff(cat(1,X(k).RecordStartTimeMATLAB));NaN]*86400 – cat(1,X(k).NumberSamples)./cat(1,X(k).SampleRate))./cat(1,X(k).NumberSamples);
I(i).OverlapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) < -.5) + 1);
I(i).OverlapTime = cat(1,X(I(i).OverlapBlockIndex).RecordStartTimeMATLAB);
I(i).GapBlockIndex = k(find(I(i).ClockDrift.*cat(1,X(k).NumberSamples).*cat(1,X(k).SampleRate) > .5) + 1);
I(i).GapTime = cat(1,X(I(i).GapBlockIndex).RecordStartTimeMATLAB);
end
end
if nargout > 1
varargout{2} = I;
end
% — 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(‘Timen(%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)
plot(I(i).GapTime(ii),X(I(i).GapBlockIndex(ii)).d,’r’)
else
plot(repmat(I(i).GapTime(ii),1,2),ylim,’r’)
end
end
for ii = 1:length(I(i).OverlapBlockIndex)
if ~isempty(X(I(i).OverlapBlockIndex(ii)).d)
plot(I(i).OverlapTime(ii),X(I(i).OverlapBlockIndex(ii)).d,’g’)
else
plot(repmat(I(i).OverlapTime(ii),1,2),ylim,’g’)
end
end
hold off
end
set(gca,’XLim’,xlim,’FontSize’,8)
h = ylabel(un{i},’Interpreter’,’none’);
if nc > max_channel_label
set(gca,’YTick’,[])
set(h,’Rotation’,0,’HorizontalAlignment’,’right’,’FontSize’,8)
end
datetick(‘x’,’keeplimits’)
set(gca,’XTickLabel’,[])
grid on
if i == 1
title(sprintf(‘mini-SEED file "%s"n%d channels (%d rec. @ %s – %g data – %s – %s)’, …
f,length(un),length(X),rl_text,numel(cat(1,X(k).d)),sr_text,ef_text),’Interpreter’,’none’)
end
if i == nc
datetick(‘x’,’keeplimits’)
xlabel(sprintf(‘Timen(%s to %s)’,datestr(xlim(1)),datestr(xlim(2))))
end
end
v = version;
if str2double(v(1))>=7
linkaxes(findobj(gcf,’type’,’axes’),’x’)
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function D = read_data_record
% read_data_record uses global variables f, fid, offset, le, ef, wo, rl,
% and verbose. It reads a data record and returns a structure D.
global f fid offset le ef wo rl verbose notc force
fseek(fid,offset,’bof’);
% — read fixed section of Data Header (48 bytes)
D.SequenceNumber = fread(fid,6,’*char’)’;
D.DataQualityIndicator = fread(fid,1,’*char’);
D.ReservedByte = fread(fid,1,’*char’);
D.StationIdentifierCode = fread(fid,5,’*char’)’;
D.LocationIdentifier = fread(fid,2,’*char’)’;
D.ChannelIdentifier = fread(fid,3,’*char’)’;
D.NetworkCode = fread(fid,2,’*char’)’;
D.ChannelFullName = sprintf(‘%s:%s:%s:%s’,deblank(D.NetworkCode), …
deblank(D.StationIdentifierCode),deblank(D.LocationIdentifier), …
deblank(D.ChannelIdentifier));
% Start Time decoding
[D.RecordStartTime,swapflag] = readbtime;
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
if swapflag
if le
machinefmt = ‘ieee-be’;
le = 0;
else
machinefmt = ‘ieee-le’;
le = 1;
end
position = ftell(fid);
fclose(fid);
fid = fopen(f,’rb’,machinefmt);
fseek(fid,position,’bof’);
if verbose > 0
warning(‘RDMSEED:DataIntegrity’, …
‘Sequence # %s: need to switch file encoding to %s…n’, …
D.SequenceNumber,machinefmt);
end
end
D.NumberSamples = fread(fid,1,’uint16′);
% Sample Rate decoding
SampleRateFactor = fread(fid,1,’int16′);
SampleRateMultiplier = fread(fid,1,’int16′);
if SampleRateFactor > 0
if SampleRateMultiplier >= 0
D.SampleRate = SampleRateFactor*SampleRateMultiplier;
else
D.SampleRate = -1*SampleRateFactor/SampleRateMultiplier;
end
else
if SampleRateMultiplier >= 0
D.SampleRate = -1*SampleRateMultiplier/SampleRateFactor;
else
D.SampleRate = 1/(SampleRateFactor*SampleRateMultiplier);
end
end
D.ActivityFlags = fread(fid,1,’uint8′);
D.IOFlags = fread(fid,1,’uint8′);
D.DataQualityFlags = fread(fid,1,’uint8′);
D.NumberBlockettesFollow = fread(fid,1,’uint8′);
D.TimeCorrection = fread(fid,1,’int32′); % Time correction in 0.0001 s
D.OffsetBeginData = fread(fid,1,’uint16′);
D.OffsetFirstBlockette = fread(fid,1,’uint16′);
% — read the blockettes
OffsetNextBlockette = D.OffsetFirstBlockette;
D.BLOCKETTES = [];
b2000 = 0; % Number of Blockette 2000
for i = 1:D.NumberBlockettesFollow
fseek(fid,offset + OffsetNextBlockette,’bof’);
BlocketteType = fread(fid,1,’uint16′);
switch BlocketteType
case 1000
% BLOCKETTE 1000 = Data Only SEED (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1000.EncodingFormat = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.WordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.DataRecordLength = fread(fid,1,’uint8′);
D.BLOCKETTES.B1000.Reserved = fread(fid,1,’uint8′);
case 1001
% BLOCKETTE 1001 = Data Extension (8 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B1001.TimingQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.Micro_sec = fread(fid,1,’int8′);
D.BLOCKETTES.B1001.Reserved = fread(fid,1,’uint8′);
D.BLOCKETTES.B1001.FrameCount = fread(fid,1,’uint8′);
case 100
% BLOCKETTE 100 = Sample Rate (12 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B100.ActualSampleRate = fread(fid,1,’float32′);
D.BLOCKETTES.B100.Flags = fread(fid,1,’uint8′);
D.BLOCKETTES.B100.Reserved = fread(fid,1,’uint8′);
case 500
% BLOCKETTE 500 = Timing (200 bytes)
OffsetNextBlockette = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.VCOCorrection = fread(fid,1,’float32′);
D.BLOCKETTES.B500.TimeOfException = readbtime;
D.BLOCKETTES.B500.MicroSec = fread(fid,1,’int8′);
D.BLOCKETTES.B500.ReceptionQuality = fread(fid,1,’uint8′);
D.BLOCKETTES.B500.ExceptionCount = fread(fid,1,’uint16′);
D.BLOCKETTES.B500.ExceptionType = fread(fid,16,’*char’)’;
D.BLOCKETTES.B500.ClockModel = fread(fid,32,’*char’)’;
D.BLOCKETTES.B500.ClockStatus = fread(fid,128,’*char’)’;
case 2000
% BLOCKETTE 2000 = Opaque Data (variable length)
b2000 = b2000 + 1;
OffsetNextBlockette = fread(fid,1,’uint16′);
BlocketteLength = fread(fid,1,’uint16′);
OffsetOpaqueData = fread(fid,1,’uint16′);
D.BLOCKETTES.B2000(b2000).RecordNumber = fread(fid,1,’uint32′);
D.BLOCKETTES.B2000(b2000).DataWordOrder = fread(fid,1,’uint8′);
D.BLOCKETTES.B2000(b2000).Flags = fread(fid,1,’uint8′);
NumberHeaderFields = fread(fid,1,’uint8′);
HeaderFields = splitfield(fread(fid,OffsetOpaqueData-15,’*char’)’,’~’);
D.BLOCKETTES.B2000(b2000).HeaderFields = HeaderFields(1:NumberHeaderFields);
% Opaque data are stored as a single char string, but must be
% decoded using appropriate format (e.g., Quanterra Q330)
D.BLOCKETTES.B2000(b2000).OpaqueData = fread(fid,BlocketteLength-OffsetOpaqueData,’*char’)’;
otherwise
OffsetNextBlockette = fread(fid,1,’uint16′);
if verbose > 0
warning(‘RDMSEED:UnknownBlockette’, …
‘Unknown Blockette number %d (%s)!n’, …
BlocketteType,D.ChannelFullName);
end
end
end
% — read the data stream
fseek(fid,offset + D.OffsetBeginData,’bof’);
if ~force && isfield(D.BLOCKETTES,’B1000′)
EncodingFormat = D.BLOCKETTES.B1000.EncodingFormat;
WordOrder = D.BLOCKETTES.B1000.WordOrder;
D.DataRecordSize = 2^D.BLOCKETTES.B1000.DataRecordLength;
else
EncodingFormat = ef;
WordOrder = wo;
D.DataRecordSize = rl;
end
uncoded = 0;
D.d = NaN;
D.t = NaN;
switch EncodingFormat
case 0
% — decoding format: ASCII text
D.EncodingFormatName = {‘ASCII’};
D.d = fread(fid,D.DataRecordSize – D.OffsetBeginData,’*char’)’;
case 1
% — decoding format: 16-bit integers
D.EncodingFormatName = {‘INT16’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/2),’*int16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 2
% — decoding format: 24-bit integers
D.EncodingFormatName = {‘INT24’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/3),’bit24=>int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 3
% — decoding format: 32-bit integers
D.EncodingFormatName = {‘INT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*int32′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 4
% — decoding format: IEEE floating point
D.EncodingFormatName = {‘FLOAT32’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/4),’*float’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case 5
% — decoding format: IEEE double precision floating point
D.EncodingFormatName = {‘FLOAT64’};
dd = fread(fid,ceil((D.DataRecordSize – D.OffsetBeginData)/8),’*double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {10,11,19}
% — decoding formats: STEIM-1 and STEIM-2 compression
% (c) Joseph M. Steim, Quanterra Inc., 1994
steim = find(EncodingFormat==[10,11,19]);
D.EncodingFormatName = {sprintf(‘STEIM%d’,steim)};
% Steim compression decoding strategy optimized for Matlab
% — by F. Beauducel, October 2010 —
%
% 1. loads all data into a single 16xM uint32 array
% 2. gets all nibbles from the first row splitted into 2-bit values
% 3. for each possible nibble value, selects (find) and decodes
% (bitsplit) all the corresponding words, and stores results
% in a 4xN (STEIM1) or 7xN (STEIM2) array previously filled with
% NaN’s. For STEIM2 with nibbles 2 or 3, decodes also dnib values
% (first 2-bit of the word)
% 5. reduces this array with non-NaN values only
% 6. integrates with cumsum
%
% This method is about 30 times faster than a ‘C-like’ loops coding…
frame32 = fread(fid,[16,(D.DataRecordSize – D.OffsetBeginData)/64],’*uint32′);
if xor(~WordOrder,le)
frame32 = swapbytes(frame32);
end
% specific processes for STEIM-3
if steim == 3
% first bit = 1 means second differences
SecondDiff = bitshift(frame32(1,:),-31);
% checks for "squeezed flag"… and replaces frame32(1,:)
squeezed = bitand(bitshift(frame32(1,:),-24),127);
k = find(bitget(squeezed,7));
if ~isempty(k)
moredata24 = bitand(frame32(1,k),16777215);
k = find(squeezed == 80); % upper nibble 8-bit = 0x50
if ~isempty(k)
frame32(1,k) = hex2dec(‘15555555’);
end
k = find(squeezed == 96); % upper nibble 8-bit = 0x60
if ~isempty(k)
frame32(1,k) = hex2dec(‘2aaaaaaa’);
end
k = find(squeezed == 112); % upper nibble 8-bit = 0x70
if ~isempty(k)
frame32(1,k) = hex2dec(‘3fffffff’);
end
end
end
% nibbles is an array of the same size as frame32…
nibbles = bitand(bitshift(repmat(frame32(1,:),16,1),repmat(-30:2:0,size(frame32,2),1)’),3);
x0 = bitsign(frame32(2,1),32); % forward integration constant
xn = bitsign(frame32(3,1),32); % reverse integration constant
switch steim
case 1
% STEIM-1: 3 cases following the nibbles
ddd = NaN*ones(4,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 3); % nibble = 3 : one 32-bit difference
if ~isempty(k)
ddd(1,k) = bitsign(frame32(k),32);
end
case 2
% STEIM-2: 7 cases following the nibbles and dnib
ddd = NaN*ones(7,numel(frame32)); % initiates array with NaN
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 1); % dnib = 1 : one 30-bit difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),30);
end
kk = k(dnib == 2); % dnib = 2 : two 15-bit differences
if ~isempty(kk)
ddd(1:2,kk) = bitsplit(frame32(kk),30,15);
end
kk = k(dnib == 3); % dnib = 3 : three 10-bit differences
if ~isempty(kk)
ddd(1:3,kk) = bitsplit(frame32(kk),30,10);
end
end
k = find(nibbles == 3); % nibble = 3 : must look in dnib
if ~isempty(k)
dnib = bitshift(frame32(k),-30);
kk = k(dnib == 0); % dnib = 0 : five 6-bit difference
if ~isempty(kk)
ddd(1:5,kk) = bitsplit(frame32(kk),30,6);
end
kk = k(dnib == 1); % dnib = 1 : six 5-bit differences
if ~isempty(kk)
ddd(1:6,kk) = bitsplit(frame32(kk),30,5);
end
kk = k(dnib == 2); % dnib = 2 : seven 4-bit differences (28 bits!)
if ~isempty(kk)
ddd(1:7,kk) = bitsplit(frame32(kk),28,4);
end
end
case 3 % *** STEIM-3 DECODING IS ALPHA AND UNTESTED ***
% STEIM-3: 7 cases following the nibbles
ddd = NaN*ones(9,numel(frame32)); % initiates array with NaN
k = find(nibbles == 0); % nibble = 0 : two 16-bit differences
if ~isempty(k)
ddd(1:2,k) = bitsplit(frame32(k),32,16);
end
k = find(nibbles == 1); % nibble = 1 : four 8-bit differences
if ~isempty(k)
ddd(1:4,k) = bitsplit(frame32(k),32,8);
end
k = find(nibbles == 2); % nibble = 2 : must look even dnib
if ~isempty(k)
dnib2 = bitshift(frame32(k(2:2:end)),-30);
w60 = bitand(frame32(k(2:2:end)),1073741823) …
+ bitshift(bitand(frame32(k(1:2:end)),1073741823),30); % concatenates two 30-bit words
kk = find(dnib2 == 0); % dnib = 0: five 12-bit differences (60 bits)
if ~isempty(kk)
ddd(1:5,k(2*kk)) = bitsplit(w60,60,12);
end
kk = find(dnib2 == 1); % dnib = 1: three 20-bit differences (60 bits)
if ~isempty(kk)
ddd(1:3,k(2*kk)) = bitsplit(w60,60,20);
end
end
k = find(nibbles == 3); % nibble = 3 : must look 3rd bit
if ~isempty(k)
dnib = bitshift(frame32(k),-27);
kk = k(dnib == 24); % dnib = 11000 : nine 3-bit differences (27 bits)
if ~isempty(kk)
ddd(1:9,kk) = bitsplit(frame32(kk),27,3);
end
kk = k(dnib == 25); % dnib = 11001 : Not A Difference
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),27);
end
kk = k(dnib > 27); % dnib = 111.. : 29-bit sample (29 bits)
if ~isempty(kk)
ddd(1,kk) = bitsign(frame32(kk),29);
end
end
end
% Little-endian coding: needs to swap bytes
if ~WordOrder
ddd = flipud(ddd);
end
dd = ddd(~isnan(ddd)); % reduces initial array ddd: dd is non-NaN values of ddd
% controls the number of samples
if numel(dd) ~= D.NumberSamples
if verbose > 1
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%d-%03d %02d:%02d:%07.4f]: number of samples in header (%d) does not equal data (%d).n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.NumberSamples,numel(dd));
end
if numel(dd) < D.NumberSamples
D.NumberSamples = numel(dd);
end
end
% rebuilds the data vector by integrating the differences
D.d = cumsum([x0;dd(2:D.NumberSamples)]);
% controls data integrity…
if D.d(end) ~= xn
warning(‘RDMSEED:DataIntegrity’,’Problem in %s sequence # %s [%s]: data integrity check failed, last_data=%d, Xn=%d.n’, …
D.EncodingFormatName{:},D.SequenceNumber,D.RecordStartTimeISO,D.d(end),xn);
end
if D.NumberSamples == 0
D.d = nan(0,1);
end
% for debug purpose…
if verbose > 2
D.dd = dd;
D.nibbles = nibbles;
D.x0 = x0;
D.xn = xn;
end
case 12
% — decoding format: GEOSCOPE multiplexed 24-bit integer
D.EncodingFormatName = {‘GEOSCOPE24’};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/3,’bit24=>double’);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
D.d = dd(1:D.NumberSamples);
case {13,14}
% — decoding format: GEOSCOPE multiplexed 16/3 and 16/4 bit gain ranged
% (13): 16/3-bit (bit 15 is unused)
% (14): 16/4-bit
% bits 15-12 = 3 or 4-bit gain exponent (positive)
% bits 11-0 = 12-bit mantissa (positive)
% => data = (mantissa – 2048) / 2^gain
geoscope = 7 + 8*(EncodingFormat==14); % mask for gain exponent
D.EncodingFormatName = {sprintf(‘GEOSCOPE16-%d’,EncodingFormat-10)};
dd = fread(fid,(D.DataRecordSize – D.OffsetBeginData)/2,’*uint16′);
if xor(~WordOrder,le)
dd = swapbytes(dd);
end
dd = (double(bitand(dd,2^12-1))-2^11)./2.^double(bitand(bitshift(dd,-12),geoscope));
D.d = dd(1:D.NumberSamples);
case 15
% — decoding format: US National Network compression
D.EncodingFormatName = {‘USNN’};
uncoded = 1;
case 16
% — decoding format: CDSN 16-bit gain ranged
D.EncodingFormatName = {‘CDSN’};
uncoded = 1;
case 17
% — decoding format: Graefenberg 16-bit gain ranged
D.EncodingFormatName = {‘GRAEFENBERG’};
uncoded = 1;
case 18
% — decoding format: IPG – Strasbourg 16-bit gain ranged
D.EncodingFormatName = {‘IPGS’};
uncoded = 1;
case 30
% — decoding format: SRO format
D.EncodingFormatName = {‘SRO’};
uncoded = 1;
case 31
% — decoding format: HGLP format
D.EncodingFormatName = {‘HGLP’};
uncoded = 1;
case 32
% — decoding format: DWWSSN gain ranged format
D.EncodingFormatName = {‘DWWSSN’};
uncoded = 1;
case 33
% — decoding format: RSTN 16-bit gain ranged
D.EncodingFormatName = {‘RSTN’};
uncoded = 1;
otherwise
D.EncodingFormatName = {sprintf(‘** Unknown (%d) **’,EncodingFormat)};
uncoded = 1;
end
if uncoded
error(‘Sorry, the encoding format "%s" is not yet implemented.’,D.EncodingFormatName);
end
% Applies time correction (if needed)
D.RecordStartTimeMATLAB = datenum(double([D.RecordStartTime(1),0,D.RecordStartTime(2:5)])) …
+ (~notc & bitand(D.ActivityFlags,2) == 0)*D.TimeCorrection/1e4/86400;
tv = datevec(D.RecordStartTimeMATLAB);
doy = datenum(tv(1:3)) – datenum(tv(1),1,0);
D.RecordStartTime = [tv(1),doy,tv(4:5),round(tv(6)*1e4)/1e4];
D.RecordStartTimeISO = sprintf(‘%4d-%03d %02d:%02d:%07.4f’,D.RecordStartTime);
D.t = D.RecordStartTimeMATLAB;
% makes the time vector and applies time correction (if needed)
if EncodingFormat > 0
D.t = D.t + (0:(D.NumberSamples-1))’/(D.SampleRate*86400);
end
offset = ftell(fid);
fread(fid,1,’char’); % this is to force EOF=1 on last record.
if feof(fid)
offset = -1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function c = splitfield(s,d)
% splitfield(S) splits string S of D-character separated field names
C = textscan(s,’%s’,’Delimiter’,d);
c = C{1};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [d,swapflag] = readbtime
% readbtime reads BTIME structure from current opened file and returns
% D = [YEAR,DAY,HOUR,MINUTE,SECONDS]
global fid forcebe
Year = fread(fid,1,’*uint16′);
DayOfYear = fread(fid,1,’*uint16′);
Hours = fread(fid,1,’uint8′);
Minutes = fread(fid,1,’uint8′);
Seconds = fread(fid,1,’uint8′);
fseek(fid,1,0); % skip 1 byte (unused)
Seconds0001 = fread(fid,1,’*uint16′);
% Automatic detection of little/big-endian encoding
% — by F. Beauducel, March 2014 —
%
% If the 2-byte day is >= 512, the file is not opened in the correct
% endianness. If the day is 1 or 256, there is a possible byte-swap and we
% need to check also the year; but we need to consider what is a valid year:
% – years from 1801 to 2047 are OK (swapbytes >= 2312)
% – years from 2048 to 2055 are OK (swapbytes <= 1800)
% – year 2056 is ambiguous (swapbytes = 2056)
% – years from 2057 to 2311 are OK (swapbytes >= 2312)
% – year 1799 is ambiguous (swapbytes = 1799)
% – year 1800 is suspicious (swapbytes = 2055)
%
% Thus, the only cases for which we are ‘sure’ there is a byte-swap, are:
% – day >= 512
% – (day == 1 or day == 256) and (year < 1799 or year > 2311)
%
% Note: in IRIS libmseed, the test is only year>2050 or year<1920.
if ~forcebe && (DayOfYear >= 512 || (ismember(DayOfYear,[1,256]) && (Year > 2311 || Year < 1799)))
swapflag = 1;
Year = swapbytes(Year);
DayOfYear = swapbytes(DayOfYear);
Seconds0001 = swapbytes(Seconds0001);
else
swapflag = 0;
end
d = [double(Year),double(DayOfYear),Hours,Minutes,Seconds + double(Seconds0001)/1e4];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsplit(x,b,n)
% bitsplit(X,B,N) splits the B-bit number X into signed N-bit array
% X must be unsigned integer class
% N ranges from 1 to B
% B is a multiple of N
sign = repmat((b:-n:n)’,1,size(x,1));
x = repmat(x’,b/n,1);
d = double(bitand(bitshift(x,flipud(sign-b)),2^n-1)) …
– double(bitget(x,sign))*2^n;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function d = bitsign(x,n)
% bitsign(X,N) returns signed double value from unsigned N-bit number X.
% This is equivalent to bitsplit(X,N,N), but the formula is simplified so
% it is much more efficient
d = double(bitand(x,2^n-1)) – double(bitget(x,n)).*2^n; rdmseed MATLAB Answers — New Questions
Managing Fabric Data Pipelines: a step-by-step guide to source control and deployment
Introduction.
In the post Microsoft Fabric: Integration with ADO Repos and Deployment Pipelines – A Power BI Case Study. we have outlined key best practices for utilizing the seamless integration between Fabric and GIT via Azure DevOps repositories and the use of Fabric Deployment Pipelines, both features intended to improve collaborative development and agile application publishing in the Azure cloud.
Quality and value delivery of any data analysis application depends on the quality of the data that we manage to package, from the greatest quantity and diversity of reliable and truthful data sources.
Fabric Data Pipelines serve as the backbone of data integration and orchestration, allowing organizations to streamline the flow of data across disparate systems, applications, and services.
By moving and manipulating data, Fabric Data Pipelines help ensure data consistency, accuracy, and timeliness, ultimately supporting informed decision-making and driving business value.
In this post we first delve into the integration of Fabric Data Pipelines and Azure DevOps Repos, aimed at improving collaborative development and source code control. Finally, we address the key benefits of using Fabric’s content-based strategy for continuous deployment to recommend including data pipelines as part of the content to be deployed and shared.
The role of Data Pipelines in Fabric.
Figure 1 briefly shows the stages for obtaining a data analytics solution.
Figure 1. Fabric Data Pipelines are a way to ingest and transform data into a Fabric solution.
There are many options in Fabric for data ingestion and transformations before building the semantic model of a Report or Lakehouse:
To date, Fabric lists the following as items that may be subject to source code control: [Overview of Fabric Git integration – Microsoft Fabric | Microsoft Learn]
Data pipelines Lakehouse Notebooks Paginated reports Reports (except reports connected to semantic models hosted in Azure Analysis Services, SQL Server Analysis Services or reports exported by Power BI Desktop that depend on semantic models hosted in MyWorkspace) Semantic models (except push datasets, live connections, model v1, and semantic models created from the Data warehouse/lakehouse.)
The primary goal of a Data Pipeline, as an effective way to ingest data in Fabric, is to facilitate the efficient and reliable movement of data from various sources to designated destinations, while also enabling transformations and processing tasks along the way.
Why use source control for Fabric Data Pipelines?
It’s well known that data pipelines sometimes need to handle incremental/update logic by developers. And sometimes they need to recover a previous version to fix errors or maybe with the purpose of reusability.
Implementing source control for Fabric Data Pipelines is essential in modern software development practices. Source control, also known as version control, is a foundational aspect of collaborative software development, providing a systematic approach to managing changes to code and configurations throughout the development lifecycle. In the context of Fabric Data Pipelines, which play a crucial role in orchestrating data workflows and transformations, integrating source control becomes paramount for ensuring transparency, reproducibility, and reliability in data processing pipelines.
Source control is essential for managing Fabric’s data pipelines for several reasons:
It allows you to keep track of changes, revert to previous versions, and understand the evolution of your data pipeline over time. Multiple team members can work on different parts of the pipeline simultaneously without overwriting each other’s work. Ensures that any data analysis or transformation can be reproduced, which is critical for debugging and auditing purposes. In case of personnel changes, source control provides continuity, allowing new team members to understand the pipeline’s history and current state.
Next, we show A step-by-step guide to use source control and version management for a Data Pipeline in Fabric.
1. Integrate your workspace with GIT, according to [Microsoft Fabric: Integration with ADO Repos and Deployment Pipelines – A Power BI Case Study.], [Overview of Fabric Git integration – Microsoft Fabric | Microsoft Learn]
2. Create a data pipeline in your workspace. To create a new data pipeline in Fabric you can refer to [Module 1 – Create a pipeline with Data Factory – Microsoft Fabric | Microsoft Learn], [Activity overview – Microsoft Fabric | Microsoft Learn].
Figure 2 shows three pipelines created in a workspace named Workspace Dev 1 and the Workspace’s Settings for the integration with an ADO repository (more details at Microsoft Fabric: Integration with ADO Repos and Deployment Pipelines – A Power BI Case Study. – Microsoft Community Hub)
Figure 2. Workspace integrated with GIT via an ADO Repo of a project.
3. Sync content with the ADO Repo.
The next figure shows all content synced after committing changes from Fabric UI.
If you add new data pipelines or update the content of some of them, this item is marked as “Uncommitted”. Every time you want to sync, select the “Source Control” button and commit the changes.
You will see in the repo in ADO the three pipelines created in Workspace Dev1.
To retrieve a pipeline version in the repo in ADO, you must select the committing line in Azure DevOps/Repos/Commits and then, Browse files.
Another way to retrieve the content of the pipeline is going to Azure DevOps/Repos/Files and download the .zip file to obtain the code in JSON format.
How to update an existing pipeline.
4. From this point, you can return to a previous version of a data pipeline.
To return to a previous version of a data pipeline in Microsoft Fabric, you can use the Update pipeline option: [How to monitor pipeline runs – Microsoft Fabric | Microsoft Learn] Here we are listing the steps to follow and then we will show them with images.
– Navigate to your workspace and hover over your pipeline, click on the three dots to the right of your pipeline name to bring up a list of options, and Select View run history to see all your recent runs and their statuses.
The following picture illustrates the recent run history of a data pipeline.
Select “Go to Monitoring hub” produces the following:
Select “Back to Main View” shows all items that have already been run:
Open the pipeline to fix:
And then, Update pipeline.
– Here, you can select Update pipeline to make changes to your pipeline from this screen. This selection will take you back to the pipeline canvas for edition, where you can change any mapping, delete activities and so on. You can save it, validate and run it again.
Another way is updating the json code.
You can update the json code here:
– When selecting this button, you can change the pipeline’s code from the code obtained in Azure DevOps/Repos/Files.
Deployment of data pipelines.
You can define a deployment pipeline in the workspace that contains the most recent and updated items and deploy all of them to the TEST Workspace. If you want to learn more about Fabric Deployment Pipelines refer to Microsoft Fabric: Integration with ADO Repos and Deployment Pipelines – A Power BI Case Study.
You can add Data pipelines in any workspace you want in Fabric. Common data pipeline code can go a long way to ensuring reproducible results in your analysis.
Therefore, this type of content can be used in a deployment pipeline.
Sharing a data pipeline code between a DEV WORKSPACE and a TEST WORSPACE greatly reduces the potential for errors, by helping to guarantee that the transformed data used for model training is the same as the transformed data the models will use in production.
A good practice mentioned in Best practices for lifecycle management in Fabric – Microsoft Fabric | Microsoft Learn is to use different databases in each stage. That is, build separate databases for development and testing to protect production data and not overload the development database with the entire volume of production data.
For now, data pipelines are not supported to be managed by deployment parameter rules. You can learn more about Deployment Rules in Create deployment rules for Fabric’s Application lifecycle management (ALM) – Microsoft Fabric | Microsoft Learn.
However, you can edit the pipeline inside the Test Workspace to change the source (as long as it has the same data structure or file format), run the edited pipeline and refresh data to obtain the desired results. Proceed similarly with the deployed data pipeline inside the Production Workspace: edit it, run and refresh data.
Next figure shows data source and destination to be configured in a data pipeline.
Summary
Fabric Data Pipelines serve as the backbone of data integration and orchestration. Source control is essential for managing Fabric’s data pipelines for several reasons, among the most significant are being able to access previous versions for reusability purposes or recovering from errors, being able to share code between developers and knowing the evolution of the data pipeline.
We have provided a step-by-step guide to include data pipelines into source control by means of Fabric-GIT integration, describing how to retrieve a specific data pipeline code from commit’s history, and updating the data pipeline inside Fabric.
Data Pipelines must be considered in the content to be shared in the Deployment Pipelines, due to the need to ensure data consistency and security from development stages to production.
You can find more information here:
Microsoft Fabric Life Cycle Management ALM in Fabric by taik18 – YouTube
How to monitor pipeline runs – Microsoft Fabric | Microsoft Learn
Git integration and deployment for data pipelines – Microsoft Fabric | Microsoft Learn
Datasets – Refresh Dataset – REST API (Power BI Power BI REST APIs) | Microsoft Learn
Data Factory in Microsoft Fabric documentation – Microsoft Fabric | Microsoft Learn
Microsoft Tech Community – Latest Blogs –Read More
duration of free trial
How long does a free trial of MATLAB last?How long does a free trial of MATLAB last? How long does a free trial of MATLAB last? trial, free trial MATLAB Answers — New Questions
Radar IQ Data FFT/STFT Spectogram Problem
Hello,
I have data which is taken from FMCW radar. Radar specs are as in below:
Center Frequency 77GHz
Bandwidth 160MHz
Range Resolution 1m
PRF 17kHz
Azimuth Beamwidth 1
Scan Rate 10Hz,
mechanical Field of View 9
Output Power 10mW
I use FFT and STFT functions for spectogram plotting. However, it’s seems wrong for me. I want to ask about the usage of those functions. My usage of those functions as in below;
STFT:
window_size = 128;
overlap_length = 120;
fft_points= 256;
window = hamming(window_size);
[S, F, T] = stft(IQ, 1280, ‘Window’, window, ‘OverlapLength’, overlap_length, ‘FFTLength’, fft_points);
new_data_Set_STFT{index_onearray,2} = F; %Frequency
% Amplitude of Spectogram
new_data_Set_STFT{index_onearray,3} =mean(abs(S’));
% IQ data phase
new_data_Set_STFT{index_onearray,4} = atan(imag(S)/real(S));
FFT:
% IQ DATA FFT
new_data_Set{index_onearray,2} = fft(IQ(:,index_global));
% Frequency length
N = length(IQ(:,index_global)); % FFT length
fs = 256; % sampling frequency
calculation = (0:N-1)*(fs/N);
f1 = reshape(calculation, 1280, …
1);
new_data_Set{index_onearray,3} = f1; % Frequency vector
% Amplitude of Spectogram
new_data_Set{index_onearray,4} = abs(IQ(:,index_global));
% IQ data phase
new_data_Set{index_onearray,5} = angle(IQ(:,index_global));
After Plotting, STFT spektogram looks like this. In frequency and time(x time, y frequency) scale it looks wrong. What’s wrong with my code?
FFT:
Thanks for help.Hello,
I have data which is taken from FMCW radar. Radar specs are as in below:
Center Frequency 77GHz
Bandwidth 160MHz
Range Resolution 1m
PRF 17kHz
Azimuth Beamwidth 1
Scan Rate 10Hz,
mechanical Field of View 9
Output Power 10mW
I use FFT and STFT functions for spectogram plotting. However, it’s seems wrong for me. I want to ask about the usage of those functions. My usage of those functions as in below;
STFT:
window_size = 128;
overlap_length = 120;
fft_points= 256;
window = hamming(window_size);
[S, F, T] = stft(IQ, 1280, ‘Window’, window, ‘OverlapLength’, overlap_length, ‘FFTLength’, fft_points);
new_data_Set_STFT{index_onearray,2} = F; %Frequency
% Amplitude of Spectogram
new_data_Set_STFT{index_onearray,3} =mean(abs(S’));
% IQ data phase
new_data_Set_STFT{index_onearray,4} = atan(imag(S)/real(S));
FFT:
% IQ DATA FFT
new_data_Set{index_onearray,2} = fft(IQ(:,index_global));
% Frequency length
N = length(IQ(:,index_global)); % FFT length
fs = 256; % sampling frequency
calculation = (0:N-1)*(fs/N);
f1 = reshape(calculation, 1280, …
1);
new_data_Set{index_onearray,3} = f1; % Frequency vector
% Amplitude of Spectogram
new_data_Set{index_onearray,4} = abs(IQ(:,index_global));
% IQ data phase
new_data_Set{index_onearray,5} = angle(IQ(:,index_global));
After Plotting, STFT spektogram looks like this. In frequency and time(x time, y frequency) scale it looks wrong. What’s wrong with my code?
FFT:
Thanks for help. Hello,
I have data which is taken from FMCW radar. Radar specs are as in below:
Center Frequency 77GHz
Bandwidth 160MHz
Range Resolution 1m
PRF 17kHz
Azimuth Beamwidth 1
Scan Rate 10Hz,
mechanical Field of View 9
Output Power 10mW
I use FFT and STFT functions for spectogram plotting. However, it’s seems wrong for me. I want to ask about the usage of those functions. My usage of those functions as in below;
STFT:
window_size = 128;
overlap_length = 120;
fft_points= 256;
window = hamming(window_size);
[S, F, T] = stft(IQ, 1280, ‘Window’, window, ‘OverlapLength’, overlap_length, ‘FFTLength’, fft_points);
new_data_Set_STFT{index_onearray,2} = F; %Frequency
% Amplitude of Spectogram
new_data_Set_STFT{index_onearray,3} =mean(abs(S’));
% IQ data phase
new_data_Set_STFT{index_onearray,4} = atan(imag(S)/real(S));
FFT:
% IQ DATA FFT
new_data_Set{index_onearray,2} = fft(IQ(:,index_global));
% Frequency length
N = length(IQ(:,index_global)); % FFT length
fs = 256; % sampling frequency
calculation = (0:N-1)*(fs/N);
f1 = reshape(calculation, 1280, …
1);
new_data_Set{index_onearray,3} = f1; % Frequency vector
% Amplitude of Spectogram
new_data_Set{index_onearray,4} = abs(IQ(:,index_global));
% IQ data phase
new_data_Set{index_onearray,5} = angle(IQ(:,index_global));
After Plotting, STFT spektogram looks like this. In frequency and time(x time, y frequency) scale it looks wrong. What’s wrong with my code?
FFT:
Thanks for help. radar, signal processing, spectogram, fft, stft, fmcw, plotting, iq data MATLAB Answers — New Questions
solve using trapezoidal rule
Write a local function named integration to numerically integrate the tabulated values by using trapezoidal rule, if X and Y values are user input and difference between any two consecutive X values is same. Use the above local function to determine ∫ 𝑦 𝑑𝑥 from 0 to π by using following data. X= 0, π/6 ,π/3 ,π/2, 2π/3, 5π/6, π and Y= 0, 0.5 ,0.866, 1 ,0.866, 0.5, 0 .Validate the result by using appropriate built-in functionWrite a local function named integration to numerically integrate the tabulated values by using trapezoidal rule, if X and Y values are user input and difference between any two consecutive X values is same. Use the above local function to determine ∫ 𝑦 𝑑𝑥 from 0 to π by using following data. X= 0, π/6 ,π/3 ,π/2, 2π/3, 5π/6, π and Y= 0, 0.5 ,0.866, 1 ,0.866, 0.5, 0 .Validate the result by using appropriate built-in function Write a local function named integration to numerically integrate the tabulated values by using trapezoidal rule, if X and Y values are user input and difference between any two consecutive X values is same. Use the above local function to determine ∫ 𝑦 𝑑𝑥 from 0 to π by using following data. X= 0, π/6 ,π/3 ,π/2, 2π/3, 5π/6, π and Y= 0, 0.5 ,0.866, 1 ,0.866, 0.5, 0 .Validate the result by using appropriate built-in function optimization, trapezoidal rule MATLAB Answers — New Questions
email addresses
In Excel, how do I get email addresses in a cell to read just as text – NOT as an email address?
In Excel, how do I get email addresses in a cell to read just as text – NOT as an email address? Read More
error when using {}
Hi guys, im trying to run a software by Matlab and do some analysis for some models and this ‘Periodandfrequencies’ is an example of some results. But I am facing error when I want to keep the result inside the cell-array. Basicaly I want it to be iix1 cell aray and each cell is 12×7 Table.Hi guys, im trying to run a software by Matlab and do some analysis for some models and this ‘Periodandfrequencies’ is an example of some results. But I am facing error when I want to keep the result inside the cell-array. Basicaly I want it to be iix1 cell aray and each cell is 12×7 Table. Hi guys, im trying to run a software by Matlab and do some analysis for some models and this ‘Periodandfrequencies’ is an example of some results. But I am facing error when I want to keep the result inside the cell-array. Basicaly I want it to be iix1 cell aray and each cell is 12×7 Table. cell array MATLAB Answers — New Questions
Renaming files in a directory using file names in excel.
I created a excel file named “New_file_names.xlsx” and “New_file_names.csv”
Both files have the same content in column 1 and the information starts at A1 sheet1
They are in J:temp directory. The file has file names.
In directory J:temp2 they are files that I would like to rename using the information from the excel file without changing the file extensions.
After they are renamed I would like to store them in directory J;temp3.
I have a script but is giving me errors I am including it
Any help will be much appreciated.
# Specify the path to your Excel file
PS J:temp2> $excelFilePath = “J:TempNew_file_names.xlsx”
PS J:temp2>
PS J:temp2> # Load the Excel file
PS J:temp2> $excel = New-Object -ComObject Excel.Application
PS J:temp2> $workbook = $excel.Workbooks.Open($excelFilePath)
PS J:temp2> $worksheet = $workbook.Worksheets.Item(“Sheet1”)
PS J:temp2>
PS J:temp2> # Define source and destination directories
PS J:temp2> $sourceDirectory = “J:temp2”
PS J:temp2> $destinationDirectory = “J:temp3”
PS J:temp2>
PS J:temp2> # Iterate through files in the source directory
PS J:temp2> Get-ChildItem -Path $sourceDirectory | ForEach-Object {
>> $file = $_
>> $originalFileName = $file.Name
>>
>> # Retrieve the corresponding new file name from the Excel sheet
>> $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
>>
>> # Extract the actual value from the formula (if it’s a formula)
>> if ($cellValue -match ‘^=’) {
>> $cellValue = $worksheet.Evaluate($cellValue)
>> }
>>
>> # Construct the full path for the destination file
>> $newFileName = Join-Path -Path $destinationDirectory -ChildPath ($cellValue + $file.Extension)
>>
>> # Copy the file to the destination directory
>> Copy-Item -Path $file.FullName -Destination $newFileName
>> Write-Host “Renamed and copied: $($originalFileName) -> $($newFileName)”
>> }
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At line:6 char:5
+ $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Renamed and copied: 2×01 Back Off Mary Poppins-1.mkv -> J:temp3Two and a Half Man (2004)-S02E01-Back Off Mary Poppins.mkv
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At line:6 char:5
+ $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
# Clean up
PS J:temp2> $workbook.Close()
PS J:temp2> $excel.Quit()
PS J:temp2> [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)
I created a excel file named “New_file_names.xlsx” and “New_file_names.csv”Both files have the same content in column 1 and the information starts at A1 sheet1They are in J:temp directory. The file has file names.In directory J:temp2 they are files that I would like to rename using the information from the excel file without changing the file extensions.After they are renamed I would like to store them in directory J;temp3.I have a script but is giving me errors I am including itAny help will be much appreciated. # Specify the path to your Excel file
PS J:temp2> $excelFilePath = “J:TempNew_file_names.xlsx”
PS J:temp2>
PS J:temp2> # Load the Excel file
PS J:temp2> $excel = New-Object -ComObject Excel.Application
PS J:temp2> $workbook = $excel.Workbooks.Open($excelFilePath)
PS J:temp2> $worksheet = $workbook.Worksheets.Item(“Sheet1”)
PS J:temp2>
PS J:temp2> # Define source and destination directories
PS J:temp2> $sourceDirectory = “J:temp2”
PS J:temp2> $destinationDirectory = “J:temp3”
PS J:temp2>
PS J:temp2> # Iterate through files in the source directory
PS J:temp2> Get-ChildItem -Path $sourceDirectory | ForEach-Object {
>> $file = $_
>> $originalFileName = $file.Name
>>
>> # Retrieve the corresponding new file name from the Excel sheet
>> $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
>>
>> # Extract the actual value from the formula (if it’s a formula)
>> if ($cellValue -match ‘^=’) {
>> $cellValue = $worksheet.Evaluate($cellValue)
>> }
>>
>> # Construct the full path for the destination file
>> $newFileName = Join-Path -Path $destinationDirectory -ChildPath ($cellValue + $file.Extension)
>>
>> # Copy the file to the destination directory
>> Copy-Item -Path $file.FullName -Destination $newFileName
>> Write-Host “Renamed and copied: $($originalFileName) -> $($newFileName)”
>> }
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At line:6 char:5
+ $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Renamed and copied: 2×01 Back Off Mary Poppins-1.mkv -> J:temp3Two and a Half Man (2004)-S02E01-Back Off Mary Poppins.mkv
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At line:6 char:5
+ $cellValue = $worksheet.Cells.Item($originalFileName, 1).Formula
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
# Clean up
PS J:temp2> $workbook.Close()
PS J:temp2> $excel.Quit()
PS J:temp2> [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) Read More
Unlock PC after locking it from “find my device “
Hi,
I have a win11 laptop with all updates installed.
There is a microsoft account user and another local user – both admins
For testing the lock behavior form MS online account, I locked the laptop through “find my device -> lock”.
On the laptop i attempted to sign in with both the MS account and local user account, but then I get an error stating: An administrator has restricted sign in. To sign in, make sure your device is connected to the internet, and have your administrator sign in first.
Which admin account does the message refer to? Both users on the laptop are administrators. I do not have the built in “Administrator” set up.
For the local account I get the above message immediately, for the MS account I get an option “forgot PIN” it seems to be doing something then immediately goes back to the local account login.
I expected that there is an UN-Lock setting in the online account “find my device” settings but there isn’t any.
It doesn’t make sense that you can lock a PC without having an unlock option in the same place, also
Google searches only led me to inaccurate or non-working solutions.
How can I resolve this situation?
Hi, I have a win11 laptop with all updates installed. There is a microsoft account user and another local user – both admins For testing the lock behavior form MS online account, I locked the laptop through “find my device -> lock”. On the laptop i attempted to sign in with both the MS account and local user account, but then I get an error stating: An administrator has restricted sign in. To sign in, make sure your device is connected to the internet, and have your administrator sign in first. Which admin account does the message refer to? Both users on the laptop are administrators. I do not have the built in “Administrator” set up. For the local account I get the above message immediately, for the MS account I get an option “forgot PIN” it seems to be doing something then immediately goes back to the local account login. I expected that there is an UN-Lock setting in the online account “find my device” settings but there isn’t any.It doesn’t make sense that you can lock a PC without having an unlock option in the same place, also Google searches only led me to inaccurate or non-working solutions. How can I resolve this situation? Read More
Default timezone for new user is PST not GMT
We are a charity based in the UK and when I set up a new user their timezone seems to get set as PST rather than GMT. I selected the licence location as the UK and I don’t see anywhere else I can see a location/timezone, so I have the following questions:
1. How can I ensure future new users are in the GMT timezone
2. How can I change current users in the wrong timezone?
For example, when I try and register a meeting and invite someone who is physically in the same timezone as me, the following message appears in Outlook “*user name* is in a different time zone. Use the Scheduling Assistant to find time across time zones.“
Thanks
We are a charity based in the UK and when I set up a new user their timezone seems to get set as PST rather than GMT. I selected the licence location as the UK and I don’t see anywhere else I can see a location/timezone, so I have the following questions: 1. How can I ensure future new users are in the GMT timezone2. How can I change current users in the wrong timezone? For example, when I try and register a meeting and invite someone who is physically in the same timezone as me, the following message appears in Outlook “*user name* is in a different time zone. Use the Scheduling Assistant to find time across time zones.” Thanks Read More
Getting powershell to scroll horizontally instead of word wrap
Is it possible to get powershell to horizontally scroll for long lines of text instead of having them wrap automatically to the next line?
I’m running python, and if you’re familiar with python dataframes you can think of it like a speadsheet. I’m having python output many columns, and right now it’s wrapping the output to separate lines. Think of having a sheet in excel where for more columns instead of having a horizontal scroll excel wraps it – it’s very unreadable.
Right now, I have to redirect my output to a .txt file and then open in notepad, where I can horizontally scroll without word wrap, to see the output in a readable fashion. However, if I could make powershell horizontally scroll instead of wrapping, this would save me a step.
Alternately, if not possible in powershell but possible in plain old command prompt I can run python in the command prompt. However, I’d prefer not to as I can’t SSH into remote servers from plain command prompt, and sometimes I need to run python remotely so it would be useful to do it in powershell, thanks.
Is it possible to get powershell to horizontally scroll for long lines of text instead of having them wrap automatically to the next line?I’m running python, and if you’re familiar with python dataframes you can think of it like a speadsheet. I’m having python output many columns, and right now it’s wrapping the output to separate lines. Think of having a sheet in excel where for more columns instead of having a horizontal scroll excel wraps it – it’s very unreadable.Right now, I have to redirect my output to a .txt file and then open in notepad, where I can horizontally scroll without word wrap, to see the output in a readable fashion. However, if I could make powershell horizontally scroll instead of wrapping, this would save me a step.Alternately, if not possible in powershell but possible in plain old command prompt I can run python in the command prompt. However, I’d prefer not to as I can’t SSH into remote servers from plain command prompt, and sometimes I need to run python remotely so it would be useful to do it in powershell, thanks. Read More
Sites won’t add to Collections
Hi, I don’t know when this issue arose, but currently, when I open Collections and click on “Add current page”, nothing at all happens. Anyone else got this and found a solution?
Version 126.0.2580.0 (Official build) canary (64-bit)
Hi, I don’t know when this issue arose, but currently, when I open Collections and click on “Add current page”, nothing at all happens. Anyone else got this and found a solution? Version 126.0.2580.0 (Official build) canary (64-bit) Read More
How to evaluate Trained detector on test dataset?
Hello,
How can I evaluate Trained detector on test dataset, pelase? Here example code:
tic
detectionResults = detect(Trained_detector, testData, ‘MiniBatchSize’, 50);
% Evaluate the object detector using average precision metric.
[ap,recall,precision] = evaluateDetectionPrecision(detectionResults, testData);
classID = 1;
figure
plot(recall{classID},precision{classID},’LineWidth’,4)
xlabel("recall")
ylabel("accuracy")
grid on
title(sprintf("AP = %.3f",ap(classID)))
toc
Here Error:
Expected I to be one of these types:
double, single, int16, uint16, uint8, logical
Instead its type was matlab.io.datastore.CombinedDatastore.Hello,
How can I evaluate Trained detector on test dataset, pelase? Here example code:
tic
detectionResults = detect(Trained_detector, testData, ‘MiniBatchSize’, 50);
% Evaluate the object detector using average precision metric.
[ap,recall,precision] = evaluateDetectionPrecision(detectionResults, testData);
classID = 1;
figure
plot(recall{classID},precision{classID},’LineWidth’,4)
xlabel("recall")
ylabel("accuracy")
grid on
title(sprintf("AP = %.3f",ap(classID)))
toc
Here Error:
Expected I to be one of these types:
double, single, int16, uint16, uint8, logical
Instead its type was matlab.io.datastore.CombinedDatastore. Hello,
How can I evaluate Trained detector on test dataset, pelase? Here example code:
tic
detectionResults = detect(Trained_detector, testData, ‘MiniBatchSize’, 50);
% Evaluate the object detector using average precision metric.
[ap,recall,precision] = evaluateDetectionPrecision(detectionResults, testData);
classID = 1;
figure
plot(recall{classID},precision{classID},’LineWidth’,4)
xlabel("recall")
ylabel("accuracy")
grid on
title(sprintf("AP = %.3f",ap(classID)))
toc
Here Error:
Expected I to be one of these types:
double, single, int16, uint16, uint8, logical
Instead its type was matlab.io.datastore.CombinedDatastore. image processing, deep learning, image analysis, computer vision MATLAB Answers — New Questions
Need help solving heat equation using adi method
This is my equation, which I solve using the ADI scheme, but it doesn’t work correctly; it only works with a very small dt. Can anyone help me?
Nx = 50;
Ny = 50;
dx = 1.0 / (Nx – 1);
dy = 2.0 / (Ny – 1);
T = 0.00001;
dt = 0.000000001;
Nt = 1000; % Total number of time steps
alpha = 4; % Diffusion coefficient
x = linspace(0, 1, Nx);
y = linspace(0, 2, Ny);
[X, Y] = meshgrid(x, y);
U = Y .* X + 1; % Initial condition
function val = f(x, y, t)
val = exp(t) * cos(pi * x / 2) * sin(pi * y / 4);
end
function U = apply_boundary_conditions(U, x, y, dy, dx)
U(:, 1) = 1; % y=0
U(:, end) = U(:, end-1) + dy .* x’; % y=2
U(1, 🙂 = U(2, 🙂 – dx * y; % x=0
U(end, 🙂 = y’ + 1; % x=1
end
% Thomas algorithm
function x = thomas_algorithm(a, b, c, d)
n = length(d);
c_star = zeros(n-1, 1);
d_star = zeros(n, 1);
x = zeros(n, 1);
c_star(1) = c(1) / b(1);
d_star(1) = d(1) / b(1);
for i = 2:n-1
temp = b(i) – a(i-1) * c_star(i-1);
c_star(i) = c(i) / temp;
d_star(i) = (d(i) – a(i-1) * d_star(i-1)) / temp;
end
d_star(n) = (d(n) – a(n-1) * d_star(n-1)) / b(n);
x(n) = d_star(n);
for i = n-1:-1:1
x(i) = d_star(i) – c_star(i) * x(i+1);
end
end
% ADI method
for n = 1:Nt
U = apply_boundary_conditions(U, x, y, dy, dx);
% First half-step: X-direction implicit, Y-direction explicit
for j = 2:Ny-1
a = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
b = (1 + alpha * dt / dx^2) * ones(Nx, 1);
c = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
d = U(j, 2:end-1)’ + 0.5 * alpha * dt / dy^2 * (U(j+1, 2:end-1) – 2 * U(j, 2:end-1) + U(j-1, 2:end-1))’ + dt * f(x(2:end-1), y(j), n*dt);
U(j, 2:end-1) = thomas_algorithm(a, b(2:end-1), c, d);
end
% Second half-step: Y-direction implicit, X-direction explicit
for i = 2:Nx-1
a = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
b = (1 + alpha * dt / dy^2) * ones(Ny, 1);
c = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
d = U(2:end-1, i) + 0.5 * alpha * dt / dx^2 * (U(2:end-1, i+1) – 2 * U(2:end-1, i) + U(2:end-1, i-1)) + dt * f(x(i), y(2:end-1), n*dt);
U(2:end-1, i) = thomas_algorithm(a, b(2:end-1), c, d);
end
U = apply_boundary_conditions(U, x, y, dy, dx);
end
% Visualization
surf(X, Y, U);
title(‘ADI Solution at T=’ + string(T));
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘U’);
colorbar;This is my equation, which I solve using the ADI scheme, but it doesn’t work correctly; it only works with a very small dt. Can anyone help me?
Nx = 50;
Ny = 50;
dx = 1.0 / (Nx – 1);
dy = 2.0 / (Ny – 1);
T = 0.00001;
dt = 0.000000001;
Nt = 1000; % Total number of time steps
alpha = 4; % Diffusion coefficient
x = linspace(0, 1, Nx);
y = linspace(0, 2, Ny);
[X, Y] = meshgrid(x, y);
U = Y .* X + 1; % Initial condition
function val = f(x, y, t)
val = exp(t) * cos(pi * x / 2) * sin(pi * y / 4);
end
function U = apply_boundary_conditions(U, x, y, dy, dx)
U(:, 1) = 1; % y=0
U(:, end) = U(:, end-1) + dy .* x’; % y=2
U(1, 🙂 = U(2, 🙂 – dx * y; % x=0
U(end, 🙂 = y’ + 1; % x=1
end
% Thomas algorithm
function x = thomas_algorithm(a, b, c, d)
n = length(d);
c_star = zeros(n-1, 1);
d_star = zeros(n, 1);
x = zeros(n, 1);
c_star(1) = c(1) / b(1);
d_star(1) = d(1) / b(1);
for i = 2:n-1
temp = b(i) – a(i-1) * c_star(i-1);
c_star(i) = c(i) / temp;
d_star(i) = (d(i) – a(i-1) * d_star(i-1)) / temp;
end
d_star(n) = (d(n) – a(n-1) * d_star(n-1)) / b(n);
x(n) = d_star(n);
for i = n-1:-1:1
x(i) = d_star(i) – c_star(i) * x(i+1);
end
end
% ADI method
for n = 1:Nt
U = apply_boundary_conditions(U, x, y, dy, dx);
% First half-step: X-direction implicit, Y-direction explicit
for j = 2:Ny-1
a = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
b = (1 + alpha * dt / dx^2) * ones(Nx, 1);
c = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
d = U(j, 2:end-1)’ + 0.5 * alpha * dt / dy^2 * (U(j+1, 2:end-1) – 2 * U(j, 2:end-1) + U(j-1, 2:end-1))’ + dt * f(x(2:end-1), y(j), n*dt);
U(j, 2:end-1) = thomas_algorithm(a, b(2:end-1), c, d);
end
% Second half-step: Y-direction implicit, X-direction explicit
for i = 2:Nx-1
a = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
b = (1 + alpha * dt / dy^2) * ones(Ny, 1);
c = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
d = U(2:end-1, i) + 0.5 * alpha * dt / dx^2 * (U(2:end-1, i+1) – 2 * U(2:end-1, i) + U(2:end-1, i-1)) + dt * f(x(i), y(2:end-1), n*dt);
U(2:end-1, i) = thomas_algorithm(a, b(2:end-1), c, d);
end
U = apply_boundary_conditions(U, x, y, dy, dx);
end
% Visualization
surf(X, Y, U);
title(‘ADI Solution at T=’ + string(T));
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘U’);
colorbar; This is my equation, which I solve using the ADI scheme, but it doesn’t work correctly; it only works with a very small dt. Can anyone help me?
Nx = 50;
Ny = 50;
dx = 1.0 / (Nx – 1);
dy = 2.0 / (Ny – 1);
T = 0.00001;
dt = 0.000000001;
Nt = 1000; % Total number of time steps
alpha = 4; % Diffusion coefficient
x = linspace(0, 1, Nx);
y = linspace(0, 2, Ny);
[X, Y] = meshgrid(x, y);
U = Y .* X + 1; % Initial condition
function val = f(x, y, t)
val = exp(t) * cos(pi * x / 2) * sin(pi * y / 4);
end
function U = apply_boundary_conditions(U, x, y, dy, dx)
U(:, 1) = 1; % y=0
U(:, end) = U(:, end-1) + dy .* x’; % y=2
U(1, 🙂 = U(2, 🙂 – dx * y; % x=0
U(end, 🙂 = y’ + 1; % x=1
end
% Thomas algorithm
function x = thomas_algorithm(a, b, c, d)
n = length(d);
c_star = zeros(n-1, 1);
d_star = zeros(n, 1);
x = zeros(n, 1);
c_star(1) = c(1) / b(1);
d_star(1) = d(1) / b(1);
for i = 2:n-1
temp = b(i) – a(i-1) * c_star(i-1);
c_star(i) = c(i) / temp;
d_star(i) = (d(i) – a(i-1) * d_star(i-1)) / temp;
end
d_star(n) = (d(n) – a(n-1) * d_star(n-1)) / b(n);
x(n) = d_star(n);
for i = n-1:-1:1
x(i) = d_star(i) – c_star(i) * x(i+1);
end
end
% ADI method
for n = 1:Nt
U = apply_boundary_conditions(U, x, y, dy, dx);
% First half-step: X-direction implicit, Y-direction explicit
for j = 2:Ny-1
a = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
b = (1 + alpha * dt / dx^2) * ones(Nx, 1);
c = -alpha * dt / (2 * dx^2) * ones(Nx-1, 1);
d = U(j, 2:end-1)’ + 0.5 * alpha * dt / dy^2 * (U(j+1, 2:end-1) – 2 * U(j, 2:end-1) + U(j-1, 2:end-1))’ + dt * f(x(2:end-1), y(j), n*dt);
U(j, 2:end-1) = thomas_algorithm(a, b(2:end-1), c, d);
end
% Second half-step: Y-direction implicit, X-direction explicit
for i = 2:Nx-1
a = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
b = (1 + alpha * dt / dy^2) * ones(Ny, 1);
c = -alpha * dt / (2 * dy^2) * ones(Ny-1, 1);
d = U(2:end-1, i) + 0.5 * alpha * dt / dx^2 * (U(2:end-1, i+1) – 2 * U(2:end-1, i) + U(2:end-1, i-1)) + dt * f(x(i), y(2:end-1), n*dt);
U(2:end-1, i) = thomas_algorithm(a, b(2:end-1), c, d);
end
U = apply_boundary_conditions(U, x, y, dy, dx);
end
% Visualization
surf(X, Y, U);
title(‘ADI Solution at T=’ + string(T));
xlabel(‘X’);
ylabel(‘Y’);
zlabel(‘U’);
colorbar; adischeme heat equations MATLAB Answers — New Questions
Parfor “Out of Memory during deserialization” in large matrix operations
I am trying to use parfor for a large matrix operation. I am getting Out of Memory during deserialization error. Is there a way to minimize the memory? Below is the minimal example code:
clc; clear;
warpedImages = num2cell(uint8(randi([0,255], 1654, 6288, 3, 35)),1:3);
warpedImages = reshape(warpedImages,1,[]);
% Initialze
n = length(warpedImages);
sigmaN = 10;
sigmag = 0.1;
panoramasize = size(warpedImages{1});
Amat = cell(n);
Bvec = zeros(n,1);
IuppeIdx = nonzeros(triu(reshape(1:numel(Amat), size(Amat))));
Amat_temp = cell(1,length(IuppeIdx));
matSize = size(Amat);
% 4D warped images (Slicing)
wim_4d = cell2mat(reshape(warpedImages,1,1,1,[]));
% Get the Ibarijs and Nijs
parfor i = 1:length(IuppeIdx)
% Index to subscripts
[ii,jj] = ind2sub(matSize, IuppeIdx(i));
if ii == jj
diag_val_1 = 0;
diag_val_2 = 0;
Z = 1:n;
Z(Z==ii) = [];
for d = Z
[Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d));
diag_val_1 = diag_val_1 + ( (Nij + Nij) .* Ibarij.^2 );
diag_val_2 = diag_val_2 + Nij;
end
diag_val = diag_val_1 + (sigmaN^2/sigmag^2) * diag_val_2;
B_val = (sigmaN^2/sigmag^2) * diag_val_2;
Amat_temp{i} = diag_val;
Bvec(i) = B_val
end
if ii ~= jj
[Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,jj));
Amat_temp{i} = -(Nij+Nij) .* (Ibarij .* Ibarji);
end
end
function [Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, Imij, Imji)
Ibarij = zeros(panoramasize,’uint8′);
Ibarji = zeros(panoramasize,’uint8′);
% Overlay the warpedImage onto the panorama.
maski = imbinarize(rgb2gray(255 * Imij));
maskj = imbinarize(rgb2gray(255 * Imji));
% Find the overlap mask
Nij_im = maski & maskj;
Nij_im = imfill(Nij_im, ‘holes’);
Nijidx = repmat(Nij_im, 1, 1, size(Imij,3));
% Get the overlapping region RGB values for two images
Ibarij(Nijidx) = Imij(Nijidx);
Ibarji(Nijidx) = Imji(Nijidx);
% Convert to double
Ibarij_double = double(Ibarij);
Ibarji_double = double(Ibarji);
% Nij
Nij = sum(sum(Nij_im));
% Ibar ijs
Ibarij = reshape(sum(sum(Ibarij_double)) ./ Nij, 1, 3);
Ibarji = reshape(sum(sum(Ibarji_double)) ./ Nij, 1, 3);
% Replace NaNs by zeros
Ibarij(isnan(Ibarij)) = 0;
Ibarji(isnan(Ibarji)) = 0;
end
Line [Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d)); throws a warning message: The entire array or structure ‘wim_4d’ is a broadcast variable. This might result in unnecessary communication overhead. I have used ind2sub for getting the subscripts as it is easy to work. However, wim_4d(:,:,:,ii) and others cannot be sliced. Any other suggestion and help is appreciated!I am trying to use parfor for a large matrix operation. I am getting Out of Memory during deserialization error. Is there a way to minimize the memory? Below is the minimal example code:
clc; clear;
warpedImages = num2cell(uint8(randi([0,255], 1654, 6288, 3, 35)),1:3);
warpedImages = reshape(warpedImages,1,[]);
% Initialze
n = length(warpedImages);
sigmaN = 10;
sigmag = 0.1;
panoramasize = size(warpedImages{1});
Amat = cell(n);
Bvec = zeros(n,1);
IuppeIdx = nonzeros(triu(reshape(1:numel(Amat), size(Amat))));
Amat_temp = cell(1,length(IuppeIdx));
matSize = size(Amat);
% 4D warped images (Slicing)
wim_4d = cell2mat(reshape(warpedImages,1,1,1,[]));
% Get the Ibarijs and Nijs
parfor i = 1:length(IuppeIdx)
% Index to subscripts
[ii,jj] = ind2sub(matSize, IuppeIdx(i));
if ii == jj
diag_val_1 = 0;
diag_val_2 = 0;
Z = 1:n;
Z(Z==ii) = [];
for d = Z
[Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d));
diag_val_1 = diag_val_1 + ( (Nij + Nij) .* Ibarij.^2 );
diag_val_2 = diag_val_2 + Nij;
end
diag_val = diag_val_1 + (sigmaN^2/sigmag^2) * diag_val_2;
B_val = (sigmaN^2/sigmag^2) * diag_val_2;
Amat_temp{i} = diag_val;
Bvec(i) = B_val
end
if ii ~= jj
[Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,jj));
Amat_temp{i} = -(Nij+Nij) .* (Ibarij .* Ibarji);
end
end
function [Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, Imij, Imji)
Ibarij = zeros(panoramasize,’uint8′);
Ibarji = zeros(panoramasize,’uint8′);
% Overlay the warpedImage onto the panorama.
maski = imbinarize(rgb2gray(255 * Imij));
maskj = imbinarize(rgb2gray(255 * Imji));
% Find the overlap mask
Nij_im = maski & maskj;
Nij_im = imfill(Nij_im, ‘holes’);
Nijidx = repmat(Nij_im, 1, 1, size(Imij,3));
% Get the overlapping region RGB values for two images
Ibarij(Nijidx) = Imij(Nijidx);
Ibarji(Nijidx) = Imji(Nijidx);
% Convert to double
Ibarij_double = double(Ibarij);
Ibarji_double = double(Ibarji);
% Nij
Nij = sum(sum(Nij_im));
% Ibar ijs
Ibarij = reshape(sum(sum(Ibarij_double)) ./ Nij, 1, 3);
Ibarji = reshape(sum(sum(Ibarji_double)) ./ Nij, 1, 3);
% Replace NaNs by zeros
Ibarij(isnan(Ibarij)) = 0;
Ibarji(isnan(Ibarji)) = 0;
end
Line [Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d)); throws a warning message: The entire array or structure ‘wim_4d’ is a broadcast variable. This might result in unnecessary communication overhead. I have used ind2sub for getting the subscripts as it is easy to work. However, wim_4d(:,:,:,ii) and others cannot be sliced. Any other suggestion and help is appreciated! I am trying to use parfor for a large matrix operation. I am getting Out of Memory during deserialization error. Is there a way to minimize the memory? Below is the minimal example code:
clc; clear;
warpedImages = num2cell(uint8(randi([0,255], 1654, 6288, 3, 35)),1:3);
warpedImages = reshape(warpedImages,1,[]);
% Initialze
n = length(warpedImages);
sigmaN = 10;
sigmag = 0.1;
panoramasize = size(warpedImages{1});
Amat = cell(n);
Bvec = zeros(n,1);
IuppeIdx = nonzeros(triu(reshape(1:numel(Amat), size(Amat))));
Amat_temp = cell(1,length(IuppeIdx));
matSize = size(Amat);
% 4D warped images (Slicing)
wim_4d = cell2mat(reshape(warpedImages,1,1,1,[]));
% Get the Ibarijs and Nijs
parfor i = 1:length(IuppeIdx)
% Index to subscripts
[ii,jj] = ind2sub(matSize, IuppeIdx(i));
if ii == jj
diag_val_1 = 0;
diag_val_2 = 0;
Z = 1:n;
Z(Z==ii) = [];
for d = Z
[Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d));
diag_val_1 = diag_val_1 + ( (Nij + Nij) .* Ibarij.^2 );
diag_val_2 = diag_val_2 + Nij;
end
diag_val = diag_val_1 + (sigmaN^2/sigmag^2) * diag_val_2;
B_val = (sigmaN^2/sigmag^2) * diag_val_2;
Amat_temp{i} = diag_val;
Bvec(i) = B_val
end
if ii ~= jj
[Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,jj));
Amat_temp{i} = -(Nij+Nij) .* (Ibarij .* Ibarji);
end
end
function [Ibarij,Ibarji,Nij] = getIbarNij(panoramasize, Imij, Imji)
Ibarij = zeros(panoramasize,’uint8′);
Ibarji = zeros(panoramasize,’uint8′);
% Overlay the warpedImage onto the panorama.
maski = imbinarize(rgb2gray(255 * Imij));
maskj = imbinarize(rgb2gray(255 * Imji));
% Find the overlap mask
Nij_im = maski & maskj;
Nij_im = imfill(Nij_im, ‘holes’);
Nijidx = repmat(Nij_im, 1, 1, size(Imij,3));
% Get the overlapping region RGB values for two images
Ibarij(Nijidx) = Imij(Nijidx);
Ibarji(Nijidx) = Imji(Nijidx);
% Convert to double
Ibarij_double = double(Ibarij);
Ibarji_double = double(Ibarji);
% Nij
Nij = sum(sum(Nij_im));
% Ibar ijs
Ibarij = reshape(sum(sum(Ibarij_double)) ./ Nij, 1, 3);
Ibarji = reshape(sum(sum(Ibarji_double)) ./ Nij, 1, 3);
% Replace NaNs by zeros
Ibarij(isnan(Ibarij)) = 0;
Ibarji(isnan(Ibarji)) = 0;
end
Line [Ibarij, Ibarji, Nij] = getIbarNij(panoramasize, wim_4d(:,:,:,ii), wim_4d(:,:,:,d)); throws a warning message: The entire array or structure ‘wim_4d’ is a broadcast variable. This might result in unnecessary communication overhead. I have used ind2sub for getting the subscripts as it is easy to work. However, wim_4d(:,:,:,ii) and others cannot be sliced. Any other suggestion and help is appreciated! parfor, memory MATLAB Answers — New Questions
How do I get my old university account as in gmail account?
I have one old account with university email address but now I dont have that email address so I need to connect that account to my new gmail account so How can I do it?
I dont have access to my old account anymore. Thank you
old account
https://in.mathworks.com/matlabcentral/profile/authors/14080250
New account is
https://in.mathworks.com/matlabcentral/profile/authors/14080250I have one old account with university email address but now I dont have that email address so I need to connect that account to my new gmail account so How can I do it?
I dont have access to my old account anymore. Thank you
old account
https://in.mathworks.com/matlabcentral/profile/authors/14080250
New account is
https://in.mathworks.com/matlabcentral/profile/authors/14080250 I have one old account with university email address but now I dont have that email address so I need to connect that account to my new gmail account so How can I do it?
I dont have access to my old account anymore. Thank you
old account
https://in.mathworks.com/matlabcentral/profile/authors/14080250
New account is
https://in.mathworks.com/matlabcentral/profile/authors/14080250 support, matlab, account MATLAB Answers — New Questions
Set up Teams premium license and verify from end user teams application the license status
Hello ,
i will enable for many users the teams premium license .how to check from end user that its license is synchronized from end user teams application ?may be just check one new capability is showing from the teams application .if yes ,is there a very simple verification?
how to enforce manually the premium license in case the end used desktop teams application doesn’t get synchronized with the team premium license ?
regards
Hello , i will enable for many users the teams premium license .how to check from end user that its license is synchronized from end user teams application ?may be just check one new capability is showing from the teams application .if yes ,is there a very simple verification?how to enforce manually the premium license in case the end used desktop teams application doesn’t get synchronized with the team premium license ?regards Read More
Help with creating an Excel formula starting with a cell with text and number
Hello.
I am seeking help to create a simple formula to show ticket sales.
My starting cell has a description of the ticket category with the price of the ticket. The next cell, in the adjacent column the number of those tickets sold will be entered. I simply want to grab the number from the first cell and multiply with the number sold in a third cell. I have tried but I cant get around the text in the first cell and not an advanced user in Excel. Thank you in advance for your help.
Hello.I am seeking help to create a simple formula to show ticket sales.My starting cell has a description of the ticket category with the price of the ticket. The next cell, in the adjacent column the number of those tickets sold will be entered. I simply want to grab the number from the first cell and multiply with the number sold in a third cell. I have tried but I cant get around the text in the first cell and not an advanced user in Excel. Thank you in advance for your help. Read More
How to set up a registration page for a Teams weinbar with a choice of multiple dates and times
I want to set one webinar registration page where users have a choice of selecting different dates. I did see a post from January that is locked that said under Registration to Select Limit Registration start and end time.
But I don’t have that option under Registration. Under Registration I have Configuration and Attendee Status…and there is nothing under Configuration to Limit Registration Start and End Time.
Help!
I want to set one webinar registration page where users have a choice of selecting different dates. I did see a post from January that is locked that said under Registration to Select Limit Registration start and end time. But I don’t have that option under Registration. Under Registration I have Configuration and Attendee Status…and there is nothing under Configuration to Limit Registration Start and End Time. Help! Read More