-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSplot.m
More file actions
119 lines (104 loc) · 2.96 KB
/
SSplot.m
File metadata and controls
119 lines (104 loc) · 2.96 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
function [] = SSplot(Data,dataFile,plotDir,tBox,tHead)
% SSplot - initial plot for Single Station processing
%
% Usage: SSplot(Data)
% SSplot(Data,dataFile,plotDir)
% SSplot(Data,dataFile,plotDir,tBox,tHead)
%
% The dataFile is needed for the title and for the output
% file names; the plotDir is needed to save the plot.
if nargin == 1
dataFile = '';
end
if nargin < 3
SAVE = 0;
else
% create a directory to save the plots
if ~exist(plotDir,'dir'); mkdir(plotDir); end
SAVE = 1;
cd (plotDir);
end
[temp,fileRoot] = fileparts(dataFile);
if isempty(fileRoot)
fileRoot = 'data';
end
% calculate median, MAD for a subsample of time series
subData = Data(:,1:100:end);
dataMed = median(subData,2);
for k = 1:5
subData(k,:) = abs(subData(k,:)-dataMed(k));
end
ii = size(Data,2);
medRange = 3*max(4*sqrt(ii/400000),1);
dataScale = medRange*median(subData,2);
% if a channel is missing, still plot the data
for k=1:5
if dataScale(k)==0
dataScale(k) = 1;
end
end
figure('Position',[20,40,560,460],...
'PaperPosition',[1,1,6.5,9],...
'PaperOrientation','Portrait',...
'Name','EM data channels')
nch = 5;
xl = .8; yl = .85/nch;
yspace = .025;
y0 = .1; x0 = .1;
CH = {'H_x','H_y','H_z','E_x','E_y'};
for k = 1:nch
rect = [x0,y0+(k-1)*yl,xl,yl-yspace];
axes('Position',rect);
plot(Data(k,:)-dataMed(k),'Color','b');
set(gca,'FontSize',12,'FontWeight','demi',...
'ylim',[-dataScale(k),dataScale(k)]);
y = get(gca,'ylim');
x = get(gca,'xlim');
labPos = [x(1)+.9*(x(2)-x(1)),y(2)-.15*(y(2)-y(1))];
text(labPos(1),labPos(2),CH{k},'FontSize',14,'FontWeight','demi')
if(k ~= 1)
set(gca,'XtickLabel','');
end
end
title(dataFile,'Interpreter','none')
if SAVE
print('-djpeg90','-r300',fileRoot);
end
if nargin < 3
return
end
subData = tBox(:,1:100:end);
dataMed = median(subData,2);
subData = abs(subData(k,:)-dataMed(k));
ii = size(Data,2);
medRange = 3*max(4*sqrt(ii/400000),1);
dataScale = medRange*median(subData,2);
Temp(1,:) = tBox-median(tBox); tempScale(1) = max((max(tBox)-min(tBox))/2,0.01);
Temp(2,:) = tHead-median(tHead); tempScale(2) = max((max(tHead)-min(tHead))/2,0.01);
figure('Position',[600,40,400,400],...
'PaperPosition',[1,1,6.5,5],...
'PaperOrientation','Portrait',...
'Name','Temperature variations')
nch = 2;
xl = .8; yl = .8/nch;
yspace = .025;
y0 = .15; x0 = .1;
T = {'\delta t_{box}','\delta t_{head}'};
for k = 1:nch
rect = [x0,y0+(k-1)*yl,xl,yl-yspace];
axes('Position',rect);
plot(Temp(k,:),'Color','r');
set(gca,'FontSize',12,'FontWeight','demi',...
'ylim',[-tempScale(k),tempScale(k)]);
y = get(gca,'ylim');
x = get(gca,'xlim');
labPos = [x(1)+.85*(x(2)-x(1)),y(2)-.15*(y(2)-y(1))];
text(labPos(1),labPos(2),T{k},'FontSize',14,'FontWeight','demi')
if(k ~= 1)
set(gca,'XtickLabel','');
end
end
title(dataFile,'Interpreter','none')
if SAVE
print('-djpeg90','-r300',[fileRoot '_t']);
end