Пример #1
0
def getData(numMeas, duration, sampRate):
    
    rotorCounts = np.zeros([sampRate*duration, numMeas])
    
    for j in range(0, numMeas):
        rotorCounts[:, j] = cnt.retrieveData(duration, sampRate)
        
        rotorFreq = processData( rotorCounts[:, j], sampRate, duration )
        
        print 'count ' + str(j + 1) + ' of ' + str(numMeas) + ' taken successfully. [' + str(rotorFreq) + ' degs/sec]'
        # Kazem, 3.16.2012 - I added the reporting of data for convenience.
    
    return rotorCounts
Пример #2
0
def getData(numMeas, duration, sampRate):

    rotorCounts = np.zeros([sampRate * duration, numMeas])

    for j in range(0, numMeas):
        rotorCounts[:, j] = cnt.retrieveData(duration, sampRate)

        rotorFreq = processData(rotorCounts[:, j], sampRate, duration)

        print 'count ' + str(j + 1) + ' of ' + str(
            numMeas) + ' taken successfully. [' + str(rotorFreq) + ' degs/sec]'
        # Kazem, 3.16.2012 - I added the reporting of data for convenience.

    return rotorCounts
Пример #3
0
def hystSet(temps, motorFreqs, durations=10.0, sampRates=2048,
            tempTime=60, motorTime=15, sampleDescription='Water'):
    
    revFreqs = motorFreqs[(motorFreqs.size-2)::-1]
    revRates = sampRates[(motorFreqs.size-2)::-1]
    revDurs = durations[(motorFreqs.size-2)::-1]
    
    initialize()                   #Initialize ports, files, and constants (see below) 
 
    # save a description of the experiment to its directory
    descriptionHdr = 'duration (s), sampRate (cnts/s), motorFreq (1/s), pauseTime (s)'
    
    descriptionArray = np.column_stack((durations, sampRates, motorFreqs, np.repeat(0, durations.size)))
    
    directory = createDirectories()         # create a directory for this experiment's data
    
    # save a description of the experiment to its directory
    np.savetxt(directory + 'description-HysterisisTest.txt', descriptionArray, fmt='%d', delimiter=', ', header=sampleDescription+'\n'+descriptionHdr)    
    
    # these arrays need to be the same length
    if not motorFreqs.size == sampRates.size == durations.size:
        sys.exit('Error: motorFreqs, sampRates, and durations are not the same length.')
        
    for temp in temps:
        stirFreq = 2000.0                                   #Set stirring speed for bath
        setBath(temp, stirFreq, minStableTime=tempTime)     #Set temperature and wait for stability (see below)
        
        for i in range(motorFreqs.size):                    #Cycle through motorFreqs
            motorFreq = motorFreqs[i]
            sampRate = sampRates[i]
            duration = durations[i]
            
            print 'motorFreq is ' + str(motorFreq) + ' deg/sec, sampRate is ' + str(sampRate) + ' samples/sec, and duration is ' + str(duration) + ' seconds.'
                        
            # ***************** SHEAR SAMPLE FOR DATA *****************            
            
            # We want to measure steady shear, so wait for motor and sample to achieve speed
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime)
            if breakBool: break                             #Break if motorFreq is above threshold
            
            rotorCounts = cnt.retrieveData(duration, sampRate)
            
            rotorFreq = processData( rotorCounts, sampRate, duration )
            
            print 'Data for '+ str(motorFreq) +' deg/sec taken successfully. [rotorFreq: ' + str(rotorFreq) + ' degs/sec]'
            
            # Wait for 15 seconds for steady shear
            #time.sleep(15.0)
            
            fname = 'rotorSpeedsUp-'+ str(motorFreq).zfill(4) +'.txt'
            
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile( rotorCounts, directory + fname, 
                        [duration, sampRate, motorFreq, motorTime, 0] )
        
        
        for i in range(revFreqs.size):                    #Cycle through motorFreqs
            motorFreq = revFreqs[i]
            sampRate = revRates[i]
            duration = revDurs[i]
            
            print 'motorFreq is ' + str(motorFreq) + ' deg/sec, sampRate is ' + str(sampRate) + ' samples/sec, and duration is ' + str(duration) + ' seconds.'
                        
            # ***************** SHEAR SAMPLE FOR DATA *****************            
            
            # We want to measure steady shear, so wait for motor and sample to achieve speed
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime)
            if breakBool: break                             #Break if motorFreq is above threshold
            
            rotorCounts = cnt.retrieveData(duration, sampRate)
            
            rotorFreq = processData( rotorCounts, sampRate, duration )
            
            print 'Data for '+ str(motorFreq) +' deg/sec taken successfully. [rotorFreq: ' + str(rotorFreq) + ' degs/sec]'
            
            # Wait for 15 seconds for steady shear
            #time.sleep(15.0)
            
            fname = 'rotorSpeedsDown-'+ str(motorFreq).zfill(4) +'.txt'
            fname = 'rotorSpeedsDown-'+ str(motorFreq).zfill(4) +'.txt'
            
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile( rotorCounts, directory + fname, 
                        [duration, sampRate, motorFreq, motorTime, 0] )
            
        print 'Measurements at ' + str(temp) + ' degrees C completed.'
        
    closeUp()
