-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTSplotKMS.m
More file actions
109 lines (93 loc) · 3.2 KB
/
TSplotKMS.m
File metadata and controls
109 lines (93 loc) · 3.2 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
% TSplot is a simple driver program for time series plotting.
% It prompts the user for a data file, in one of several formats,
% reads this file, and initializes the time series plotting interface.
%
% First a couple of options which are hard-coded here:
decFac = 1;
% return full data set (no decimation);scale into
scale = 1; %if scale == 1 data are returned with units of nT and mV
% note: not divided by dipole length!
% physical units (but no other filter corrections applied)
tUnits = 'Seconds';
% tUnits = initial time units for labeling time series plots
% other choices are 'Seconds','Minutes','Days'
nTunits = 6;
% Number of Hours (more generally, tUnits) to plot on one pag3e
% this program just reads one file, obtained by browsing
% load one NIMS data ...
[filename, pathname, filterindex] = ...
uigetfile('*','Data File to Plot');
[header,y] = readKMS([pathname filename]);
% get sampling rate, start time etc. from header
dt = 1./header.sampling_frequency;
% initialize structure "plotStart"
[plotStart] = plotSetup(tUnits,nTunits,dt);
[nch,~] = size(y);
% define 2 character strings for labeling channels
chType = ['?','B','E','U','B','B','B','E'];
ch = [];
for k = 1:nch
ch = [ch; chType(header.sensor_ID{k}+1) lower(header.sensor_component{k})];
end
% sort out time-date
temp = strsplit(header.GPS_time_info,',');
hr = str2num(temp{2}(1:2));
min = str2num(temp{2}(3:4));
sec = str2num(temp{2}(5:end));
mo = str2num(temp{3});
day = str2num(temp{4});
year = str2num(temp{5});
dataStart = datestr([year mo day hr min sec]);
% by default let's set clock reference to start of year that data are
% collected in
dataZero = datestr([year 1 1 0 0 0]);
% t0 gives sample number of first data point, referenced to clock zero
% (i.e., sample 1 is at stroke of clock zero
t0 = datenum(dataStart)-datenum(dataZero);
t0 = t0*86400/dt+1;
temp = strsplit(filename,'.');
sta = [];
for k = 1:nch
sta = [sta; temp{1}];
end
% set up dummy unit system response ... this can use info in header
freq = [1,1e-6]./dt;
[SysTF] = setUnitSysTF(nch,freq);
% reset nPw (# of points to plot initially on one page) now
% that dt has been read from data file (NOTE: dt returned
% by readTSnims accounts for subsampling by a factor of decFac)
nPw = fix(plotStart.tFac*plotStart.nTunits/dt);
plotStart.nPw = nPw;
% Initialize cell arrays for data, time series metadata,
% window metadata, etc.
TSc = {};
TSp = {};
TSd = {};
TSw = {};
TSdata = {};
TSfigInd = zeros(100,1);
% set up TSd
TSd1 = setTSd(y,t0,dt,ch,sta,SysTF);
TSd1.sta = char(TSd1.sta);
TSdata0 = (TSd1.range(:,1)+TSd1.range(:,2))/2;
rng = (TSd1.range(:,2)-TSd1.range(:,1))/2;
rng = plotStart.rangeScale*rng;
TSd1.range(:,1:2) = [ TSdata0-rng TSdata0+rng];
% are these needed???
TSd1.DataDir = pathname;
TSd1.arrayID = '';
% copy into cell arrays
iA = 1;
TSdata{iA} = y;
TSd{iA} = TSd1;
[hTSw,TSw1] = plotTSwin(TSd{1},plotStart);
TSfigInd(hTSw.Number) = 1;
i0 = TSw1.i0; i1 = TSw1.i1; di = TSw1.di;
yFac = TSw1.yFac;
ddt = TSd{1}.dt/TSw1.tFac;
t0 = (TSd{1}.t0)*(1-TSw1.t0Eq0)/TSw1.tFac;
I = [i0:di:i1];
[TSw1] = plotPage(ddt*I+t0,...
yFac*TSdata{1}(:,I),...
TSw1,TSd{1},1);
TSw{1} = TSw1;