-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotTSwin.m
More file actions
352 lines (351 loc) · 15.3 KB
/
plotTSwin.m
File metadata and controls
352 lines (351 loc) · 15.3 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
function [hTSw,TSw] = plotTSwin(TSd,plotStart)
% initialize plotting window
% Usage: [hTSw,TSw] = plotTSwin(TSd,plotStart)
hTSw = figure('Interruptible','on','Position',plotStart.rect,...
'menubar','none','numbertitle','off');
plotParams % Colors: bgc,bgc2,fgc Frame: ixf,iyf,xframe,yframe
% TS plots: plots
dtsp=(1-xframe)*0.1;
zbarpos=[ plotpos(1) 0.97 plotpos(3) 0.02]; % was [0.4 0.97 0.55 0.02]
% Axis Scaling on upper menu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hTaxis = uimenu('Parent',hTSw,'Label','Axis Scaling/Centering');
uimenu(hTaxis,'Label','Relative to Start ',...
'checked','off','Tag','t0','Callback','plotTScbk',...
'UserData',0);
hTunits = uimenu(hTaxis,'Label','Time Units',...
'Tag','Time units');
uimenu(hTunits,'Label','Seconds',...
'checked','off','Tag','tUnits','callback','plotTScbk',...
'UserData',1);
uimenu(hTunits,'Label','Minutes',...
'checked','off','Tag','tUnits','callback','plotTScbk',...
'UserData',60);
uimenu(hTunits,'Label','Hours',...
'checked','off','Tag','tUnits','callback','plotTScbk',...
'UserData',3600);
uimenu(hTunits,'Label','Days',...
'checked','off','Tag','tUnits','callback','plotTScbk',...
'UserData',86400);
hYunits = uimenu(hTaxis,'Label','Y axes factor',...
'Tag','Y units');
uimenu(hYunits,'Label','.001',...
'checked','off','Tag','yUnits','callback','plotTScbk',...
'UserData',.001);
uimenu(hYunits,'Label','1',...
'checked','off','Tag','yUnits','callback','plotTScbk',...
'UserData',1);
uimenu(hYunits,'Label','10',...
'checked','off','Tag','yUnits','callback','plotTScbk',...
'UserData',10);
uimenu(hYunits,'Label','1000',...
'checked','off','Tag','yUnits','callback','plotTScbk',...
'UserData',1000);
uimenu(hTaxis,'Label','Set unif. y limit',...
'Tag','Uniform ylim','Callback','plotTScbk');
uimenu(hTaxis,'label','Centered ','Tag','Centered',...
'checked','on','CallBack','plotTScbk');
uimenu(hTaxis,'label','Save Y limits ','Tag','Save Y Limits',...
'checked','off','CallBack','plotTScbk');
uimenu(hTaxis,'label','Load Y limits ','Tag','Load Y Limits',...
'checked','off','CallBack','plotTScbk');
% end of Axis Scaling/Centering %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Mark Data Segments Menu (now on UPPER menu)
hMDS= uimenu(hTSw,'Label','Mark Data Segments');
uimenu(hMDS,'label','Mark data ','Tag','Mark','Callback','plotTScbk');
uimenu(hMDS,'label','Unmark data ','Tag','Unmark','Callback','plotTScbk');
uimenu(hMDS,'label','Zoom plot ','Tag','Zoom plot','Callback','plotTScbk');
uimenu(hMDS,'label','Clear marks ','Tag','Clear marks','Callback','plotTScbk');
uimenu(hMDS,'label','Load bad record','Tag','Load bad rec','Callback','plotTScbk');
uimenu(hMDS,'label','Save bad record','Tag','Save bad rec','Callback','plotTScbk');
% uimenu(hMDS,'label','Reprocess data ','Tag','Reprocess','Callback','plotTScbk');
hMask = axes('Position',zbarpos,'Ytick',[],'Xtick',[]); % keep for now
% get rid of later
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Coherence on Upper Menu
hTaxis = uimenu('Parent',hTSw,'Label','Spectra');
uimenu(hTaxis,'Label','Plot Coherence',...
'checked','off','Tag','McohPlot','Callback','plotTScbk',...
'UserData',0);
uimenu(hTaxis,'Label','Plot Spectrum',...
'checked','off','Tag','SpecPlot','Callback','plotTScbk',...
'UserData',0);
% end of Coherence %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MCH = zeros(TSd.nch,1);
mCH = zeros(TSd.nch,1);
i0 = plotStart.i0;
di = plotStart.di;
tUnits = plotStart.tUnits;
tFac = plotStart.tFac;
eval(['set(findobj(' '''Label''' ',tUnits),' '''checked''' ',' '''on''' ')'])
t0Eq0 = plotStart.t0Eq0;
if(t0Eq0)
set(findobj('Tag','t0'),'checked','on')
end
T12 = plotStart.T12;
yFac = plotStart.yFac;
eval(['set(findobj(' '''Label''' ',num2str(yFac)),' '''checked''' ',' '''on''' ')'])
nPw = plotStart.nPw;
chPlt = ones(TSd.nch,1);
chPltOld = ones(TSd.nch,1);
centered = plotStart.centered;
if centered==0, set(findobj('Tag','Centered'),'checked','off');end
page = plotStart.page;
npage = ceil(TSd.npts/nPw);
nch = TSd.nch;
% YL is range NOW on right side of plots
for ic = 1:nch
YLch(ic,1) = (1-centered) * mean(TSd.range(ic,1:2));
YLch(ic,2) = (TSd.range(ic,2)-TSd.range(ic,1))/2;
if(TSd.SysTF.PhysU)
YLch(ic,2) = YLch(ic,2)*TSd.range(ic,3);
end
end
YL = [YLch(:,2)-YLch(:,1) YLch(:,2)+YLch(:,1)];
YL = mkshort(YL);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ACh = zeros(nch,1);
PCh = zeros(nch,1);
SChM = zeros(nch,1);
SChP = zeros(nch,1);
%%%%%%%%%%%%%%%%%%% double frame for control panel %%%%%%%%%%%%%%%%%%%%%%%%%%%
uicontrol(hTSw,'Style','frame','Units','normalized',...
'Position',[ixf iyf xframe yframe],...
'BackgroundColor',bgc);
dwin=min(0.02*xframe,0.02*yframe);
uicontrol(hTSw,'Style','frame','Units','normalized',...
'Position',[ixf+dwin iyf+dwin xframe-2*dwin yframe-2*dwin],...
'BackgroundColor',bgc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% UPPER BOTTONS, 3 fields %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ubn=3;
ubdwin=max(0.5*dwin,0.002);
ubwidth = (xframe-2*dwin-(ubn+1)*ubdwin)/ubn;
ubheight= max(0.05,0.05*yframe);
ubxpos=ixf+dwin+ubdwin;
ubypos=iyf+yframe-2*dwin-ubdwin-ubheight;
din=0.002;
% #Pts frame
uicontrol(hTSw,'Style','frame','Units','normalized',...
'Position',[ubxpos ubypos 2*ubwidth+ubdwin ubheight],...
'BackgroundColor',bgc);
% #Pts text
uicontrol(hTSw,'Style','text','String','# Pts',...
'Units','normalized','Position',...
[ubxpos+din ubypos+din ubwidth ubheight-2*din],...
'HorizontalAlignment','Center',...
'FontUnits','normalized',...
'FontSize',.5,...
'FontWeight','demi',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:));
% #Pts edit
ubxpos=ubxpos+ubwidth+ubdwin;
NPtWin = uicontrol(hTSw,'Style','edit',...
'String',num2str(nPw),...
'Tag','chnumpt',...
'Units','normalized',...
'Position',[ubxpos+din ubypos+din ubwidth-2*din ubheight-2*din],...
'FontUnits','normalized',...
'FontSize',.5,...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:),...
'Callback','plotTScbk');
% Replot
ubxpos=ubxpos+ubwidth+ubdwin;
uicontrol(hTSw,'Style','Pushbutton',...
'Units','normalized',...
'Position',[ubxpos ubypos ubwidth ubheight],...
'Tag','replot',...
'String','Replot',...
'FontUnits','normalized',...
'FontSize',.5,...
'FontWeight','demi',...
'Callback','plotTScbk',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% "-" Reset "+" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ubxpos=ixf+dwin+ubdwin;
ubypos=iyf+yframe-2*dwin-2*ubdwin-2*ubheight;
% -
uicontrol(hTSw,'Style','Pushbutton','String','-',...
'Units','normalized',...
'Position',[ubxpos ubypos ubwidth ubheight],...
'Tag','zoomOut',...
'FontUnits','normalized',...
'FontSize',.6,...
'FontWeight','bold',...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:),...
'Callback','plotTScbk');
% Reset
ubxpos=ubxpos+ubwidth+ubdwin;
uicontrol(hTSw,'Style','Pushbutton','String','Reset',...
'Units','normalized',...
'Position',[ubxpos ubypos ubwidth ubheight],...
'Tag','reset',...
'FontUnits','normalized',...
'FontSize',.5,...
'FontWeight','demi',...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:),...
'Callback','plotTScbk');
% +
ubxpos=ubxpos+ubwidth+ubdwin;
uicontrol(hTSw,'Style','Pushbutton','String','+',...
'Units','normalized',...
'Position',[ubxpos ubypos ubwidth ubheight],...
'Tag','zoomIn',...
'FontUnits','normalized',...
'FontSize',.6,...
'FontWeight','bold',...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:),...
'Callback','plotTScbk');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% LOWER buttons in control panel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% now frame adjustable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lbn=3; % number of lower buttons
lbdwin=max(0.5*dwin,0.002);
lbwidth = (xframe-2*dwin-(lbn+1)*lbdwin)/lbn;
lbheight= max(0.05,0.05*yframe);
lbxpos=ixf+dwin+lbdwin;
% Prev
uicontrol(hTSw,'Style','Pushbutton',...
'Units','normalized',...
'Position',[lbxpos iyf+2*dwin lbwidth lbheight],...
'String','Prev',...
'Tag','PrevPage',...
'FontUnits','normalized',...
'FontSize',.4167,...
'FontWeight','demi',...
'Callback','plotTScbk',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:));
% Next
lbxpos=lbxpos+lbwidth+lbdwin;
uicontrol(hTSw,'Style','Pushbutton', ...
'Units','normalized',...
'Position',[lbxpos iyf+2*dwin lbwidth lbheight],...
'String','Next',...
'Tag','NextPage',...
'FontUnits','normalized',...
'FontSize',.4167,...
'FontWeight','demi',...
'Callback','plotTScbk',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:));
% Quit
lbxpos=lbxpos+lbwidth+lbdwin;
uicontrol('Style','Pushbutton',...
'Units','normalized',...
'Position',[lbxpos iyf+2*dwin lbwidth lbheight],...
'String','Quit',...
'Tag','Quit',...
'FontUnits','normalized',...
'FontSize',.4167,...
'FontWeight','demi',...
'Callback','plotTScbk',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:));
% Goto
lbxpos=ixf+dwin+lbdwin;lbypos=iyf+lbheight+dwin+2*lbdwin;
uicontrol(gcf,'Style','text',...
'String',['Go';'to'],...
'Units','normalized',...
'Position',[lbxpos lbypos lbwidth lbheight],...
'FontUnits','normalized',...
'FontSize',.4167,...
'FontWeight','demi',...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:));
lbxpos=lbxpos+lbwidth+lbdwin;
h_gotopage =uicontrol(gcf,'Style','edit',...
'String',num2str(page),...
'Units','normalized',...
'Position',[lbxpos lbypos lbwidth lbheight],...
'Tag','gotoPage',...
'BackgroundColor',bgc2,...
'ForegroundColor',fgc(2,:),...
'FontUnits','normalized',...
'FontSize',.4167,...
'FontWeight','demi',...
'Callback','plotTScbk');
lbxpos=lbxpos+lbwidth+lbdwin;
ss = sprintf('page#\n %d/%d',page,npage);
PAGE = uicontrol(gcf,'Style','text',...
'String',ss,...
'Units','normalized',...
'Position',[lbxpos lbypos lbwidth lbheight],...
'FontWeight','demi',...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:));
%%%%%%%%%%%%%%%%%%%%% Channel BUTTONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[ncol,nrow,staN]=NcolNrow(TSd.sta,TSd.ch_id);
% space for the buttons in control panel
cby=yframe-2*(ubheight+ubdwin)-2*(lbheight+lbdwin);
cbx=xframe-4*dwin;
cbh=(cby-(max(nrow+1)+1)*ubdwin)/max(nrow+1);
cbw=cbx/ncol;
cbh=min(cbh,0.05);
cbw=min(cbw,lbwidth); % Lana, Aug 2005, was min(cbw,0.05);
% Channel buttons are centered
xpos=ixf+2*dwin+(cbx-cbw*ncol-ubdwin*(ncol-1))/2;
ypos=iyf+yframe-2*(lbheight+lbdwin)-(cby-cbh*max(nrow)-ubdwin*(max(nrow)-1))/2;
%
for icol = 1:ncol
ypos=iyf+yframe-2*(lbheight+lbdwin)-(cby-cbh*max(nrow)-ubdwin*(max(nrow)-1))/2;
uicontrol(hTSw,'Style','Text',...
'String',staN(icol,:),...
'Units','normalized','Position',[xpos ypos cbw cbh],...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:),...
'FontUnits','normalized',...
'FontSize',.4,...
'FontWeight','demi');
chid=[];ic=[];
for k=1:nch
if TSd.sta(k,:)==staN(icol,:),chid=[chid;TSd.ch_id(k,:)];ic=[ic,k];end
end
for irow=1:nrow(icol)
ypos=ypos-cbh-ubdwin;
uicontrol(hTSw,'Style','PushButton',...
'String',chid(irow,:),...
'Units','normalized','Position',[xpos ypos cbw cbh],...
'Tag','chonoff','ToolTipString','Channel plot ON/OFF',...
'UserData',ic(irow),...
'BackgroundColor',bgc,...
'ForegroundColor',fgc(2,:),...
'FontUnits','normalized',...
'FontSize',.4,...
'FontWeight','demi',...
'CallBack','plotTScbk');
end
xpos=xpos+ubdwin+cbw;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plotting window structure:
% Structure TSw (Time series plot description)
% ACh(nch) axis handles for each channel
% PCh(nch) line handles for each channel
% SChM(nch),SChP(nch) handles for channel zoom controls
% YLch(nch,2) [center,range] defines ylim for each channel
% mCH, MCH are handles for max/min windows
% nPw # of points to be plotted in one frame
% i0 data array index for first point plotted in window
% di data index skip factor (1 = no skip)
% i1 data array index for last point plotted in window
% chPlt, chPltOld 0/1 arrays indicating which channels
% are active (i.e., to be plotted)
% centered indicator for centered TS
% PAGE handle to page number indicator
% page page number
% npage number of pages
% NOTE: many of the fields are blank until the first call to plotPage
TSw = struct('ACh',ACh,'PCh',PCh,'YLch',YLch,'mCH',mCH,'MCH',MCH,...
'nPw',nPw,'i0',i0,'i1',nPw,'di',di,'chPlt',chPlt,...
'chPltOld',chPltOld,'centered',centered,'PAGE',PAGE,...
'page',page,'npage',npage,'SChP',SChP,'SChM',SChM,...
't0Eq0',t0Eq0,'tUnits',tUnits,'tFac',tFac,'yFac',yFac,...
'hMask',hMask,'T12',T12);