コード例 #1
0
ファイル: timeTest.py プロジェクト: dsoto/swData
def plotTime(fileIn):
    rx.readDataFileHeader(fileIn)
    data = rx.readDataFileArray(fileIn)
    
    timeStrings = data['time']
    
    timeSeconds = [float(ts[0:2])*3600+float(ts[3:5])*60+float(ts[6:]) for ts in timeStrings]
    
    import numpy as np
    timeSeconds = np.array(timeSeconds)
    timeSeconds = timeSeconds - timeSeconds[0]
    
    #print timeSeconds
    
    plt.plot(timeSeconds,'o')
コード例 #2
0
ファイル: parseChaco.py プロジェクト: dsoto/swData
    def __init__(self, fileName, fOut):
        super(plotBox, self).__init__()

        self.isAccepted = True
        self.fOut = fOut
        self.message = "Analysis Acceptable?"
        self.vPlot = VPlotContainer(padding=10)
        self.vPlot.stack_order = "top_to_bottom"
        topPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(topPlot)
        bottomPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(bottomPlot)

        # def parseFileName():
        self.fileName = fileName
        # get complete path of data file
        fullFileName = os.path.abspath(fileName)
        self.fileName = os.path.split(fullFileName)[1]
        self.shortFileName = os.path.splitext(self.fileName)[1]
        self.plotTitle = self.shortFileName

        # def readData():
        fileIn = open(fileName, "r")
        hD = rx.readDataFileHeader(fileIn)
        dD = rx.readDataFileArray(fileIn)

        self.normal = numpy.array(map(float, dD["voltageForceNormal"]))
        self.shear = numpy.array(map(float, dD["voltageForceLateral"]))
        self.index = numpy.arange(len(self.normal))

        # index dictionary
        iD = rx.parseForceTrace(hD, dD)
        self.pointX[0] = iD["indexContact"]
        self.pointY[0] = self.normal[iD["indexContact"]]
        self.pointX[1] = iD["indexMaxPreload"]
        self.pointY[1] = self.normal[iD["indexMaxPreload"]]
        self.pointX[2] = iD["indexMaxAdhesion"]
        self.pointY[2] = self.normal[iD["indexMaxAdhesion"]]

        # def constructPlots():
        self.plotdata = ArrayPlotData(
            index=self.index, normal=self.normal, shear=self.shear, pointX=self.pointX, pointY=self.pointY
        )
        self.normalPlot = Plot(self.plotdata)
        self.normalPlot.plot(("index", "normal"), type="line", color="blue")
        self.normalPlot.plot(
            ("pointX", "pointY"),
            type="scatter",
            marker="diamond",
            marker_size=5,
            color=(0.0, 0.0, 1.0, 0.5),
            outline_color="none",
        )
        # set range of plot
        self.normalPlot.value_range.set_bounds(-1.5, 1.5)
        self.shearPlot = Plot(self.plotdata)
        self.shearPlot.plot(("index", "shear"), type="line", color="green")

        self.normalPlot.overlays.append(
            customTool(
                plotBox=self,
                component=self.normalPlot,
                axis="index_x",
                inspect_mode="indexed",
                write_metadata=True,
                color="black",
                is_listener=False,
            )
        )

        self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
        self.normalPlot.tools.append(PanTool(self.normalPlot, drag_button="right"))

        self.normalPlot.title = "Normal Force Trace"
        self.shearPlot.title = "Shear Force Trace"
        topPlot.add(self.shearPlot)
        bottomPlot.add(self.normalPlot)

        self.shearPlot.index_range = self.normalPlot.index_range
