Skip to content

Instantly share code, notes, and snippets.

@cpascual
cpascual / signalmethodwrapper.py
Created April 28, 2016 12:41
Wrapper to work around signal and method conflicts
class SignalMethodWrapper(object):
"""Object that can act simultaneously as a pyqtBoundSignal and as a callable
method.
It optionally allows to log deprecation messages whe used as a signal
or as a method or both
"""
def __init__(self, pyqtboundsignal, method, alt_sig=None, alt_meth=None,
name='<wrapper>'):
from PyQt4 import Qt
class Signaller(Qt.QObject):
signal = Qt.pyqtSignal()
class Base(object):
"""Base is not a QObject but provides a pyqtSignal signal member via
a Signaller hidden behind a property"""
import h5py
import numpy
import time
import sys
from multiprocessing import Process
FNAME = 'foo.h5'
#find trunks
find . -type d -iname trunk > /tmp/find-trunk.txt &
#filter paths
cat /tmp/find-trunk.txt | sed 's/\.\(.*\)\/trunk/\1/' > /tmp/paths.tst
# to make script
# sed 's/\.\(.*\)\/trunk/grep -v \1 \| \\/' > /tmp/filter.sh
# edit /tmp/filter.sh
@cpascual
cpascual / pgtaurus.py
Last active March 10, 2017 12:52
Proof of concept for plotting a taurus attribute with pyqtgraph
import sys
import numpy
from taurus.external.qt import QtGui
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.base import TaurusBaseComponent
from pyqtgraph import PlotDataItem
class TaurusPlotDataItem(PlotDataItem, TaurusBaseComponent):
"""A taurus-ified PlotDataItem"""
@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
"""
@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)
"""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 / 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
@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):