Changed selection rule. Now works not only with numbers, but with any text. Character that the name starts with are used to find matches now.
This commit is contained in:
1 parent
43ac9c00bb
commit
d12594598e
1 file changed
+15
-14
+15
-14
@@ -36,6 +36,7 @@ arguments
|
||||
options.range (1,:) double {mustBePositive} =[ ];
|
||||
options.energyScale char {mustBeMember(options.energyScale, ...
|
||||
{'kinetic', 'binding'})} = 'kinetic'
|
||||
options.spectrumNumberPrefixLength double {mustBePositive, mustBeInteger} = 7
|
||||
end
|
||||
|
||||
|
||||
@@ -104,17 +105,17 @@ for i = 1:length(processIdx)
|
||||
bestRefRow = validRefs(minIdx);
|
||||
end
|
||||
case 'spectrumNumber'
|
||||
% Extract the 4-digit number at the start of the name (e.g., '0033')
|
||||
specNumStr = regexp(currName, '^\d{4}', 'match', 'once');
|
||||
if ~isempty(specNumStr)
|
||||
% Find references that start with 'XXXX_'
|
||||
searchPattern = [specNumStr, '_'];
|
||||
% Use the first N characters of the name as the matching prefix
|
||||
prefixLen = options.spectrumNumberPrefixLength;
|
||||
if length(currName) >= prefixLen
|
||||
searchPattern = currName(1:prefixLen);
|
||||
validRefs = refIdx(startsWith(DataTable.name(refIdx), searchPattern));
|
||||
if ~isempty(validRefs)
|
||||
bestRefRow = validRefs(1); % Take the first exact match
|
||||
bestRefRow = validRefs(1);
|
||||
end
|
||||
else
|
||||
warning('Row %d: Could not extract a 4-digit spectrum number from name "%s".', currRow, currName);
|
||||
warning('Row %d: Name "%s" is shorter than the requested prefix length (%d). Skipping.', ...
|
||||
currRow, currName, prefixLen);
|
||||
end
|
||||
|
||||
% Validate we found a match
|
||||
@@ -221,9 +222,9 @@ for i = 1:length(processIdx)
|
||||
else
|
||||
[normFactor, MaxIdx] = max(DataTable.(options.tableVariable){bestRefRow});
|
||||
if strcmpi(options.energyScale, 'kinetic')
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.scientaEkin_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.scientaEkin_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
else
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.bindingEnergy_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.bindingEnergy_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
end
|
||||
end
|
||||
|
||||
@@ -284,9 +285,9 @@ for i = 1:length(processIdx)
|
||||
else
|
||||
[normFactor, MaxIdx] = max(DataTable.(options.tableVariable){bestRefRow});
|
||||
if strcmpi(options.energyScale, 'kinetic')
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.scientaEkin_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.scientaEkin_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
else
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.bindingEnergy_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.bindingEnergy_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
end
|
||||
end
|
||||
if normFactor == 0, normFactor = 1; end % Protect against /0
|
||||
@@ -352,11 +353,11 @@ for i = 1:length(processIdx)
|
||||
|
||||
else
|
||||
[normFactor, MaxIdx] = max(DataTable.(options.tableVariable){bestRefRow});
|
||||
if strcmpi(options.energyScale, 'kinetic')
|
||||
if strcmpi(options.energyScale, 'kinetic')
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.scientaEkin_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
else
|
||||
else
|
||||
fprintf('Norming %s with %s at %.1f eV: %.1e\n', DataTable.name{currRow}, DataTable.name{bestRefRow}, DataTable.bindingEnergy_eV{bestRefRow}(MaxIdx),normFactor );
|
||||
end
|
||||
end
|
||||
end
|
||||
if normFactor == 0, normFactor = 1; end % Protect against /0
|
||||
DataTable.spectrum_countsNorm{currRow} = yData ./ normFactor;
|
||||
|
||||
Reference in new issue
Block a user