コード例 #3
0
ファイル: parseChaco.py プロジェクト: dsoto/swData
	def __init__(self, fileName, fOut):
		super(plotBox, self).__init__()

		self.isAccepted = True
		self.fOut = fOut
		self.message = 'Analysis Acceptable?'
		self.vPlot = VPlotContainer(padding = 10)
		self.vPlot.stack_order = 'top_to_bottom'
		topPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(topPlot)
		bottomPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(bottomPlot)

		# def parseFileName():
		self.fileName = fileName
		# get complete path of data file
		fullFileName = os.path.abspath(fileName)
		self.fileName = os.path.split(fullFileName)[1]
		self.shortFileName = os.path.splitext(self.fileName)[1]
		self.plotTitle = self.shortFileName

		# def readData():
		fileIn = open(fileName,'r')
		hD = rx.readDataFileHeader(fileIn)
		dD = rx.readDataFileArray(fileIn)

		self.normal = numpy.array(map(float,dD['voltageForceNormal']))
		self.shear  = numpy.array(map(float,dD['voltageForceLateral']))
		self.index  = numpy.arange(len(self.normal))

		# index dictionary
		iD = rx.parseForceTrace(hD,dD)
		self.pointX[0] = iD['indexContact']
		self.pointY[0] = self.normal[iD['indexContact']]
		self.pointX[1] = iD['indexMaxPreload']
		self.pointY[1] = self.normal[iD['indexMaxPreload']]
		self.pointX[2] = iD['indexMaxAdhesion']
		self.pointY[2] = self.normal[iD['indexMaxAdhesion']]

		# def constructPlots():
		self.plotdata = ArrayPlotData(index = self.index,
		                              normal = self.normal,
		                              shear = self.shear,
		                              pointX = self.pointX,
		                              pointY = self.pointY)
		self.normalPlot = Plot(self.plotdata)
		self.normalPlot.plot(('index','normal'), type = 'line',
		                                         color = 'blue')
		self.normalPlot.plot(('pointX','pointY'), type = 'scatter',
		                                          marker = 'diamond',
		                                          marker_size = 5,
		                                          color = (0.0,0.0,1.0,0.5),
		                                          outline_color = 'none')
		self.normalPlot.value_range.set_bounds(-1,1)
		self.shearPlot = Plot(self.plotdata)
		self.shearPlot.plot(('index','shear'),type='line',color='green')

		self.normalPlot.overlays.append(customTool(plotBox = self,
		                                   component = self.normalPlot,
		                                   axis = 'index_x',
		                                   inspect_mode = 'indexed',
		                                   write_metadata = True,
		                                   color = 'black',
		                                   is_listener = False))

		self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
		self.normalPlot.tools.append(PanTool(self.normalPlot,drag_button = 'right'))

		self.normalPlot.title = 'Normal Force Trace'
		self.shearPlot.title  = 'Shear Force Trace'
		topPlot.add(self.shearPlot)
		bottomPlot.add(self.normalPlot)

		self.shearPlot.index_range = self.normalPlot.index_range
コード例 #4
0
ファイル: analyzeLimitSurface.py プロジェクト: dsoto/swData
def main():
    import sys
    sys.path.append('../roxanne')
    sys.path.append('../../roxanne')
    import roxanne
    import glob
    import os.path
    import numpy

    parseFileIn = open('testOut.dat','r')
    parseDict = roxanne.readDataFileArray(parseFileIn)
    print parseDict.keys()
    
    fOut = open('analyzed.data','w')
    fileNameList = glob.glob('a*.0.data')
    outputList = ['fileName',
                  'anglePitch',
                  'forceMaxAdhesion',
                  'forceMaxShear']

    # removed angle pulloff from output list
    sep = '\t'
    headerString = sep.join(outputList)
    fOut.write(headerString)
    fOut.write('\n')
    
    for fileName in fileNameList:

        print 'processing file : ' + fileName

        # TODO - pulloff angle from trajectory file name

        fileIn = open(fileName)
        headerDict = roxanne.readDataFileHeader(fileIn)
        dataDict = roxanne.readDataFileArray(fileIn)

        voltageLateral        =  map(float,dataDict['voltageForceLateral'])
        voltageNormal         =  map(float,dataDict['voltageForceNormal'])
        positionNormalMicron  =  map(float,dataDict['voltagePositionX']) * 10
        positionLateralMicron =  map(float,dataDict['voltagePositionY']) * 10

        voltageLateral        = -numpy.array(voltageLateral)
        voltageNormal         =  numpy.array(voltageNormal)
        positionNormalMicron  =  numpy.array(positionNormalMicron) * 10
        positionLateralMicron =  numpy.array(positionLateralMicron) * 10

        cantileverDict = roxanne.getCantileverData(headerDict['cantilever'])

        normalStiffness      = cantileverDict['normalStiffness']
        lateralStiffness     = cantileverDict['lateralStiffness']
        normalDisplacement   = cantileverDict['normalDisplacement']
        lateralDisplacement  = cantileverDict['lateralDisplacement']
        lateralAmplification = float(headerDict['latAmp'])
        normalAmplification  = float(headerDict['norAmp'])
        rollAngle            = float(headerDict['rollAngle'])
        pitchAngle           = float(headerDict['pitchAngle'])
