예제 #1
0
파일: KaZimm.py 프로젝트: kedmond/KaZimm
def singleSet(temps, motorFreqs, numMeas=10, substance='Water', pauseTime=1, tempTime=120, motorTime=60, countTime=10.0, plotResults = True):
    initialize(substance)                               #Initialize ports, files, and constants (see below) 
    for temp in temps:
        stirFreq = 200.0                                    #Set stirring speed for bath
        setBath(temp, stirFreq, minStableTime=tempTime)     #Set temperature and wait for stability (see below)
        
        for motorFreq in motorFreqs:                        #Cycle through motorFreqs
        
            # before each measurement, we reset the chains by stirring them up, and then letting them reform
            print 'Spinning rotor for ' + str(motorTime) + ' seconds.'             
            setMotorFreq(stirFreq, sleepTime=motorTime)    # Prevent sedimentation
            
            print 'Pausing rotor for ' + str(pauseTime) + ' seconds.'             
            setMotorFreq(0, sleepTime=pauseTime)    # Pause, perhaps to wait for chains to form 
            
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime) #Set motor and checks if motorFreq is too high (high value may be changed in method setMotorFreq) (see below)
            if breakBool: break                             #Break if motorFreq is above threshold
            rotorFreqs = getData(numMeas, countTime=countTime)                   #Data retrieval (see below)
            plt.savefig('Figs/'+time.strftime("%y-%m-%d-%H-%M-%S", time.localtime())+'-'+str(motorFreq)+'.png')
            data = processData(temp, motorFreq, rotorFreqs) #Data processing (see below)
            
            # calculate the std. error:
            #se = numpy.std(rotorFreqs) / sqrt(numpy.size(rotorFreqs))
            
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err.
            writeToFile( data )
            
            
        print 'Measurements at ' + str(temp) + ' degrees C completed.'
        
    closeUp()   
    
    if plotResults and len(data) > 1:
        kplt.plotData(os.getcwd(), Filename, writeFile=True, fit=False)
예제 #2
0
파일: KaZimm3.py 프로젝트: kedmond/KaZimm
def singleSet(temps, motorFreqs, autoCount=False, countTime=10.0, numMeas=10, pauseTime=1, sampRate=2048, tempTime=120, motorTime=60, printDataBool=False, plotResults = True, substance='Water'):
    initialize(substance)                               #Initialize ports, files, and constants (see below) 
    
    for temp in temps:
        stirFreq = 400.0                                    #Set stirring speed for bath
        setBath(temp, stirFreq, minStableTime=tempTime)     #Set temperature and wait for stability (see below)
        
        for motorFreq in motorFreqs:                        #Cycle through motorFreqs
            print 'motorFreq is ' + str(motorFreq) + ' deg/sec.'
            # 28.Feb.2014, Kaz: minimize sampRate to avoid data overflow for longer runs at slow shear:
            rates = 2**np.array(range(4, 12))
            
            minSampRate = (20.0 * motorFreq/3.6)
            # rational is that you need at least 15 counts per tick, which I determined experimentally
            # with 100 ticks per rotation, and 3.6 degrees per tick
            # 15 counts/tick * (motorRate deg./sec. / 3.6 deg./tick) = minCountRate counts/second
            
            sampRate = rates[np.abs(rates-minSampRate).argmin()]
            if (sampRate-minSampRate) < 0 and sampRate != rates[-1]:
                sampRate = rates[np.abs(rates-minSampRate).argmin()+1]
         	
            print 'sampRate is ' + str(sampRate) + ' samples/sec.'
            
            # before each measurement, we reset the chains by stirring them up, and then letting them reform
            print 'Spinning rotor for ' + str(motorTime) + ' seconds.'             
            setMotorFreq(stirFreq, sleepTime=motorTime)    # Prevent sedimentation
            
            print 'Pausing rotor for ' + str(pauseTime) + ' seconds.'             
            setMotorFreq(0, sleepTime=pauseTime)    # Pause, perhaps to wait for chains to form 
            
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime) #Set motor and checks if motorFreq is too high (high value may be changed in method setMotorFreq) (see below)
            if breakBool: break                             #Break if motorFreq is above threshold
            
            # autoCount sets the count time to however long it takes for the motor to complete to full rotations
            if autoCount == True:
                cTime = np.ceil(720./motorFreq)
                print 'Counting for ' + str(cTime) + ' seconds.'
                rotorFreqs = getData(numMeas, countTime=cTime, sampRate=sampRate, printDataBool=printDataBool)     #Data retrieval (see below)
            else:
                rotorFreqs = getData(numMeas, countTime=countTime, sampRate=sampRate, printDataBool=printDataBool) #Data retrieval (see below)
                
            plt.savefig('Figs/'+time.strftime("%y-%m-%d-%H-%M-%S", time.localtime())+'-'+str(motorFreq)+'.png')
            data = processData(temp, motorFreq, rotorFreqs) #Data processing (see below)
            
            # calculate the std. error:
            #se = numpy.std(rotorFreqs) / sqrt(numpy.size(rotorFreqs))
            
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile( data )
            
        print 'Measurements at ' + str(temp) + ' degrees C completed.'
        
    closeUp()   
    
    if plotResults and len(data) > 1:
        kplt.plotData(os.getcwd(), Filename, writeFile=True, fit=False)
