1 | function [Pyy, fy, Pyy_Int, FileName] = plotbpmpsd(FileName, LineColorInput, HoldFlag1) |
---|
2 | %PLOTBPMPSD - Plots data taken will getbpmpsd |
---|
3 | % [Pxx, f, PxxInt, FileName] = plotbpmpsd(FileName, LineType, HoldFlag) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. FileName - Filename or '' to browse |
---|
7 | % 2. LineType - Line type, like '-r' |
---|
8 | % 3. HoldFlag - 0 -> new plot |
---|
9 | % else -> hold last plot |
---|
10 | % |
---|
11 | % OUTPUTS |
---|
12 | % 1. Pxx - Power spectrum |
---|
13 | % 2. f - Frequency vector |
---|
14 | % 3. PxxInt - Cumulated integrated power spectrum |
---|
15 | % 4. FileName - Filename used |
---|
16 | % |
---|
17 | % Written by Greg Portmann |
---|
18 | |
---|
19 | |
---|
20 | if nargin < 1 |
---|
21 | FileName = []; |
---|
22 | end |
---|
23 | if nargin < 2 |
---|
24 | LineColorInput = 'b'; |
---|
25 | end |
---|
26 | if nargin < 3 |
---|
27 | HoldFlag1 = 0; |
---|
28 | end |
---|
29 | |
---|
30 | if isempty(FileName) |
---|
31 | [FileName, DirectoryName] = uigetfile('*.mat', 'Select a configuration file to load'); |
---|
32 | if FileName == 0 |
---|
33 | return |
---|
34 | else |
---|
35 | load([DirectoryName FileName]); |
---|
36 | end |
---|
37 | else |
---|
38 | load(FileName); |
---|
39 | end |
---|
40 | |
---|
41 | if exist('PxxAvg', 'var') |
---|
42 | Pxx = PxxAvg; |
---|
43 | Pyy = PyyAvg; |
---|
44 | Xrms = XAvgRMS; |
---|
45 | Yrms = YAvgRMS; |
---|
46 | end |
---|
47 | |
---|
48 | newList = editlist(DeviceList, 'BPM', zeros(size(DeviceList,1),1)); |
---|
49 | if isempty(newList) |
---|
50 | return |
---|
51 | end |
---|
52 | j = findrowindex(newList(1,:), DeviceList); |
---|
53 | |
---|
54 | if ~HoldFlag1 |
---|
55 | clf reset |
---|
56 | end |
---|
57 | |
---|
58 | subplot(2,2,1); |
---|
59 | if HoldFlag1 |
---|
60 | hold on; |
---|
61 | end |
---|
62 | NumFreqRemove = length(find(Pxx(j,:)==0)); |
---|
63 | loglog(fx(NumFreqRemove+1:end), 1e12*Pxx(j,NumFreqRemove+1:end), LineColorInput); |
---|
64 | if HoldFlag1 |
---|
65 | title(sprintf('BPMx POWER SPECTRUM (%d points)',length(fx))); |
---|
66 | else |
---|
67 | title(sprintf('BPMx(%d,%d) POWER SPECTRUM (%d points)',DeviceList(j,:),length(fx))); |
---|
68 | end |
---|
69 | xlabel('Frequency [Hz]'); |
---|
70 | ylabel('BPMx PSD [\mum^2/Hz]'); |
---|
71 | grid on; |
---|
72 | legend off; |
---|
73 | aa=axis; |
---|
74 | axis([1 fx(end) aa(3) aa(4)]); |
---|
75 | %axis([1 fx(end) 1e-3 10]); |
---|
76 | |
---|
77 | % Position spectrum |
---|
78 | subplot(2,2,3); |
---|
79 | if HoldFlag1 |
---|
80 | hold on; |
---|
81 | end |
---|
82 | semilogx(fx(NumFreqRemove:end), 1e12*Pxx_Int(j,NumFreqRemove:end), LineColorInput); |
---|
83 | if HoldFlag1 |
---|
84 | title(sprintf('BPMx Integrated PSD')); |
---|
85 | else |
---|
86 | title(sprintf('BPMx(%d,%d) Integrated PSD (RMS=%.1f \\mum)',DeviceList(j,:),1e6*Xrms(j))); |
---|
87 | end |
---|
88 | xlabel('Frequency [Hz]'); |
---|
89 | ylabel('Mean Square Displacement [\mum^2]'); |
---|
90 | grid on; |
---|
91 | legend off; |
---|
92 | aa=axis; |
---|
93 | axis([1 fx(end) aa(3) aa(4)]); |
---|
94 | |
---|
95 | subplot(2,2,2); |
---|
96 | if HoldFlag1 |
---|
97 | hold on; |
---|
98 | end |
---|
99 | loglog(fy(NumFreqRemove+1:end), 1e12*Pyy(j,NumFreqRemove+1:end), LineColorInput); |
---|
100 | if HoldFlag1 |
---|
101 | title(sprintf('BPMy POWER SPECTRUM (%d points)',length(fy))); |
---|
102 | else |
---|
103 | title(sprintf('BPMy(%d,%d) POWER SPECTRUM (%d points)',DeviceList(j,:),length(fy))); |
---|
104 | end |
---|
105 | xlabel('Frequency [Hz]'); |
---|
106 | ylabel('BPMy PSD [\mum^2/Hz]'); |
---|
107 | grid on; |
---|
108 | legend off; |
---|
109 | aa=axis; |
---|
110 | axis([1 fx(end) aa(3) aa(4)]); |
---|
111 | %axis([1 fx(end) 1e-3 10]); |
---|
112 | |
---|
113 | % Position spectrum |
---|
114 | subplot(2,2,4); |
---|
115 | if HoldFlag1 |
---|
116 | hold on; |
---|
117 | end |
---|
118 | semilogx(fy(NumFreqRemove:end), 1e12*Pyy_Int(j,NumFreqRemove:end), LineColorInput); |
---|
119 | if HoldFlag1 |
---|
120 | title(sprintf('BPMy Integrated PSD')); |
---|
121 | else |
---|
122 | title(sprintf('BPMy(%d,%d) Integrated PSD (RMS=%.1f \\mum)',DeviceList(j,:),1e6*Yrms(j))); |
---|
123 | addlabel(1,0,datestr(TimeStart)); |
---|
124 | end |
---|
125 | xlabel('Frequency [Hz]'); |
---|
126 | ylabel('Mean Square Displacement [\mum^2]'); |
---|
127 | grid on; |
---|
128 | legend off; |
---|
129 | aa=axis; |
---|
130 | axis([1 fx(end) aa(3) aa(4)]); |
---|
131 | |
---|