Skip to content

Instantly share code, notes, and snippets.

@cpascual
cpascual / bootstrap.ps1
Last active December 16, 2020 23:41
recipe for installing taurus dependencies on Windows 10 using conda
# Powershell script for installing taurus dependencies on a windows10 machine using conda
# I use it for provisioning a vagrant win10 machine
# Install SSL as a workaround for conda bug https://github.com/conda/conda/issues/6064
echo "Installing SSL"
wget "https://slproweb.com/download/Win64OpenSSL-1_1_1a.msi" -OutFile "$env:TMP\SSL.msi"
msiexec /quiet /i "$env:TMP\SSL.msi"
echo "Downloading conda"
$condainstallerurl = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
$condainstaller = "$env:TMP\\Miniconda3-latest-Windows-x86_64.exe"
@cpascual
cpascual / inspectorline.py
Last active March 8, 2023 09:37
InspectorLine : a simple example on how to inspect curve data with a moveable vertical line in pyqtgraph
from PyQt5 import Qt
from pyqtgraph import InfiniteLine, TextItem
import numpy as np
class InspectorLine(InfiniteLine):
def __init__(self, ):
super(InspectorLine, self).__init__(angle=90, movable=True)
self._labels = []
@cpascual
cpascual / tpg_example.py
Created November 9, 2018 14:48
a taurus_pyqtgraph example: plot of a curve with 2 models (x and y) and with time axis
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.tpg import TaurusPlotDataItem, DateAxisItem
import pyqtgraph as pg
if __name__ == '__main__':
import sys
app = TaurusApplication()
w = pg.PlotWidget()
@cpascual
cpascual / autopantool.py
Last active March 8, 2023 09:38
pyqtgraph AutoPan tool example
# Demo of a "tool" for pyqtgraph that, when attached to a plot item it adds a menu
# action that, when toggled, checks for new data periodically and auto pans the X axis.
# The new-data-checking period is dynamically adjusted depending on the range being
# displayed
#
# Snippet adapted from the taurus_pyqtgraph.autopantool module to be used without taurus.
# See:
# https://github.com/taurus-org/taurus_pyqtgraph/blob/master/taurus_pyqtgraph/autopantool.py
@cpascual
cpascual / pg_time_axis.py
Last active March 12, 2024 19:24
An example on how to use a timestamp-based axis with pyqtgraph. This file has been adapted from taurus_pyqtgraph: https://github.com/taurus-org/taurus_pyqtgraph/blob/master/taurus_pyqtgraph/dateaxisitem.py
#!/usr/bin/env python
#############################################################################
#
# This file was adapted from Taurus TEP17, but all taurus dependencies were
# removed so that it works with just pyqtgraph
#
# Just run it and play with the zoom to see how the labels and tick positions
# automatically adapt to the shown range
#
@cpascual
cpascual / gaussianfit.py
Created December 21, 2017 12:31
A simple example on fitting a gaussian
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def gauss(x, H, A, x0, sigma):
return H + A * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2))
def gauss_fit(x, y):
@cpascual
cpascual / approach_a.py
Last active August 21, 2017 08:22
A simple example of using taurus eval scheme with pandas to read a column of a CSV data file
"""
A simple example of using taurus eval scheme with pandas to
read a column of a CSV data file
"""
#create a dummy csv file with 2 columns with headers "x" and "y"
data=\
'''
x,y
2,4
"""A nexus file summary tool implemented with h5py"""
import h5py
import sys
def print_dset(dset):
print '\t', dset
for k, v in sorted(dset.attrs.iteritems()):
print "\t\t@%s=%s" % (k,v)
@cpascual
cpascual / trendcurveprops.py
Created April 21, 2017 13:34
Recipe for changing curve appearance properties in a TaurusTrend
import sys
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.plot import TaurusTrend
app = TaurusApplication()
w = TaurusTrend()
model = 'sys/tg_test/1/ampli'
w.setModel(model)
@cpascual
cpascual / ipap_rw_example.py
Last active June 14, 2017 14:35
Eval+IcePAP
"""
Examples on using the evaluation scheme for exposing icepap driver values
as taurus attributes
Note that:
- the first attribute is writable
- The second and 3rd attributes do not even require defining MyIpap
"""