예제 #3
0
파일: KaZimm3.py 프로젝트: kedmond/KaZimm
def singleSet(temps,
              motorFreqs,
              autoCount=False,
              countTime=10.0,
              numMeas=10,
              pauseTime=1,
              sampRate=2048,
              tempTime=120,
              motorTime=60,
              printDataBool=False,
              plotResults=True,
              substance='Water'):
    initialize(substance)  #Initialize ports, files, and constants (see below)

    for temp in temps:
        stirFreq = 400.0  #Set stirring speed for bath
        setBath(temp, stirFreq, minStableTime=tempTime
                )  #Set temperature and wait for stability (see below)

        for motorFreq in motorFreqs:  #Cycle through motorFreqs
            print 'motorFreq is ' + str(motorFreq) + ' deg/sec.'
            # 28.Feb.2014, Kaz: minimize sampRate to avoid data overflow for longer runs at slow shear:
            rates = 2**np.array(range(4, 12))

            minSampRate = (20.0 * motorFreq / 3.6)
            # rational is that you need at least 15 counts per tick, which I determined experimentally
            # with 100 ticks per rotation, and 3.6 degrees per tick
            # 15 counts/tick * (motorRate deg./sec. / 3.6 deg./tick) = minCountRate counts/second

            sampRate = rates[np.abs(rates - minSampRate).argmin()]
            if (sampRate - minSampRate) < 0 and sampRate != rates[-1]:
                sampRate = rates[np.abs(rates - minSampRate).argmin() + 1]

            print 'sampRate is ' + str(sampRate) + ' samples/sec.'

            # before each measurement, we reset the chains by stirring them up, and then letting them reform
            print 'Spinning rotor for ' + str(motorTime) + ' seconds.'
            setMotorFreq(stirFreq,
                         sleepTime=motorTime)  # Prevent sedimentation

            print 'Pausing rotor for ' + str(pauseTime) + ' seconds.'
            setMotorFreq(0, sleepTime=pauseTime
                         )  # Pause, perhaps to wait for chains to form

            breakBool = setMotorFreq(
                motorFreq, sleepTime=motorTime
            )  #Set motor and checks if motorFreq is too high (high value may be changed in method setMotorFreq) (see below)
            if breakBool: break  #Break if motorFreq is above threshold

            # autoCount sets the count time to however long it takes for the motor to complete to full rotations
            if autoCount == True:
                cTime = np.ceil(720. / motorFreq)
                print 'Counting for ' + str(cTime) + ' seconds.'
                rotorFreqs = getData(
                    numMeas,
                    countTime=cTime,
                    sampRate=sampRate,
                    printDataBool=printDataBool)  #Data retrieval (see below)
            else:
                rotorFreqs = getData(
                    numMeas,
                    countTime=countTime,
                    sampRate=sampRate,
                    printDataBool=printDataBool)  #Data retrieval (see below)

            plt.savefig('Figs/' +
                        time.strftime("%y-%m-%d-%H-%M-%S", time.localtime()) +
                        '-' + str(motorFreq) + '.png')
            data = processData(temp, motorFreq,
                               rotorFreqs)  #Data processing (see below)

            # calculate the std. error:
            #se = numpy.std(rotorFreqs) / sqrt(numpy.size(rotorFreqs))

            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile(data)

        print 'Measurements at ' + str(temp) + ' degrees C completed.'

    closeUp()

    if plotResults and len(data) > 1:
        kplt.plotData(os.getcwd(), Filename, writeFile=True, fit=False)