-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScopes.py
96 lines (92 loc) · 3.34 KB
/
Scopes.py
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
import numpy as np
from scipy.integrate import cumtrapz
from scipy.fft import rfft, rfftfreq, irfft
class Scopes:
def __init__(self, shot, currentStart=1400., path=r'//LINNA/scopes/'):
self.sh = shot
self.pth = path
self.start = float(currentStart)
def getCh(self, scopeNumber, channel):
voltName = 'scope' + str(scopeNumber)
if(channel[0]=='E'):
voltName += 'E'
voltName += '_' + self.sh
timeName = voltName + 'time'
voltName += '_' + channel
volts = np.genfromtxt(self.pth+voltName)[0:-1]
time = np.genfromtxt(self.pth+timeName)
return time, volts
def getRog1(self):
return self.getCh(2,'C1')
def getRog2(self):
return self.getCh(2,'C2')
def getRogA(self):
return self.getCh(1,'D1')
def getRogB(self):
return self.getCh(1, 'D2')
def getdIdt_G(self):
return self.getCh(10,'A1')
def getdIdt_H(self):
return self.getCh(10,'A2')
def getdIdt_C(self):
return self.getCh(10,'B1')
def getdIdt_Z(self):
return self.getCh(10,'B2')
def getLine_G(self):
return self.getCh(10,'C1')
def getLine_H(self):
return self.getCh(10,'C2')
def getLine_C(self):
return self.getCh(10,'D1')
def getLine_Z(self):
return self.getCh(10,'D2')
def getMarx_G(self):
return self.getCh(11,'C1')
def getMarx_H(self):
return self.getCh(11,'C2')
def getMarx_C(self):
return self.getCh(11,'D1')
def getMarx_Z(self):
return self.getCh(11,'D2')
class Channel:
def __init__(self, scope_object, scope_number, channel_key, attenuation):
self.currentStart = scope_object.start
self.t, self.v = scope_object.getCh(scope_number, channel_key)
self.v *= attenuation
def low_pass(self, cuttoff_s):
c_ns = cuttoff_s*1e-9
v_fft = rfft(self.v)
N = self.t.shape[0]
dt = self.t[1]-self.t[0]
f = rfftfreq(N, dt)
window = f<c_ns
self.v_filt = irfft(v_fft*window)
class Rogowski:
def __init__(self, channel, calibration=3.):
self.channel = channel
self.calibration = calibration
def getInductiveComponent(self, other_probe):
t = self.channel.t - self.channel.currentStart
v1 = self.channel.v
v2 = other_probe.channel.v
inductive = (v1 - v2)*0.5
return t, inductive
def getcapacitiveComponent(self, other_probe):
t = self.channel.t - self.channel.currentStart
v1 = self.channel.v
v2 = other_probe.channel.v
inductive = (v1 + v2)*0.5
return t, inductive
def getCurrent(self, other_probe=None, numPosts=8, backoff=10.):
if(other_probe is None):
t = self.channel.t - self.channel.currentStart
V = self.channel.v
else:
t, V = self.getInductiveComponent(other_probe)
currentStartIndex = np.argmin( np.abs(t+backoff) )
t_trimmed = t[currentStartIndex:]
V_trimmed = V[currentStartIndex:]
intergrated = cumtrapz(V_trimmed, x=t_trimmed, initial=0.)
intergrated *= self.calibration
intergrated *= numPosts
return t_trimmed, intergrated