Пример #4
0
def rampSet(temps, motorFreqs, durations=10.0, numMeas=10, pauseTime=1, sampRates=2048, 
            tempTime=60, motorTime=60, printDataBool=False, plotResults=False, sampleDescription='Water'):
    
    initialize()                   #Initialize ports, files, and constants (see below) 
 
    # save a description of the experiment to its directory
    descriptionHdr = 'duration (s), sampRate (cnts/s), motorFreq (1/s), pauseTime (s)'
    
    descriptionArray = np.column_stack((durations, sampRates, motorFreqs, np.repeat(pauseTime, durations.size)))
    
    directory = createDirectories()         # create a directory for this experiment's data
    
    # save a description of the experiment to its directory
    np.savetxt(directory + 'description-RampTest.txt', descriptionArray, fmt='%d', delimiter=', ', header=sampleDescription+'\n'+descriptionHdr)    
    
    # these arrays need to be the same length
    if not motorFreqs.size == sampRates.size == durations.size:
        sys.exit('Error: motorFreqs, sampRates, and durations are not the same length.')
        
    for temp in temps:
        stirFreq = 2000.0                                   #Set stirring speed for bath
        setBath(temp, stirFreq, minStableTime=tempTime)     #Set temperature and wait for stability (see below)
        
        for i in range(motorFreqs.size):                    #Cycle through motorFreqs
            motorFreq = motorFreqs[i]
            sampRate = sampRates[i]
            duration = durations[i]
            
            print 'motorFreq is ' + str(motorFreq) + ' deg/sec, sampRate is ' + str(sampRate) + ' samples/sec, and duration is ' + str(duration) + ' seconds.'
            
            # before each measurement, we reset the chains by stirring them up, and then letting them reform

            rotorCountsUp = np.zeros([sampRate*duration, numMeas])
            rotorCountsDown = np.zeros([sampRate*duration, numMeas])
            
            for j in range(numMeas):
                
                # ***************** STIR UP SAMPLE *****************
                
                print 'Spinning rotor for ' + str(motorTime) + ' seconds.'             
                breakBool = setMotorFreq(stirFreq, sleepTime=motorTime)     # Prevent sedimentation
                if breakBool: break                             #Break if motorFreq is above threshold
                
                # ***************** REST SAMPLE *****************            
                
                print 'Pausing rotor for ' + str(pauseTime) + ' seconds.'             
                breakBool = setMotorFreq(0, sleepTime=pauseTime)            # Pause, perhaps to wait for chains to form 
                if breakBool: break                             #Break if motorFreq is above threshold
                
                # ***************** SHEAR SAMPLE FOR DATA *****************            
                
                # Must begin acquiring immediately after motor begins
                
                breakBool = setMotorFreq(motorFreq, sleepTime=0.0)
                
                rotorCountsUp[:, j] = cnt.retrieveData(duration, sampRate)
                
                rotorFreq = processData( rotorCountsUp[:, j], sampRate, duration )
                
                print 'Ramp up ' + str(j + 1) + ' of ' + str(numMeas) + ' taken successfully. [' + str(rotorFreq) + ' degs/sec]'
                
                # Wait for 15 seconds for steady shear
                time.sleep(15.0)
                
                # Stop the motor, and record how the sample slows
                breakBool = setMotorFreq(0.0, sleepTime=0.0)
                # (high value may be changed in method setMotorFreq) (see below)
                if breakBool: break                             #Break if motorFreq is above threshold
                
                rotorCountsDown[:, j] = cnt.retrieveData(duration, sampRate)
                
                rotorFreq = processData( rotorCountsDown[:, j], sampRate, duration )
                
                print 'Ramp down ' + str(j + 1) + ' of ' + str(numMeas) + ' taken successfully. [' + str(rotorFreq) + ' degs/sec]'

            fnameUp = 'rotorSpeedsUp-'+ str(motorFreq).zfill(4) +'.txt'
            fnameDown = 'rotorSpeedsDown-'+ str(motorFreq).zfill(4) +'.txt'
            
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile( rotorCountsUp, directory + fnameUp, 
                        [duration, sampRate, motorFreq, motorTime, pauseTime] )
                        
            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile( rotorCountsDown, directory + fnameDown, 
                        [duration, sampRate, motorFreq, motorTime, pauseTime] )
            
        print 'Measurements at ' + str(temp) + ' degrees C completed.'
        
    closeUp()
