-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcallbackPlotPeaks.m
68 lines (54 loc) · 2.23 KB
/
callbackPlotPeaks.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function callbackPlotPeaks(obj, evt, ternHandles, specHandles)
%CALLBACKPLOTPEAKS plots the experimental XRD pattern and the reconstructed
%pattern from the peak identification algorithm. The user can use this to
%determine a good confidence factor.
set(ternHandles.buttonPlotPeaks, 'Callback', []);
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
fSpecPlot = specHandles.fSpecPlot;
specInfo = fSpecPlot.UserData;
xTernPoints = ternInfo.xCoords;
yTernPoints = ternInfo.yCoords;
XRDData = specInfo.XRDData;
confidenceFactor = ternHandles.editConfFactor.UserData;
figure(ternHandles.fTernDiagram);
[xSelect, ySelect] = ginput(1);
indexPoint = findNearestPoint(xSelect, ySelect, ...
ternInfo.numPoints, xTernPoints, yTernPoints);
hold on;
% outline selected point
if ishandle(ternInfo.pointOutline) == 1
delete(ternInfo.pointOutline);
end
ternInfo.pointOutline = scatter(xTernPoints(indexPoint), ...
yTernPoints(indexPoint), 'k');
angles = XRDData(:, indexPoint * 2 - 1);
intensity = XRDData(:, indexPoint * 2);
if angles(1) ~= 0
[~, ~, ~, ~, signal, ~, ~] = ...
findPeakXRD(angles, intensity, confidenceFactor);
if ishandle(ternInfo.fXRDPlot) == 1
figure(ternInfo.fXRDPlot);
clf;
else
ternInfo.fXRDPlot = figure;
set(gcf, 'color', 'w');
set(gcf, 'Name', 'XRD Plot and Reconstructed Pattern for Selected Point');
end
xrdPlotAxes = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
subplot(2, 1, 1, xrdPlotAxes);
plot(XRDData(:, indexPoint * 2 - 1), XRDData(:, indexPoint * 2));
xlabel('Angle');
ylabel('Intensity');
reconPlotAxes = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
subplot(2, 1, 2, reconPlotAxes);
plot(angles, signal);
xlabel('Angle (2\theta)');
ylabel('Intensity');
end
figTern.UserData = ternInfo;
fSpecPlot.UserData = specInfo;
set(ternHandles.buttonPlotPeaks, 'Callback', {@callbackPlotPeaks, ternHandles, specHandles});
end