Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding get_nbdata #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions IO/phase_history/cphd/open_cphd_reader.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@

%% Specify reader object methods-- close() method already defined above
readerobj.read_cphd = @read_data;
readerobj.get_nbdata = @get_nbdata;
readerobj.get_meta = @() xml_meta;

%% READ_CPHD method of this reader object
Expand Down Expand Up @@ -183,6 +184,17 @@
end
end

% Function to get only the nbdata
function [nbdata] = get_nbdata(pulse_indices, channel)
if (nargin<2)
channel = 1;
end
if (nargin<1)
pulse_indices = 'all';
end
[~, nbdata] = read_data(pulse_indices, [], channel);
end

%% Function for reading data with memory mapped files
% Faster and easier
function data_out = chip_with_mm(pulse_indices, sample_indices, channel)
Expand Down
13 changes: 13 additions & 0 deletions IO/phase_history/cphd30/open_cphd30_reader.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
meta.native.cphd30 = cphd_preamble; % Save original format

readerobj.read_cphd=@read_data;
readerobj.get_nbdata =@get_nbdata;
readerobj.get_meta=@() meta;
readerobj.close=@() fclose(fid);

Expand Down Expand Up @@ -161,6 +162,18 @@
end
end


% Function to get only the nbdata
function [nbdata] = get_nbdata(pulse_indices, channel)
if (nargin<2)
channel = 1;
end
if (nargin<1)
pulse_indices = 'all';
end
[~, nbdata] = read_data(pulse_indices, [], channel);
end

% Assumes a single channel dataset
function nbdata = read_all_noninterleaved_nb()
fseek(fid, cphd_preamble.pulseStart, 'bof');
Expand Down
12 changes: 12 additions & 0 deletions IO/phase_history/crsd/open_crsd_reader.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@

%% Specify reader object methods-- close() method already defined above
readerobj.read_raw = @read_data;
readerobj.get_nbdata = @get_nbdata;
readerobj.get_meta = @() xml_meta;

%% READ_RAW method of this reader object
Expand Down Expand Up @@ -159,6 +160,17 @@
end
end

% Function to get only the nbdata
function [nbdata] = get_nbdata(pulse_indices, channel)
if (nargin<2)
channel = 1;
end
if (nargin<1)
pulse_indices = 'all';
end
[~, nbdata] = read_data(pulse_indices, [], channel);
end

%% Function for reading data with memory mapped files
% Faster and easier
function data_out = chip_with_mm(pulse_indices, sample_indices, channel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@

%% Setup reader object
readerobj.read_cphd=@read_data;
readerobj.get_nbdata =@get_nbdata;
readerobj.get_meta=@() cphd_meta;
readerobj.close=@() 1;

%% Functino for READ_CPHD method
function [wbvectors, nbdata] = read_data(pulse_indices, sample_indices, channels)
function [wbvectors, nbdata] = read_data(pulse_indices, sample_indices)
% Parse input parameters
if (nargin<1)||strcmpi(pulse_indices,'all')
pulse_indices=1:cphd_meta.Data.Channel.NumVectors;
Expand All @@ -149,6 +150,17 @@
end
end

% Function to get only the nbdata
function [nbdata] = get_nbdata(pulse_indices, channel)
if (nargin<2)
channel = 1;
end
if (nargin<1)
pulse_indices = 'all';
end
[~, nbdata] = read_data(pulse_indices, [], channel);
end

end

% //////////////////////////////////////////
Expand Down