Skip to content

Commit

Permalink
Bug fixes in code; First scan was run in the lab off his code
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-freeman committed Jan 20, 2017
1 parent 633203a commit 2052685
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
10 changes: 10 additions & 0 deletions place/automate/osci_card/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
osciCard.controller.__doc__). The remaining modules are used by the
controller module or are used for testing.
"""
import os
constantHeader = '/usr/local/AlazarTech/include/AlazarCmd.h'
constantFileName = os.path.join(os.path.dirname(__file__), "AlazarCmd.py")
try:
from . import AlazarCmd as cons
except ImportError:
if os.path.isfile(constantHeader):
from .parseConstants import parseHeader
parseHeader(constantHeader, constantFileName)
from . import AlazarCmd as cons
from .controller import (
BasicController,
ContinuousController,
Expand Down
7 changes: 3 additions & 4 deletions place/automate/osci_card/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,14 @@

import numpy as np
import matplotlib.pyplot as plt
import os.path
import os

from os.path import isfile
constantHeader = '/usr/local/AlazarTech/include/AlazarCmd.h'
constantFileName = os.path.join(os.path.dirname(__file__), "AlazarCmd.py")
try:
from . import AlazarCmd as cons
except ImportError:
if isfile(constantHeader):
if os.path.isfile(constantHeader):
from .parseConstants import parseHeader
parseHeader(constantHeader, constantFileName)
from . import AlazarCmd as cons
Expand Down Expand Up @@ -356,7 +355,7 @@ def _convertRawDataToInts(self, raw):
a = len(raw)
shorts = unpack(str(a) + 'B', raw)
a = len(shorts)
return [(shorts[2 * i + 1] * 256 + shorts[2 * i]) / 4 for i in range(a / 2)]
return [(shorts[2 * i + 1] * 256 + shorts[2 * i]) // 4 for i in range(a // 2)]

def _updateChannelCount(self):
"""
Expand Down
30 changes: 17 additions & 13 deletions place/automate/osci_card/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
@author: henrik
'''
import os
constantHeader = '/usr/local/AlazarTech/include/AlazarCmd.h'
constantFileName = os.path.join(os.path.dirname(__file__), "AlazarCmd.py")
try:
import AlazarCmd as cons
from . import AlazarCmd as cons
except ImportError:
pass # methods to this module will fail
if os.path.isfile(constantHeader):
from .parseConstants import parseHeader
parseHeader(constantHeader, constantFileName)
from . import AlazarCmd as cons
from functools import reduce

def getNamesOfConstantsThatStartWith(beginning):
Expand All @@ -23,30 +29,28 @@ def getValuesOfConstantsThatStartWith(beginning):

def getSampleRateFrom(name):
"""converts a string defining a sample rate to the rate in Hertz."""
import string
name = string.lstrip(name, "SAMPLE_RATE_")
name = string.rstrip(name, "SPS")
name = name.lstrip("SAMPLE_RATE_")
name = name.rstrip("SPS")
if name[-1] == "K":
exponent = 3
name = string.rstrip(name, "K")
name = name.rstrip("K")
elif name[-1] == "M":
exponent = 6
name = string.rstrip(name, "M")
name = name.rstrip("M")
elif name[-1] == "G":
exponent = 9
name = string.rstrip(name, "G")
name = name.rstrip("G")
return int(name) * 10 ** exponent

def getInputRangeFrom(name):
"""converts a string defining a input range to the range in Volt."""
import string
name = string.lstrip(name, "INPUT_RANGE_PM_")
name = string.rstrip(name, "V")
name = name.lstrip("INPUT_RANGE_PM_")
name = name.rstrip("V")
exponent = 0
if name[-1] == "M":
exponent = -3
name = string.rstrip(name, "M")
name = string.rstrip(name, '_')
name = name.rstrip("M")
name = name.rstrip('_')
return int(name) * 10 ** exponent

# Author: A.Polino
Expand Down
1 change: 0 additions & 1 deletion place/scripts/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
# PLACE modules
import place.automate.osci_card.controller as card
from place.automate.xps_control.XPS_C8_drivers import XPS
from place.automate.polytec.vibrometer import Polytec, PolytecDecoder, PolytecSensorHead
from place.automate.new_focus.picomotor import PMot
try:
from place.automate.new_focus.Calibrate import Position, getInverse, get_distance # TODO why does this file not exist in repo?
Expand Down

0 comments on commit 2052685

Please sign in to comment.