Commit 446955d1 authored by Carmelo Magnafico's avatar Carmelo Magnafico
Browse files

update MatMust_getDataFromName to allow aggregation statements

parent 0ed6f790
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -135,6 +135,9 @@ classdef MatMust < handle
            %   'dump','plot' optional parameter to dump and plot the data
            %   'calibrated' optional parameter that specify that you want
            %   calibrated data
            % You can add aggration funcition
            % aggregation = [days | hours | minutes ]
            % aggregation = [ FIRST | LAST | MAX | MIN | AVERAGE]
          
            % intialize data output
            data = [];
@@ -151,7 +154,7 @@ classdef MatMust < handle
                end
            end
            
            if any(ismember(varargin,'calibrated')) calibrate = 'true'; else calibrate = 'false'; end
            if any(cellfun(@(x) strcmp(x, 'calibrated'), varargin )) calibrate = 'true'; else calibrate = 'false'; end

            query = ['dataproviders/',ds,'/parameters/data'];
            obj.GEToptions.HeaderFields = {'Authorization', obj.tockenstruct.token};
@@ -167,6 +170,11 @@ classdef MatMust < handle
                    'calibrate', calibrate,...
                    'mode', 'SIMPLE'};

            if any(cellfun(@(x) strcmp(x, 'aggregation'), varargin )) args = [args, 'aggregation',  varargin{find(cellfun(@(x) strcmp(x, 'aggregation'), varargin )) +1} ]; end
            if any(cellfun(@(x) strcmp(x, 'aggregationFunction'), varargin )) args = [args, 'aggregationFunction',  varargin{find(cellfun(@(x) strcmp(x, 'aggregationFunction'), varargin )) +1} ]; end
            if any(cellfun(@(x) strcmp(x, 'aggregationValue'), varargin )) args = [args, 'aggregationValue', varargin{find(cellfun(@(x) strcmp(x, 'aggregationValue'), varargin )) +1}  ]; end

    
            try
                response = webread([obj.url,obj.urlsub, query], args{:} ,obj.GEToptions);
            catch ME
@@ -193,7 +201,7 @@ classdef MatMust < handle
            end

            if nargin > 5
                if any(ismember(varargin,'dump'))
                if any(cellfun(@(x) strcmp(x, 'dump'), varargin ))
                    fprintf('+++++++++++++ DATA RESULT LIST +++++++++++++\n');
                    for i=1:numel(data{1})
                         if isempty(data{i}(i).data)
@@ -223,7 +231,7 @@ classdef MatMust < handle
                    end
                    fprintf('+++++++++++++++++++++++++++++++++++++++++\n');
                end
                if any(ismember(varargin,'plot'))
                if any(cellfun(@(x) strcmp(x, 'plot'), varargin ))
                     for i=1:numel(data) 
                        if isempty(data{i}.data)
                             continue
+11 −3
Original line number Diff line number Diff line
@@ -135,6 +135,9 @@ classdef MatMust < handle
            %   'dump','plot' optional parameter to dump and plot the data
            %   'calibrated' optional parameter that specify that you want
            %   calibrated data
            % You can add aggration funcition
            % aggregation = [days | hours | minutes ]
            % aggregation = [ FIRST | LAST | MAX | MIN | AVERAGE]
          
            % intialize data output
            data = [];
@@ -151,7 +154,7 @@ classdef MatMust < handle
                end
            end
            
            if any(ismember(varargin,'calibrated')) calibrate = 'true'; else calibrate = 'false'; end
            if any(cellfun(@(x) strcmp(x, 'calibrated'), varargin )) calibrate = 'true'; else calibrate = 'false'; end

            query = ['dataproviders/',ds,'/parameters/data'];
            obj.GEToptions.HeaderFields = {'Authorization', obj.tockenstruct.token};
@@ -167,6 +170,11 @@ classdef MatMust < handle
                    'calibrate', calibrate,...
                    'mode', 'SIMPLE'};

            if any(cellfun(@(x) strcmp(x, 'aggregation'), varargin )) args = [args, 'aggregation',  varargin{find(cellfun(@(x) strcmp(x, 'aggregation'), varargin )) +1} ]; end
            if any(cellfun(@(x) strcmp(x, 'aggregationFunction'), varargin )) args = [args, 'aggregationFunction',  varargin{find(cellfun(@(x) strcmp(x, 'aggregationFunction'), varargin )) +1} ]; end
            if any(cellfun(@(x) strcmp(x, 'aggregationValue'), varargin )) args = [args, 'aggregationValue', varargin{find(cellfun(@(x) strcmp(x, 'aggregationValue'), varargin )) +1}  ]; end

    
            try
                response = webread([obj.url,obj.urlsub, query], args{:} ,obj.GEToptions);
            catch ME
@@ -193,7 +201,7 @@ classdef MatMust < handle
            end

            if nargin > 5
                if any(ismember(varargin,'dump'))
                if any(cellfun(@(x) strcmp(x, 'dump'), varargin ))
                    fprintf('+++++++++++++ DATA RESULT LIST +++++++++++++\n');
                    for i=1:numel(data{1})
                         if isempty(data{i}(i).data)
@@ -223,7 +231,7 @@ classdef MatMust < handle
                    end
                    fprintf('+++++++++++++++++++++++++++++++++++++++++\n');
                end
                if any(ismember(varargin,'plot'))
                if any(cellfun(@(x) strcmp(x, 'plot'), varargin ))
                     for i=1:numel(data) 
                        if isempty(data{i}.data)
                             continue
+2 −0
Original line number Diff line number Diff line
@@ -67,5 +67,7 @@ data = M.MatMust_searchTMparFromName('Est sc ang rate', act_proj,'dump','Descrip
%you can get more than a variable a time
data = M.MatMust_getDataFromName(act_proj, {'NCAD09A1','NCAD09A2','NCAD09A3'}, dataStart , dataStop, 'plot');

data = M.MatMust_getDataFromName(act_proj, {'NCAD09A1','NCAD09A2','NCAD09A3'}, dataStart , dataStop, 'plot', 'aggregation', 'minutes', 'aggregationValue', 10, 'aggregationFunction', 'AVERAGE');