diff --git a/matlab/src/classes/@MatMust/MatMust.m b/matlab/src/classes/@MatMust/MatMust.m index c350487ba2990329b8cd605c83eec4d1b7624572..873f0e391557e8546c8a959460258c6c310e66d2 100644 --- a/matlab/src/classes/@MatMust/MatMust.m +++ b/matlab/src/classes/@MatMust/MatMust.m @@ -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 diff --git a/matlab/test/classes/@MatMust/MatMust.m b/matlab/test/classes/@MatMust/MatMust.m index c350487ba2990329b8cd605c83eec4d1b7624572..873f0e391557e8546c8a959460258c6c310e66d2 100644 --- a/matlab/test/classes/@MatMust/MatMust.m +++ b/matlab/test/classes/@MatMust/MatMust.m @@ -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 diff --git a/matlab/test/test.m b/matlab/test/test.m index f10e3ed11d2e498d60e674497473da4b2db82ba0..985d49fd925deaee05781cc6a390cbff58830d92 100644 --- a/matlab/test/test.m +++ b/matlab/test/test.m @@ -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'); +