forked from brandondube/AberrationSwissArmyKnife
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWPlotter.m
81 lines (71 loc) · 2.78 KB
/
WPlotter.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
classdef WPlotter
methods (Static = true)
function [] = plotSliceX(AberrationSwissArmyKnife)
%plots central horizontal slice of wavefront W
checkW(AberrationSwissArmyKnife);
plot(AberrationSwissArmyKnife.wAxis, AberrationSwissArmyKnife.wSliceX);
xlabel('Normalized Pupil Radius');
ylabel('OPD [\lambda]');
xlim([-1, 1]);
grid on
end
function [] = plotSliceY(AberrationSwissArmyKnife)
%plots central horizontal slice of wavefront W
checkW(AberrationSwissArmyKnife);
plot(AberrationSwissArmyKnife.wAxis, AberrationSwissArmyKnife.wSliceY);
xlabel('Normalized Pupil Radius');
ylabel('OPD [\lambda]');
xlim([-1, 1]);
grid on
end
function [fig, ax] = plotSliceXY(AberrationSwissArmyKnife)
%plots slice through both the X and Y axis of the pupil
checkW(AberrationSwissArmyKnife);
fig = figure;
hold on
plot(AberrationSwissArmyKnife.wAxis, AberrationSwissArmyKnife.wSliceX, '.-');
plot(AberrationSwissArmyKnife.wAxis, AberrationSwissArmyKnife.wSliceY, '.-');
xlabel('Normalized Pupil Radius');
ylabel('OPD [\lambda]');
xlim([-1 1]);
grid on
ax = gca;
end
function [fig, ax] = plot3D(AberrationSwissArmyKnife, plotType)
%plot 3D rendition of W.
if nargin < 2
plotType = 'surf';
end
checkW(AberrationSwissArmyKnife);
fig = figure;
axis square;
wAxis = AberrationSwissArmyKnife.wAxis;
[X, Y] = meshgrid(wAxis, wAxis');
paddingPixels = length(wAxis) / (AberrationSwissArmyKnife.padding - 1);
shift = ceil(paddingPixels / 2);
ext = size(X, 1);
plotX = X(shift : ext - shift, shift : ext - shift);
plotY = Y(shift : ext - shift, shift : ext - shift);
plotW = AberrationSwissArmyKnife.wPhase(shift : ext - shift, shift : ext - shift);
switch lower(plotType)
case 'mesh'
mesh(plotX, plotY, plotW);
case 'surf'
surf(plotX, plotY, plotW, 'EdgeColor', 'none');
end
xlim([-1, 1]);
ylim([-1, 1]);
view(0, 90);
xlabel('Normalized Pupil X');
ylabel('Normalized Pupil Y');
c = colorbar();
c.Label.String = 'OPD [\lambda]';
ax = gca;
end
end
end
function [] = checkW(AberrationSwissArmyKnife)
if (isempty(AberrationSwissArmyKnife.w))
AberrationSwissArmyKnife.buildPupil();
end
end