#        anglePulloff         = float(headerDict['anglePulloff'])

        defaultAmplification = 100
        lateralDisplacement = (lateralDisplacement * lateralAmplification /
                                                     defaultAmplification)
        normalDisplacement = (normalDisplacement * normalAmplification /
                                                  defaultAmplification)

        # use cantilever values to convert voltages to forces
        lateralForceMuN = (voltageLateral *
                                   lateralStiffness / lateralDisplacement)
        normalForceMuN  = (voltageNormal * normalStiffness /
                                   normalDisplacement)

        # get location of filename in parseDict
        # and pull data from same index in the other arrays
        #fileName = os.path.splitext(fileName)
        #fileName = fileName[0]
        fileNames = parseDict['dataFileName']
        indexFileName = fileNames.index(fileName)

        indexContact     = parseDict['indexContact'][indexFileName]
        indexPreload     = parseDict['indexMaxPreload'][indexFileName]
        indexMaxAdhesion = parseDict['indexMaxAdhesion'][indexFileName]
        
        indexContact = int(indexContact)
        indexPreload = int(indexPreload)
        indexMaxAdhesion = int(indexMaxAdhesion)

        # get forces at contact, preload, pulloff
        normalForceContactMuN = normalForceMuN[indexContact]
        normalForcePreloadMuN = normalForceMuN[indexPreload]
        normalForcePulloffMuN = normalForceMuN[indexMaxAdhesion]

        shearForceContactMuN  = lateralForceMuN[indexContact]
        shearForcePreloadMuN  = lateralForceMuN[indexPreload]
        shearForcePulloffMuN  = lateralForceMuN[indexMaxAdhesion]

        normalCantileverVoltageContact     = voltageNormal[indexContact]
        normalCantileverVoltagePreload     = voltageNormal[indexPreload]
        normalCantileverVoltageMaxAdhesion = voltageNormal[indexMaxAdhesion]

        normalStagePositionContact     = positionNormalMicron[indexContact]
        normalStagePositionPreload     = positionNormalMicron[indexPreload]
        normalStagePositionMaxAdhesion = positionNormalMicron[indexMaxAdhesion]

        # calculate effective stage preload
        normalStagePreload = (normalStagePositionMaxAdhesion -
                                                    normalStagePositionContact)
        # calculate effective cantilever deflection
        normalCantileverDeflection = ((normalCantileverVoltageContact -
                                                                     normalCantileverVoltageMaxAdhesion)/
                                                                     normalDisplacement)
        # calculate effective microwedge deflection (effective preload)
        effectivePreload = normalCantileverDeflection + normalStagePreload
        # adhesion force = maxAdhesion - force at contact
        maxAdhesionMuN = (normalForcePulloffMuN -
                                                            normalForceContactMuN)
        # shear force = maxShear - force at contact
        maxShearMuN = (shearForcePulloffMuN -
                                                     shearForceContactMuN)
        # calculate effective stiffness of structure
        # force at preload - force at contact = force of preload
        forcePreload = normalForcePreloadMuN - normalForceContactMuN
        stageMovement = normalStagePositionPreload - normalStagePositionContact
        normalCantileverDeflection = ((normalCantileverVoltageContact -
                                   normalCantileverVoltagePreload)/
                                   normalDisplacement)

        # stage movement between contact and preload - cantilever deflection
        effectiveStiffness = forcePreload/(stageMovement-normalCantileverDeflection)