Пример #5
0
# manage things more easily.

freqs = np.array([50, 100, 200, 400, 600, 800, 1000, 2000])
dur = np.array([600, 420, 300, 240, 120, 60, 30, 10])
sr = np.array([128, 128, 256, 512, 512, 1024, 1024, 2048])

numMeas = 5

i = 0

# make an empty array to save the data:
dataStack = np.zeros((sr[i] * dur[i], numMeas))

# normally data is acquired like this:
for run in range(numMeas):
    dataStack[:, i] = cnt.retrieveData(sr[0], dur[0])

# *** Create directory structure for data from experiments ***

rootDir = '/home/kedmond/Desktop/'
dateDir = time.strftime('%d%b%Y') + '/'
expStr = 'Experiment'
expNum = 1

# Look for other "Experiment" directories, and create the next one

if not os.path.exists(rootDir + dateDir + expStr + str(expNum)):
    os.makedirs(rootDir + dateDir + expStr + str(expNum))
    # going forward, this is where to store data
    directory = rootDir + dateDir + expStr + str(expNum)
else:
Пример #6
0
# manage things more easily.

freqs = np.array([50, 100, 200, 400, 600, 800, 1000, 2000])
dur = np.array([600, 420, 300, 240, 120, 60, 30, 10])
sr = np.array([128, 128, 256, 512, 512, 1024, 1024, 2048])

numMeas = 5

i = 0

# make an empty array to save the data:
dataStack = np.zeros((sr[i] * dur[i], numMeas))

# normally data is acquired like this:
for run in range(numMeas):
    dataStack[:, i] = cnt.retrieveData(sr[0], dur[0])

# *** Create directory structure for data from experiments ***

rootDir = "/home/kedmond/Desktop/"
dateDir = time.strftime("%d%b%Y") + "/"
expStr = "Experiment"
expNum = 1

# Look for other "Experiment" directories, and create the next one

if not os.path.exists(rootDir + dateDir + expStr + str(expNum)):
    os.makedirs(rootDir + dateDir + expStr + str(expNum))
    # going forward, this is where to store data
    directory = rootDir + dateDir + expStr + str(expNum)
