From 20682f431f43790f8975c22d3aff77d2fd8e7fc1 Mon Sep 17 00:00:00 2001 From: Alexius Wadell Date: Sun, 29 Jan 2017 20:15:59 -0500 Subject: [PATCH] Removed Filtering Filtering wasn't very well done, has limited use and can be covered using mapReduce. --- @datasource/datasource.m | 5 +---- @datasource/getChannel.m | 21 ++------------------ @datasource/refreshGate.m | 15 -------------- @datasource/setGate.m | 16 --------------- Samples/analysisSample.m | 16 --------------- Samples/gateSample.m | 42 --------------------------------------- 6 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 @datasource/refreshGate.m delete mode 100644 @datasource/setGate.m delete mode 100644 Samples/analysisSample.m delete mode 100644 Samples/gateSample.m diff --git a/@datasource/datasource.m b/@datasource/datasource.m index 062379a..6fd6e0b 100644 --- a/@datasource/datasource.m +++ b/@datasource/datasource.m @@ -6,8 +6,7 @@ Data = struct; %Structure of Logged Data Entry = struct; %Structure of masterDirectory Channel = {}; %Cell Array of logged channels - Detail = []; %Structure of Details - Gate = struct; %Structure for gating function + Detail = []; %Structure of Details dm = []; %Handle to Datamaster Object MatPath = ''; %Full path to .mat file end @@ -67,8 +66,6 @@ function clearData(ds,varargin) newTime = Sync(varargin) - setGate(ds, filterHandle) - varargout = mapReduce(ds, mapFun, reduceFun, varargin) [cdf_2, x, y, duration] = CDF2(ds,varargin) diff --git a/@datasource/getChannel.m b/@datasource/getChannel.m index 70221dd..86abaaf 100644 --- a/@datasource/getChannel.m +++ b/@datasource/getChannel.m @@ -8,7 +8,6 @@ p.addRequired('ds',@(x) isa(x,'datasource') && length(x)==1); p.addRequired('chanName',@(x) ischar(x) || iscell(x)); p.addOptional('filter', 'none', @(x) any(strcmp(x,{'none','hampel','median'}))); - p.addOptional('gate', 'off', @(x) any(strcmp(x,{'off', 'on', 'refresh'}))); p.addOptional('unit', 'base', @ischar); end @@ -39,33 +38,17 @@ %Number of Standard of deviations a sample must deviate to be an outlier nSigma = 3; - %Apply Filer + %Apply Filter ds.Data.(chanName).Value = hampel(ds.Data.(chanName).Value,k,nSigma); case 'median' %Number of samples on either side to be used when computing the median n = 13; - %Apply Filer + %Apply Filter ds.Data.(chanName).Value = medfilt1(ds.Data.(chanName).Value,n); end end - %% Apply Gating - if strcmp(p.Results.gate, 'on') || strcmp(p.Results.gate, 'refresh') - %Refresh Gate if requested/required - if strcmp(p.Results.gate, 'refresh') || isempty(ds.Gate.Value) - ds.clearData(chanName); - ds.refreshGate; - end - - %Find Samples to Drop - dropIndex = floor(interp1(ds.Gate.Time, 1* ds.Gate.Value, ds.Data.(chanName).Time)); - - %Drop samples - ds.Data.(chanName).Value(~dropIndex) = []; - ds.Data.(chanName).Time(~dropIndex) = []; - end - %% Convert Units if ~strcmp(p.Results.unit,'') %Convert Unit diff --git a/@datasource/refreshGate.m b/@datasource/refreshGate.m deleted file mode 100644 index bdb1971..0000000 --- a/@datasource/refreshGate.m +++ /dev/null @@ -1,15 +0,0 @@ -function refreshGate(ds) - %Compute the time and value array for the stored gating function - - %Assert the datasource has a gateFunction - if ~isa(ds.Gate.gateFun, 'function_handle') - errorStruct.message = 'gateFun must be a function handle'; - errorStruct.identifier = 'Datamaster:datasource:setGate'; - error(errorStruct); - end - - %Compute Gate - [ds.Gate.Value, ds.Gate.Time] = ds.Gate.gateFun(ds); - - %Check that the gating is valid - assert(all(1*ds.Gate.Value == 0 | 1*ds.Gate.Value == 1), 'value must output 1 or 0') diff --git a/@datasource/setGate.m b/@datasource/setGate.m deleted file mode 100644 index 5e8563b..0000000 --- a/@datasource/setGate.m +++ /dev/null @@ -1,16 +0,0 @@ -function setGate(ds, gateHandle) - %Set the function used to generate the gate - - %Assert the gateHandle is a function handle - if ~isa(gateHandle, 'function_handle') - errorStruct.message = 'gateHandle must be a function handle'; - errorStruct.identifier = 'Datamaster:datasource:setGAte'; - error(errorStruct); - end - - % Add gateHandle to each datasource - for i = 1:length(ds) - %Set Filter - ds(i).Gate.gateFun = gateHandle; - end -end \ No newline at end of file diff --git a/Samples/analysisSample.m b/Samples/analysisSample.m deleted file mode 100644 index aa1183b..0000000 --- a/Samples/analysisSample.m +++ /dev/null @@ -1,16 +0,0 @@ -function [ outputs ] = analysisSample(ds, otherInputs) - %This is a sample function to demonstrate how to write a function to - %analyize data using Datamaster - %Input - %ds: At a bare minimum the first input must be a array of datasource - %otherInputs: Any number of additional inputs can be used by the - %function - % - %Outputs: No requirements exist for the output of the function - - %Now do any preallocation that needs to occur for example - - - -end - diff --git a/Samples/gateSample.m b/Samples/gateSample.m deleted file mode 100644 index deb1488..0000000 --- a/Samples/gateSample.m +++ /dev/null @@ -1,42 +0,0 @@ -function [value, time] = gateSample(ds) - % This is a sample function to show how to create a gating function - % At a bare minimum the function must take the form: - % [value, time, otherOutputs] = gateFunction(datasource) - % Input: - % ds: a single datasource object - % Other Inputs: gateFunction will only be pasted a datasource - % If other inputs are required they should be passed via an anonymous function - % - % Output: The order must be [value, time] - % value: Strictly 1 or 0 (Not Logical) - % time: the time when the sample is valid/invalid - - %First Load all channels needed for the gating function - %Strictly speaking channels can be loaded at any point - %However there is a significant speed penalty for not loading at once - ds.loadChannels({'Engine_RPM', 'Throttle_Pos', 'Manifold_Pres'}); - - % Apply any filtering that is required at this point - ds.getChannel('Throttle_Pos','filter','hampel'); - - %Synchronize sampling rates for all loaded channels - %Save the new time vector to each - %Note: filtering via getChannel will break synchronization - time = ds.Sync; - - %Now create the value array - %Set to 1: To include data into the results - %Set to 0: To excluded data from results - - %Get each channels - speed = ds.getChannel('Engine_RPM'); - throttle = ds.getChannel('Throttle_Pos'); - map = ds.getChannel('Manifold_Pres'); - - %Compute values for each time points - value = (speed.Value >= 1000 & speed.Value <= 6000); - value = (abs(gradient(throttle.Value)./gradient(throttle.Time)) < 10) & value; - value = (map.Value >= 90 & map.Value <= 180) & value; - - %Remember value must be strictly 0 or 1 (Or Logical) - value = 1 * value; \ No newline at end of file