-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTSplot.m
More file actions
110 lines (96 loc) · 3.19 KB
/
TSplot.m
File metadata and controls
110 lines (96 loc) · 3.19 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
% 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 = 'Hours';
% 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
% Assumed sampling rate (used to calculate number of points in
% the plotting window only ... should recompute after reading file)
dt = 1;
% initialize structure "plotStart"
[plotStart] = plotSetup(tUnits,nTunits,dt)
% this program just reads one file, obtained by browsing
% load one NIMS data ...
[filename, pathname, filterindex] = ...
uigetfile({'*.bin','NIMS bin files'; ...
'*.dbn','decimated NIMS bin files';...
'*.mat', 'mat files'; ...
'*.asc', 'ascii file with start time'}, ...
'Data File to Plot');
FileNames{1} = filename;
eval(['cd ' pathname])
if filterindex==4
[y,dt,clock_zero,data_start] = readTSasc(filename);
[nch,npts] = size(y);
t0 = datenum(data_start)-datenum(clock_zero);
t0 = round(t0*24*3600/dt);
switch nch
case 3
ch = ['Hx';'Hy';'Hz'];
case 5
ch = ['Hx';'Hy';'Hz';'Ex';'Ey'];
otherwise
ch = [];
for ich = 1:nch
ch = [ ch ; 'ch' num2str(ich)];
end
end
temp = strsplit(filename,'.');
sta = [];
for k = 1:nch
sta = [sta; temp{1}];
end
% set up dummy unit system response
freq = [1,1e-6]./dt;
[SysTF] = setUnitSysTF(nch,freq);
else
% new version of readTSnims can now handle mat files also ...
[y,SysTF,dt,t0,clock_zero,ch,sta,error] = readTSnims(FileNames,decFac,scale);
end
% 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,clock_zero);
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;