Loading .gitignore +1 −1 Original line number Diff line number Diff line # remove Auth file matlab/test/auth.json matlab/test/credentials.json matlab/src/classes/@MatMust/MatMust.m +22 −15 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ classdef MatMust < handle methods function obj = MatMust(varargin) % Initialize the values obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',30, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',30, 'MediaType','application/x-www-form-urlencoded'); obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',180, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',180, 'MediaType','application/x-www-form-urlencoded'); obj.url = 'https://bepicolombo.esac.esa.int/webclient-must/'; obj.urlsub = 'mustlink/'; obj.tockenfilename = 'auth.json'; Loading Loading @@ -175,20 +175,20 @@ classdef MatMust < handle end if isa(response,'struct') data{1} = response; data = arrayfun(@(x) x, response, 'UniformOutput', false); else data = response; end %refine date string to adapt MATLAB date format for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data{1}.name) continue end data_par = data{1}(i).data; data_par = data{i}.data; t = num2cell(datenum(datetime('1970-01-01', 'TimeZone','utc'))+(str2num(str2mat(data_par.date))/1000/86400)); [data{1}(i).data.dateMAT] = deal(t{:}); [data{i}.data.dateMAT] = deal(t{:}); clear t end Loading Loading @@ -224,19 +224,23 @@ classdef MatMust < handle fprintf('+++++++++++++++++++++++++++++++++++++++++\n'); end if any(ismember(varargin,'plot')) for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) continue end data_par = data{1}(i).data; data_par =data{i}.data; figure title(sprintf('%s-%s: %s -> %s\n', data{1}(i).subsystem, data{1}(i).type, data{1}(i).name, data{1}(i).description )) if isfield('subsystem', data{i}) title(sprintf('%s-%s: %s -> %s\n', data{i}.subsystem,data{i}.type, data{i}.name, data{i}.description )) else title(sprintf('%s: %s -> %s\n', data{i}.type, data{i}.name, data{i}.description )) end if strcmp(calibrate,'true') switch class(data_par(1).calibratedValue) case 'char' indx = [1,find(diff([data_par.value])~=0)]+1; ylabels = string; ylabels([unique([data_par.value],'stable')]) = replace({data_par(indx).calibratedValue},'_',' '); ylabels([unique([data_par.value],'stable')]) = unique(replace({data_par(indx).calibratedValue},'_',' '),'stable'); plot([data_par.dateMAT], [data_par.value], '-x' ); set(gca,'ytick',unique([data_par.value],'sorted')) set(gca,'yticklabel',ylabels) Loading @@ -250,12 +254,15 @@ classdef MatMust < handle plot([data_par.dateMAT], [data_par.value], '-x' ); end xlabel('time'); if isfield(data{1}(i), 'unit') ylabel(data{1}(i).unit); if isfield(data{i}, 'unit') ylabel(data{i}.unit); end title([data{1}(i).description,' - ',data{1}(i).name]); title([data{i}.description,' - ',data{i}.name]); datetick('x'); grid on if exist('dataFigShowUpdatefcn')==2 set(datacursormode(gcf),'UpdateFcn',@dataFigShowUpdatefcn) end end end end Loading matlab/test/classes/@MatMust/MatMust.m +27 −42 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ classdef MatMust < handle methods function obj = MatMust(varargin) % Initialize the values obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',30, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',30, 'MediaType','application/x-www-form-urlencoded'); obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',180, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',180, 'MediaType','application/x-www-form-urlencoded'); obj.url = 'https://bepicolombo.esac.esa.int/webclient-must/'; obj.urlsub = 'mustlink/'; obj.tockenfilename = 'auth.json'; Loading Loading @@ -175,20 +175,20 @@ classdef MatMust < handle end if isa(response,'struct') data{1} = response; data = arrayfun(@(x) x, response, 'UniformOutput', false); else data = response; end %refine date string to adapt MATLAB date format for i=1:numel(data{1}) if isempty(data{1}(i).data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data.name) for i=1:numel(data) if isempty(data{i}.data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data{1}.name) continue end data_par = data{1}(i).data; data_par = data{i}.data; t = num2cell(datenum(datetime('1970-01-01', 'TimeZone','utc'))+(str2num(str2mat(data_par.date))/1000/86400)); [data{1}(i).data.dateMAT] = deal(t{:}); [data{i}.data.dateMAT] = deal(t{:}); clear t end Loading Loading @@ -224,19 +224,23 @@ classdef MatMust < handle fprintf('+++++++++++++++++++++++++++++++++++++++++\n'); end if any(ismember(varargin,'plot')) for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) continue end data_par = data{1}(i).data; data_par =data{i}.data; figure title(sprintf('%s-%s: %s -> %s\n', data{1}(i).subsystem, data{1}(i).type, data{1}(i).name, data{1}(i).description )) if isfield('subsystem', data{i}) title(sprintf('%s-%s: %s -> %s\n', data{i}.subsystem,data{i}.type, data{i}.name, data{i}.description )) else title(sprintf('%s: %s -> %s\n', data{i}.type, data{i}.name, data{i}.description )) end if strcmp(calibrate,'true') switch class(data_par(1).calibratedValue) case 'char' indx = [1,find(diff([data_par.value])~=0)]+1; ylabels = string; ylabels([unique([data_par.value],'stable')]) = replace({data_par(indx).calibratedValue},'_',' '); ylabels([unique([data_par.value],'stable')]) = unique(replace({data_par(indx).calibratedValue},'_',' '),'stable'); plot([data_par.dateMAT], [data_par.value], '-x' ); set(gca,'ytick',unique([data_par.value],'sorted')) set(gca,'yticklabel',ylabels) Loading @@ -250,18 +254,21 @@ classdef MatMust < handle plot([data_par.dateMAT], [data_par.value], '-x' ); end xlabel('time'); if isfield(data{1}(i), 'unit') ylabel(data{1}(i).unit); if isfield(data{i}, 'unit') ylabel(data{i}.unit); end title([data{1}(i).description,' - ',data{1}(i).name]); title([data{i}.description,' - ',data{i}.name]); datetick('x'); grid on if exist('dataFigShowUpdatefcn')==2 set(datacursormode(gcf),'UpdateFcn',@dataFigShowUpdatefcn) end end end end end function o = MatMust_searchTMparFromName(obj, namequery, dataproviders, varargin) function t = MatMust_searchTMparFromName(obj, namequery, dataproviders, varargin) % +++ % MatMust_searchTMparFromName % Search a parameter into the requested dataprovider (es. BEPICRUISE) Loading @@ -281,18 +288,16 @@ classdef MatMust < handle query = 'metadata/treesearch'; obj.GEToptions.HeaderFields = {'Authorization', obj.tockenstruct.token}; if isa(dataproviders,'cell') dataprovidersstr = char(join(dataproviders,',')); else dataprovidersstr = dataproviders; dataproviders = char(join(dataproviders,',')); end try optindx = strcmp(varargin,'Description')+strcmp(varargin,'Unit')+strcmp(varargin,'Id'); if any(find(optindx)) field = join(varargin(find(optindx)),','); response = webread([obj.url,obj.urlsub, query], 'field',['name,',char(field)],'text',namequery,'dataproviders', dataprovidersstr ,obj.GEToptions); response = webread([obj.url,obj.urlsub, query], 'field',['name,',char(field)],'text',namequery,'dataproviders', dataproviders ,obj.GEToptions); else response = webread([obj.url,obj.urlsub, query], 'field','name','text',namequery,'dataproviders', dataprovidersstr ,obj.GEToptions); response = webread([obj.url,obj.urlsub, query], 'field','name','text',namequery,'dataproviders', dataproviders ,obj.GEToptions); end t = response ; catch ME Loading @@ -318,26 +323,6 @@ classdef MatMust < handle end end end % output only requested ds if isa(dataproviders,'cell') c = 0; for i = 1:numel(t) for j = 1:numel(dataproviders) if strcmp(t(i).type, [dataproviders(j), ' params'] ) c = c+1; o(c) = t(i); end end end else c = 0; for i = 1:numel(t) if strcmp(t(i).type, [dataproviders, ' params'] ) c = c+1; o(c) = t(i); end end end end function MatMust_login(obj, varargin ) % login Loading matlab/test/credentials.json 0 → 100644 +4 −0 Original line number Diff line number Diff line { "username":"ygagarin", "password":":YG_password" } No newline at end of file matlab/test/test.m +19 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,12 @@ close all addpath('./classes/'); M = MatMust; credentials = jsondecode(fileread('credentials.json')); % for info type help "MatMust_login" MatMust_login(M, jsondecode('{"username": "ajejebrazorv", "password": "123456%!", "maxDuration": false}')); opts = struct("username", credentials.username, "password", credentials.password ,"maxDuration", false); MatMust_login(M, opts); % Ask for the Projects available to the user Loading @@ -37,11 +41,23 @@ proj_list = M.MatMust_getUserLinkedProjects('dump'); % +++++++++++++++++ act_proj = 'BEPICRUISE'; dataStart = '2018-11-26 13:00:00'; dataStop = '2018-11-26 13:40:00'; % for info type "help MatMust_getDataFromName" % MatMust_getDataFromName(obj, ds, parname, dateStart, dateStop, options ) data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', '2018-11-26 13:00:00', '2018-11-26 13:40:00'); data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', dataStart, dataStop); % or if you want to plot data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', '2018-11-26 13:00:00', '2018-11-26 13:40:00', 'plot'); data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', dataStart, dataStop, 'plot'); %search a mnemonic in data = M.MatMust_searchTMparFromName('Est sc ang rate', act_proj,'dump','Description'); %you can get more than a variable a time data = M.MatMust_getDataFromName('BEPICRUISE', {'NCAD09A1','NCAD09A2','NCAD09A3'}, dataStart , dataStop, 'plot'); Loading
.gitignore +1 −1 Original line number Diff line number Diff line # remove Auth file matlab/test/auth.json matlab/test/credentials.json
matlab/src/classes/@MatMust/MatMust.m +22 −15 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ classdef MatMust < handle methods function obj = MatMust(varargin) % Initialize the values obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',30, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',30, 'MediaType','application/x-www-form-urlencoded'); obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',180, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',180, 'MediaType','application/x-www-form-urlencoded'); obj.url = 'https://bepicolombo.esac.esa.int/webclient-must/'; obj.urlsub = 'mustlink/'; obj.tockenfilename = 'auth.json'; Loading Loading @@ -175,20 +175,20 @@ classdef MatMust < handle end if isa(response,'struct') data{1} = response; data = arrayfun(@(x) x, response, 'UniformOutput', false); else data = response; end %refine date string to adapt MATLAB date format for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data{1}.name) continue end data_par = data{1}(i).data; data_par = data{i}.data; t = num2cell(datenum(datetime('1970-01-01', 'TimeZone','utc'))+(str2num(str2mat(data_par.date))/1000/86400)); [data{1}(i).data.dateMAT] = deal(t{:}); [data{i}.data.dateMAT] = deal(t{:}); clear t end Loading Loading @@ -224,19 +224,23 @@ classdef MatMust < handle fprintf('+++++++++++++++++++++++++++++++++++++++++\n'); end if any(ismember(varargin,'plot')) for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) continue end data_par = data{1}(i).data; data_par =data{i}.data; figure title(sprintf('%s-%s: %s -> %s\n', data{1}(i).subsystem, data{1}(i).type, data{1}(i).name, data{1}(i).description )) if isfield('subsystem', data{i}) title(sprintf('%s-%s: %s -> %s\n', data{i}.subsystem,data{i}.type, data{i}.name, data{i}.description )) else title(sprintf('%s: %s -> %s\n', data{i}.type, data{i}.name, data{i}.description )) end if strcmp(calibrate,'true') switch class(data_par(1).calibratedValue) case 'char' indx = [1,find(diff([data_par.value])~=0)]+1; ylabels = string; ylabels([unique([data_par.value],'stable')]) = replace({data_par(indx).calibratedValue},'_',' '); ylabels([unique([data_par.value],'stable')]) = unique(replace({data_par(indx).calibratedValue},'_',' '),'stable'); plot([data_par.dateMAT], [data_par.value], '-x' ); set(gca,'ytick',unique([data_par.value],'sorted')) set(gca,'yticklabel',ylabels) Loading @@ -250,12 +254,15 @@ classdef MatMust < handle plot([data_par.dateMAT], [data_par.value], '-x' ); end xlabel('time'); if isfield(data{1}(i), 'unit') ylabel(data{1}(i).unit); if isfield(data{i}, 'unit') ylabel(data{i}.unit); end title([data{1}(i).description,' - ',data{1}(i).name]); title([data{i}.description,' - ',data{i}.name]); datetick('x'); grid on if exist('dataFigShowUpdatefcn')==2 set(datacursormode(gcf),'UpdateFcn',@dataFigShowUpdatefcn) end end end end Loading
matlab/test/classes/@MatMust/MatMust.m +27 −42 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ classdef MatMust < handle methods function obj = MatMust(varargin) % Initialize the values obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',30, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',30, 'MediaType','application/x-www-form-urlencoded'); obj.POSToptions = weboptions('RequestMethod', 'POST', 'ArrayFormat', 'json', 'Timeout',180, 'MediaType','application/json'); obj.GEToptions = weboptions('RequestMethod', 'GET', 'ArrayFormat', 'repeating', 'Timeout',180, 'MediaType','application/x-www-form-urlencoded'); obj.url = 'https://bepicolombo.esac.esa.int/webclient-must/'; obj.urlsub = 'mustlink/'; obj.tockenfilename = 'auth.json'; Loading Loading @@ -175,20 +175,20 @@ classdef MatMust < handle end if isa(response,'struct') data{1} = response; data = arrayfun(@(x) x, response, 'UniformOutput', false); else data = response; end %refine date string to adapt MATLAB date format for i=1:numel(data{1}) if isempty(data{1}(i).data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data.name) for i=1:numel(data) if isempty(data{i}.data) fprintf('+++ WARNING\n%s for %s\n', 'No Data existing in time span', data{1}.name) continue end data_par = data{1}(i).data; data_par = data{i}.data; t = num2cell(datenum(datetime('1970-01-01', 'TimeZone','utc'))+(str2num(str2mat(data_par.date))/1000/86400)); [data{1}(i).data.dateMAT] = deal(t{:}); [data{i}.data.dateMAT] = deal(t{:}); clear t end Loading Loading @@ -224,19 +224,23 @@ classdef MatMust < handle fprintf('+++++++++++++++++++++++++++++++++++++++++\n'); end if any(ismember(varargin,'plot')) for i=1:numel(data{1}) if isempty(data{1}(i).data) for i=1:numel(data) if isempty(data{i}.data) continue end data_par = data{1}(i).data; data_par =data{i}.data; figure title(sprintf('%s-%s: %s -> %s\n', data{1}(i).subsystem, data{1}(i).type, data{1}(i).name, data{1}(i).description )) if isfield('subsystem', data{i}) title(sprintf('%s-%s: %s -> %s\n', data{i}.subsystem,data{i}.type, data{i}.name, data{i}.description )) else title(sprintf('%s: %s -> %s\n', data{i}.type, data{i}.name, data{i}.description )) end if strcmp(calibrate,'true') switch class(data_par(1).calibratedValue) case 'char' indx = [1,find(diff([data_par.value])~=0)]+1; ylabels = string; ylabels([unique([data_par.value],'stable')]) = replace({data_par(indx).calibratedValue},'_',' '); ylabels([unique([data_par.value],'stable')]) = unique(replace({data_par(indx).calibratedValue},'_',' '),'stable'); plot([data_par.dateMAT], [data_par.value], '-x' ); set(gca,'ytick',unique([data_par.value],'sorted')) set(gca,'yticklabel',ylabels) Loading @@ -250,18 +254,21 @@ classdef MatMust < handle plot([data_par.dateMAT], [data_par.value], '-x' ); end xlabel('time'); if isfield(data{1}(i), 'unit') ylabel(data{1}(i).unit); if isfield(data{i}, 'unit') ylabel(data{i}.unit); end title([data{1}(i).description,' - ',data{1}(i).name]); title([data{i}.description,' - ',data{i}.name]); datetick('x'); grid on if exist('dataFigShowUpdatefcn')==2 set(datacursormode(gcf),'UpdateFcn',@dataFigShowUpdatefcn) end end end end end function o = MatMust_searchTMparFromName(obj, namequery, dataproviders, varargin) function t = MatMust_searchTMparFromName(obj, namequery, dataproviders, varargin) % +++ % MatMust_searchTMparFromName % Search a parameter into the requested dataprovider (es. BEPICRUISE) Loading @@ -281,18 +288,16 @@ classdef MatMust < handle query = 'metadata/treesearch'; obj.GEToptions.HeaderFields = {'Authorization', obj.tockenstruct.token}; if isa(dataproviders,'cell') dataprovidersstr = char(join(dataproviders,',')); else dataprovidersstr = dataproviders; dataproviders = char(join(dataproviders,',')); end try optindx = strcmp(varargin,'Description')+strcmp(varargin,'Unit')+strcmp(varargin,'Id'); if any(find(optindx)) field = join(varargin(find(optindx)),','); response = webread([obj.url,obj.urlsub, query], 'field',['name,',char(field)],'text',namequery,'dataproviders', dataprovidersstr ,obj.GEToptions); response = webread([obj.url,obj.urlsub, query], 'field',['name,',char(field)],'text',namequery,'dataproviders', dataproviders ,obj.GEToptions); else response = webread([obj.url,obj.urlsub, query], 'field','name','text',namequery,'dataproviders', dataprovidersstr ,obj.GEToptions); response = webread([obj.url,obj.urlsub, query], 'field','name','text',namequery,'dataproviders', dataproviders ,obj.GEToptions); end t = response ; catch ME Loading @@ -318,26 +323,6 @@ classdef MatMust < handle end end end % output only requested ds if isa(dataproviders,'cell') c = 0; for i = 1:numel(t) for j = 1:numel(dataproviders) if strcmp(t(i).type, [dataproviders(j), ' params'] ) c = c+1; o(c) = t(i); end end end else c = 0; for i = 1:numel(t) if strcmp(t(i).type, [dataproviders, ' params'] ) c = c+1; o(c) = t(i); end end end end function MatMust_login(obj, varargin ) % login Loading
matlab/test/credentials.json 0 → 100644 +4 −0 Original line number Diff line number Diff line { "username":"ygagarin", "password":":YG_password" } No newline at end of file
matlab/test/test.m +19 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,12 @@ close all addpath('./classes/'); M = MatMust; credentials = jsondecode(fileread('credentials.json')); % for info type help "MatMust_login" MatMust_login(M, jsondecode('{"username": "ajejebrazorv", "password": "123456%!", "maxDuration": false}')); opts = struct("username", credentials.username, "password", credentials.password ,"maxDuration", false); MatMust_login(M, opts); % Ask for the Projects available to the user Loading @@ -37,11 +41,23 @@ proj_list = M.MatMust_getUserLinkedProjects('dump'); % +++++++++++++++++ act_proj = 'BEPICRUISE'; dataStart = '2018-11-26 13:00:00'; dataStop = '2018-11-26 13:40:00'; % for info type "help MatMust_getDataFromName" % MatMust_getDataFromName(obj, ds, parname, dateStart, dateStop, options ) data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', '2018-11-26 13:00:00', '2018-11-26 13:40:00'); data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', dataStart, dataStop); % or if you want to plot data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', '2018-11-26 13:00:00', '2018-11-26 13:40:00', 'plot'); data = M.MatMust_getDataFromName('BEPICRUISE', 'NSA03016', dataStart, dataStop, 'plot'); %search a mnemonic in data = M.MatMust_searchTMparFromName('Est sc ang rate', act_proj,'dump','Description'); %you can get more than a variable a time data = M.MatMust_getDataFromName('BEPICRUISE', {'NCAD09A1','NCAD09A2','NCAD09A3'}, dataStart , dataStop, 'plot');