53 lines
2.2 KiB
Matlab
53 lines
2.2 KiB
Matlab
function DataTable = addSampleNotes(DataTable,fileNumber,notesToAdd,dataMonth,dataYear,tableSelection)
|
|
%addSampleNotes adds a sample description to the data
|
|
%
|
|
% FileList = addSampleNotes(FileList,44,'Ice with N2 and phenol in Ar (bad data)',2,2022);
|
|
%
|
|
% Input to this function are
|
|
%
|
|
% * the name of the data table,
|
|
% * the file numbers of the SES scans to which the info should be added
|
|
% * a text string describing the sample,
|
|
% * the month and the year that the data was aquired
|
|
% * optional: 'XPS' or 'NEXAFS' as last input argument to limit to either XPS data or NEXAFS
|
|
% data
|
|
|
|
% check if "sample" table variable (column) exist, if not add it
|
|
existColumn = strcmp('sample',DataTable.Properties.VariableNames);
|
|
if ~any(existColumn)
|
|
DataTable.sample = cellstr(repmat(' ',size(DataTable,1),1));
|
|
end
|
|
|
|
for ii = 1:length(fileNumber)
|
|
if ~exist('tableSelection','var')
|
|
% select the data
|
|
tmpMatch = (startsWith(DataTable.name, sprintf('%04.0f',fileNumber(ii)))) & ...
|
|
(month(DataTable.lastModifiedDatenum) == dataMonth) &...
|
|
(year(DataTable.lastModifiedDatenum) == dataYear);
|
|
else
|
|
if matches(tableSelection,'XPS')
|
|
% select the data
|
|
tmpMatch = (startsWith(DataTable.name, sprintf('%04.0f',fileNumber(ii)))) & ...
|
|
(month(DataTable.lastModifiedDatenum) == dataMonth) &...
|
|
(year(DataTable.lastModifiedDatenum) == dataYear) &...
|
|
(endsWith(DataTable.name, '.ibw'));
|
|
elseif matches(tableSelection,'NEXAFS')
|
|
% select the data
|
|
tmpMatch = (startsWith(DataTable.name, sprintf('%04.0f',fileNumber(ii)))) & ...
|
|
(month(DataTable.lastModifiedDatenum) == dataMonth) &...
|
|
(year(DataTable.lastModifiedDatenum) == dataYear)&...
|
|
(endsWith(DataTable.name, '.h5'));
|
|
end
|
|
end
|
|
% clear existing data (to prevent 2 entries per field)
|
|
existColumn = strcmp('sample',DataTable.Properties.VariableNames);
|
|
if any(existColumn)
|
|
if ~isempty(DataTable(tmpMatch,:).sample)
|
|
DataTable(tmpMatch,:).sample = cellstr(repmat(' ',size(DataTable(tmpMatch,:),1),1));
|
|
end
|
|
end
|
|
DataTable(tmpMatch,:).sample = cellstr(repmat(notesToAdd,size(DataTable(tmpMatch,:),1),1));
|
|
end
|
|
end
|
|
|