-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo4.jl
77 lines (61 loc) · 2.39 KB
/
demo4.jl
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
#Demo 4: Multi-dimensional datasets (advanced usage)
#-------------------------------------------------------------------------------
using CMDimData
using CMDimData.MDDatasets
using CMDimData.EasyPlot
import Printf: @sprintf
#==Attributes
===============================================================================#
LBL_AXIS_TIME = "Time (s)"
LBL_AXIS_AMPLITUDE = "Amplitude"
#==Input data
===============================================================================#
tfund = 1e-9 #Fundamental
osr = 20 #(fundamental) oversampling ratio
nfund = 20 #cycles of the fundamental
#==Computations
===============================================================================#
t = DataF1(0:(tfund/osr):(nfund*tfund))
tmax = maximum(t)
#Generate parameter sweeps:
sweeplist = PSweep[
PSweep("period", [1,2,3]*tfund)
PSweep("slope", [-1,0,1]*(1/tmax))
PSweep("offset", [-.4, 0, .9])
]
#Generate data:
lines = DataHR{DataF1}(sweeplist) #Create empty dataset
tones = DataHR{DataF1}(sweeplist) #Create empty dataset
for inds in subscripts(lines)
(T, m, b) = coordinates(lines, inds)
lines.elem[inds...] = DataF1(t.x, (x)->m*x+b)
tones.elem[inds...] = sin(t*(2pi/T))
end
tones += lines #Create shifted dataset
#Filter on 2T harmonic:
tones_2T = getsubarray(tones, period=2tfund)
#Filter on 3T harmonic:
tones_3T = getsubarray(tones, period=3tfund)
#Filter on increasing slope (3rd index):
tones_incm = getsubarray(tones, :,3,:)
#==Generate plot
===============================================================================#
strns(T) = @sprintf("%.1f ns", T/1e-9) #Generate string with # of ns from supplied value
plot = cons(:plot, nstrips=4, legend=false, #Legend too busy with GracePlot
ystrip1 = set(axislabel=LBL_AXIS_AMPLITUDE, striplabel="Tones"),
ystrip2 = set(axislabel=LBL_AXIS_AMPLITUDE, striplabel="Tones ($(strns(2tfund)))"),
ystrip3 = set(axislabel=LBL_AXIS_AMPLITUDE, striplabel="Tones ($(strns(3tfund)))"),
ystrip4 = set(axislabel=LBL_AXIS_AMPLITUDE, striplabel="Tones (increasing slope)"),
xaxis = set(label=LBL_AXIS_TIME),
)
push!(plot,
cons(:wfrm, tones, strip=1),
cons(:wfrm, tones_2T, strip=2),
cons(:wfrm, tones_3T, strip=3),
cons(:wfrm, tones_incm, strip=4),
)
pcoll = cons(:plot_collection, title="Mulit-Dataset Tests: Subarrays", ncolumns=1)
push!(pcoll, plot)
#==Return pcoll to user (call evalfile(...))
===============================================================================#
pcoll