else:
Пример #7
0
def hystSet(temps,
            motorFreqs,
            durations=10.0,
            sampRates=2048,
            tempTime=60,
            motorTime=15,
            sampleDescription='Water'):

    revFreqs = motorFreqs[(motorFreqs.size - 2)::-1]
    revRates = sampRates[(motorFreqs.size - 2)::-1]
    revDurs = durations[(motorFreqs.size - 2)::-1]

    initialize()  #Initialize ports, files, and constants (see below)

    # save a description of the experiment to its directory
    descriptionHdr = 'duration (s), sampRate (cnts/s), motorFreq (1/s), pauseTime (s)'

    descriptionArray = np.column_stack(
        (durations, sampRates, motorFreqs, np.repeat(0, durations.size)))

    directory = createDirectories(
    )  # create a directory for this experiment's data

    # save a description of the experiment to its directory
    np.savetxt(directory + 'description-HysterisisTest.txt',
               descriptionArray,
               fmt='%d',
               delimiter=', ',
               header=sampleDescription + '\n' + descriptionHdr)

    # these arrays need to be the same length
    if not motorFreqs.size == sampRates.size == durations.size:
        sys.exit(
            'Error: motorFreqs, sampRates, and durations are not the same length.'
        )

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

        for i in range(motorFreqs.size):  #Cycle through motorFreqs
            motorFreq = motorFreqs[i]
            sampRate = sampRates[i]
            duration = durations[i]

            print 'motorFreq is ' + str(
                motorFreq) + ' deg/sec, sampRate is ' + str(
                    sampRate) + ' samples/sec, and duration is ' + str(
                        duration) + ' seconds.'

            # ***************** SHEAR SAMPLE FOR DATA *****************

            # We want to measure steady shear, so wait for motor and sample to achieve speed
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime)
            if breakBool: break  #Break if motorFreq is above threshold

            rotorCounts = cnt.retrieveData(duration, sampRate)

            rotorFreq = processData(rotorCounts, sampRate, duration)

            print 'Data for ' + str(
                motorFreq) + ' deg/sec taken successfully. [rotorFreq: ' + str(
                    rotorFreq) + ' degs/sec]'

            # Wait for 15 seconds for steady shear
            #time.sleep(15.0)

            fname = 'rotorSpeedsUp-' + str(motorFreq).zfill(4) + '.txt'

            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile(rotorCounts, directory + fname,
                        [duration, sampRate, motorFreq, motorTime, 0])

        for i in range(revFreqs.size):  #Cycle through motorFreqs
            motorFreq = revFreqs[i]
            sampRate = revRates[i]
            duration = revDurs[i]

            print 'motorFreq is ' + str(
                motorFreq) + ' deg/sec, sampRate is ' + str(
                    sampRate) + ' samples/sec, and duration is ' + str(
                        duration) + ' seconds.'

            # ***************** SHEAR SAMPLE FOR DATA *****************

            # We want to measure steady shear, so wait for motor and sample to achieve speed
            breakBool = setMotorFreq(motorFreq, sleepTime=motorTime)
            if breakBool: break  #Break if motorFreq is above threshold

            rotorCounts = cnt.retrieveData(duration, sampRate)

            rotorFreq = processData(rotorCounts, sampRate, duration)

            print 'Data for ' + str(
                motorFreq) + ' deg/sec taken successfully. [rotorFreq: ' + str(
                    rotorFreq) + ' degs/sec]'

            # Wait for 15 seconds for steady shear
            #time.sleep(15.0)

            fname = 'rotorSpeedsDown-' + str(motorFreq).zfill(4) + '.txt'
            fname = 'rotorSpeedsDown-' + str(motorFreq).zfill(4) + '.txt'

            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile(rotorCounts, directory + fname,
                        [duration, sampRate, motorFreq, motorTime, 0])

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

    closeUp()
