rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
trial_testers = [IPTester('trial', params=v) for v in trial_packages] runners.extend(zip(trial_packages, trial_testers))
nose_pkg_names.append('kernel') trial_pkg_names.append('kernel') nose_packages = ['IPython.%s' % m for m in nose_pkg_names ] trial_packages = ['IPython.%s' % m for m in trial_pkg_names ] runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ] runners.extend([ (v, IPTester('trial', params=v)) for ...
def make_runners(): """Define the top-level packages that need to be tested. """ nose_packages = ['config', 'core', 'extensions', 'frontend', 'lib', 'scripts', 'testing', 'utils', # Note that we list the kernel here, though the bulk of it # is twisted-based, because nose picks up doctests that # twisted doesn't. 'kern...
ipjoin('testing', 'tools'),
def make_exclude(): """Make patterns of modules and packages to exclude from testing. For the IPythonDoctest plugin, we need to exclude certain patterns that cause testing problems. We should strive to minimize the number of skipped modules, since this means untested code. As the testing machinery solidifies, this l...
self.runner = ['python', iptest_path, '-v']
self.runner = tools.cmd2argv(iptest_path) + ['-v']
def __init__(self,runner='iptest',params=None): """Create new test runner.""" if runner == 'iptest': # Find our own 'iptest' script OS-level entry point try: iptest_path = os.path.abspath(find_cmd('iptest')) except FindCmdError: # Script not installed (may be the case for testing situations # that are running from a so...
self.runner = ['python', os.path.abspath(find_cmd('trial'))]
self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial')))
def __init__(self,runner='iptest',params=None): """Create new test runner.""" if runner == 'iptest': # Find our own 'iptest' script OS-level entry point try: iptest_path = os.path.abspath(find_cmd('iptest')) except FindCmdError: # Script not installed (may be the case for testing situations # that are running from a so...
out.append((tag,out_path,pfiles))
out.append((out_path, pfiles))
def make_dir_struct(tag,base,out_base): """Make the directory structure of all files below a starting dir. This is just a convenience routine to help build a nested directory hierarchy because distutils is too stupid to do this by itself. XXX - this needs a proper docstring! """ # we'll use these a lot below lbase =...
data_files = [ ('data',manpagebase, manpages), ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
data_files = [ (manpagebase, manpages), (pjoin(docdirbase, 'extensions'), igridhelpfiles),
def find_data_files(): """ Find IPython's data_files. Most of these are docs. """ docdirbase = pjoin('share', 'doc', 'ipython') manpagebase = pjoin('share', 'man', 'man1') # Simple file lists can be made by hand manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz'))) igridhelpfiles = filter(isfile, glob(pjoi...
'ipythonqt = IPython.frontend.qt.console.ipythonqt:main',
'ipython-qtconsole = IPython.frontend.qt.console.ipythonqt:main',
def cleanup(): """Clean up the junk left around by the build process""" if "develop" not in sys.argv: try: shutil.rmtree('ipython.egg-info') except: try: os.unlink('ipython.egg-info') except: pass
iptest_path = pjoin(genutils.get_ipython_package_dir(), 'scripts','iptest')
pak_dir = os.path.abspath(genutils.get_ipython_package_dir()) iptest_path = pjoin(pak_dir, 'scripts', 'iptest')
def __init__(self,runner='iptest',params=None): """Create new test runner.""" if runner == 'iptest': # Find our own 'iptest' script OS-level entry point try: iptest_path = os.path.abspath(find_cmd('iptest')) except FindCmdError: # Script not installed (may be the case for testing situations # that are running from a so...
def populateBackground( server, style, tiles, image ):
def populateBackground( server, cachelocation, tiles, image ):
def populateBackground( server, style, tiles, image ): rootx = tiles['x']['min'] rooty = tiles['y']['min'] zoom = str(tiles['zoom']) templocation = os.path.join(cachelocation, style) if not os.path.isdir(templocation): os.mkdir(templocation)
templocation = os.path.join(cachelocation, style) if not os.path.isdir(templocation): os.mkdir(templocation)
if not os.path.isdir(cachelocation): os.makedirs(cachelocation)
def populateBackground( server, style, tiles, image ): rootx = tiles['x']['min'] rooty = tiles['y']['min'] zoom = str(tiles['zoom']) templocation = os.path.join(cachelocation, style) if not os.path.isdir(templocation): os.mkdir(templocation)
temptilename = '-'.join( ['cache', zoom, str(x), str(y) ] ) + '.png' temptilename = os.path.join(templocation, temptilename)
temptilename = '-'.join( [zoom, str(x), str(y) ] ) + '.png' temptilename = os.path.join(cachelocation, temptilename)
def populateBackground( server, style, tiles, image ): rootx = tiles['x']['min'] rooty = tiles['y']['min'] zoom = str(tiles['zoom']) templocation = os.path.join(cachelocation, style) if not os.path.isdir(templocation): os.mkdir(templocation)
image = Tile.populateBackground(self.options.get('tileserver'), self.options.get('renderer'), self.tiles, image)
cachelocation = os.path.join('.', self.options.get('cache'), self.options.get('renderer')) image = Tile.populateBackground(self.options.get('tileserver'), cachelocation, self.tiles, image)
def drawTrack(self, filename = ''):
def getPixelForCoord( point, bounds, tiles ): return [1,1] pass
def getPixelForCoord( point, bounds, imagesize ): return (((bounds[0][1] - point[1] ) / bounds[2][1] * imagesize[1]) + 128 , ((bounds[0][0] - point[0] ) / bounds[2][0] * imagesize[0]) + 128)
def calculateTilesAuto( points ):
bounds = [(),()]
bounds = [(),(), ()]
def calculateTilesAuto( points ):
pointlist = map( lambda x: Tile.getPixelForCoord(x, self.bounds, self.tiles), self.points)
pointlist = map( lambda x: Tile.getPixelForCoord(x, self.bounds, imagesize), self.points)
def drawTrack(self, filename):
@staticmethod def quickTest( tiles ): for x in range(tiles['x']['min'],tiles['x']['min'] + tiles['x']['count'] + 1): for y in range(tiles['y']['min'],tiles['y']['min'] + tiles['y']['count'] + 1): print Tile.getTileURL( x, y, tiles['zoom'] )
def getTileURL( xtile, ytile, zoom ): return '/'.join( [tileserver, str(zoom), str(xtile), str(ytile)] ) + '.png'
return {'x': { 'min':tilexmin - expand, 'max':tilexmax + expand, 'count': tilexmax - tilexmin + 2 * expand }, 'y': { 'min':tileymin - expand, 'max':tileymax + expand, 'count': tileymax - tileymin + 2 * expand },
return {'x': { 'min':tilexmin - expand, 'max':tilexmax + 1+expand, 'count': tilexmax - tilexmin +1 + 2 * expand }, 'y': { 'min':tileymin - expand, 'max':tileymax + 1+expand, 'count': tileymax - tileymin +1 + 2 * expand },
def calculateTiles( points, zoom = 10 ):
while ( (tiles['x']['count']+1) * (tiles['y']['count']+1) > (osize * osize) ):
while ( (tiles['x']['count']) * (tiles['y']['count']) > (osize+1 * osize+1) ):
def calculateTilesAuto( points ):
fromx = rootx - x fromy = rooty - y
fromx = abs(rootx - x) fromy = abs(rooty - y)
def calculateTilesAuto( points ):
urllib.urlretrieve( Tile.getTileURL( x, y, tiles['zoom'] ), temptilename )
if not os.path.isfile( temptilename ): urllib.urlretrieve( Tile.getTileURL( x, y, tiles['zoom'] ), temptilename )
def calculateTilesAuto( points ):
image.paste( tile, (256*rootx, 256*rooty ))
print 256*fromx print 256*fromy image.paste( tile, (256*fromx, 256*fromy ))
def calculateTilesAuto( points ):
self.delta[0] = self.bounds[0][0] - self.bounds[1][0] self.delta[1] = self.bounds[0][1] - self.bounds[1][1]
def computeBounds(self): # here we use self.points and get the area of the drawing # (tiles), and figure out the lat/long bounds # then we return self.tiles = Tile.calculateTilesAuto( self.points )
Tile.populateBackground(self.tiles, image)
image = Tile.populateBackground(self.tiles, image)
def drawTrack(self, filename): # write track out to this filename
track.loadFromFile('winchcombe.gpx')
track.loadFromFile('2010-07-12_12-18-49.gpx')
def drawTrack(self, filename): # write track out to this filename
'notice': 'small'
'notice': 'normal'
def populateBackground( server, cachelocation, tiles, image ): global verbose
if verbose: print 'Supplied arguments', options, args
def drawTrack( self, filename = '' ): global verbose if verbose: print 'GPX.drawTrack()'
temptilename = '-'.join( ['cache', str(zoom), str(x), str(y) ] ) + '.png'
temptilename = '-'.join( ['cache', str(tiles['zoom']), str(x), str(y) ] ) + '.png'
def calculateTilesAuto( points ):
@staticmethod def calculateTiles( points, zoom = 10 ):
@staticmethod def calculateTiles( bounds, zoom = 10 ):
def getTileURL( xtile, ytile, zoom ): return '/'.join( [tileserver, str(zoom), str(xtile), str(ytile)] ) + '.png'
for point in points: [xtile, ytile] = Tile.getNumber( point[0], point[1], zoom ) tilexmin = min(xtile, tilexmin) tilexmax = max(xtile, tilexmax) tileymin = min(ytile, tileymin) tileymax = max(ytile, tileymax) expand = 1 return {'x': { 'min':tilexmin - expand, 'max':tilexmax + 1+expand, 'count': tilexmax - tilexmin +...
[tilexmin, tileymin] = Tile.getNumber( bounds[0][0], bounds[0][1], zoom ) [tilexmax, tileymax] = Tile.getNumber( bounds[1][0], bounds[1][1], zoom ) return {'x': { 'min':tilexmin, 'max':tilexmax , 'count': tilexmax - tilexmin +1 }, 'y': { 'min':tileymin, 'max':tileymax , 'count': tileymax - tileymin +1 },
def calculateTiles( points, zoom = 10 ):
def calculateTilesAuto( points ):
def calculateTilesAuto( bounds ):
def calculateTilesAuto( points ):
tiles = Tile.calculateTiles( points, zoomdefault ) while ( (tiles['x']['count']) * (tiles['y']['count']) > (osize+1 * osize+1) ):
tiles = Tile.calculateTiles( bounds, zoomdefault ) while ( (tiles['x']['count']) * (tiles['y']['count']) >= (osize * osize) ):
def calculateTilesAuto( points ):
return Tile.calculateTiles( points, zoomdefault )
return Tile.calculateTiles( bounds, zoomdefault )
def calculateTilesAuto( points ):
return (((bounds[0][1] - point[1] ) / bounds[2][1] * imagesize[1]) + 128 , ((bounds[0][0] - point[0] ) / bounds[2][0] * imagesize[0]) + 128)
return (int((bounds[0][1] - point[1] ) / bounds[2][1] * imagesize[0]) , int((bounds[0][0] - point[0] ) / bounds[2][0] * imagesize[1]))
def calculateTilesAuto( points ):
bounds = [(),(), ()] delta = [0,0]
tilesbounds = [(),(), ()]
def calculateTilesAuto( points ):
self.tiles = Tile.calculateTilesAuto( self.points ) self.bounds[0] = Tile.getCoords( self.tiles['x']['min'], self.tiles['y']['min'], self.tiles['zoom'] )
latmin = longmin = 200000 latmax = longmax = -200000 for point in self.points: latmin = min(point[0], latmin) latmax = max(point[0], latmax) longmin = min(point[1], longmin) longmax = max(point[1], longmax) self.pointsbounds = [(latmax, longmin), (latmin, longmax)] self.tiles = Tile.calculateTilesAuto( self.pointsbou...
def computeBounds(self): # here we use self.points and get the area of the drawing # (tiles), and figure out the lat/long bounds # then we return self.tiles = Tile.calculateTilesAuto( self.points )
self.bounds[1] = Tile.getCoords( self.tiles['x']['max']+1, self.tiles['y']['max']+1, self.tiles['zoom'] ) self.bounds[2] = ( self.bounds[0][0] - self.bounds[1][0], self.bounds[0][1] - self.bounds[1][1] )
self.tilesbounds[1] = Tile.getCoords( self.tiles['x']['max']+1, self.tiles['y']['max']+1, self.tiles['zoom'] ) self.tilesbounds[2] = ( self.tilesbounds[0][0] - self.tilesbounds[1][0], self.tilesbounds[0][1] - self.tilesbounds[1][1] )
def computeBounds(self): # here we use self.points and get the area of the drawing # (tiles), and figure out the lat/long bounds # then we return self.tiles = Tile.calculateTilesAuto( self.points )
pointlist = map( lambda x: Tile.getPixelForCoord(x, self.bounds, imagesize), self.points)
pointlist = map( lambda x: Tile.getPixelForCoord(x, self.tilesbounds, imagesize), self.points)
def drawTrack(self, filename):
draw.line(pointlist, fill='blue', width=2) trim = int(256/2) image = image.crop( tuple( [trim, trim] + map( lambda x: x-trim, image.size) ) )
draw.line(pointlist, fill='black', width=1) if osize*osize < self.tiles['x']['count']*self.tiles['y']['count']: path = [ Tile.getPixelForCoord( self.pointsbounds[0], self.tilesbounds, imagesize), Tile.getPixelForCoord( self.pointsbounds[1], self.tilesbounds, imagesize) ] imagebox = [ [0,0], list(imagesize) ] if i...
def drawTrack(self, filename):
pass
def drawTrack(self, filename):
track.loadFromFile('winchcombe.gpx')
track.loadFromFile('2010-07-12_12-18-49.gpx') print "Loaded"
def drawTrack(self, filename):
track.drawTrack('output.png')
track.drawTrack('output2.png')
def drawTrack(self, filename):
def trigger(self, groupCtx, devCtxs):
def triggerDevs(self, groupCtx, devCtxs): """Create a packet to trigger other devices and the group context.""" p = self.makePacket() return p def triggerRunContext(self, groupCtx, devCtxs):
def trigger(self, groupCtx, devCtxs): """Create a packet to trigger other devices and the group context.""" p = self.makePacket() p.send_trigger(groupCtx) for ctx in devCtxs: p.send_trigger(ctx) p.wait_for_trigger(len(devCtxs)) return p
for ctx in devCtxs: p.send_trigger(ctx) p.wait_for_trigger(len(devCtxs))
def trigger(self, groupCtx, devCtxs): """Create a packet to trigger other devices and the group context.""" p = self.makePacket() p.send_trigger(groupCtx) for ctx in devCtxs: p.send_trigger(ctx) p.wait_for_trigger(len(devCtxs)) return p
dev.trigger(self.ctx, devCtxs)))
dev.triggerDevs(self.ctx, devCtxs), dev.triggerRunContext(self.ctx, devCtxs)))
def makePackets(self, devs, timingOrder, page, reps, sync=249, multiBlockBoards=[]): """Make packets to run a sequence on this board group.
triggerAll = defer.DeferredList([p[1].send() for p in collectPkts], consumeErrors=True)
def padSRAM(dev): dev, mem, sram, slave, delay = dev if isinstance(sram, tuple): delay = (delay, sram[2]) sram = '\x00' * (SRAM_BLOCK0_LEN*4 - len(sram[0])) + sram[0] + sram[1] return dev, mem, sram, slave, delay
if all(s for s, r in results): readAll = sendAll(readPkts, 'Read', boardOrder)
if not all(success for success, result in results): clearPkts, msg = self.makeClearPackets(devs, results) yield sendAll(clearPkts, 'Timeout Recovery', boardOrder) for (success, result), pkts in zip(results, collectPkts): collectPkt, triggerDevs, triggerRunContext = pkts if not success: yield triggerRun...
def padSRAM(dev): dev, mem, sram, slave, delay = dev if isinstance(sram, tuple): delay = (delay, sram[2]) sram = '\x00' * (SRAM_BLOCK0_LEN*4 - len(sram[0])) + sram[0] + sram[1] return dev, mem, sram, slave, delay
else: clearPkts, msg = self.makeClearPackets(devs, results) try: yield sendAll(clearPkts, 'Timeout Recovery', boardOrder) finally: readLock.release() raise Exception(msg)
raise TimeoutError(msg) readAll = sendAll(readPkts, 'Read', boardOrder) readLock.release()
def padSRAM(dev): dev, mem, sram, slave, delay = dev if isinstance(sram, tuple): delay = (delay, sram[2]) sram = '\x00' * (SRAM_BLOCK0_LEN*4 - len(sram[0])) + sram[0] + sram[1] return dev, mem, sram, slave, delay
timing = numpy.vstack(self.extractTiming(r) for r in results)
if len(results): timing = numpy.vstack(self.extractTiming(r) for r in results) else: timing = []
def padSRAM(dev): dev, mem, sram, slave, delay = dev if isinstance(sram, tuple): delay = (delay, sram[2]) sram = '\x00' * (SRAM_BLOCK0_LEN*4 - len(sram[0])) + sram[0] + sram[1] return dev, mem, sram, slave, delay
ans = yield bg.run(devices, reps, setupReqs, getTimingData, timingOrder, c['master_sync'], set(setupState)) returnValue(ans)
retries = self.retries attempt = 1 while True: try: ans = yield bg.run(devices, reps, setupReqs, getTimingData, timingOrder, c['master_sync'], set(setupState)) returnValue(ans) except TimeoutError, err: with open('C:\\dac_timeout_log.txt', 'a') as logfile: print 'attempt %d - error: %s' % (attempt, err) print >>logfi...
def run_sequence(self, c, reps=30, getTimingData=True, setupPkts=[], setupState=[]): """Executes a sequence on one or more boards.
str = "INTERPOLATION -- Resistances: %s -- Temperatures: %s" % (self.calibrations[0][1], self.calibrations[0][2])
str = "INTERPOLATION -- Resistances: %s -- Temperatures: %s" % (self.calibrations[channel][1], self.calibrations[channel][2])
def printCalibration(self, channel): str = '' try: if self.calibrations[channel][0] == INTERPOLATION: str = "INTERPOLATION -- Resistances: %s -- Temperatures: %s" % (self.calibrations[0][1], self.calibrations[0][2]) elif self.calibrations[channel][0] == FUNCTION: str = "FUNCTION: %s -- Inverse: %s" % (self.calibration...
str = "FUNCTION: %s -- Inverse: %s" % (self.calibrations[0][1], self.calibrations[0][2])
str = "FUNCTION: %s -- Inverse: %s" % (self.calibrations[channel][1], self.calibrations[channel][2])
def printCalibration(self, channel): str = '' try: if self.calibrations[channel][0] == INTERPOLATION: str = "INTERPOLATION -- Resistances: %s -- Temperatures: %s" % (self.calibrations[0][1], self.calibrations[0][2]) elif self.calibrations[channel][0] == FUNCTION: str = "FUNCTION: %s -- Inverse: %s" % (self.calibration...
for i in range(5):
for i in range(max(self.readOrder)):
def reloadCalibrations(self): # load resistance->temperature function from registry # there are actually multiple functions--one for each channel, # and a device default in case any of the channels' are missing # self.calibrations[0] = device default calibration, self.calibrations[1-5] for channels 1-5 # see comment ab...
try: p = reg.packet() p.cd(dir) p.get("Read Order", key="ro") ans = yield p.send() self.readOrder = ans["ro"] except Exception: self.readOrder = READ_ORDER self.readings = [(0, datetime.now())] * len(set(self.readOrder)) print "READINGS %s" % self.readings.__str__()
def reloadCalibrations(self): # load resistance->temperature function from registry # there are actually multiple functions--one for each channel, # and a device default in case any of the channels' are missing # self.calibrations[0] = device default calibration, self.calibrations[1-5] for channels 1-5 # see comment ab...
for i in range(5):
for i in range(max(self.readOrder)):
def getTemperatures(self): # we now do this channel by channel. oh yeah. result = [] for i in range(5): result.append((self.getSingleTemp(i+1), self.readings[i][1])) return result
'switchPosition': 2, 'timeMaggedDown': None, 'scheduledMagDownTime': time.time(), 'scheduledMagUpTime': time.time(),
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
else: self.psMaxCurrent()
def cycle(self): """ this function should get called after the server finishes connecting. it doesn't return. each of the statuses will have a sleep for a given amount of time (usually 1s or rampWaitTime). """ self.state('alive', True) self.log("Now cycling.") while self.state('alive'): # check to see if we should star...
self.state('scheduledMagDownTime', self.state('magUpCompletedTime') + newValue * 60.0)
self.state('scheduledMagDownTime', self.state('magUpCompletedTime') + newValue * 60.0) elif var == 'schedulingActive' and newValue: self.state('autoControl', True)
def state(self, var, newValue = None): if newValue is not None: self.stateVars[var] = newValue self.log('Set %s to %s' % (var, str(newValue))) # if we changed the field wait time, we may need to change scheduled mag down time if var == 'fieldWaitTime' and self.state('magUpCompletedTime') > 1: self.state('scheduledMagDo...
@setting(70, "Show Calibrations") def show_calibrations(self, c): """ Returns the volt-to-resistance calibrations used with the lock-in. Which one to use is selected by switchPosition. """ dev = self.selectedDevice(c) return dev.voltToResCalibs
def is_recording(self, c): """ Returns whether recording or not. """ dev = self.selectedDevice(c) return dev.state('recordTemp')
p.timeout(5)
p.timeout(TIMEOUT)
def connect(self, server, port): """Connect to a heat switch device.""" print 'connecting to "%s" on port "%s"...' % (server.name, port), self.server = server self.ctx = server.context() self.port = port p = self.packet() p.open(port) p.baudrate(2400) p.read() # clear out the read buffer p.timeout(5)
'': a[56],
'serDAC': a[56],
def processReadback(resp): a = np.fromstring(resp, dtype='<u1') return { 'build': a[51], '': a[56], 'noPllLatch': bool((a[58] & 0x80) > 0), 'ackoutI2C': a[61], 'I2Cbytes': a[69:61:-1], }
ch['cosine'] = np.floor(cosineAmp * np.cos(phi) + 0.5).astype('uint8')
ch['cosine'] = np.floor(cosineAmp * np.sin(phi) + 0.5).astype('uint8')
def adc_trig_magnitude(self, c, channel, sineAmp, cosineAmp): """Set the magnitude of sine and cosine functions for a demodulation channel. (ADC only) The channel indicates which demodulation channel to use, in the range 0 to N-1 where N is the number of channels (currently 4). sineAmp and cosineAmp are the magnitude...
'fastTempRecordDelay': 10, 'fastTempMaxT': 4, 'fastTempMaxTime': 12*60, 'fastTempHSStop': True,
'fastRecordingRecordDelay': 10, 'fastRecordingMaxT': 4, 'fastRecordingMaxTime': 12*60, 'fastRecordingHSStop': True,
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
delay = self.state('fastTempRecordDelay')
delay = self.state('fastRecordingRecordDelay')
def tempCycle(self): """ this function should be called when the temperature recording starts, and will return when it stops. it will loop every either 10s or 10 min and then call record temp. this also checks each time to see if we should continue recording. """ while self.state('recordTemp'): # make the record self.r...
return (t > self.state('fastRecordingMaxT') or (time.time() - self.state('fastRecordingStartTime') > self.state('fastRecordingMaxTime') * 60))
return ((t is nan) or (t > self.state('fastRecordingMaxT')) or (time.time() - self.state('fastRecordingStartTime') > self.state('fastRecordingMaxTime') * 60))
def shouldStopFastRecording(self): (t, r) = self.ruoxStatus() return (t > self.state('fastRecordingMaxT') or (time.time() - self.state('fastRecordingStartTime') > self.state('fastRecordingMaxTime') * 60))
while reading == base:
while (reading == base) and (pkt[0] < 0xffff - 16):
def dac_fifo(self, c, chan): """Moves the LVDS into a region where the FIFO counter is stable, adjusts the clock polarity and phase offset to make FIFO counter = 3, and finally returns LVDS setting back to original value """ op = getCommand({'A': 2, 'B': 3}, chan) dev = self.selectedDevice(c)
except:
except Exception:
def res2temp(r): try: return ((math.log(r) - 6.02) / 1.76) ** (-1/.345) except: return 0.0
except:
except Exception:
def temp2res(t): try: return math.exp(1.76*(t**(-0.345)) + 6.02) except: return 0.0
@setting(10, 'Temperatures', returns=['*(v[K], t)'])
@setting(10, 'Temperatures', returns='*(v[K], t)')
def readLoop(self, idx=0): while self.alive: # read only one specific channel if self.onlyChannel > 0: chan = self.onlyChannel yield util.wakeupCall(SETTLE_TIME) r = yield self.query('RDGR? %d' % chan) self.readings[chan-1] = float(r), datetime.now() # scan over channels else: chan = READ_ORDER[idx] yield self.selectCh...
@setting(11, 'Resistances', returns=['*(v[Ohm], t)'])
@setting(11, 'Resistances', returns='*(v[Ohm], t)')
def temperatures(self, c): """Read channel temperatures.
@setting(12, 'Select channel', channel=['w'], returns=['w'])
@setting(12, 'Select channel', channel='w', returns='w')
def resistances(self, c): """Read channel voltages.
@setting(56, 'Heater Output', returns=['v[%]'])
@setting(56, 'Heater Output', returns='v[%]')
def heaterrange(self, c, limit=None): """Sets the Heater Range""" dev = self.selectedDevice(c) ans = yield dev.setHeaterRange(limit) returnValue(ans)
yield self.packet().read().send()
return self.packet().read().send()
def read(self): """Read data from the RF Mux""" print 'trying to read 1' yield self.packet().read().send()
print ans['links']
def loadConfigInfo(self): """Load configuration information from the registry.""" reg = self.client.registry p = reg.packet() p.cd(['', 'Servers', 'RF Mux'], True) p.get('Serial Links', '*(ss)', key='links') ans = yield p.send() self.serialLinks = ans['links'] print ans['links']
time = numpy.linspace(0,HORZ_DIVISIONS*secPerDiv*recordLength(*1.0/2500),recordLength)
try: time = numpy.linspace(0,HORZ_DIVISIONS*secPerDiv*recordLength*(1.0/2500),recordLength) except: time = secPerDiv
def get_trace(self, c, channel, start=1, stop=2500): """Get a trace from the scope. OUTPUT - (array voltage in volts, array time in seconds) """
'logfile': 'N:\servers\ADR\%s-log.txt' % self.name,
'logfile': '%s-log.txt' % self.name,
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
with open(self.state('logfile')) as f: s = f.read() return s
f = open(self.state('logfile')) s = f.read() f.close() return s
def getEntireLog(self): s = '' with open(self.state('logfile')) as f: s = f.read() return s
'recordFast': False,
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
'tempRecordDelay': 600, 'fastRecordingRecordDelay': 10, 'fastRecordingMaxT': 4, 'fastRecordingMaxTime': 12*60, 'fastRecordingHSStop': True, 'fastRecordingStartTime': None,
'tempRecordDelay': 10,
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
self.cycle()
reactor.callLater(0.1, self.cycle)
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
if (not self.state('recordFast')) and self.state('autoRecord') and (yield self.shouldStartFastRecording()): self.startFastRecording()
def cycle(self): """ this function should get called after the server finishes connecting. it doesn't return. each of the statuses will have a sleep for a given amount of time (usually 1s or rampWaitTime). """ self.state('alive', True) while self.state('alive'): # check to see if we should start recording temp #print "...
if self.state('recordFast') and self.state('autoRecord') and self.shouldStopFastRecording(): self.stopFastRecording()
def tempCycle(self): """ this function should be called when the temperature recording starts, and will return when it stops. it will loop every either 10s or 10 min and then call record temp. this also checks each time to see if we should continue recording. """ while self.state('recordTemp'): # make the record self.r...
if self.state('recordFast'): delay = self.state('fastRecordingRecordDelay') else: delay = self.state('tempRecordDelay')
break
def tempCycle(self): """ this function should be called when the temperature recording starts, and will return when it stops. it will loop every either 10s or 10 min and then call record temp. this also checks each time to see if we should continue recording. """ while self.state('recordTemp'): # make the record self.r...
e = reactor.callLater(delay, d.callback, None)
e = reactor.callLater(self.state('tempRecordDelay'), d.callback, None)
def tempCycle(self): """ this function should be called when the temperature recording starts, and will return when it stops. it will loop every either 10s or 10 min and then call record temp. this also checks each time to see if we should continue recording. """ while self.state('recordTemp'): # make the record self.r...
self.tempCycle()
reactor.callLater(0.1, self.tempCycle)
def startRecording(self): self.state('recordTemp', True) self.tempCycle()
def startFastRecording(self): self.state('recordFast', True) self.state('fastRecordingStartTime', time.time()) e = self.state('tempDelayedCall') if e: try: e.reset(0) except twisted.internet.error.AlreadyCalled: pass if not self.state('recordTemp'): self.startRecording() def stopFastRecording(self): self.state('record...
def startFastRecording(self): self.state('recordFast', True) self.state('fastRecordingStartTime', time.time()) e = self.state('tempDelayedCall') if e: try: e.reset(0) # reset the counter except twisted.internet.error.AlreadyCalled: pass if not self.state('recordTemp'): self.startRecording()
temp = (yield ls.server.temperatures(context=ls.ctxt))[0].value
temp = (yield ls.server.temperatures(context=ls.ctxt))[1].value
def shouldStartRecording(self): """ determines whether we should start recording. """ try: ls = self.peripheralsConnected['lakeshore'] temp = (yield ls.server.temperatures(context=ls.ctxt))[0].value returnValue(temp < self.state('recordingTemp')) except Exception, e: #print e returnValue(False)
temp = (yield ls.server.temperatures(context=ls.ctxt))[0].value
temp = (yield ls.server.temperatures(context=ls.ctxt))[1].value
def shouldStopRecording(self): """ determines whether to stop recording. conditions: temp > 250K, --??? """ try: ls = self.peripheralsConnected['lakeshore'] temp = (yield ls.server.temperatures(context=ls.ctxt))[0].value #print "%s %s" % (temp, self.state('recordingTemp')) returnValue(temp > self.state('recordingTemp')...
self.selectedDevice(c).startRecording()
dev = self.selectedDevice(c) dev.state('autoRecord', False) dev.startRecording()
def start_recording(self, c): """ Start recording temp. """ self.selectedDevice(c).startRecording()
@setting(62, "Start Fast Recording") def start_fast_recording(self, c): """ Start fast recording temperature. Will start recording temperature if not before. """ self.selectedDevice(c).startFastRecording() @setting(63, "Stop Fast Recording") def stop_fast_recording(self, c): """ Stop fast recording temperature. Regular...
@setting(62, "Is Recording") def is_recording(self, c): """ Returns whether recording or not. """ dev = self.selectedDevice(c) return dev.state('recordTemp')
def stop_recording(self, c): """ Stop recording temp. """ self.selectedDevice(c).stopRecording()
if pkt[0] > 0xffff:
if pkt[0] >= 0x600:
def dac_fifo(self, c, chan): """Moves the LVDS into a region where the FIFO counter is stable, adjusts the clock polarity and phase offset to make FIFO counter = 3, and finally returns LVDS setting back to original value """ op = getCommand({'A': 2, 'B': 3}, chan) dev = self.selectedDevice(c)
@setting(21, 'list peripherals') def list_peripherals(self,c): dev = self.selectedDevice(c) return dev.peripheralsConnected @setting(22, 'refresh peripherals')
@setting(21, 'refresh peripherals', returns=[''])
def findDevices(self): """Finds all ADR configurations in the registry at CONFIG_PATH and returns a list of (ADR_name,(),peripheralDictionary). INPUTS - none OUTPUT - List of (ADRName,(connectionObject,context),peripheralDict) tuples. """ deviceList=[] reg = self.client.registry yield reg.cd(CONFIG_PATH) resp = yield r...
returnValue([FUNCTION, ans.fun, ans.inv])
def loadSingleCalibration(self, reg, path): try: p = reg.packet() p.cd(path) p.get("Calibration Type", key="type") ans = yield p.send() if ans.type.upper() == "INTERPOLATION": p = reg.packet() p.cd(path) p.get("Resistances", key="res") p.get("Temperatures", key="temp") ans = yield p.send() returnValue([INTERPOLATION, a...
np.log(np.array(self.calibrations[calIndex][2])), np.log(np.array(self.calibrations[calIndex][1]))
np.log(np.array(self.calibrations[calIndex][2][::-1])), np.log(np.array(self.calibrations[calIndex][1][::-1]))
def singleTempToRes (self, temp, channel, calIndex=-1): if calIndex = -1: calIndex = channel try: if self.calibrations[calIndex][0] == INTERPOLATION: # do the log-log interpolation in reverse return (np.exp(np.interp(np.log(temp), np.log(np.array(self.calibrations[calIndex][2])), np.log(np.array(self.calibrations[calIn...
'ruoxSwitch': 3,
'ruoxSwitch': 2,
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
self.ruoxCoefsHigh = [-0.3199412, 5.74884e-8, -8.8409e-11] self.ruoxCoefsLow = [-0.77127, 1.0068e-4, -1.072e-9] self.highTempRuoxCurve = lambda r, p: 1 / (p[0] + p[1] * r**2 * np.log(r) + p[2] * r**3) self.lowTempRuoxCurve = lambda r, p: 1 / (p[0] + p[1] * r * np.log(r) + p[2] * r**2 * np.log(r)) self.voltToResCalibs =...
def connect(self, *args, **peripheralDict): """ TODO: Add error checking and handling """ #Give the ADR a client connection to LabRAD. #ADR's use the same connection as the ADR server. #Each ADR makes LabRAD requests in its own context.
yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") p = reg.packet()
yield reg.cd(CONFIG_PATH, context=self.ctxt) yield reg.cd("defaults", context=self.ctxt) keys = (yield reg.dir(context=self.ctxt))[1] if "volt to res %s" % self.name in keys: vtrKey = "volt to res %s" % self.name else: vtrKey = "volt to res" p = reg.packet(context=self.ctxt)
def loadDefaultsFromRegistry(self): reg = self.cxn.registry yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") # load the vars about ruox calibration p = reg.packet() p.get("high temp ruox curve", key="htrc") p.get("low temp ruox curve", key="ltrc") p.get("resistance cutoff", key="rescut") p.get("ruox channel", key="ru...
p.get("volt to resistance calibrations", key="vtrc")
p.get(vtrKey, key="vtr")
def loadDefaultsFromRegistry(self): reg = self.cxn.registry yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") # load the vars about ruox calibration p = reg.packet() p.get("high temp ruox curve", key="htrc") p.get("low temp ruox curve", key="ltrc") p.get("resistance cutoff", key="rescut") p.get("ruox channel", key="ru...
self.ruoxCoefsHigh = map(lambda x: x.value, ans.rch) self.ruoxCoefsLow = map(lambda x: x.value, ans.rcl) self.highTempRuoxCurve = lambda r, p: eval(ans.htrc) self.lowTempRuoxCurve = lambda r, p: eval(ans.ltrc) self.voltToResCalibs = map(lambda x: x.value, ans.ctrc) self.resistanceCutoff = ans.rescut.value self.ruoxChan...
self.state('ruoxCoefsHigh', map(lambda x: x.value, ans.rch)) self.state('ruoxCoefsLow', map(lambda x: x.value, ans.rcl)) self.state('highTempRuoxCurve', lambda r, p: eval(ans.htrc)) self.state('lowTempRuoxCurve', lambda r, p: eval(ans.ltrc)) self.state('voltToResCalibs', map(lambda x: x.value, ans.vtr)) self.state('res...
def loadDefaultsFromRegistry(self): reg = self.cxn.registry yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") # load the vars about ruox calibration p = reg.packet() p.get("high temp ruox curve", key="htrc") p.get("low temp ruox curve", key="ltrc") p.get("resistance cutoff", key="rescut") p.get("ruox channel", key="ru...
yield reg.cd("state variables") (dirs, keys) = yield reg.dir()
yield reg.cd("state variables", context=self.ctxt) (dirs, keys) = yield reg.dir(context=self.ctxt)
def loadDefaultsFromRegistry(self): reg = self.cxn.registry yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") # load the vars about ruox calibration p = reg.packet() p.get("high temp ruox curve", key="htrc") p.get("low temp ruox curve", key="ltrc") p.get("resistance cutoff", key="rescut") p.get("ruox channel", key="ru...
val = yield reg.get(key)
val = yield reg.get(key, context=self.ctxt)
def loadDefaultsFromRegistry(self): reg = self.cxn.registry yield reg.cd(CONFIG_PATH) yield reg.cd("defaults") # load the vars about ruox calibration p = reg.packet() p.get("high temp ruox curve", key="htrc") p.get("low temp ruox curve", key="ltrc") p.get("resistance cutoff", key="rescut") p.get("ruox channel", key="ru...