Wednesday, 22 November 2017

Showing Raw Data curves in TaurusPlot or TaurusTrend

The easiest way is to use the importAscii method to load data from a file:
    !head test.csv
    1383260422.0    0.0928575       0.0116941
    1383260452.0    0.0975427       0.00988106
    1383260482.0    0.0953354       0.00834905

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.plot import TaurusPlot
import sys

csvfile = sys.argv[1:]

app = TaurusApplication()
plot = TaurusPlot()
plot.importAscii(filenames=csvfile,xcol=0)
plot.setXIsTime(True)
plot.show()

sys.exit(app.exec_())

It can be done also using raw PyQwt
import fandango
import PyTangoArchiving as pta
rd = pta.Reader('hdb')

ats = fandango.tango.get_matching_device_attributes('sr04/vc/eps-plc-01/*TC*'
vals = rd.get_attributes_values(ats,'2011-10-18','2011-10-22',correlate=False,text=False,asHistoryBuffer=False)

from PyQt4 import Qt,Qwt5
from PyQt4.Qwt5 import qpl

qapp = Qt.QApplication([])
def get_color_for_i(i):
    top = 256**3
    tot = top/i
    c = tot
    return Qt.QColor(c%256,(c/256)%256,((c/256)/256)%256
p = qplt.Plot(*[qplt.Curve([x[0] for x in c],[y[1] for y in c],'curve %d'%i,qplt.Pen(get_color_for_i(i))) for i,c in enumerate(vals.values())])

----

I've actually done a pull request on Taurus to do it in this way:

generate raw data from archiving and/or matlab:

archiving2csv --noheader --noepoch <model1> <model2> <date1> <date2> /tmp/file.csv
the generated file can then be opened by taurusplot just doing:

taurusplot -x t --import=/tmp/file.csv

No comments:

Post a Comment