Пример #8
0
def rampSet(temps,
            motorFreqs,
            durations=10.0,
            numMeas=10,
            pauseTime=1,
            sampRates=2048,
            tempTime=60,
            motorTime=60,
            printDataBool=False,
            plotResults=False,
            sampleDescription='Water'):

    initialize()  #Initialize ports, files, and constants (see below)

    # save a description of the experiment to its directory
    descriptionHdr = 'duration (s), sampRate (cnts/s), motorFreq (1/s), pauseTime (s)'

    descriptionArray = np.column_stack(
        (durations, sampRates, motorFreqs, np.repeat(pauseTime,
                                                     durations.size)))

    directory = createDirectories(
    )  # create a directory for this experiment's data

    # save a description of the experiment to its directory
    np.savetxt(directory + 'description-RampTest.txt',
               descriptionArray,
               fmt='%d',
               delimiter=', ',
               header=sampleDescription + '\n' + descriptionHdr)

    # these arrays need to be the same length
    if not motorFreqs.size == sampRates.size == durations.size:
        sys.exit(
            'Error: motorFreqs, sampRates, and durations are not the same length.'
        )

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

        for i in range(motorFreqs.size):  #Cycle through motorFreqs
            motorFreq = motorFreqs[i]
            sampRate = sampRates[i]
            duration = durations[i]

            print 'motorFreq is ' + str(
                motorFreq) + ' deg/sec, sampRate is ' + str(
                    sampRate) + ' samples/sec, and duration is ' + str(
                        duration) + ' seconds.'

            # before each measurement, we reset the chains by stirring them up, and then letting them reform

            rotorCountsUp = np.zeros([sampRate * duration, numMeas])
            rotorCountsDown = np.zeros([sampRate * duration, numMeas])

            for j in range(numMeas):

                # ***************** STIR UP SAMPLE *****************

                print 'Spinning rotor for ' + str(motorTime) + ' seconds.'
                breakBool = setMotorFreq(
                    stirFreq, sleepTime=motorTime)  # Prevent sedimentation
                if breakBool: break  #Break if motorFreq is above threshold

                # ***************** REST SAMPLE *****************

                print 'Pausing rotor for ' + str(pauseTime) + ' seconds.'
                breakBool = setMotorFreq(
                    0, sleepTime=pauseTime
                )  # Pause, perhaps to wait for chains to form
                if breakBool: break  #Break if motorFreq is above threshold

                # ***************** SHEAR SAMPLE FOR DATA *****************

                # Must begin acquiring immediately after motor begins

                breakBool = setMotorFreq(motorFreq, sleepTime=0.0)

                rotorCountsUp[:, j] = cnt.retrieveData(duration, sampRate)

                rotorFreq = processData(rotorCountsUp[:, j], sampRate,
                                        duration)

                print 'Ramp up ' + str(j + 1) + ' of ' + str(
                    numMeas) + ' taken successfully. [' + str(
                        rotorFreq) + ' degs/sec]'

                # Wait for 15 seconds for steady shear
                time.sleep(15.0)

                # Stop the motor, and record how the sample slows
                breakBool = setMotorFreq(0.0, sleepTime=0.0)
                # (high value may be changed in method setMotorFreq) (see below)
                if breakBool: break  #Break if motorFreq is above threshold

                rotorCountsDown[:, j] = cnt.retrieveData(duration, sampRate)

                rotorFreq = processData(rotorCountsDown[:, j], sampRate,
                                        duration)

                print 'Ramp down ' + str(j + 1) + ' of ' + str(
                    numMeas) + ' taken successfully. [' + str(
                        rotorFreq) + ' degs/sec]'

            fnameUp = 'rotorSpeedsUp-' + str(motorFreq).zfill(4) + '.txt'
            fnameDown = 'rotorSpeedsDown-' + str(motorFreq).zfill(4) + '.txt'

            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile(rotorCountsUp, directory + fnameUp,
                        [duration, sampRate, motorFreq, motorTime, pauseTime])

            # Data recording: temp. - motorFreq. - avg. rotor Freq. - std. err. - sampRate - duration
            writeToFile(rotorCountsDown, directory + fnameDown,
                        [duration, sampRate, motorFreq, motorTime, pauseTime])

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

    closeUp()