예제 #1
0
 def multimeasure(self, interval=.1, totalmeasurements=None, totaltime=None, digits=4) -> DataStructures.Dataset:
     """Takes regular measurements, up to a max number or time, and returns a Dataset object
     interval <float>, time between each measurement
     totalmeasurements <int>, max number of measurements
     totaltime <float>, max time of series of measurements
     [digits] <int>, how many digits to round to
     """
     if totalmeasurements == None and totaltime == None:
         print('Error, no max measurements or time provided.')
         return None    
     elif totaltime != None and totalmeasurements == None:
         tm = totaltime / interval
     elif totaltime == None and totalmeasurements != None:
         tm = totalmeasurements
     else:
         tm = min(totaltime / interval, totalmeasurements)
     if self.__verbose__:
         print(self.__name__,'taking',tm,'measurements over',tm*interval,'seconds')
     o = DataStructures.Dataset() # initialize Dataset
     while len(o) < tm: # until I have enough data points
         o.append(self.measure(digits))
         time.sleep(interval)
     if self.__verbose__:
         print(self.__name__,'completed multimeasure')
     self.__lastresult__ = o
     return o
예제 #2
0
 def multisweep(self,
                a,
                b,
                step,
                passes,
                reverse=True) -> DataStructures.Dataset:
     """Takes repeated series of measurements across an angle range
     a <float>, a and b must be within [-1, 1]
     b <float>, 
     step <float>, must agree with a -> b direction
     passes <int>, how many times to repeat the sweep
     reverse <bool>, alternate left->right, right->left
     """
     if self.__verbose__:
         print(self.__name__, 'sweeping from', a, 'to', b, 'with step',
               step, ',', passes, 'times')
     r = DataStructures.Dataset()
     goback = False
     count = 0
     while count < passes:
         if reverse and goback:
             r.append(self.measure(b, a, step))
             goback = False
         else:
             r.append(self.measure(a, b, step))
             goback = True
         count += 1
     self.__lastresult__ = r
     return r
예제 #3
0
 def continuousmeasure(self, interval, digits=4, imagemaxdist=30) -> DataStructures.Dataset:
     d = DataStructures.Dataset([])
     try:
         if self.__verbose__:
             print(self.__name__,'measuring every',interval,'...')
         while True:
             d.append(self.measure(digits, True, imagemaxdist))
             time.sleep(interval)
     except KeyboardInterrupt:
         self.__lastresult__ = d
         return d
예제 #4
0
 def sweep(self, a, b, step) -> DataStructures.Dataset:
     """Takes a series of measurements across an angle range
     a <float>, a and b must be within [-1, 1]
     b <float>, 
     step <float>, must agree with a -> b direction
     """
     if b == a or step == 0:
         print('Error, distance or step 0')
     elif (b < a and step > 0) or (b > a and step < 0):
         print('Error, step and a -> b do not match')
     else:
         if self.__verbose__:
             print(self.__name__, 'sweeping from', a, 'to', b, 'with step',
                   step)
         x = self.__linearsteps__(a, b, step)
         r = DataStructures.Dataset([])
         for i in x:
             self.move(i)
             r.append(self.measure())
         self.__lastresult__ = r
         return r
예제 #5
0
 def __constructresult__(self,result) -> DataStructures.Dataset:
     d = DataStructures.Dataset([])
     t = General.TimeString()
     d.add(dist=result, time=t)
     return d
예제 #6
0
 def __constructresult__(self, result) -> DataStructures.Dataset:
     d = DataStructures.Dataset([])
     t = General.TimeString()
     p = self.__position__
     d.add(dist=result, time=t, pos=p)
     return d