Added chopp and trigger signals on raw channel 15
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
@@ -7,8 +7,9 @@ import mdsthin
|
|||||||
from mdsthin.exceptions import TreeNNF, TreeFOPENR
|
from mdsthin.exceptions import TreeNNF, TreeFOPENR
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
ADC_CHANNELS = 14 # channels stored in ISTTOK MDSplus trees
|
ADC_CHANNELS = 16 # channels stored in ISTTOK MDSplus trees
|
||||||
ADC_DECIM_RATE = 200 # FPGA decimation
|
ADC_DECIM_RATE = 200 # FPGA decimation
|
||||||
|
ADC_BIT_LSHIFT = 2**14
|
||||||
|
|
||||||
MDSTREENAME = 'isttokmarte'
|
MDSTREENAME = 'isttokmarte'
|
||||||
|
|
||||||
@@ -29,22 +30,22 @@ class ClientMdsThin():
|
|||||||
Models an MDS Thin Client connection to ISTTOK ATCA2 server
|
Models an MDS Thin Client connection to ISTTOK ATCA2 server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, url=MDS_URL, num_channels=12):
|
def __init__(self, num_channels=ADC_CHANNELS, url=MDS_URL):
|
||||||
"""
|
"""
|
||||||
Initializes the connection to the High-Precision-AD-HAT
|
Initializes the connection to the High-Precision-AD-HAT
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# self.client = mdsClient(MDSPLUS_HOST, user='oper')
|
|
||||||
self.client = mdsthin.Connection('ssh://' + url)
|
self.client = mdsthin.Connection('ssh://' + url)
|
||||||
#self.client.openTree(MDSTREENAME, shot)
|
|
||||||
except TreeFOPENR:
|
except TreeFOPENR:
|
||||||
print(f"Tree {MDSTREENAME} / Shot {shot} Not found")
|
print(f"Tree {MDSTREENAME} / Shot {shot} Not found")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
self.num_channels = num_channels
|
||||||
self.adcRawData = []
|
self.adcRawData = []
|
||||||
|
self.choppTrigg = []
|
||||||
self.adcIntegData = []
|
self.adcIntegData = []
|
||||||
|
|
||||||
def getTreeData(self, shot=5240):
|
def getTreeData(self, shot=52740):
|
||||||
try:
|
try:
|
||||||
self.client.openTree(MDSTREENAME, shot)
|
self.client.openTree(MDSTREENAME, shot)
|
||||||
except TreeFOPENR:
|
except TreeFOPENR:
|
||||||
@@ -58,11 +59,18 @@ class ClientMdsThin():
|
|||||||
node0 = ADC_INTEG.format(0)
|
node0 = ADC_INTEG.format(0)
|
||||||
dim = "dim_of({})".format(node0)
|
dim = "dim_of({})".format(node0)
|
||||||
self.timeI = self.client.get(dim).data()
|
self.timeI = self.client.get(dim).data()
|
||||||
for i in range(ADC_CHANNELS):
|
for i in range(self.num_channels):
|
||||||
data = self.client.get(ADC_RAW.format(i)).data()
|
data = self.client.get(ADC_RAW.format(i)).data()
|
||||||
self.adcRawData.append(data[:, 0])
|
adc_raw = data[:, 0].astype(int)
|
||||||
|
adc_raw = adc_raw // ADC_BIT_LSHIFT
|
||||||
|
self.adcRawData.append(adc_raw)
|
||||||
data = self.client.get(ADC_INTEG.format(i)).data()
|
data = self.client.get(ADC_INTEG.format(i)).data()
|
||||||
self.adcIntegData.append(data[:, 0])
|
self.adcIntegData.append(data[:, 0])
|
||||||
|
data = self.client.get(ADC_RAW.format(15)).data()
|
||||||
|
adc_bits = data[:, 0].astype(int)
|
||||||
|
adc_bits &= 0x3
|
||||||
|
# breakpoint()
|
||||||
|
self.choppTrigg = adc_bits
|
||||||
|
|
||||||
def calcEoWo(self):
|
def calcEoWo(self):
|
||||||
if not self.adcRawData:
|
if not self.adcRawData:
|
||||||
@@ -71,14 +79,13 @@ class ClientMdsThin():
|
|||||||
print(f"Samples {totalSamples:d}, time {totalSamples/2e3:.3f} ms")
|
print(f"Samples {totalSamples:d}, time {totalSamples/2e3:.3f} ms")
|
||||||
Eoffset = np.zeros(ADC_CHANNELS, dtype=int)
|
Eoffset = np.zeros(ADC_CHANNELS, dtype=int)
|
||||||
Woffset = np.zeros(ADC_CHANNELS)
|
Woffset = np.zeros(ADC_CHANNELS)
|
||||||
for i in range(ADC_CHANNELS):
|
for i in range(self.num_channels):
|
||||||
Eoffset[i] = np.mean(self.adcRawData[i]).astype(int)
|
Eoffset[i] = np.mean(self.adcRawData[i]).astype(int)
|
||||||
intData = self.adcIntegData[i]
|
intData = self.adcIntegData[i]
|
||||||
Woffset[i] = (intData[-1] - intData[0]) / totalSamples
|
Woffset[i] = (intData[-1] - intData[0]) / totalSamples
|
||||||
return Eoffset, Woffset
|
return Eoffset, Woffset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Script to get data from remote MDS server')
|
description='Script to get data from remote MDS server')
|
||||||
|
|||||||
@@ -32,12 +32,16 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
parser.add_argument('-s', '--shot', type=int,
|
parser.add_argument('-s', '--shot', type=int,
|
||||||
help='Mds+ pulse Number ([1, ...])', default=100)
|
help='Mds+ pulse Number ([1, ...])', default=100)
|
||||||
|
parser.add_argument('-c', '--crange', nargs='+', type=int,
|
||||||
|
help='Channel plots (1 16)', default=[1, 12])
|
||||||
|
#parser.add_argument('-n', '--nchannels', type=int,
|
||||||
|
# help='Number of channels)', default=ADC_CHANNELS)
|
||||||
parser.add_argument('-m', '--maxpoints', type=int,
|
parser.add_argument('-m', '--maxpoints', type=int,
|
||||||
help='Max points to plot', default=50000)
|
help='Max points to plot', default=50000)
|
||||||
parser.add_argument('-a', '--averages', action='store_true',
|
parser.add_argument('-a', '--averages', action='store_true',
|
||||||
help='calc Averages')
|
help='calc Averages')
|
||||||
parser.add_argument('-d', '--decimated', action='store_true',
|
# parser.add_argument('-d', '--decimated', action='store_true',
|
||||||
help='Use decimated data')
|
# help='Use decimated data')
|
||||||
# parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
# parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
||||||
parser.add_argument('-z', '--zero', action='store_true',
|
parser.add_argument('-z', '--zero', action='store_true',
|
||||||
help='Zero integral Lines')
|
help='Zero integral Lines')
|
||||||
@@ -47,7 +51,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print(f"args.shot {args.shot}")
|
print(f"args.shot {args.shot}")
|
||||||
self.mclient = cltMds(url=args.url)
|
self.mclient = cltMds(url=args.url, num_channels=ADC_CHANNELS)
|
||||||
self.mclient.getTreeData(shot=args.shot)
|
self.mclient.getTreeData(shot=args.shot)
|
||||||
# gr_wid = pg.GraphicsLayoutWidget(show=True)
|
# gr_wid = pg.GraphicsLayoutWidget(show=True)
|
||||||
cw = QtWidgets.QWidget()
|
cw = QtWidgets.QWidget()
|
||||||
@@ -58,48 +62,68 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
pw1 = pg.PlotWidget(name='Plot1') ## giving the plots names allows us to link their axes
|
pw1 = pg.PlotWidget(name='Plot1') ## giving the plots names allows us to link their axes
|
||||||
pw1.addLegend()
|
pw1.addLegend()
|
||||||
glay.addWidget(pw1, 0, 0)
|
glay.addWidget(pw1, 0, 0)
|
||||||
glay.setRowStretch(0, 1)
|
|
||||||
glay.setRowStretch(1, 2)
|
|
||||||
|
|
||||||
# self.setCentralWidget(gr_wid)
|
# self.setCentralWidget(gr_wid)
|
||||||
self.setCentralWidget(cw)
|
self.setCentralWidget(cw)
|
||||||
self.setWindowTitle('pyqtgraph ISTTOK')
|
self.setWindowTitle('pyqtgraph ISTTOK')
|
||||||
|
|
||||||
# p1 = gr_wid.addPlot(0,0, 1,1, title="raw data")
|
# p1 = gr_wid.addPlot(0,0, 1,1, title="raw data")
|
||||||
|
start_ch = args.crange[0] - 1
|
||||||
|
end_ch = args.crange[1]
|
||||||
|
if (args.averages):
|
||||||
|
Eoffset, Woffset = self.mclient.calcEoWo()
|
||||||
|
# nChannels = len(mclient.adcRawData)
|
||||||
|
print(f"EO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(end_ch):
|
||||||
|
print(f"{Eoffset[i]:d} ", end='')
|
||||||
|
print(" ")
|
||||||
|
print(f"WO: {ADC_CHANNELS} ", end='')
|
||||||
|
for i in range(end_ch):
|
||||||
|
print(f"{Woffset[i]:0.3f} ", end='')
|
||||||
|
print(" ")
|
||||||
time = self.mclient.timeR
|
time = self.mclient.timeR
|
||||||
for i in range(ADC_CHANNELS):
|
for i in range(start_ch, end_ch):
|
||||||
dataAdc = self.mclient.adcRawData[i]
|
dataAdc = self.mclient.adcRawData[i]
|
||||||
pw1.plot(dataAdc, pen=pg.mkPen(i, width=1),
|
pw1.plot(dataAdc[:args.maxpoints], pen=pg.mkPen(i, width=1),
|
||||||
name="ch {}".format(i))
|
name="ch {}".format(i))
|
||||||
|
|
||||||
pw2 = pg.PlotWidget(name='integ data') ## giving the plots names allows us to link their axes
|
pw2 = pg.PlotWidget(name='Integ data')
|
||||||
pw2.addLegend()
|
pw2.addLegend()
|
||||||
|
pw2.setXLink('Plot1')
|
||||||
glay.addWidget(pw2, 1, 0)
|
glay.addWidget(pw2, 1, 0)
|
||||||
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
||||||
|
|
||||||
time = self.mclient.timeI
|
time = self.mclient.timeI
|
||||||
for i in range(ADC_CHANNELS):
|
for i in range(start_ch, end_ch):
|
||||||
|
# for i in range(args.nchannels):
|
||||||
data = self.mclient.adcIntegData[i]
|
data = self.mclient.adcIntegData[i]
|
||||||
pw2.plot(data, pen=pg.mkPen(i, width=1),
|
if (args.zero):
|
||||||
|
data -= data[0] # / 2.0e6 # LSB * sec
|
||||||
|
pw2.plot(data[:args.maxpoints], pen=pg.mkPen(i, width=1),
|
||||||
name="ch {}".format(i))
|
name="ch {}".format(i))
|
||||||
|
|
||||||
#, pen=(255,0,0), name="Red curve")
|
#, pen=(255,0,0), name="Red curve")
|
||||||
|
|
||||||
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
||||||
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
||||||
|
|
||||||
time = self.mclient.timeI
|
# time = self.mclient.timeI
|
||||||
for i in range(6):
|
# for i in range(6):
|
||||||
data = self.mclient.adcIntegData[i]
|
# data = self.mclient.adcIntegData[i]
|
||||||
pw2.plot(data, pen=pg.mkPen(i, width=1))
|
# pw2.plot(data, pen=pg.mkPen(i, width=1))
|
||||||
#, pen=(255,0,0), name="Red curve")
|
#, pen=(255,0,0), name="Red curve")
|
||||||
|
|
||||||
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
||||||
self.resize(800, 700)
|
pw3 = pg.PlotWidget(name='Chop Trigg')
|
||||||
self.show()
|
pw3.setXLink('Plot1')
|
||||||
# SLOT: This has default parameters and can be called without a value
|
data = self.mclient.choppTrigg
|
||||||
def my_custom_fn(self, a="HELLLO!", b=5):
|
pw3.plot(data[:args.maxpoints], pen=pg.mkPen(i, width=1))
|
||||||
print(a, b)
|
glay.addWidget(pw3, 2, 0)
|
||||||
|
glay.setRowStretch(0, 1)
|
||||||
|
glay.setRowStretch(1, 2)
|
||||||
|
glay.setRowStretch(2, 1)
|
||||||
|
|
||||||
|
self.resize(900, 800)
|
||||||
|
self.show()
|
||||||
|
|
||||||
mkQApp("ColorBarItem Example")
|
mkQApp("ColorBarItem Example")
|
||||||
main_window = MainWindow()
|
main_window = MainWindow()
|
||||||
@@ -120,5 +144,9 @@ if __name__ == '__main__':
|
|||||||
l.addWidget(saveBtn)
|
l.addWidget(saveBtn)
|
||||||
# sub1.addItem(saveBtn)
|
# sub1.addItem(saveBtn)
|
||||||
glay.addLayout(l, 0, 2)
|
glay.addLayout(l, 0, 2)
|
||||||
|
# SLOT: This has default parameters and can be called without a value
|
||||||
|
def my_custom_fn(self, a="HELLLO!", b=5):
|
||||||
|
print(a, b)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user