From 3ad03d5b66340fec3194dd6d4cddfcfb9c814a42 Mon Sep 17 00:00:00 2001 From: "RADIAL\\brian.day" Date: Fri, 9 Jun 2023 16:42:56 -0400 Subject: [PATCH 1/5] updating cphd read to allow you to return just the nbdata without needing to request the wbdata as well --- IO/phase_history/cphd/open_cphd_reader.m | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/IO/phase_history/cphd/open_cphd_reader.m b/IO/phase_history/cphd/open_cphd_reader.m index 136721b..3a5891e 100644 --- a/IO/phase_history/cphd/open_cphd_reader.m +++ b/IO/phase_history/cphd/open_cphd_reader.m @@ -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 @@ -176,10 +177,25 @@ % Copy selected vector-based data to a structure if nargout>1 - fldnames = fieldnames(vbp_all); - for fn_index = 1:numel(fldnames) - nbdata.(fldnames{fn_index}) = vbp_all(channel).(fldnames{fn_index})(pulse_indices,:); - end + nbdata = get_nbdata(pulse_indices, channel); + end + end + + %% Function for reading only the narrowband data + % Faster than calling read_data when you only want nbdata + function [nbdata] = get_nbdata(pulse_indices, channel) + % Compute default input parameters + if (nargin<3) + channel=1; + end + if (nargin<1)||strcmpi(pulse_indices,'all') + pulse_indices=1:double(xml_meta.Data.Channel(channel).NumVectors); + end + + % read just the nb data + fldnames = fieldnames(vbp_all); + for fn_index = 1:numel(fldnames) + nbdata.(fldnames{fn_index}) = vbp_all(channel).(fldnames{fn_index})(pulse_indices,:); end end From cb013f2fa6db20e67fea488c1c5df6ebe7e90b5f Mon Sep 17 00:00:00 2001 From: "RADIAL\\brian.day" Date: Mon, 12 Jun 2023 17:17:51 -0400 Subject: [PATCH 2/5] reverted changes in the cphd reader specifically --- IO/phase_history/cphd/open_cphd_reader.m | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/IO/phase_history/cphd/open_cphd_reader.m b/IO/phase_history/cphd/open_cphd_reader.m index 3a5891e..136721b 100644 --- a/IO/phase_history/cphd/open_cphd_reader.m +++ b/IO/phase_history/cphd/open_cphd_reader.m @@ -142,7 +142,6 @@ %% 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 @@ -177,25 +176,10 @@ % Copy selected vector-based data to a structure if nargout>1 - nbdata = get_nbdata(pulse_indices, channel); - end - end - - %% Function for reading only the narrowband data - % Faster than calling read_data when you only want nbdata - function [nbdata] = get_nbdata(pulse_indices, channel) - % Compute default input parameters - if (nargin<3) - channel=1; - end - if (nargin<1)||strcmpi(pulse_indices,'all') - pulse_indices=1:double(xml_meta.Data.Channel(channel).NumVectors); - end - - % read just the nb data - fldnames = fieldnames(vbp_all); - for fn_index = 1:numel(fldnames) - nbdata.(fldnames{fn_index}) = vbp_all(channel).(fldnames{fn_index})(pulse_indices,:); + fldnames = fieldnames(vbp_all); + for fn_index = 1:numel(fldnames) + nbdata.(fldnames{fn_index}) = vbp_all(channel).(fldnames{fn_index})(pulse_indices,:); + end end end From d2029136d92c25766fcfb4b583ac947dde8d8b15 Mon Sep 17 00:00:00 2001 From: "RADIAL\\brian.day" Date: Mon, 12 Jun 2023 17:19:30 -0400 Subject: [PATCH 3/5] Adding the get_nbdata method in open_ph_reader so we can define it for every reader type based on what methods it has --- IO/phase_history/open_ph_reader.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/IO/phase_history/open_ph_reader.m b/IO/phase_history/open_ph_reader.m index 5ca07d8..0af36f9 100644 --- a/IO/phase_history/open_ph_reader.m +++ b/IO/phase_history/open_ph_reader.m @@ -65,6 +65,13 @@ end readerobj = eval(['open_' format_string '_reader(''' filename ''', varargin{:});']); +% Define the get_nbdata for each reader object +if exist(ro,'read_cphd') + readerobj.get_nbdata = ro.read_cphd('all', []); +elseif exist(ro,'read_raw') + readerobj.get_nbdata = ro.read_raw('all', []); +end + end % ////////////////////////////////////////// From ed5cef6d80a5d211f21174f5b2d002cdeb415b6c Mon Sep 17 00:00:00 2001 From: "RADIAL\\brian.day" Date: Mon, 12 Jun 2023 17:51:00 -0400 Subject: [PATCH 4/5] adding the get_nbdata functions to both cphd and crsd readers. It was complicated to add the anonymous functions to the open_ph_reader since it has multiple outputs. --- IO/phase_history/cphd/open_cphd_reader.m | 12 ++++++++++++ IO/phase_history/crsd/open_crsd_reader.m | 12 ++++++++++++ IO/phase_history/open_ph_reader.m | 7 ------- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/IO/phase_history/cphd/open_cphd_reader.m b/IO/phase_history/cphd/open_cphd_reader.m index 136721b..eb28757 100644 --- a/IO/phase_history/cphd/open_cphd_reader.m +++ b/IO/phase_history/cphd/open_cphd_reader.m @@ -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 @@ -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) diff --git a/IO/phase_history/crsd/open_crsd_reader.m b/IO/phase_history/crsd/open_crsd_reader.m index 5ea2c5f..f2f441d 100644 --- a/IO/phase_history/crsd/open_crsd_reader.m +++ b/IO/phase_history/crsd/open_crsd_reader.m @@ -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 @@ -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) diff --git a/IO/phase_history/open_ph_reader.m b/IO/phase_history/open_ph_reader.m index 0af36f9..5ca07d8 100644 --- a/IO/phase_history/open_ph_reader.m +++ b/IO/phase_history/open_ph_reader.m @@ -65,13 +65,6 @@ end readerobj = eval(['open_' format_string '_reader(''' filename ''', varargin{:});']); -% Define the get_nbdata for each reader object -if exist(ro,'read_cphd') - readerobj.get_nbdata = ro.read_cphd('all', []); -elseif exist(ro,'read_raw') - readerobj.get_nbdata = ro.read_raw('all', []); -end - end % ////////////////////////////////////////// From eeaa5d7bd69acb20622dfb057ede8d8650989477 Mon Sep 17 00:00:00 2001 From: "RADIAL\\brian.day" Date: Mon, 12 Jun 2023 17:57:03 -0400 Subject: [PATCH 5/5] Adding get_nbdata to cphd30 and gotcha_public_release --- IO/phase_history/cphd30/open_cphd30_reader.m | 13 +++++++++++++ .../gotcha_public_release/open_gotchapr_reader.m | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/IO/phase_history/cphd30/open_cphd30_reader.m b/IO/phase_history/cphd30/open_cphd30_reader.m index 166bb7b..82be0d2 100644 --- a/IO/phase_history/cphd30/open_cphd30_reader.m +++ b/IO/phase_history/cphd30/open_cphd30_reader.m @@ -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); @@ -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'); diff --git a/IO/phase_history/gotcha/gotcha_public_release/open_gotchapr_reader.m b/IO/phase_history/gotcha/gotcha_public_release/open_gotchapr_reader.m index b311de2..fd44316 100644 --- a/IO/phase_history/gotcha/gotcha_public_release/open_gotchapr_reader.m +++ b/IO/phase_history/gotcha/gotcha_public_release/open_gotchapr_reader.m @@ -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; @@ -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 % //////////////////////////////////////////