diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-07 13:54:40 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-07 13:54:40 -0500 |
commit | ccbb6a5ad8c2577de718ed27e74e2eedc98708df (patch) | |
tree | 6b893e090946a227d42fef5d3a8727e24f996e5e /examples | |
parent | 89a05b3ce0f13a7685abf069753e10c77dce74dc (diff) | |
download | pyExpControl-ccbb6a5ad8c2577de718ed27e74e2eedc98708df.tar.gz pyExpControl-ccbb6a5ad8c2577de718ed27e74e2eedc98708df.zip |
added Apparatus class
Diffstat (limited to 'examples')
-rw-r--r-- | examples/grab_eit_shapes.py | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/examples/grab_eit_shapes.py b/examples/grab_eit_shapes.py index a79b8ea..c068df2 100644 --- a/examples/grab_eit_shapes.py +++ b/examples/grab_eit_shapes.py @@ -3,7 +3,7 @@ import logging # this should be done before justpy is called or log formatter does not work logging.basicConfig(format='%(asctime)s %(levelname)8s %(name)s: %(message)s', datefmt='%m/%d/%Y %H:%M:%S') -import justpy as jp +# import justpy as jp import pyvisa import numpy as np import matplotlib as mpl @@ -36,6 +36,73 @@ def getConfig(apparatus): config[n]=i.getConfig() return config +class Apparatus(BasicInstrument): + def __init__(self, *args, **kwds): + super().__init__(*args, **kwds) + self.setLockinSlope(0) + + @BasicInstrument.tsdb_append + def getBCurrent(self): + scope = self.instruments['scope.monitor'] + ch=scope.getTrace(2, decimate=False) + bCurrent = np.mean(ch.y.values); # mV -> mA + return bCurrent + + def getErrAndEit(self): + scope = self.instruments['scope.feedback'] + # we need to freeze scope since this two values are taken on the same scope + trg_mode = scope.getTriggerMode() + scope.setTriggerMode('STOP') + err = self.getErr() + eit = self.getEIT() + scope.setTriggerMode(trg_mode) + return(err,eit) + + + + @BasicInstrument.tsdb_append + def getErr(self): + scope = self.instruments['scope.feedback'] + ch1=scope.getTrace(1, decimate=False) + err = np.mean(ch1.y.values) + return err + + @BasicInstrument.tsdb_append + def getEIT(self): + scope = self.instruments['scope.feedback'] + ch3=scope.getTrace(3, decimate=False) + eit = np.mean(ch3.y.values) + return eit + + @BasicInstrument.tsdb_append + def setFeefback(self, val): + freq0 = self.getRFreq() + self.setRFreq(freq0+val) + + @BasicInstrument.tsdb_append + def getRFreq(self): + rfgen = self.instruments['rfgen'] + return rfgen.getFreqFixed() + + @BasicInstrument.tsdb_append + def setRFreq(self,val): + rfgen = self.instruments['rfgen'] + rfgen.setFreqFixed(val) + + @BasicInstrument.tsdb_append + def getRFAmplitude(self): + rfgen = self.instruments['rfgen'] + return rfgen.getRFAmplitude() + + @BasicInstrument.tsdb_append + def setRFAmplitude(self, val): + rfgen = self.instruments['rfgen'] + return rfgen.setRFAmplitude(val) + + @BasicInstrument.tsdb_append + def setLockinSlope(self, val): + self.lockin_slope=val + if __name__ == '__main__': # TSDB logger setting @@ -84,6 +151,7 @@ if __name__ == '__main__': # scope_mon.setChanVoltageOffset(2, -0.0726) # if we want to save new set of traces repeat this two commands + scope_fdbk.config['tags'] = {} scope_fdbk.config['tags']['apparatus']=getConfig(apparatus) scope_fdbk.save( maxRequiredPoints=1000 ) |