Import is now backward compatible with files dating 2018

This commit is contained in:
bartels-rausch committed 2024-04-23 12:50:06 +02:00
1 parent 3f0d9be72a
commit 43889de25b
2834 files changed
+7371 -168

No files matched your search

+252 -168
View File
@@ -125,11 +125,11 @@ dataPath_NEXAFS = fullfile(dataPath, 'NEXAFS');
dataPath_LabView = fullfile(dataPath, 'Pressure');
%
if ~isfolder(dataPath_XPS)
warning('There is something wrong with the path. Check for typo and that the drives are mounted')
disp('There is something wrong with the path. Check for typo and that the drives are mounted')
disp('I quit now')
return
if ~isfolder(dataPath_XPS)
warning('There is something wrong with the path. Check for typo and that the drives are mounted')
disp('There is something wrong with the path. Check for typo and that the drives are mounted')
disp('I quit now')
return
end
@@ -187,7 +187,7 @@ if endsWith(p.Results.mode,'Pick')
end
filePickXps = filePick(endsWith(filePick,'.ibw'));
filePickNexafs = filePick(endsWith(filePick,'.h5'));
if isempty(filePickXps)
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.trallalla']);
else
@@ -241,10 +241,10 @@ end
% get date of last and first .ibw file in folder .
tmp.fileinfo = dir([dataPath_XPS '/*.ibw']);
if isempty(tmp.fileinfo)
warning('There appears to be no file in the SES folder. Add at least one file first.')
warning('There appears to be no file in the SES folder. Add at least one file first.')
disp('There appears to be no file in the SES folder. Add at least one file first.')
disp('I quit now')
return
return
end
try
@@ -321,7 +321,7 @@ for ii = 1:size(TmpFileList{1},1) % cycle through each XPS file
if PE.Ndim == 3
PE.regionIterations = size(PE.y,2);
PE.sequenceIterations = size(PE.y,3);
elseif PE.Ndim == 2
elseif PE.Ndim == 2
PE.regionIterations = 1;
PE.sequenceIterations = size(PE.y,2);
else
@@ -399,158 +399,241 @@ disp('*************************************************')
% to select individual meta data. The data can be directly addressed and
% written into the list structure:
if datenum(filedate_first) >= datenum('31-Dec-2019 23:59:00')
for ii = 1:size(TmpFileList{2},1) % do this for each list element
% if datenum(filedate_first) >= datenum('31-Dec-2017 23:59:00') %('31-Dec-2019 23:59:00')
for ii = 1:size(TmpFileList{2},1) % do this for each list element
%if ~isempty(h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/energy'))
% creation date of file
TmpFileList{2}(ii).creationDate = datevec(NaN);
%if ~isempty(h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/energy'))
% creation date of file
TmpFileList{2}(ii).creationDate = datevec(NaN);
try
% read data
%if datenum(filedate_first) <= datenum('21-Nov-2020 00:01:00') % Date not exaclty certain.
try
% read data
%if datenum(filedate_first) <= datenum('21-Nov-2020 00:01:00') % Date not exaclty certain.
try
TmpImage= h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/spectrum');
TmpImage= h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/spectrum');
%else
catch
catch
try
TmpImage = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/scienta spectrum');
catch
TmpImage = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/detector/data'); % pre-2020 (?) h5 structure
end
% 21.8.20 changed from spectrum to scienta spectrum, later
% switched back to scienta.
end
% 21.8.20 changed from spectrum to scienta spectrum, later
% switched back to spectrum.
% Spectrum
TmpFileList{2}(ii).spectrum_counts = NaN;
TmpFileList{2}(ii).spectrum_countsPerSecond = NaN;
% Spectrum
TmpFileList{2}(ii).spectrum_counts = NaN;
TmpFileList{2}(ii).spectrum_countsPerSecond = NaN;
% import Photon Energy (cols)
% import Photon Energy (cols)
try
TmpXrayEkin = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/energy'); % X-ray excitation energy; Photon energy in eV
TmpXrayEkin(TmpXrayEkin==0)=[];
catch
TmpXrayEkin = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/PhotonEnergy'); % X-ray excitation energy; Photon energy in eV
TmpXrayEkin(TmpXrayEkin==0)=[];
end
if isempty(TmpXrayEkin)
TmpFileList{2}(ii).xRayEkinRange_eV = [NaN NaN];
else
TmpFileList{2}(ii).xRayEkinRange_eV = [TmpXrayEkin(1) TmpXrayEkin(end)];
end
% Make unique
[TmpFileList{2}(ii).xRayEkin_eV, ind] = unique(TmpXrayEkin);
TmpFileList{2}(ii).image = TmpImage(:,ind);
if isempty(TmpXrayEkin)
TmpFileList{2}(ii).xRayEkinRange_eV = [NaN NaN];
else
TmpFileList{2}(ii).xRayEkinRange_eV = [TmpXrayEkin(1) TmpXrayEkin(end)];
end
% NEXAFS pass energy
% Make unique
[TmpFileList{2}(ii).xRayEkin_eV, ind] = unique(TmpXrayEkin);
TmpFileList{2}(ii).image = TmpImage(:,ind);
TmpFileList{2}(ii).image = TmpImage(:,ind);
% NEXAFS pass energy
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/PassEnergy'); % in eV
TmpFileList{2}(ii).scientaPassEnergy_eV = str2double(tmp(1));
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/PassEnergy'); % in eV
if tmp(1) == 1
TmpFileList{2}(ii).scientaPassEnergy_eV = 20;
elseif tmp(1) == 2
TmpFileList{2}(ii).scientaPassEnergy_eV = 50;
elseif tmp(1) == 3
TmpFileList{2}(ii).scientaPassEnergy_eV = 100;
elseif tmp(1) == 4
TmpFileList{2}(ii).scientaPassEnergy_eV = 200;
end
end
% NEXAFS dwell time
if datenum(filedate_first) >= datenum('1-Feb-2020 23:59:00')
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaStepTime')*1000; % in ms
% NEXAFS dwell time
if datenum(filedate_first) >= datenum('1-Feb-2020 23:59:00')
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaStepTime')*1000; % in ms
else
else
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/StepTime')*1000; % in ms
catch
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/StepTime')*1000; % in ms
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/ScientaStepTime')*1000;
end
end
TmpFileList{2}(ii).scientaDwellTime_ms = tmp(1);
% NEXAFS region Name
if TmpFileList{2}(ii).xRayEkinRange_eV(:,1) <= 530 && TmpFileList{2}(ii).xRayEkinRange_eV(:,2) >= 530
TmpFileList{2}(ii).regionName = 'O K-edge NEXAFS';
else
TmpFileList{2}(ii).regionName = 'NEXAFS';
end
end
TmpFileList{2}(ii).scientaDwellTime_ms = tmp(1);
% NEXAFS region Name
if TmpFileList{2}(ii).xRayEkinRange_eV(:,1) <= 530 && TmpFileList{2}(ii).xRayEkinRange_eV(:,2) >= 530
TmpFileList{2}(ii).regionName = 'O K-edge NEXAFS';
else
TmpFileList{2}(ii).regionName = 'NEXAFS';
end
% Acquisition mode
% Acquisition mode
try
TmpFileList{2}(ii).scientaAcquisitionMode = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/AcquisitionMode');
if strcmp(TmpFileList{2}(ii).scientaAcquisitionMode,'Fixed')
% NEXAFS kinetic energy window - fixed mode
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/AcquireMode');
if tmp(1) == 0
TmpFileList{2}(ii).scientaAcquisitionMode = "Swept";
elseif tmp(1) == 1
TmpFileList{2}(ii).scientaAcquisitionMode = "Fixed";
end
clear tmp
end
if strcmp(TmpFileList{2}(ii).scientaAcquisitionMode,'Fixed')
% NEXAFS kinetic energy window - fixed mode
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaCenterEnergy'); % in eV
TmpFileList{2}(ii).scientaEkinRange_eV = [tmp(1)-TmpFileList{2}(ii).scientaPassEnergy_eV/20 tmp(1)+TmpFileList{2}(ii).scientaPassEnergy_eV/20];
TmpFileList{2}(ii).scientaEkinStep_eV = NaN;
TmpFileList{2}(ii).scientaEkin_eV = linspace(TmpFileList{2}(ii).scientaEkinRange_eV(:,1)...
,TmpFileList{2}(ii).scientaEkinRange_eV(:,2),size(TmpFileList{2}(ii).image,1))';
else
% NEXAFS kinetic energy window - scan mode
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaCenterEnergy'); % in eV
end
TmpFileList{2}(ii).scientaEkinRange_eV = [tmp(1)-TmpFileList{2}(ii).scientaPassEnergy_eV/20 tmp(1)+TmpFileList{2}(ii).scientaPassEnergy_eV/20];
TmpFileList{2}(ii).scientaEkinStep_eV = NaN;
TmpFileList{2}(ii).scientaEkin_eV = linspace(TmpFileList{2}(ii).scientaEkinRange_eV(:,1)...
,TmpFileList{2}(ii).scientaEkinRange_eV(:,2),size(TmpFileList{2}(ii).image,1))';
else
% NEXAFS kinetic energy window - scan mode
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaLowEnergy'); % in eV
tmp2 = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/ScientaHighEnergy');
TmpFileList{2}(ii).scientaEkinRange_eV = [tmp(1) tmp2(1)];
TmpFileList{2}(ii).scientaEkinStep_eV = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/StepSize');
TmpFileList{2}(ii).scientaEkin_eV = [TmpFileList{2}(ii).scientaEkinRange_eV(:,1):TmpFileList{2}(ii).scientaEkinStep_eV(1):TmpFileList{2}(ii).scientaEkinRange_eV(:,2)]';
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LowEnergy'); % in eV
tmp2 = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/HighEnergy');
end
% read I_0
TmpFileList{2}(ii).scientaEkinRange_eV = [tmp(1) tmp2(1)];
clearvars tmp
try
TmpFileList{2}(ii).scientaEkinStep_eV = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/StepSize');
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/StepSize');
TmpFileList{2}(ii).scientaEkinStep_eV = abs(tmp(1));
end
TmpFileList{2}(ii).scientaEkin_eV = [TmpFileList{2}(ii).scientaEkinRange_eV(:,1):TmpFileList{2}(ii).scientaEkinStep_eV(1):TmpFileList{2}(ii).scientaEkinRange_eV(:,2)]';
end
clearvars tmp
% read I_0
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/i0');
TmpFileList{2}(ii).beamlineInt = abs(tmp(ind));
catch
end
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/RM2I0');
catch
end
% Lens Mode
try
TmpFileList{2}(ii).beamlineInt = abs(tmp(ind));
catch
TmpFileList{2}(ii).beamlineInt = NaN(size(ind,1),1);
end
% Lens Mode
try
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/LensMode');
TmpFileList{2}(ii).scientaLensMode = tmp{1};
clearvars tmp
TmpFileList{2}(ii).scientaRegionIterations = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/NumIterations');
TmpFileList{2}(ii).scientaSequenceIterations = 1;
catch
warning('Problem with a NEXAFS data file in NEXAFS list')
disp('Problem with a NEXAFS data file in NEXAFS list')
fprintf('Number %.0f: %s \n',ii,[TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name])
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{2}(ii).datenum))
end
TmpFileList{2}(ii).imageRoh = TmpFileList{2}(ii).image;
TmpFileList{2}(ii).spectrum_countsPerSecondRoh = TmpFileList{2}(ii).spectrum_countsPerSecond;
% log
TmpFileList{2}(ii).importDate = datestr(now);
try
TmpFileList{2}(ii).analysisDir = file.mFile;
catch
TmpFileList{2}(ii).analysisDir = pwd;
end
end
%end
else
for ii = 1:size(TmpFileList{2},1) % do this for each list element
try
% NEXAFS pass energy
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/PassEnergy'); % in eV
% TODO: Confirm that this assignment is correct. (The number refer to the list number in epics software)
if tmp(1) == 1
TmpFileList{2}(ii).passEnergy_eV = {[20]};
elseif tmp(1) == 2
TmpFileList{2}(ii).passEnergy_eV = {[50]};
elseif tmp(1) == 3
TmpFileList{2}(ii).passEnergy_eV = {[100]};
elseif tmp(1) == 4
TmpFileList{2}(ii).passEnergy_eV = {[200]};
end
% NEXAFS dwell time
if datenum(filedate_first) >= datenum('1-Feb-2020 23:59:00')
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/ScientaStepTime')*1000; % in ms
else
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/StepTime')*1000; % in ms
end
TmpFileList{2}(ii).dwellTime_ms = tmp(1);
% NEXAFS region Name
TmpFileList{2}(ii).regionName = 'NEXAFS';
% FIXME: Can we differentiate O K-edge, N K-edge, C K-edge based on the h5-file meta data?
% NEXAFS kinetic energy window
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LowEnergy'); % in eV
tmp2 = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/HighEnergy');
TmpFileList{2}(ii).kinRange_eV = [tmp(1) tmp2(1)];
% Lens mode
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LensMode');
TmpFileList{2}(ii).scientaLensMode = tmp{1};
clearvars tmp
catch
warning('Problem with a NEXAFS data file in NEXAFS list')
disp('Problem with a NEXAFS data file in NEXAFS list')
fprintf('Number %.0f: %s \n',ii,[TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name])
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{2}(ii).datenum))
TmpFileList{2}(ii).scientaLensMode = num2str(tmp(1));
end
clearvars tmp
try
TmpFileList{2}(ii).scientaRegionIterations = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/NumIterations');
catch
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/NumIterations');
TmpFileList{2}(ii).scientaRegionIterations = tmp(1);
end
TmpFileList{2}(ii).scientaSequenceIterations = 1;
catch
warning('Problem with a NEXAFS data file in NEXAFS list')
disp('Problem with a NEXAFS data file in NEXAFS list')
fprintf('Number %.0f: %s \n',ii,[TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name])
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{2}(ii).datenum))
end
TmpFileList{2}(ii).imageRoh = TmpFileList{2}(ii).image;
TmpFileList{2}(ii).spectrum_countsPerSecondRoh = TmpFileList{2}(ii).spectrum_countsPerSecond;
% log
TmpFileList{2}(ii).importDate = datestr(now);
try
TmpFileList{2}(ii).analysisDir = file.mFile;
catch
TmpFileList{2}(ii).analysisDir = pwd;
end
end
% check for empty entries
% else
% for ii = 1:size(TmpFileList{2},1) % do this for each list element
% try
% % NEXAFS pass energy
% tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/PassEnergy'); % in eV
% % TODO: Confirm that this assignment is correct. (The number refer to the list number in epics software)
% if tmp(1) == 1
% TmpFileList{2}(ii).passEnergy_eV = {[20]};
% elseif tmp(1) == 2
% TmpFileList{2}(ii).passEnergy_eV = {[50]};
% elseif tmp(1) == 3
% TmpFileList{2}(ii).passEnergy_eV = {[100]};
% elseif tmp(1) == 4
% TmpFileList{2}(ii).passEnergy_eV = {[200]};
% end
%
% % NEXAFS dwell time
% if datenum(filedate_first) >= datenum('1-Feb-2020 23:59:00')
% tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/ScientaStepTime')*1000; % in ms
%
% else
% tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/StepTime')*1000; % in ms
% end
% TmpFileList{2}(ii).dwellTime_ms = tmp(1);
% % NEXAFS region Name
% TmpFileList{2}(ii).regionName = 'NEXAFS';
% % FIXME: Can we differentiate O K-edge, N K-edge, C K-edge based on the h5-file meta data?
%
% % NEXAFS kinetic energy window
% tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LowEnergy'); % in eV
% tmp2 = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/HighEnergy');
% TmpFileList{2}(ii).kinRange_eV = [tmp(1) tmp2(1)];
%
% % Lens mode
% tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LensMode');
% TmpFileList{2}(ii).scientaLensMode = tmp{1};
% clearvars tmp
% catch
% warning('Problem with a NEXAFS data file in NEXAFS list')
% disp('Problem with a NEXAFS data file in NEXAFS list')
% fprintf('Number %.0f: %s \n',ii,[TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name])
% fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{2}(ii).datenum))
% end
%
% end
% end
disp('*************************************************')
disp('* Voila: Done reading and writing NEXAFS data! *')
@@ -808,6 +891,7 @@ if ~any(existColumn)
end
% add the imported data to previous list (if passed to function upon call)
if istable(p.Results.DataTable) % do this only if previous list was input to function call
% find table variables that are missing in ListFiles
existColumn = strcmp('sample',p.Results.DataTable.Properties.VariableNames);
if ~any(existColumn)
@@ -834,21 +918,21 @@ if istable(p.Results.DataTable) % do this only if previous list was input to fun
end
end
% % % sort the tables, if they have not the same order
% tmpCompareTables = cellfun(@isequal, ListFiles.Properties.VariableNames', p.Results.DataTable.Properties.VariableNames');
%
% if ~all(tmpCompareTables)
% indexDifferenzes = find(ismember(p.Results.DataTable.Properties.VariableNames',ListFiles.Properties.VariableNames(~tmpCompareTables)','rows'));
% nameListFiles =ListFiles.Properties.VariableNames(~tmpCompareTables);
%
% for ii = 1:size(indexDifferenzes,1)
% tmpIndx = find(ismember(p.Results.DataTable.Properties.VariableNames',nameListFiles{ii},'rows'));
% tmpPreviousVarName = p.Results.DataTable.Properties.VariableNames{tmpIndx-1};
% ListFiles = movevars(ListFiles,nameListFiles{ii},'After',tmpPreviousVarName);
% fprintf("%s comes after %s \n", nameListFiles{ii},tmpPreviousVarName)
% end
%
% end
% % % sort the tables, if they have not the same order
% tmpCompareTables = cellfun(@isequal, ListFiles.Properties.VariableNames', p.Results.DataTable.Properties.VariableNames');
%
% if ~all(tmpCompareTables)
% indexDifferenzes = find(ismember(p.Results.DataTable.Properties.VariableNames',ListFiles.Properties.VariableNames(~tmpCompareTables)','rows'));
% nameListFiles =ListFiles.Properties.VariableNames(~tmpCompareTables);
%
% for ii = 1:size(indexDifferenzes,1)
% tmpIndx = find(ismember(p.Results.DataTable.Properties.VariableNames',nameListFiles{ii},'rows'));
% tmpPreviousVarName = p.Results.DataTable.Properties.VariableNames{tmpIndx-1};
% ListFiles = movevars(ListFiles,nameListFiles{ii},'After',tmpPreviousVarName);
% fprintf("%s comes after %s \n", nameListFiles{ii},tmpPreviousVarName)
% end
%
% end
@@ -887,7 +971,7 @@ end
function LabView = LabView_importData(fullFileName,varargin)
%
% LabView_importData reads data log ASCII files stored by LabView into
% a Matlab time series.
% a Matlab time series.
%
% LabView = LabView_importData(A) imports file A
% and stores its content as time series in a structure called "LabView".
@@ -979,7 +1063,7 @@ if isstruct(p.Results.appendToStructure)
end
%%
if datenum(filedate) <= datenum('04-Mar-2019 13:30:00')
fid = fopen(p.Results.fullFileName);
data = textscan(fid, ...
'%s %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f',...
@@ -1000,25 +1084,25 @@ elseif datenum(filedate) >= datenum('15-Sep-2021 01:00:00') && datenum(filedate)
fid = fopen(p.Results.fullFileName);
data = textscan(fid, ...
'%s %s %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f',...
'HeaderLines',1); %
'HeaderLines',1); %
fclose(fid);
% the date formating in the dat file is really messed up. Try to make
% it consitent with MATLAB. The problem is that MATLAB does not
% understand 1 digit month and hours.
%
%
%
% Split the date in column 1 into year,month,day
newDateSplit = cellfun(@(x) split(char(x),'/'),data{1},'UniformOutput', false);
% Split the time in column 2 into hours, minutes, seconds
newTimeSplit = cellfun(@(x) split(char(x),':'),data{2},'UniformOutput', false);
% combine both with the am/pm string in column 3 to a new datestring
customDateStr = cellfun(@(x,y,z) [datestr(datenum([str2double(x{3}),str2double(x{1}),str2double(x{2}),str2double(y{1}),str2double(y{2}),str2double(y{3})])), ' ', char(z)], newDateSplit,newTimeSplit,data{3}, 'uniformOutput',false) ;
% define time series
% define time series
LabView.(['ts_' datestr(customDateStr{1},'YYYYmmdd_HHMM')]) ...
= timeseries([data{10} data{4} data{5} data{6} data{12} ...
data{13} data{14} data{7} data{8} data{17} data{18} data{19} data{21}], ...
data{13} data{14} data{7} data{8} data{17} data{18} data{19} data{21}], ...
customDateStr);
LabView.(['ts_' datestr(customDateStr{1},'YYYYmmdd_HHMM')]).Name ...
= 'Readout Napp Chamber raw signal';
@@ -1027,21 +1111,21 @@ elseif datenum(filedate) >= datenum('15-Sep-2021 01:00:00') && datenum(filedate)
elseif datenum(filedate) >= datenum('01-Apr-2023 02:00:00')
fid = fopen(p.Results.fullFileName);
fid = fopen(p.Results.fullFileName);
data = textscan(fid, ...
'%s %s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f',...
'HeaderLines',1);
'HeaderLines',1);
% data file has 2 text columns, followed by 18 numeric columns (THE AM
% PM IS MISSING and some changes to the LabView file. Confirm with Luca....)
fclose(fid);
% define time series
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]) ...
= timeseries([data{9} data{3} data{4} data{5} data{11} ...
data{12} data{20} data{6} data{7} data{15} data{16} data{17} data{19}] , ...
datestr(datenum([char(data{1}), char(data{2})],...
'dd.mm.yyyyHH:MM:SS'),0));
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]) ...
= timeseries([data{9} data{3} data{4} data{5} data{11} ...
data{12} data{20} data{6} data{7} data{15} data{16} data{17} data{19}] , ...
datestr(datenum([char(data{1}), char(data{2})],...
'dd.mm.yyyyHH:MM:SS'),0));
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]).Name ...
= 'Readout Napp Chamber raw signal';
clear fid ans formatOut nans t x
@@ -1053,13 +1137,13 @@ else
'HeaderLines',1); % data file has 2 text columns, followed by 14 numeric columns
fclose(fid);
% define time series
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]) ...
= timeseries([data{9} data{3} data{4} data{5} data{11} ...
data{12} data{13} data{6} data{7} data{16} data{17} data{18} data{20}] , ...
datestr(datenum([char(data{1}), char(data{2})],...
'dd.mm.yyyyHH:MM:SS'),0));
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]) ...
= timeseries([data{9} data{3} data{4} data{5} data{11} ...
data{12} data{13} data{6} data{7} data{16} data{17} data{18} data{20}] , ...
datestr(datenum([char(data{1}), char(data{2})],...
'dd.mm.yyyyHH:MM:SS'),0));
LabView.(['ts_' datestr(datenum([char(data{1}{1}), char(data{2}{1})],'dd.mm.yyyyHH:MM:SS'),'YYYYmmdd_HHMM')]).Name ...
= 'Readout Napp Chamber raw signal';
clear fid ans formatOut nans t x
@@ -1067,10 +1151,10 @@ end
end
function data_structure = LabView_combine(data_structure)
% LabView_combine can be used to merge time series into one.
% LabView_combine can be used to merge time series into one.
%
% LabView = LabView_combine(LabView) merges all timeseries in the structure
% LabView into the new timeseries "merge"
% LabView = LabView_combine(LabView) merges all timeseries in the structure
% LabView into the new timeseries "merge"
% and adds this timeseries to the LabView structure
%
%