From c732ed6778bbe6025d6a0b89ca87bd34ab90800a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 26 Nov 2008 15:19:29 -0500 Subject: [PATCH] Minor hack to z_piezo.py to support calibcant.config module. --- z_piezo.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/z_piezo.py b/z_piezo.py index ceb4d90..6b1e539 100644 --- a/z_piezo.py +++ b/z_piezo.py @@ -34,6 +34,13 @@ BASE_FIG_NUM = 50 LOG_RAMPS = False LOG_DIR = '/home/wking/rsrch/data/z_piezo' +# Hackish defaults for the calibcant.config module +DEFAULT_GAIN = 20 # Vpiezo / Voutput +DEFAULT_SENSITIVITY = 7.41 # nm_surface/Volt_piezo +DEFAULT_ZERO_PHOTODIODE_BITS = 2**15 +DEFAULT_VPHOTO_IN_2_VOLTS = lambda vbits : (vbits-DEFAULT_ZERO_PHOTODIODE_BITS)/3276.8 +DEFAULT_VZP_OUT_2_VOLTS = lambda vbits : (vbits-DEFAULT_ZERO_PHOTODIODE_BITS)/3276.8 + DEFAULT_ZP_CHAN = 0 DEFAULT_ZP_MON_CHAN = 1 DEFAULT_DEF_CHAN = 0 @@ -44,8 +51,16 @@ if USE_ABCD_DEFLECTION : # C D # looking in along the laser -import pycomedi.single_aio as single_aio -import pycomedi.simult_aio as simult_aio +class NoComedi (ImportError): + "Missing comedi. Don't initialize a z_piezo instance." + pass + +try: + import pycomedi.single_aio as single_aio + import pycomedi.simult_aio as simult_aio + HAS_COMEDI = True +except ImportError, e: + HAS_COMEDI = False from numpy import array, arange, ones, zeros, linspace, uint16, float, sin, pi from scipy.stats import linregress @@ -66,8 +81,10 @@ class z_piezo : def __init__(self, zp_chan=DEFAULT_ZP_CHAN, zp_mon_chan=DEFAULT_ZP_MON_CHAN, def_chan=DEFAULT_DEF_CHAN) : - self.sensitivity = 7.41 # nm_surface/Volt_piezo - self.gain = 20 # Vpiezo / Voutput + if HAS_COMEDI is not True: + raise NoComedi + self.sensitivity = DEFAULT_SENSITIVITY + self.gain = DEFAULT_GAIN self.nm2Vout = self.sensitivity * self.gain # nm_surface / V_output self.chan_info = _chan_info(zp_chan, zp_mon_chan, def_chan) -- 2.26.2