#        print indexContact
#        input()
        fOut.write(fileName + '\t')
        fOut.write('% 5.1f\t' % pitchAngle )
#        fOut.write('% 5.3f\t' % effectivePreload)
        fOut.write('% 5.3f\t' % maxAdhesionMuN)
        fOut.write('% 5.3f\t' % maxShearMuN)
#        fOut.write('% 5.3f\t' % normalStagePositionPreload)
#        fOut.write('% 5.3f\t' % normalStagePositionContact)
#        fOut.write('% 5.3f\t' % forcePreload)
#        fOut.write('% 5.3f\t' % stageMovement)
#        fOut.write('% 5.3f\t' % effectiveStiffness)
        fOut.write('\n')

    fOut.close()
コード例 #5
0
ファイル: forceSpace.py プロジェクト: dsoto/swData
def main():
    #dataDirectory = '../031-20100111-sws16-ls/data/separated/'
    dataDirectory = '../033-20100302-sws17-ls/data/separated/'
    parsedFileName = dataDirectory + '033-analyzedAngle.data'
    parsedFileName = dataDirectory + '033-parsed.dat'
    parseFileIn = open(parsedFileName)
    parseDict = rx.readDataFileArray(parseFileIn)
    angle = convertToFloatArray(parseDict['angle'])
    
    fileNameList = parseDict['dataFileName']
    

    for i,fileName in enumerate(fileNameList):
        fullFileName = dataDirectory + fileName
        print('processing file : ', fullFileName)
        
        fileIn = open(fullFileName)
        headerDict = rx.readDataFileHeader(fileIn)
        dataD = rx.readDataFileArray(fileIn)
        
        # convert lists to arrays of floats
        voltageLateral = convertToFloatArray(dataD['voltageForceLateral'])
        voltageNormal  = convertToFloatArray(dataD['voltageForceNormal'])
        positionNormalMicron = convertToFloatArray(dataD['voltagePositionX'])
        positionLateralMicron = convertToFloatArray(dataD['voltagePositionY'])
        
        # make conversions 
        voltageLateral = -voltageLateral
        voltageNormal = voltageNormal
        positionLateralMicron = positionLateralMicron * 10.0
        positionNormalMicron = positionNormalMicron * 10.0
        
        cantileverDict = rx.getCantileverData(headerDict['cantilever'])
        normalStiffness      = cantileverDict['normalStiffness']
        lateralStiffness     = cantileverDict['lateralStiffness']
        normalDisplacement   = cantileverDict['normalDisplacement']
        lateralDisplacement  = cantileverDict['lateralDisplacement']
        lateralAmplification = float(headerDict['latAmp'])
        normalAmplification  = float(headerDict['norAmp'])
        
        defaultAmplification = 100
        lateralDisplacement = (lateralDisplacement * lateralAmplification /
                                                     defaultAmplification)
        normalDisplacement = (normalDisplacement * normalAmplification /
                                                  defaultAmplification)
        
        # use cantilever values to convert voltages to forces
        lateralForceMuN = (voltageLateral *
                                   lateralStiffness / lateralDisplacement)
        normalForceMuN  = (voltageNormal * normalStiffness /
                                   normalDisplacement)
                                   
        # get location of filename in parseDict
        # and pull data from same index in the other arrays
        #fileName = os.path.splitext(fileName)
        #fileName = fileName[0]
        #fileNames = parseDict['dataFileName']
        #fileNameNoPath = os.path.split(fileName)[1]
        #indexFileName = fileNames.index(fileNameNoPath)

        # get indices for events in force trace
        indexContact     = parseDict['indexContact'][i]
        indexPreload     = parseDict['indexMaxPreload'][i]
        indexMaxAdhesion = parseDict['indexMaxAdhesion'][i]
        indexContact = int(indexContact)
        indexPreload = int(indexPreload)
        indexMaxAdhesion = int(indexMaxAdhesion)

        # get forces at contact, preload, pulloff
        normalForceContactMuN = normalForceMuN[indexContact]
        normalForcePreloadMuN = normalForceMuN[indexPreload]
        normalForcePulloffMuN = normalForceMuN[indexMaxAdhesion]

        shearForceContactMuN  = lateralForceMuN[indexContact]
        shearForcePreloadMuN  = lateralForceMuN[indexPreload]
        shearForcePulloffMuN  = lateralForceMuN[indexMaxAdhesion]

        lateralForceMuN = lateralForceMuN[0:indexMaxAdhesion]
        normalForceMuN = normalForceMuN[0:indexMaxAdhesion]
        
        # subtract off forces at contact?
        # slice forces [0:indexMaxAdhesion]

        lateralForceMuN -= shearForceContactMuN
        normalForceMuN -= normalForceContactMuN
        
        x = angle[i]/90.0
        myColor = (x,0,1-x)
        #print(myColor)
        
        plt.grid()
        plt.plot(lateralForceMuN, normalForceMuN, 
                 color = mpl.cm.get_cmap('jet')(x), 
                 label = str(i),
                 linewidth = 0.1,
                 alpha = 0.5)
        plt.title('force space')
        
        # plot forces on plot thang


    #plt.legend()
    #plt.colorbar()
    #plt.show()
    plt.savefig(dataDirectory+'forceSpace.pdf')
    return
