Started to include Speces lab XPS data. nappFileList, nappPlot, and peakFit should work
This commit is contained in:
1 parent
fa1323b96d
commit
2e5f3eaf1c
2 files changed
+304
-146
No files matched your search
+4
-4
@@ -336,14 +336,14 @@ if contains(p.Results.tableVariable,'spectrum')
|
||||
|
||||
% Create axes
|
||||
hold(gca,'on');
|
||||
if (contains(p.Results.energyScale,'kinetic') & endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw'))
|
||||
if (contains(p.Results.energyScale,'kinetic') & (endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw') | endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'xy')))
|
||||
hplot = plot(p.Results.DataTable(p.Results.tableSelection,:).scientaEkin_eV{ii},...
|
||||
p.Results.DataTable(p.Results.tableSelection,:).(p.Results.tableVariable){ii}');
|
||||
hplot.LineWidth = lw;
|
||||
hXLabel = xlabel('Electron kinetic energy [eV]');
|
||||
xlim([p.Results.DataTable(p.Results.tableSelection,:).scientaEkinRange_eV(ii,1) p.Results.DataTable(p.Results.tableSelection,:).scientaEkinRange_eV(ii,2)]);
|
||||
|
||||
elseif (contains(p.Results.energyScale,'binding') & endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw'))
|
||||
elseif (contains(p.Results.energyScale,'binding') & (endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw')| endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'xy')))
|
||||
hplot = plot(p.Results.DataTable(p.Results.tableSelection,:).bindingEnergy_eV{ii},...
|
||||
p.Results.DataTable(p.Results.tableSelection,:).(p.Results.tableVariable){ii}');
|
||||
hplot.LineWidth = lw;
|
||||
@@ -415,7 +415,7 @@ if contains(p.Results.tableVariable,'spectrum')
|
||||
% axes('Parent',gcf,'XDir','reverse')
|
||||
hold(gca,'on');
|
||||
for ii = 1:size(p.Results.DataTable(p.Results.tableSelection,:),1)
|
||||
if endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw')
|
||||
if (endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw') | endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'xy'))
|
||||
hplot = plot(p.Results.DataTable(p.Results.tableSelection,:).scientaEkin_eV{ii},...
|
||||
p.Results.DataTable(p.Results.tableSelection,:).(p.Results.tableVariable){ii}','DisplayName',p.Results.DataTable(p.Results.tableSelection,:).name{ii},'Color',tmp_color(ii,:));
|
||||
hplot.LineWidth = lw;
|
||||
@@ -427,7 +427,7 @@ if contains(p.Results.tableVariable,'spectrum')
|
||||
hold(gca,'on');
|
||||
|
||||
for ii = 1:size(p.Results.DataTable(p.Results.tableSelection,:),1)
|
||||
if endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw')
|
||||
if (endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'ibw') | endsWith(p.Results.DataTable(p.Results.tableSelection,:).name{ii},'xy'))
|
||||
hplot = plot(p.Results.DataTable(p.Results.tableSelection,:).bindingEnergy_eV{ii},...
|
||||
p.Results.DataTable(p.Results.tableSelection,:).(p.Results.tableVariable){ii}','DisplayName',p.Results.DataTable(p.Results.tableSelection,:).name{ii},'Color',tmp_color(ii,:));
|
||||
hplot.LineWidth = lw;
|
||||
|
||||
+300
-142
@@ -82,7 +82,7 @@ function ListFiles = nappFileList(dataPath,varargin)
|
||||
%% Input
|
||||
% Define conditions and defaults of input
|
||||
defaultMode = 'local';
|
||||
expectedMode = {'local','nappDrive','localNew','nappDrivePick','localPick'};
|
||||
expectedMode = {'local','nappDrive','dataDrive','localNew','nappDrivePick','localPick','dataPick'};
|
||||
defaultImportLabView = 'on';
|
||||
expectedImportLabView = {'on','off'};
|
||||
% Parse input
|
||||
@@ -116,8 +116,19 @@ elseif contains(p.Results.mode,'nappDrive')
|
||||
elseif ispc
|
||||
server = '\\fs03\';
|
||||
end
|
||||
elseif contains(p.Results.mode,'data')
|
||||
% Data server address
|
||||
if ismac
|
||||
server = '/Volumes/';
|
||||
elseif ispc
|
||||
server = '\\fs101\';
|
||||
end
|
||||
end
|
||||
if contains(p.Results.mode,'data')
|
||||
dataPath = fullfile(server,'5505','Data',dataPath);
|
||||
else
|
||||
dataPath = fullfile(server,'NAPP','SC Data',dataPath);
|
||||
end
|
||||
dataPath = fullfile(server,'NAPP','SC Data',dataPath);
|
||||
% Data Paths to subdirectories for specific files:
|
||||
dataPath_XPS = fullfile(dataPath, 'SES');
|
||||
dataPath_Photo = fullfile(dataPath, 'Photos');
|
||||
@@ -178,7 +189,7 @@ end
|
||||
if endsWith(p.Results.mode,'Pick')
|
||||
% select files (Xps or Nexafs, ignoring photos) to be imported from data directory
|
||||
% (data can be taken from any directory; files need to be in same directory)
|
||||
[filePick,pathPick] = uigetfile({'*.ibw;*.h5'},...
|
||||
[filePick,pathPick] = uigetfile({'*.ibw;*.h5';'*.xy'},...
|
||||
'Select One or More Files', dataPath,...
|
||||
'MultiSelect', 'on');
|
||||
% make lists for Nexafs and for XPS
|
||||
@@ -187,6 +198,7 @@ if endsWith(p.Results.mode,'Pick')
|
||||
end
|
||||
filePickXps = filePick(endsWith(filePick,'.ibw'));
|
||||
filePickNexafs = filePick(endsWith(filePick,'.h5'));
|
||||
filePickXY = filePick(endsWith(filePick,'.xy'));
|
||||
|
||||
if isempty(filePickXps)
|
||||
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.trallalla']);
|
||||
@@ -202,13 +214,26 @@ if endsWith(p.Results.mode,'Pick')
|
||||
TmpFileList{2}(ii,1) = dir([pathPick filePickNexafs{ii}]);
|
||||
end
|
||||
end
|
||||
% make a empty file list for photos, to be consitent with code
|
||||
if isempty(filePickXY)
|
||||
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.trallalla']);
|
||||
else
|
||||
for ii = 1:size(filePickXps,2)
|
||||
TmpFileList{1}(ii,1) = dir([pathPick filePickXps{ii}]);
|
||||
end
|
||||
end
|
||||
% make a empty file list for photos, to be consitent
|
||||
TmpFileList{3} = dir([dataPath_Photo filesep '**' filesep '*.trallalla']);
|
||||
else
|
||||
|
||||
% SES files in IGOR format list all files, then get rid of system files
|
||||
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.ibw']);
|
||||
TmpFileList{1} = TmpFileList{1}(find(~cellfun(@isempty,regexp({TmpFileList{1}.name},'^[a-zA-Z0-9]\w*')))); %#ok<FNDSB>
|
||||
% SES files in IGOR format or SpecsLab in .xy format: list all files, then get rid of system files
|
||||
if contains(p.Results.mode,'data')
|
||||
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.xy']);
|
||||
TmpFileList{1} = TmpFileList{1}(find(~cellfun(@isempty,regexp({TmpFileList{1}.name},'^[a-zA-Z0-9]\w*')))); %#ok<FNDSB>
|
||||
else
|
||||
TmpFileList{1} = dir([dataPath_XPS filesep '**' filesep '*.ibw']);
|
||||
TmpFileList{1} = TmpFileList{1}(find(~cellfun(@isempty,regexp({TmpFileList{1}.name},'^[a-zA-Z0-9]\w*')))); %#ok<FNDSB>
|
||||
end
|
||||
|
||||
% EPICS files in h5 format list all files, then get rid of system files
|
||||
TmpFileList{2} = dir([dataPath_NEXAFS filesep '**' filesep '*.h5']);
|
||||
TmpFileList{2} = TmpFileList{2}(find(~cellfun(@isempty,regexp({TmpFileList{2}.name},'^[a-zA-Z0-9]\w*')))); %#ok<FNDSB>
|
||||
@@ -221,7 +246,11 @@ else
|
||||
|
||||
% only process new files
|
||||
if (istable(p.Results.DataTable) & matches(p.Results.mode,'localNew')) % do this only if previous list was input to function call
|
||||
tmpXpsFiles = endsWith(p.Results.DataTable.name,'.ibw'); % get XPS files in current data table
|
||||
tmpXpsFiles = endsWith(p.Results.DataTable.name,'.ibw'); % get Scienta XPS files in current data table
|
||||
tmpMissingFiles = ~ismember({TmpFileList{1}(:).name},p.Results.DataTable.name(tmpXpsFiles,:)); % find those files that are yet imported
|
||||
TmpFileList{1} = TmpFileList{1}(tmpMissingFiles);
|
||||
|
||||
tmpXpsFiles = endsWith(p.Results.DataTable.name,'.xy'); % get Specs XPS files in current data table
|
||||
tmpMissingFiles = ~ismember({TmpFileList{1}(:).name},p.Results.DataTable.name(tmpXpsFiles,:)); % find those files that are yet imported
|
||||
TmpFileList{1} = TmpFileList{1}(tmpMissingFiles);
|
||||
|
||||
@@ -238,8 +267,12 @@ end
|
||||
|
||||
|
||||
|
||||
% get date of last and first .ibw file in folder .
|
||||
tmp.fileinfo = dir([dataPath_XPS '/*.ibw']);
|
||||
% get date of first .ibw or .xy file in folder .
|
||||
if contains(p.Results.mode,'data')
|
||||
tmp.fileinfo = dir([dataPath_XPS '/*.xy']);
|
||||
else
|
||||
tmp.fileinfo = dir([dataPath_XPS '/*.ibw']);
|
||||
end
|
||||
if isempty(tmp.fileinfo)
|
||||
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.')
|
||||
@@ -248,11 +281,19 @@ if isempty(tmp.fileinfo)
|
||||
end
|
||||
|
||||
try
|
||||
if contains(p.Results.mode,'data')
|
||||
tmp.fileinfo = dir([dataPath_XPS '/*.xy']);
|
||||
filedate_first = tmp.fileinfo(1).datenum;
|
||||
clearvars name tmp
|
||||
else
|
||||
tmp.fileinfo = dir([dataPath_XPS '/*.ibw']);
|
||||
filedate_first = tmp.fileinfo(1).datenum;
|
||||
clearvars name tmp
|
||||
catch
|
||||
disp('Error getting ibw file date.')
|
||||
end
|
||||
catch
|
||||
warning('There appears to be something wrong with the SES or Specs file.')
|
||||
disp('There appears to be something wrong with the SES or Specs file.')
|
||||
|
||||
end
|
||||
|
||||
%% Import XPS data to get SES settings
|
||||
@@ -268,125 +309,242 @@ end
|
||||
% are damaged, or not complete (because measurement was aborted) to
|
||||
% "ignore_filename".
|
||||
|
||||
for ii = 1:size(TmpFileList{1},1) % cycle through each XPS file
|
||||
if contains(p.Results.mode,'data') % for Specs xy data %TODO this is based on file location, needs work!!!!
|
||||
for ii = 1:size(TmpFileList{1},1) % cycle through each XPS file
|
||||
|
||||
|
||||
try
|
||||
PE = IBWread([TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name]); % read XPS file
|
||||
catch
|
||||
warning('Problem reading the Igor file')
|
||||
disp('Problem reading the Igor file')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
fclose('all');
|
||||
|
||||
try
|
||||
%% Convert SES meta data into variables
|
||||
%
|
||||
% Upon import, all meta data are written into _WaveNotes_ variable.
|
||||
% Here, I select the meta data for each setting and write those
|
||||
% into individual variables that are then added to the list.
|
||||
|
||||
% Split the WaveNotes text string into individual strings at each line break.
|
||||
% (This is a work-around. Did not manage to select values with regexp
|
||||
% function only.)
|
||||
tmp = regexp(PE.WaveNotes, '\r', 'split');
|
||||
% Then, read out the values into variables using a combination of string operations:
|
||||
|
||||
% Start date/time of measurement
|
||||
PE.creationDate = datevec([char(regexp(tmp{29},'((?<=Date=).*)','match')) ...
|
||||
' ' char(regexp(tmp{30},'((?<=Time=).*)','match'))]);
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(char(regexp(tmp{5},'((?<=Pass Energy=).*)','match')));
|
||||
% Dwell time (or step time)
|
||||
PE.dwellTime = str2double(char(regexp(tmp{15},'((?<=Step Time=).*)','match')));
|
||||
% Energy step
|
||||
PE.scientaEkinStep = str2double(char(regexp(tmp{14},'((?<=Energy Step=).*)','match')));
|
||||
% Region name
|
||||
PE.regionName = char(regexp(tmp{3},'((?<=Region Name=).*)','match'));
|
||||
% Acquisition Mode
|
||||
PE.acquisitionMode = char(regexp(tmp{9},'((?<=Acquisition Mode=).*)','match'));
|
||||
|
||||
% kinetic energy
|
||||
for n = 1:size(PE.y,1)
|
||||
PE.x(n)= PE.x0(1) + (n-1)*PE.dx(1);
|
||||
end
|
||||
% lens mode
|
||||
PE.lensMode = char(regexp(tmp{4},'((?<=Lens Mode=).*)','match'));
|
||||
% define iterations
|
||||
%
|
||||
% There is a BUG in this code. The SES file apparently has the same
|
||||
% structure for 1 seq. iteration and several reg. iterations and
|
||||
% several seq. iterations and 1 region iteration.
|
||||
if PE.Ndim == 3
|
||||
PE.regionIterations = size(PE.y,2);
|
||||
PE.sequenceIterations = size(PE.y,3);
|
||||
elseif PE.Ndim == 2
|
||||
PE.regionIterations = 1;
|
||||
PE.sequenceIterations = size(PE.y,2);
|
||||
else
|
||||
PE.regionIterations = 1;
|
||||
PE.sequenceIterations = size(PE.y,2);
|
||||
end
|
||||
|
||||
% average region iterations
|
||||
if PE.Ndim == 3
|
||||
PE.y = squeeze(mean(PE.y,2));
|
||||
elseif PE.Ndim == 2
|
||||
% PE.y = squeeze(mean(PE.y,2));
|
||||
|
||||
end
|
||||
% normalise data to 1ms
|
||||
PE.y = PE.y .* 1000 ./ PE.dwellTime;
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(char(regexp(tmp{5},'((?<=Pass Energy=).*)','match')));
|
||||
catch
|
||||
warning('Problem reading the PE variable')
|
||||
disp('Problem reading the PE variable')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
|
||||
%% Write SES meta data variables into XPS FileList structure
|
||||
|
||||
try
|
||||
TmpFileList{1}(ii).creationDate = PE.creationDate;
|
||||
TmpFileList{1}(ii).image = PE.y;
|
||||
TmpFileList{1}(ii).spectrum_counts = NaN;
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecond = NaN;
|
||||
TmpFileList{1}(ii).xRayEkin_eV = NaN;
|
||||
TmpFileList{1}(ii).xRayEkinRange_eV = [NaN NaN];
|
||||
% SES pass energy
|
||||
TmpFileList{1}(ii).scientaPassEnergy_eV = PE.passEnergy; % in eV
|
||||
% SES dwell time
|
||||
TmpFileList{1}(ii).scientaDwellTime_ms = PE.dwellTime; % in ms
|
||||
% SES region Name
|
||||
TmpFileList{1}(ii).regionName = PE.regionName;
|
||||
TmpFileList{1}(ii).scientaAcquisitionMode = PE.acquisitionMode;
|
||||
% SES kinetic energy window
|
||||
TmpFileList{1}(ii).scientaEkinRange_eV = [PE.x(1) PE.x(end)];
|
||||
TmpFileList{1}(ii).scientaEkinStep_eV = PE.scientaEkinStep;
|
||||
TmpFileList{1}(ii).scientaEkin_eV = PE.x;
|
||||
% Beamline Intensity (I0 during NEXAFS)
|
||||
TmpFileList{1}(ii).beamlineInt = cell(1);
|
||||
% SES lens mode
|
||||
TmpFileList{1}(ii).scientaLensMode = PE.lensMode;
|
||||
TmpFileList{1}(ii).scientaRegionIterations = PE.regionIterations;
|
||||
TmpFileList{1}(ii).scientaSequenceIterations = PE.sequenceIterations;
|
||||
TmpFileList{1}(ii).imageRoh = PE.y;
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecondRoh = NaN;
|
||||
TmpFileList{1}(ii).importDate = datestr(now);
|
||||
try
|
||||
TmpFileList{1}(ii).analysisDir = file.mFile;
|
||||
%data
|
||||
[fid,~] = fopen([TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name],'rt');
|
||||
tmpSpecsData = textscan(fid,'%f%f','Delimiter', '\b', 'CommentStyle','#'); % this reads the data; comment lines are ignored
|
||||
fclose(fid);
|
||||
% comments
|
||||
opts = delimitedTextImportOptions("NumVariables", 1);
|
||||
% Specify range and delimiter
|
||||
opts.DataLines = [1, 45];
|
||||
opts.Delimiter = "\t";
|
||||
% Specify column names and types
|
||||
opts.VariableNames = "metaData";
|
||||
opts.VariableTypes = "char";
|
||||
% Specify file level properties
|
||||
opts.ExtraColumnsRule = "ignore";
|
||||
opts.EmptyLineRule = "skip";
|
||||
opts.ConsecutiveDelimitersRule = "join";
|
||||
% Specify variable properties
|
||||
opts = setvaropts(opts, "metaData", "WhitespaceRule", "preserve");
|
||||
opts = setvaropts(opts, "metaData", "EmptyFieldRule", "auto");
|
||||
tmpSpecsComments = readtable([TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name],opts);
|
||||
|
||||
|
||||
catch
|
||||
TmpFileList{1}(ii).analysisDir = pwd;
|
||||
warning('Problem reading the Specs file')
|
||||
disp('Problem reading the Specs file')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
|
||||
|
||||
|
||||
try
|
||||
%% Convert Specs meta data into variables
|
||||
|
||||
% data
|
||||
tmpEndFirstSpectrum = find(diff(tmpSpecsData{1})<0,1); % FIXME: imports only first spectrum
|
||||
% counts/s
|
||||
PE.y = tmpSpecsData{2}(1:tmpEndFirstSpectrum);
|
||||
% kinetic energy
|
||||
PE.x = tmpSpecsData{1}(1:tmpEndFirstSpectrum);
|
||||
% RayEnergy
|
||||
PE.xRayEkin_eV{:} = str2double(extractAfter(tmpSpecsComments(29,:).metaData{:},"# Excitation Energy:"));
|
||||
PE.xRayEkinRange_eV =[ PE.xRayEkin_eV{1} PE.xRayEkin_eV{end}];
|
||||
% Start date/time of measurement
|
||||
PE.creationDate = extractBetween(char(tmpSpecsComments(20,:).metaData{:}),"# Acquisition Date:","UTC");
|
||||
PE.creationDate = datetime(PE.creationDate,'InputFormat','MM/dd/yy HH:mm:ss','PivotYear',2000,'TimeZone','UTC');
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(extractAfter(tmpSpecsComments(31,:).metaData{:},"# Pass Energy:"));
|
||||
% Dwell time (or step time)
|
||||
PE.dwellTime = str2double(extractAfter(tmpSpecsComments(28,:).metaData{:},"# Dwell Time: "));
|
||||
% Energy step
|
||||
tmpEnergyStep = diff(PE.x);
|
||||
PE.scientaEkinStep = tmpEnergyStep(1);
|
||||
if range(tmpEnergyStep) ~= 0
|
||||
disp("Ups something wrong with the energy steps")
|
||||
end
|
||||
% Region name
|
||||
PE.regionName = strtrim(extractAfter(tmpSpecsComments(18,:).metaData{:},"# Region:"));
|
||||
% Acquisition Mode
|
||||
PE.acquisitionMode = strtrim(extractAfter(tmpSpecsComments(25,:).metaData{:},"# Scan Mode:"));
|
||||
PE.regionIterations = str2double(extractAfter(tmpSpecsComments(39,:).metaData{:},"# Number of Scans:"));
|
||||
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(extractAfter(tmpSpecsComments(31,:).metaData{:},"# Pass Energy:"));
|
||||
catch
|
||||
warning('Problem reading the PE variable')
|
||||
disp('Problem reading the PE variable')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
|
||||
%% Write SES meta data variables into XPS FileList structure
|
||||
|
||||
try
|
||||
TmpFileList{1}(ii).creationDate = datevec(PE.creationDate);
|
||||
TmpFileList{1}(ii).image = {NaN};
|
||||
TmpFileList{1}(ii).spectrum_counts = NaN;
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecond = PE.y;
|
||||
TmpFileList{1}(ii).xRayEkin_eV = PE.xRayEkin_eV;
|
||||
TmpFileList{1}(ii).xRayEkinRange_eV = PE.xRayEkinRange_eV;
|
||||
% SES pass energy
|
||||
TmpFileList{1}(ii).scientaPassEnergy_eV = PE.passEnergy; % in eV
|
||||
% SES dwell time
|
||||
TmpFileList{1}(ii).scientaDwellTime_ms = PE.dwellTime; % in ms
|
||||
% SES region Name
|
||||
TmpFileList{1}(ii).regionName = PE.regionName;
|
||||
TmpFileList{1}(ii).scientaAcquisitionMode = PE.acquisitionMode;
|
||||
% SES kinetic energy window
|
||||
TmpFileList{1}(ii).scientaEkinRange_eV = [PE.x(1) PE.x(end)];
|
||||
TmpFileList{1}(ii).scientaEkinStep_eV = PE.scientaEkinStep;
|
||||
TmpFileList{1}(ii).scientaEkin_eV = PE.x;
|
||||
% Beamline Intensity (I0 during NEXAFS)
|
||||
TmpFileList{1}(ii).beamlineInt = cell(1);
|
||||
% SES lens mode
|
||||
TmpFileList{1}(ii).scientaLensMode = {' '};
|
||||
TmpFileList{1}(ii).scientaRegionIterations = PE.regionIterations;
|
||||
TmpFileList{1}(ii).scientaSequenceIterations = NaN;
|
||||
TmpFileList{1}(ii).imageRoh = {NaN};
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecondRoh = PE.y;
|
||||
TmpFileList{1}(ii).importDate = datestr(now);
|
||||
try
|
||||
TmpFileList{1}(ii).analysisDir = file.mFile;
|
||||
catch
|
||||
TmpFileList{1}(ii).analysisDir = pwd;
|
||||
end
|
||||
catch
|
||||
warning('Problem with a XPS data file for XPS list')
|
||||
disp('Problem with a XPS data file for XPS list')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{1}(ii).datenum))
|
||||
end
|
||||
catch
|
||||
warning('Problem with a XPS data file for XPS list')
|
||||
disp('Problem with a XPS data file for XPS list')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{1}(ii).datenum))
|
||||
end
|
||||
|
||||
else % for Scienta igor data
|
||||
for ii = 1:size(TmpFileList{1},1) % cycle through each XPS file
|
||||
|
||||
|
||||
try
|
||||
PE = IBWread([TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name]); % read XPS file
|
||||
catch
|
||||
warning('Problem reading the Igor file')
|
||||
disp('Problem reading the Igor file')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
fclose('all');
|
||||
|
||||
try
|
||||
%% Convert SES meta data into variables
|
||||
%
|
||||
% Upon import, all meta data are written into _WaveNotes_ variable.
|
||||
% Here, I select the meta data for each setting and write those
|
||||
% into individual variables that are then added to the list.
|
||||
|
||||
% Split the WaveNotes text string into individual strings at each line break.
|
||||
% (This is a work-around. Did not manage to select values with regexp
|
||||
% function only.)
|
||||
tmp = regexp(PE.WaveNotes, '\r', 'split');
|
||||
% Then, read out the values into variables using a combination of string operations:
|
||||
|
||||
% Start date/time of measurement
|
||||
PE.creationDate = datevec([char(regexp(tmp{29},'((?<=Date=).*)','match')) ...
|
||||
' ' char(regexp(tmp{30},'((?<=Time=).*)','match'))]);
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(char(regexp(tmp{5},'((?<=Pass Energy=).*)','match')));
|
||||
% Dwell time (or step time)
|
||||
PE.dwellTime = str2double(char(regexp(tmp{15},'((?<=Step Time=).*)','match')));
|
||||
% Energy step
|
||||
PE.scientaEkinStep = str2double(char(regexp(tmp{14},'((?<=Energy Step=).*)','match')));
|
||||
% Region name
|
||||
PE.regionName = char(regexp(tmp{3},'((?<=Region Name=).*)','match'));
|
||||
% Acquisition Mode
|
||||
PE.acquisitionMode = char(regexp(tmp{9},'((?<=Acquisition Mode=).*)','match'));
|
||||
|
||||
% kinetic energy
|
||||
for n = 1:size(PE.y,1)
|
||||
PE.x(n)= PE.x0(1) + (n-1)*PE.dx(1);
|
||||
end
|
||||
% lens mode
|
||||
PE.lensMode = char(regexp(tmp{4},'((?<=Lens Mode=).*)','match'));
|
||||
% define iterations
|
||||
%
|
||||
% There is a BUG in this code. The SES file apparently has the same
|
||||
% structure for 1 seq. iteration and several reg. iterations and
|
||||
% several seq. iterations and 1 region iteration.
|
||||
if PE.Ndim == 3
|
||||
PE.regionIterations = size(PE.y,2);
|
||||
PE.sequenceIterations = size(PE.y,3);
|
||||
elseif PE.Ndim == 2
|
||||
PE.regionIterations = 1;
|
||||
PE.sequenceIterations = size(PE.y,2);
|
||||
else
|
||||
PE.regionIterations = 1;
|
||||
PE.sequenceIterations = size(PE.y,2);
|
||||
end
|
||||
|
||||
% average region iterations
|
||||
if PE.Ndim == 3
|
||||
PE.y = squeeze(mean(PE.y,2));
|
||||
elseif PE.Ndim == 2
|
||||
% PE.y = squeeze(mean(PE.y,2));
|
||||
|
||||
end
|
||||
% normalise data to 1ms
|
||||
PE.y = PE.y .* 1000 ./ PE.dwellTime;
|
||||
% Pass energy
|
||||
PE.passEnergy = str2double(char(regexp(tmp{5},'((?<=Pass Energy=).*)','match')));
|
||||
catch
|
||||
warning('Problem reading the PE variable')
|
||||
disp('Problem reading the PE variable')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
end
|
||||
|
||||
%% Write SES meta data variables into XPS FileList structure
|
||||
|
||||
try
|
||||
TmpFileList{1}(ii).creationDate = PE.creationDate;
|
||||
TmpFileList{1}(ii).image = PE.y;
|
||||
TmpFileList{1}(ii).spectrum_counts = NaN;
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecond = NaN;
|
||||
TmpFileList{1}(ii).xRayEkin_eV = NaN;
|
||||
TmpFileList{1}(ii).xRayEkinRange_eV = [NaN NaN];
|
||||
% SES pass energy
|
||||
TmpFileList{1}(ii).scientaPassEnergy_eV = PE.passEnergy; % in eV
|
||||
% SES dwell time
|
||||
TmpFileList{1}(ii).scientaDwellTime_ms = PE.dwellTime; % in ms
|
||||
% SES region Name
|
||||
TmpFileList{1}(ii).regionName = PE.regionName;
|
||||
TmpFileList{1}(ii).scientaAcquisitionMode = PE.acquisitionMode;
|
||||
% SES kinetic energy window
|
||||
TmpFileList{1}(ii).scientaEkinRange_eV = [PE.x(1) PE.x(end)];
|
||||
TmpFileList{1}(ii).scientaEkinStep_eV = PE.scientaEkinStep;
|
||||
TmpFileList{1}(ii).scientaEkin_eV = PE.x;
|
||||
% Beamline Intensity (I0 during NEXAFS)
|
||||
TmpFileList{1}(ii).beamlineInt = cell(1);
|
||||
% SES lens mode
|
||||
TmpFileList{1}(ii).scientaLensMode = PE.lensMode;
|
||||
TmpFileList{1}(ii).scientaRegionIterations = PE.regionIterations;
|
||||
TmpFileList{1}(ii).scientaSequenceIterations = PE.sequenceIterations;
|
||||
TmpFileList{1}(ii).imageRoh = PE.y;
|
||||
TmpFileList{1}(ii).spectrum_countsPerSecondRoh = NaN;
|
||||
TmpFileList{1}(ii).importDate = datestr(now);
|
||||
try
|
||||
TmpFileList{1}(ii).analysisDir = file.mFile;
|
||||
catch
|
||||
TmpFileList{1}(ii).analysisDir = pwd;
|
||||
end
|
||||
catch
|
||||
warning('Problem with a XPS data file for XPS list')
|
||||
disp('Problem with a XPS data file for XPS list')
|
||||
fprintf('Number %.0f: %s \n',ii,[TmpFileList{1}(ii).folder filesep TmpFileList{1}(ii).name])
|
||||
fprintf('Number %.0f: %s \n',ii,datestr(TmpFileList{1}(ii).datenum))
|
||||
end
|
||||
end
|
||||
end
|
||||
disp('*************************************************')
|
||||
disp('* Voila: Done reading & writing XPS data! *')
|
||||
@@ -420,8 +578,8 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
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;
|
||||
@@ -493,12 +651,12 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
TmpFileList{2}(ii).scientaAcquisitionMode = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/scan 1/attrs/AcquisitionMode');
|
||||
catch
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/AcquireMode');
|
||||
if tmp(1) == 0
|
||||
if tmp(1) == 0
|
||||
TmpFileList{2}(ii).scientaAcquisitionMode = "Swept";
|
||||
elseif tmp(1) == 1
|
||||
TmpFileList{2}(ii).scientaAcquisitionMode = "Fixed";
|
||||
end
|
||||
clear tmp
|
||||
TmpFileList{2}(ii).scientaAcquisitionMode = "Fixed";
|
||||
end
|
||||
clear tmp
|
||||
end
|
||||
|
||||
if strcmp(TmpFileList{2}(ii).scientaAcquisitionMode,'Fixed')
|
||||
@@ -508,10 +666,10 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
catch
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/CenterEnergy'); % in eV
|
||||
end
|
||||
|
||||
TmpFileList{2}(ii).scientaEkinRange_eV = [double(tmp(1))-TmpFileList{2}(ii).scientaPassEnergy_eV/20 double(tmp(1))+TmpFileList{2}(ii).scientaPassEnergy_eV/20];
|
||||
|
||||
|
||||
|
||||
TmpFileList{2}(ii).scientaEkinRange_eV = [double(tmp(1))-TmpFileList{2}(ii).scientaPassEnergy_eV/20 double(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))';
|
||||
@@ -534,7 +692,7 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
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
|
||||
@@ -542,8 +700,8 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
catch
|
||||
end
|
||||
try
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/RM2I0');
|
||||
catch
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/RM2I0');
|
||||
catch
|
||||
end
|
||||
|
||||
try
|
||||
@@ -562,16 +720,16 @@ for ii = 1:size(TmpFileList{2},1) % do this for each list element
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/LensMode');
|
||||
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
|
||||
try
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/NumIterations');
|
||||
TmpFileList{2}(ii).scientaRegionIterations = double(tmp(1));
|
||||
tmp = h5read([TmpFileList{2}(ii).folder filesep TmpFileList{2}(ii).name],'/entry/instrument/NDAttributes/NumIterations');
|
||||
TmpFileList{2}(ii).scientaRegionIterations = double(tmp(1));
|
||||
catch
|
||||
TmpFileList{2}(ii).scientaRegionIterations = 1;
|
||||
TmpFileList{2}(ii).scientaRegionIterations = 1;
|
||||
end
|
||||
end
|
||||
TmpFileList{2}(ii).scientaSequenceIterations = 1;
|
||||
@@ -899,7 +1057,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)
|
||||
|
||||
Reference in new issue
Block a user