added script
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
This script get data from the MARTe2 ATCAIop stored in MDSplus
|
||||
"""
|
||||
import numpy as np
|
||||
from mdsClient import mdsClient
|
||||
import mdsthin
|
||||
from mdsthin.exceptions import TreeNNF, TreeFOPENR
|
||||
import argparse
|
||||
|
||||
@@ -13,6 +13,7 @@ ADC_DECIM_RATE = 200 # FPGA decimation
|
||||
MDSTREENAME = 'isttokmarte'
|
||||
|
||||
MDSPLUS_HOST = "192.168.1.173"
|
||||
MDS_URL = "oper@atca-marte2"
|
||||
# ADC_CHANNELS = 12 # channels stored in ISTTOK MDS
|
||||
ADC_RAW = '\\TOP.HARDWARE.ATCA_2.IOP_9.CHANNEL_{}.ADC_DECIM'
|
||||
ADC_RAW_D = '\\TOP.HARDWARE.ATCA_2.IOP_9.CHANNEL_{}.ADC_DECIM_D'
|
||||
@@ -28,13 +29,14 @@ class ClientMdsThin():
|
||||
Models an MDS Thin Client connection to ISTTOK ATCA2 server
|
||||
"""
|
||||
|
||||
def __init__(self, shot=52737, num_channels=12):
|
||||
def __init__(self, url=MDS_URL, num_channels=12):
|
||||
"""
|
||||
Initializes the connection to the High-Precision-AD-HAT
|
||||
"""
|
||||
try:
|
||||
self.client = mdsClient(MDSPLUS_HOST, user='oper')
|
||||
self.client.openTree(MDSTREENAME, shot)
|
||||
# self.client = mdsClient(MDSPLUS_HOST, user='oper')
|
||||
self.client = mdsthin.Connection('ssh://' + url)
|
||||
#self.client.openTree(MDSTREENAME, shot)
|
||||
except TreeFOPENR:
|
||||
print(f"Tree {MDSTREENAME} / Shot {shot} Not found")
|
||||
raise ValueError
|
||||
@@ -42,13 +44,24 @@ class ClientMdsThin():
|
||||
self.adcRawData = []
|
||||
self.adcIntegData = []
|
||||
|
||||
def getData(self):
|
||||
def getTreeData(self, shot=5240):
|
||||
try:
|
||||
self.client.openTree(MDSTREENAME, shot)
|
||||
except TreeFOPENR:
|
||||
print(f"Tree {MDSTREENAME} / Shot {shot} Not found")
|
||||
raise ValueError
|
||||
self.adcRawData = []
|
||||
self.adcIntegData = []
|
||||
node0 = ADC_RAW.format(0)
|
||||
dim = "dim_of({})".format(node0)
|
||||
self.timeR = self.client.get(dim).data()
|
||||
node0 = ADC_INTEG.format(0)
|
||||
dim = "dim_of({})".format(node0)
|
||||
self.timeI = self.client.get(dim).data()
|
||||
for i in range(ADC_CHANNELS):
|
||||
data = self.client.getData(ADC_RAW.format(i))
|
||||
data = self.client.get(ADC_RAW.format(i)).data()
|
||||
self.adcRawData.append(data[:, 0])
|
||||
data = self.client.getData(ADC_INTEG.format(i))
|
||||
data = self.client.get(ADC_INTEG.format(i)).data()
|
||||
self.adcIntegData.append(data[:, 0])
|
||||
|
||||
def calcEoWo(self):
|
||||
@@ -78,13 +91,16 @@ if __name__ == '__main__':
|
||||
type=int, default=[1, 12])
|
||||
parser.add_argument('-s', '--shot',
|
||||
type=int, help='Mds+ pulse Number ([1, ...])',
|
||||
default=52737)
|
||||
default=52740)
|
||||
# parser.add_argument('-e', '--averages', action='store_true', help='Calc averages')
|
||||
# parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
||||
|
||||
parser.add_argument('-u', '--url', default=MDS_URL,
|
||||
help='MDSplus host url')
|
||||
|
||||
args = parser.parse_args()
|
||||
clt = ClientMdsThin(shot=args.shot, num_channels=12)
|
||||
#clt.getData()
|
||||
clt = ClientMdsThin(url=args.url, shot=args.shot, num_channels=12)
|
||||
clt.getTreeData()
|
||||
# main(args)
|
||||
|
||||
|
||||
|
||||
124
Analysis/pqtgPlotMds.py
Normal file
124
Analysis/pqtgPlotMds.py
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script plots the MARTe2 ATCAIop samples stored in MDSplus
|
||||
All of the plots may be panned/scaled by dragging with
|
||||
the left/right mouse buttons. Right click on any plot to show a context menu.
|
||||
|
||||
To change EPICS EO, WO use. e.g.
|
||||
caput -a ISTTOK:central:ATCAIOP1-WO 14 0.191 0.174 -0.036 -0.044 0.183 0.126 0.020 0.140 -0.461 -0.572 0.022 -0.262 0.475 0.353
|
||||
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtWidgets, mkQApp
|
||||
# from mdsClient import mdsClient
|
||||
# from mdsthin.exceptions import TreeNNF
|
||||
import argparse
|
||||
|
||||
from ClientMdsThin import ClientMdsThin as cltMds
|
||||
|
||||
ADC_CHANNELS = 16 # channels stored in ISTTOK MDS
|
||||
ADC_BIT_LSHIFT = 2**14
|
||||
MDS_URL = "oper@atca-marte2"
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
""" main window """
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MainWindow, self).__init__(*args, **kwargs)
|
||||
parser = argparse.ArgumentParser(
|
||||
description="""Script to plot AtcaIop MDSplus data and calc drifts
|
||||
""")
|
||||
|
||||
parser.add_argument('-s', '--shot', type=int,
|
||||
help='Mds+ pulse Number ([1, ...])', default=100)
|
||||
parser.add_argument('-m', '--maxpoints', type=int,
|
||||
help='Max points to plot', default=50000)
|
||||
parser.add_argument('-a', '--averages', action='store_true',
|
||||
help='calc Averages')
|
||||
parser.add_argument('-d', '--decimated', action='store_true',
|
||||
help='Use decimated data')
|
||||
# parser.add_argument('-w', '--drift', action='store_true', help='Calc drifts')
|
||||
parser.add_argument('-z', '--zero', action='store_true',
|
||||
help='Zero integral Lines')
|
||||
|
||||
parser.add_argument('-u', '--url', default=MDS_URL,
|
||||
help='MDSplus host url')
|
||||
|
||||
args = parser.parse_args()
|
||||
print(f"args.shot {args.shot}")
|
||||
self.mclient = cltMds(url=args.url)
|
||||
self.mclient.getTreeData(shot=args.shot)
|
||||
# gr_wid = pg.GraphicsLayoutWidget(show=True)
|
||||
cw = QtWidgets.QWidget()
|
||||
glay = QtWidgets.QGridLayout()
|
||||
cw.setLayout(glay)
|
||||
# layout.setSpacing(0)
|
||||
# layout.setColumnStretch(layout.columnCount(), 1)
|
||||
pw1 = pg.PlotWidget(name='Plot1') ## giving the plots names allows us to link their axes
|
||||
pw1.addLegend()
|
||||
glay.addWidget(pw1, 0, 0)
|
||||
glay.setRowStretch(0, 1)
|
||||
glay.setRowStretch(1, 2)
|
||||
|
||||
# self.setCentralWidget(gr_wid)
|
||||
self.setCentralWidget(cw)
|
||||
self.setWindowTitle('pyqtgraph ISTTOK')
|
||||
|
||||
# p1 = gr_wid.addPlot(0,0, 1,1, title="raw data")
|
||||
time = self.mclient.timeR
|
||||
for i in range(ADC_CHANNELS):
|
||||
dataAdc = self.mclient.adcRawData[i]
|
||||
pw1.plot(dataAdc, pen=pg.mkPen(i, width=1),
|
||||
name="ch {}".format(i))
|
||||
|
||||
pw2 = pg.PlotWidget(name='integ data') ## giving the plots names allows us to link their axes
|
||||
pw2.addLegend()
|
||||
glay.addWidget(pw2, 1, 0)
|
||||
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
||||
|
||||
time = self.mclient.timeI
|
||||
for i in range(ADC_CHANNELS):
|
||||
data = self.mclient.adcIntegData[i]
|
||||
pw2.plot(data, pen=pg.mkPen(i, width=1),
|
||||
name="ch {}".format(i))
|
||||
#, pen=(255,0,0), name="Red curve")
|
||||
|
||||
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
||||
# piw2 = gr_wid.addPlot(1,0, 1,1, title="integ data")
|
||||
|
||||
time = self.mclient.timeI
|
||||
for i in range(6):
|
||||
data = self.mclient.adcIntegData[i]
|
||||
pw2.plot(data, pen=pg.mkPen(i, width=1))
|
||||
#, pen=(255,0,0), name="Red curve")
|
||||
|
||||
# sub1 = gr_wid.addLayout(0,2, 1,2)
|
||||
self.resize(800, 700)
|
||||
self.show()
|
||||
# SLOT: This has default parameters and can be called without a value
|
||||
def my_custom_fn(self, a="HELLLO!", b=5):
|
||||
print(a, b)
|
||||
|
||||
|
||||
mkQApp("ColorBarItem Example")
|
||||
main_window = MainWindow()
|
||||
|
||||
## Start Qt event loop
|
||||
if __name__ == '__main__':
|
||||
pg.exec()
|
||||
## Create image items
|
||||
|
||||
"""
|
||||
l = QtWidgets.QVBoxLayout()
|
||||
# sub1.addLabel("<b>Standard mouse interaction:</b><br>left-drag to pan, right-drag to zoom.")
|
||||
l.addWidget(QtWidgets.QLabel("<b>Standard mouse interaction:</b><br>left-drag to pan, right-drag to zoom."))
|
||||
saveBtn = QtWidgets.QPushButton('Channel')
|
||||
saveBtn.setCheckable(True)
|
||||
saveBtn.clicked.connect(lambda x: self.my_custom_fn(x, 25))
|
||||
|
||||
l.addWidget(saveBtn)
|
||||
# sub1.addItem(saveBtn)
|
||||
glay.addLayout(l, 0, 2)
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user