コード例 #6
0
ファイル: plotRawForceTraceAll.py プロジェクト: dsoto/swData
#!/usr/bin/env python

import sys
sys.path.append('/Users/dsoto/current/swDataFlat/roxanne')
import roxanne as rx
import numpy as np

fileNames = ['front','back']

for thisFileName in fileNames:
    fileName = thisFileName + '.data'

    fileIn = open(fileName, 'r')
    
    headDict = rx.readDataFileHeader(fileIn)
    dataDict = rx.readDataFileArray(fileIn)
    
    #print dataDict.keys()
    
    timeStrings = dataDict['time']
    timeSeconds = [float(ts[0:2])*3600+float(ts[3:5])*60+float(ts[6:]) 
                   for ts in timeStrings]
    
    import numpy as np
    timeSeconds = np.array(timeSeconds)
    timeSeconds = timeSeconds - timeSeconds[0]
    dataDict['time'] = map(str,timeSeconds)
    dataDict['time'] = timeSeconds
    
    voltageLateral        =  map(float,dataDict['voltageForceLateral'])
    voltageNormal         =  map(float,dataDict['voltageForceNormal'])
コード例 #7
0
ファイル: analyzeShearBending.py プロジェクト: dsoto/swData
def main():
    import sys
    sys.path.append('../roxanne')
    import roxanne
    import glob
    import os.path
    import numpy

    parseFileIn = open('parsed.data','r')
    parseDict = roxanne.readDataFileArray(parseFileIn)
    print parseDict.keys()
    print parseDict
    
    fOut = open('analyzed.data','w')
    fileNameList = glob.glob('./data/*sws*.data')
    outputList = ['fileName',
                  'cantileverDeflection',
                  'stagePreload',
                  'maxPreload',
                  'microwedgeDeflection',
                  'lateralSpringConstant']
    sep = '\t'
    headerString = sep.join(outputList)
    fOut.write(headerString)
    
    for fileName in fileNameList:

        print 'processing file : ' + fileName
        fileIn = open(fileName)
        headerDict = roxanne.readDataFileHeader(fileIn)
        dataDict = roxanne.readDataFileArray(fileIn)

        fullFileName = os.path.abspath(fileName)
        shortFileName = os.path.split(fullFileName)[1]
        #shortFileName = os.path.splitext(shortFileName)[0]

        voltageLateral        =  map(float,dataDict['voltageForceLateral'])
        voltageNormal         =  map(float,dataDict['voltageForceNormal'])
        positionNormalMicron  =  map(float,dataDict['voltagePositionX']) * 10
        positionLateralMicron =  map(float,dataDict['voltagePositionY']) * 10

        voltageLateral        = -numpy.array(voltageLateral)
        voltageNormal         =  numpy.array(voltageNormal)
        positionNormalMicron  =  numpy.array(positionNormalMicron) * 10
        positionLateralMicron =  numpy.array(positionLateralMicron) * 10

        cantileverDict = roxanne.getCantileverData(headerDict['cantilever'])

        normalStiffness      = cantileverDict['normalStiffness']
        lateralStiffness     = cantileverDict['lateralStiffness']
        normalDisplacement   = cantileverDict['normalDisplacement']
        lateralDisplacement  = cantileverDict['lateralDisplacement']
        lateralAmplification = float(headerDict['latAmp'])
        normalAmplification  = float(headerDict['norAmp'])
        rollAngle            = float(headerDict['rollAngle'])
        pitchAngle           = float(headerDict['pitchAngle'])

        defaultAmplification = 100
        lateralDisplacement = (lateralDisplacement * lateralAmplification /
                               defaultAmplification)
        normalDisplacement = (normalDisplacement * normalAmplification /
                              defaultAmplification)

        # use cantilever values to convert voltages to forces
        lateralForceMuN = (voltageLateral *
                           lateralStiffness / lateralDisplacement)
        normalForceMuN  = (voltageNormal * normalStiffness /
                           normalDisplacement)

        # get location of filename in parseDict
        # and pull data from same index in the other arrays
        fileName = os.path.splitext(fileName)
        fileName = fileName[0]
        fileNames = parseDict['dataFileName']
        indexFileName = fileNames.index(shortFileName)

        indexContact     = parseDict['indexContact'][indexFileName]
        indexPreload     = parseDict['indexMaxPreload'][indexFileName]
        indexMaxAdhesion = parseDict['indexMaxAdhesion'][indexFileName]
        
        indexContact = int(indexContact)
        indexPreload = int(indexPreload)
        indexMaxAdhesion = int(indexMaxAdhesion)

        # get forces at contact, preload, pulloff
        normalForceContactMuN = normalForceMuN[indexContact]
        normalForcePreloadMuN = normalForceMuN[indexPreload]
        normalForcePulloffMuN = normalForceMuN[indexMaxAdhesion]

        shearForceContactMuN  = lateralForceMuN[indexContact]
        shearForcePreloadMuN  = lateralForceMuN[indexPreload]
        shearForcePulloffMuN  = lateralForceMuN[indexMaxAdhesion]

        normalCantileverVoltageContact     = voltageNormal[indexContact]
        normalCantileverVoltagePreload     = voltageNormal[indexPreload]
        normalCantileverVoltageMaxAdhesion = voltageNormal[indexMaxAdhesion]

        shearCantileverVoltageContact     = voltageLateral[indexContact]
        shearCantileverVoltagePreload     = voltageLateral[indexPreload]
        shearCantileverVoltageMaxAdhesion = voltageLateral[indexMaxAdhesion]

        normalStagePositionContact     = positionNormalMicron[indexContact]
        normalStagePositionPreload     = positionNormalMicron[indexPreload]
        normalStagePositionMaxAdhesion = positionNormalMicron[indexMaxAdhesion]

        shearStagePositionContact     = positionLateralMicron[indexContact]
        shearStagePositionPreload     = positionLateralMicron[indexPreload]
        shearStagePositionMaxAdhesion = positionLateralMicron[indexMaxAdhesion]



        # calculate preload
        # in the shear bending test, this is from the shear trace
        stagePreload = shearStagePositionPreload - shearStagePositionContact
        
        
        # calculate deflection
        cantileverDeflection = ((shearCantileverVoltagePreload - 
                                 shearCantileverVoltageContact) / 
                                 lateralDisplacement)

        # calculate effective microwedge deflection (effective preload)
        microwedgeDeflection = stagePreload + cantileverDeflection

        # preload force 
        maxPreload = (normalForcePreloadMuN - normalForceContactMuN)
        

        fOut.write(fileName + '\t')
        fOut.write('% 5.1f\t' % cantileverDeflection)
        fOut.write('% 5.3f\t' % stagePreload)
        fOut.write('% 5.3f\t' % maxPreload)
        fOut.write('% 5.3f\t' % microwedgeDeflection)
        fOut.write('% 5.3f\t' % lateralSpringConstant)
        fOut.write('\n')

    fOut.close()