Esempio n. 1
0
def plotAspectRatio(targetid,othertargetid, targetsurfacearea,
	startStep=1,stepsize= 1,largerCondition =True ,maxarea = None, areastep = 10,
	startarea = None,
	endarea = 850):
	import numpy as np
	import matplotlib.pyplot as plt
	import os
	########################################################################
	# faceidarray for Primordia
	if not os.path.isfile("qdObject_step=001.obj"):
		return [0.,0.,0.,0.,0.,0.,0.,0.,0.]
	cell = sf.loadCellFromFile(1,resetids=True)
	initialTissueSurfaceArea = sf.getSurfaceArea(cell)
	#######################################################################
	# Starting the Calculation
	#######################################################################
	#######################################################################
	laststep = 1
	plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2}
	#######################################################################
	primordialroundnessArray = []
	primordialBoundaryroundnessArray = []
	othertissueroundnessArray = []
	tissueSurfaceAreaArray = []
	if not startarea:#no startarea given
		startarea = int(initialTissueSurfaceArea)
	#######################################################################
	listsurfacearea = np.linspace(startarea,endarea,10)
	###################################################
	for steparea in listsurfacearea:
		step,tissueSurfaceArea = sf.getTimeStep(steparea, endStep, laststep, stepsize = 10)
		########################################################################
		if not os.path.isfile("qdObject_step=%03d.obj"%step):#check if file exists
			break
		cell = sf.loadCellFromFile(step,resetids=True)
		################################################
		primordialfaces = sf.getPrimordiaFaces(cell,targetid, large = False)
		primordialfaceids = [f.getID() for f in primordialfaces]
		primordialBoundaryfaces = sf.getPrimordiaBoundaryFaceList(cell,targetid,large= True)
		primordialBoundaryfaceids = [f.getID() for f in primordialBoundaryfaces]
		othertissuefacelist = sf.getPrimordiaFaces(cell,othertargetid, large=False)+\
								sf.getPrimordiaBoundaryFaceList(cell,othertargetid,large= True)#getMeristemFaces(cell,primordialfaceids+primordialBoundaryfaceids)
		################################################
		########################################################################
		# calculate the roundness
		########################################################################
		primordiaRoundness = calculateMeanAspectRatio(primordialfaces)
		primordialBoundaryRoundness = calculateMeanAspectRatio(primordialBoundaryfaces)
		othertissueRoundness = calculateMeanAspectRatio(othertissuefacelist)
		######################################################
		tissueSurfaceAreaArray.append(tissueSurfaceArea)
		primordialroundnessArray.append(primordiaRoundness)
		primordialBoundaryroundnessArray.append(primordialBoundaryRoundness)
		othertissueroundnessArray.append(othertissueRoundness)
		########################################################################
		laststep = step
		########################################################################
		print tissueSurfaceArea, step 
	return [tissueSurfaceAreaArray,primordialroundnessArray,
			primordialBoundaryroundnessArray,othertissueroundnessArray]
def plotMeanStressGrowth(numOfLayer, targetid,endStep,eta, 
	meanstress, meandilation,
	color,startStep=0,stepsize= 1,largerCondition =True ,maxarea = None, areastep = 20,
	startarea = None,
	endarea = 850,resetids = True):
	import numpy as np
	import matplotlib.pyplot as plt
	import os
	########################################################################
	# faceidarray for Primordia
	if not os.path.isfile("qdObject_step=001.obj"):
		return [0.,0.,0.,0.,0.,0.,0.,0.,0.]
	cell = sf.loadCellFromFile(1,resetids=resetids)
	initialTissueSurfaceArea = sf.getSurfaceArea(cell)
	#######################################################################
	# Starting the Calculation
	#######################################################################
	#######################################################################
	laststep = 1
	plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2}
	#######################################################################
	orthoradialStressArray = []
	radialStressArray = []
	radialGrowthArray = []
	orthoradialGrowthArray = []
	meanstressEigenvalue1Array = []
	meanstressEigenvalue2Array = []
	meangrowthEigenvalue1Array = []
	meangrowthEigenvalue2Array = []
	meangaussianCurvatureArray = []
	###################################################
	# save standard deviations of the stress and growth
	###################################################
	radialStressSDArray = []
	orthoradialStressSDArray = []
	radialGrowthSDArray = []
	orthoradialGrowthSDArray = []
	meanstressEigenvalue1SDArray = []
	meanstressEigenvalue2SDArray = []
	meangrowthEigenvalue1SDArray = []
	meangrowthEigenvalue2SDArray = []
	###################################################
	tissueSurfaceAreaArray = []
	primordiaAreaArray = []
	boundaryAreaArray = []
	heightArray = []
	###################################################
	if not startarea:#no startarea given
		startarea = int(initialTissueSurfaceArea)
	###################################################
	listsurfacearea = np.linspace(startarea,endarea,10)
	#print listsurfacearea
	#for steparea in range(startarea, endarea, int(areastep)):
	for steparea in listsurfacearea:
		step,tissueSurfaceArea = sf.getTimeStep(steparea, endStep, laststep, stepsize = 10,resetids = resetids)
		########################################################################
		step2,tissueSurfaceArea2 = sf.getTimeStep(steparea+areastep, endStep, step, stepsize = 10,resetids = resetids)
		########################################################################
		if not os.path.isfile("qdObject_step=%03d.obj"%step):#check if file exists
			break
		cell = sf.loadCellFromFile(step,resetids=resetids)
		cell2 = sf.loadCellFromFile(step2,resetids=resetids)
		################################################
		cell.calculateStressStrain()
		################################################
		primordialface = sf.getFace(cell, targetid)
		################################################
		cell.setRadialOrthoradialVector(primordialface)
		cell.setRadialOrthoradialStress()
		################################################
		sf.calculateDilation(cell,cell2)
		########################################################################
		#  Starting the Calculation of mean growth and mean stress on boundary
		########################################################################
		# mean stress
		########################################################################
		faceList = sf.getPrimordiaBoundaryFaceList(cell,targetid,large= large)
		primordiafacelist  = sf.getPrimordiaFaces(cell, targetid, large = False)
		primordiaarea = 0.
		for face in primordiafacelist:
			primordiaarea += face.getAreaOfFace()
		######################################################
		#radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large)
		######################################################
		radialStress = []
		orthoradialStress = []
		radialGrowth = []
		orthoradialGrowth = []
		stressEigenvalue1Array = []
		stressEigenvalue2Array = []
		growthEigenvalue1Array = []
		growthEigenvalue2Array = []
		gaussianCurvatureArray = []
		dTissueSurfaceArea = tissueSurfaceArea2-tissueSurfaceArea
		boundaryarea = 0.
		for face in faceList:
			boundaryarea += face.getAreaOfFace()
			#######################################################
			radstress, orthstress,stresseigenvalue1, stresseigenvalue2  = getRadialOrthoradialStress(face)
			radGrowth, orthGrowth, growtheigenvalue1, growtheigenvalue2 = getRadialOrthoradialGrowth(face)
			#######################################################
			radialStress.append(radstress)
			orthoradialStress.append(orthstress)
			radialGrowth.append(radGrowth)
			orthoradialGrowth.append(orthGrowth)
			stressEigenvalue1Array.append(stresseigenvalue1)
			stressEigenvalue2Array.append(stresseigenvalue2)
			growthEigenvalue1Array.append(growtheigenvalue1)
			growthEigenvalue2Array.append(growtheigenvalue2)
			gaussianCurvatureArray.append(sf.getFaceWeightedGaussianCurvature(face))
		######################################################
		radialStressArray.append(np.mean(radialStress))
		orthoradialStressArray.append(np.mean(orthoradialStress))
		radialGrowthArray.append(np.mean(radialGrowth))
		orthoradialGrowthArray.append(np.mean(orthoradialGrowth))
		tissueSurfaceAreaArray.append(tissueSurfaceArea)
		primordiaAreaArray.append(primordiaarea)
		boundaryAreaArray.append(boundaryarea)
		######################################################
		height = getPrimordiaHeight(cell,targetid)
		heightArray.append(height)
		######################################################
		meanstressEigenvalue1Array.append(np.mean(stressEigenvalue1Array))
		meanstressEigenvalue2Array.append(np.mean(stressEigenvalue2Array))
		meangrowthEigenvalue1Array.append(np.mean(growthEigenvalue1Array))
		meangrowthEigenvalue2Array.append(np.mean(growthEigenvalue2Array))
		meangaussianCurvatureArray.append(np.mean(gaussianCurvatureArray))
		#######################################################
		# calculating the standard deviation
		#######################################################
		meanstressEigenvalue1SDArray.append(np.std(stressEigenvalue1Array))
		meanstressEigenvalue2SDArray.append(np.std(stressEigenvalue2Array))
		meangrowthEigenvalue1SDArray.append(np.std(growthEigenvalue1Array))
		meangrowthEigenvalue2SDArray.append(np.std(growthEigenvalue2Array))
		radialStressSDArray.append(np.std(radialStress))
		orthoradialStressSDArray.append(np.std(orthoradialStress))
		radialGrowthSDArray.append(np.std(radialGrowth))
		orthoradialGrowthSDArray.append(np.std(orthoradialGrowth))
		#meanstress.errorbar(tissueSurfaceArea, np.mean(radialStress),
		#    yerr = np.std(radialStress)/float(len(radialStress)),fmt='o',label = r":$\sigma_{r}$",c=color,**plotargs)
		#meanstress.errorbar(tissueSurfaceArea, np.mean(orthoradialStress),
		#    yerr = np.std(orthoradialStress)/float(len(orthoradialStress)),fmt='<',label = r":$\sigma_{o}$",c=color,**plotargs)
		########################################################################
		# mean dilation
		########################################################################
		#meandilation.errorbar(tissueSurfaceArea, np.mean(radialGrowth),
		#    yerr = np.std(radialGrowth)/float(len(radialGrowth)),fmt='o',label = r":$g_{r}$",c=color,**plotargs)
		#meandilation.errorbar(tissueSurfaceArea, np.mean(orthoradialGrowth),
		#    yerr = np.std(orthoradialGrowth)/float(len(orthoradialGrowth)),fmt='<',label = r":$g_{o}$",c=color,**plotargs)
		########################################################################
		laststep = step
		########################################################################
		print tissueSurfaceArea, tissueSurfaceArea2,dTissueSurfaceArea, step , step2
		########################################################################
	return [tissueSurfaceAreaArray, radialStressArray, orthoradialStressArray,
			radialGrowthArray, orthoradialGrowthArray,
			primordiaAreaArray,
			heightArray,
			meanstressEigenvalue1Array, meanstressEigenvalue2Array,
			meangrowthEigenvalue1Array, meangrowthEigenvalue2Array, boundaryAreaArray,
			radialStressSDArray, orthoradialStressSDArray, 
			radialGrowthSDArray, orthoradialGrowthSDArray,
			meanstressEigenvalue1SDArray, meanstressEigenvalue2SDArray,
			meangrowthEigenvalue1SDArray, meangrowthEigenvalue2SDArray,
			meangaussianCurvatureArray
			]
def plotGrowthAgainstFeedbackPoint(cell1,cell2, targetid,eta,plot,color='r',large = False,otherplot=None):
	################################################
	sf.calculateDilation(cell1,cell2)
	################################################
	faceList = sf.getPrimordiaBoundaryFaceList(cell1,targetid,large= large)
	radialDict, orthoradialDict = getRadialOrthoradialDict(cell1,targetid,large = large)
	maximalGrowth = []
	minimalGrowth = []
	traceGrowth = []
	absSumGrowth = []
	detGrowth = []
	radialGrowth = []
	orthoradialGrowth = []
	sumRadialOrthoradial = []
	sumAbsRadialOrthoradial = []
	######################################################
	for face in faceList:
		maximalGrowth.append(max(face.getRotGrowthEigenValue1(),
								face.getRotGrowthEigenValue2()
								)
							)
		minimalGrowth.append(min(face.getRotGrowthEigenValue1(),
								face.getRotGrowthEigenValue2()
								)
			)
		absSumGrowth.append((abs(face.getRotGrowthEigenValue1())+
									abs(face.getRotGrowthEigenValue2())
									)
							)
		traceGrowth.append((face.getRotGrowthEigenValue1()+face.getRotGrowthEigenValue2()))
		detGrowth.append((qd.getEigenMatrix(face.rotGrowth,0,0)*qd.getEigenMatrix(face.rotGrowth,1,1)-
						(qd.getEigenMatrix(face.rotGrowth,1,0)*qd.getEigenMatrix(face.rotGrowth,0,1))
						))
		radGrowth, orthGrowth = getRadialOrthoradialGrowth(face,radialDict,orthoradialDict)
		radialGrowth.append(radGrowth)
		orthoradialGrowth.append(orthGrowth)
		sumRadialOrthoradial.append(radGrowth+orthGrowth)
		sumAbsRadialOrthoradial.append(abs(radGrowth)+abs(orthGrowth))
		######################################################
	maximalGrowth = np.array(maximalGrowth)
	traceGrowth = np.array(traceGrowth)
	absSumGrowth = np.array(absSumGrowth)
	detGrowth = np.array(detGrowth)
	minimalGrowth = np.array(minimalGrowth)
	radialGrowth = np.array(radialGrowth)
	orthoradialGrowth = np.array(orthoradialGrowth)
	sumRadialOrthoradial = np.array(sumRadialOrthoradial)
	sumAbsRadialOrthoradial = np.array(sumAbsRadialOrthoradial)
	plotargs = {"markersize": 10, "capsize": 10,"elinewidth":3,"markeredgewidth":2}
	############################################################
	N = np.sqrt(len(maximalGrowth))
	if otherplot:
		#print maximalGrowth,np.mean(maximalGrowth), np.std(maximalGrowth)
		plot.errorbar(eta,np.mean(maximalGrowth), yerr = np.std(maximalGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[0].errorbar(eta,np.mean(traceGrowth), yerr = np.std(traceGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[1].errorbar(eta,np.mean(absSumGrowth), yerr = np.std(absSumGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[2].errorbar(eta,np.mean(minimalGrowth), yerr = np.std(minimalGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[3].errorbar(eta,np.mean(sumAbsRadialOrthoradial), yerr = np.std(sumAbsRadialOrthoradial)/N,fmt='o', color = color,**plotargs)
		otherplot[4].errorbar(eta,np.mean(radialGrowth), yerr = np.std(radialGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[5].errorbar(eta,np.mean(orthoradialGrowth), yerr = np.std(orthoradialGrowth)/N,fmt='o', color = color,**plotargs)
		otherplot[6].errorbar(eta,np.mean(sumRadialOrthoradial), yerr = np.std(sumRadialOrthoradial)/N,fmt='o', color = color,**plotargs)
		#otherplot[3].errorbar(eta,np.mean(absSumGrowth), yerr = np.std(absSumGrowth)/np.sqrt(len(maximalGrowth)),fmt='o', color = color)
	elif areaplot:
		plot.errorbar(eta,np.mean(maximalGrowth), yerr = np.std(maximalGrowth)/np.sqrt(len(maximalGrowth)),fmt='o', color = color,**plotargs)
	
	################################################
	return zip([np.mean(radialGrowth), np.mean(orthoradialGrowth), np.mean(sumAbsRadialOrthoradial), np.mean(absSumGrowth)],
			[np.std(radialGrowth)/N, np.std(orthoradialGrowth)/N, np.std(sumAbsRadialOrthoradial)/N, np.std(absSumGrowth)/N])
def plotStressAgainstFeedbackPoint(cell,
                                   targetid,
                                   eta,
                                   plot,
                                   color='r',
                                   large=False,
                                   otherplot=None,
                                   savefig=None):
    ################################################
    cell.calculateStressStrain()
    ################################################
    faceList = sf.getPrimordiaBoundaryFaceList(cell, targetid, large=large)
    radialDict, orthoradialDict = getRadialOrthoradialDict(cell,
                                                           targetid,
                                                           large=large)
    maximalStress = []
    minimalStress = []
    traceStress = []
    absSumStress = []
    detStress = []
    radialStress = []
    orthoradialStress = []
    sumRadialOrthoradial = []
    sumAbsRadialOrthoradial = []
    ######################################################
    for face in faceList:
        maximalStress.append(
            max(face.getStressEigenValue1(), face.getStressEigenValue2()))
        minimalStress.append(
            min(face.getStressEigenValue1(), face.getStressEigenValue2()))
        absSumStress.append((abs(face.getStressEigenValue1()) +
                             abs(face.getStressEigenValue2())))
        traceStress.append(
            (face.getStressEigenValue1() + face.getStressEigenValue2()))
        detStress.append((qd.getEigenMatrix(face.stress, 0, 0) *
                          qd.getEigenMatrix(face.stress, 1, 1) -
                          (qd.getEigenMatrix(face.stress, 1, 0) *
                           qd.getEigenMatrix(face.stress, 0, 1))))
        radstress, orthstress = getRadialOrthoradialStress(
            face, radialDict, orthoradialDict)
        radialStress.append(radstress)
        orthoradialStress.append(orthstress)
        sumRadialOrthoradial.append(radstress + orthstress)
        sumAbsRadialOrthoradial.append(abs(radstress) + abs(orthstress))
        ######################################################
    maximalStress = np.array(maximalStress)
    traceStress = np.array(traceStress)
    absSumStress = np.array(absSumStress)
    detStress = np.array(detStress)
    minimalStress = np.array(minimalStress)
    radialStress = np.array(radialStress)
    orthoradialStress = np.array(orthoradialStress)
    sumRadialOrthoradial = np.array(sumRadialOrthoradial)
    sumAbsRadialOrthoradial = np.array(sumAbsRadialOrthoradial)
    plotargs = {
        "markersize": 10,
        "capsize": 10,
        "elinewidth": 3,
        "markeredgewidth": 2
    }
    ############################################################
    N = np.sqrt(len(maximalStress))
    if otherplot:
        #print maximalStress,np.mean(maximalStress), np.std(maximalStress)
        plot.errorbar(eta,
                      np.mean(maximalStress),
                      yerr=np.std(maximalStress) / N,
                      fmt='o',
                      color=color,
                      **plotargs)
        otherplot[0].errorbar(eta,
                              np.mean(traceStress),
                              yerr=np.std(traceStress) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[1].errorbar(eta,
                              np.mean(absSumStress),
                              yerr=np.std(absSumStress) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[2].errorbar(eta,
                              np.mean(minimalStress),
                              yerr=np.std(minimalStress) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[3].errorbar(eta,
                              np.mean(sumAbsRadialOrthoradial),
                              yerr=np.std(sumAbsRadialOrthoradial) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[4].errorbar(eta,
                              np.mean(radialStress),
                              yerr=np.std(radialStress) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[5].errorbar(eta,
                              np.mean(orthoradialStress),
                              yerr=np.std(orthoradialStress) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        otherplot[6].errorbar(eta,
                              np.mean(sumRadialOrthoradial),
                              yerr=np.std(sumRadialOrthoradial) / N,
                              fmt='o',
                              color=color,
                              **plotargs)
        #otherplot[3].errorbar(eta,np.mean(absSumStress), yerr = np.std(absSumStress)/np.sqrt(len(maximalStress)),fmt='o', color = color)
        ################################
        # saveplot
        ################################
        savefig.errorbar(eta,
                         np.mean(radialStress),
                         yerr=np.std(radialStress) / N,
                         fmt='o',
                         color='m',
                         label=r'$\sigma_r$',
                         **plotargs)
        savefig.errorbar(eta,
                         np.mean(orthoradialStress),
                         yerr=np.std(orthoradialStress) / N,
                         fmt='<',
                         color='g',
                         label=r'$\sigma_o$',
                         **plotargs)
    else:
        plot.errorbar(eta,
                      np.mean(maximalStress),
                      yerr=np.std(maximalStress) / np.sqrt(len(maximalStress)),
                      fmt='o',
                      color=color,
                      **plotargs)

    ################################################
    return zip([
        np.mean(radialStress),
        np.mean(orthoradialStress),
        np.mean(sumAbsRadialOrthoradial),
        np.mean(absSumStress)
    ], [
        np.std(radialStress) / N,
        np.std(orthoradialStress) / N,
        np.std(sumAbsRadialOrthoradial) / N,
        np.std(absSumStress) / N
    ])
def plotPrincipalStress(numOfLayer,
                        targetid,
                        endStep,
                        eta,
                        meanstressplot,
                        color,
                        startStep=0,
                        stepsize=1,
                        largerCondition=True,
                        maxarea=None,
                        areastep=20,
                        startarea=None,
                        endarea=850):
    import numpy as np
    import matplotlib.pyplot as plt
    import os
    ########################################################################
    # faceidarray for Primordia
    if not os.path.isfile("qdObject_step=001.obj"):
        return [0., 0., 0., 0., 0., 0., 0., 0., 0.]
    cell = sf.loadCellFromFile(1)
    initialTissueSurfaceArea = sf.getSurfaceArea(cell)
    #######################################################################
    # Starting the Calculation
    #######################################################################
    laststep = 1
    plotargs = {
        "markersize": 10,
        "capsize": 10,
        "elinewidth": 3,
        "markeredgewidth": 2
    }
    #######################################################################
    tissueSurfaceAreaArray = []
    meanstressEigenvalue1Array = []
    meanstressEigenvalue2Array = []
    heightArray = []
    primordialAreaArray = []
    radialStressArray = []
    orthoradialStressArray = []
    if not startarea:  #no startarea given
        startarea = int(initialTissueSurfaceArea)
    for steparea in range(startarea, endarea, int(areastep)):
        step, tissueSurfaceArea = getTimeStep(steparea,
                                              endStep,
                                              laststep,
                                              stepsize=10)
        ########################################################################
        if not os.path.isfile(
                "qdObject_step=%03d.obj" % step):  #check if file exists
            break
        cell = sf.loadCellFromFile(step)
        ################################################
        cell.calculateStressStrain()
        ################################################
        primordialface = sf.getFace(cell, targetid)
        ################################################
        cell.setRadialOrthoradialVector(primordialface)
        cell.setRadialOrthoradialStress()
        ################################################
        ########################################################################
        #  Starting the Calculation of mean growth and mean stress on boundary
        ########################################################################
        # mean stress
        ########################################################################
        faceList = sf.getPrimordiaBoundaryFaceList(cell, targetid, large=large)
        height = getPrimordiaHeight(cell, targetid)
        ###############################################
        primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large=False)
        primordiaarea = 0.
        for face in primordiafacelist:
            primordiaarea += face.getAreaOfFace()
        ######################################################
        #radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large)
        ######################################################
        stressEigenvalue1Array = []
        stressEigenvalue2Array = []
        radialStress = []
        orthoradialStress = []
        for face in faceList:
            radstress = face.getRadialStress()
            orthstress = face.getOrthoradialStress()
            stresseigenvalue1 = face.getStressEigenValue1()
            stresseigenvalue2 = face.getStressEigenValue2()
            radialStress.append(radstress)
            orthoradialStress.append(orthstress)
            #######################################################
            stressEigenvalue1Array.append(stresseigenvalue1)
            stressEigenvalue2Array.append(stresseigenvalue2)
        ######################################################
        tissueSurfaceAreaArray.append(tissueSurfaceArea)
        heightArray.append(height)
        ######################################################
        meanstressEigenvalue1Array.append(np.mean(stressEigenvalue1Array))
        meanstressEigenvalue2Array.append(np.mean(stressEigenvalue2Array))
        radialStressArray.append(np.mean(radialStress))
        orthoradialStressArray.append(np.mean(orthoradialStress))
        primordialAreaArray.append(primordiaarea)
        ########################################################################
        laststep = step
        ########################################################################
    return [
        tissueSurfaceAreaArray, meanstressEigenvalue1Array,
        meanstressEigenvalue2Array,
        np.add(meanstressEigenvalue1Array, meanstressEigenvalue2Array),
        np.subtract(meanstressEigenvalue2Array,
                    meanstressEigenvalue1Array), heightArray,
        primordialAreaArray, radialStressArray, orthoradialStressArray
    ]
Esempio n. 6
0
def plotHeightGrowthScatter(numOfLayer,
                            targetid,
                            endStep,
                            eta,
                            stressscatter,
                            growthscatter,
                            stressscatter1,
                            growthscatter1,
                            anisotropyplot,
                            color='r',
                            maxeta=20,
                            startStep=0,
                            stepsize=1,
                            largerCondition=True,
                            maxarea=None,
                            areastep=20,
                            cloud=False,
                            startarea=None,
                            resetids=True,
                            endarea=850):
    import numpy as np
    import matplotlib.pyplot as plt
    import os
    ########################################################################
    # faceidarray for Primordia
    if not os.path.isfile("qdObject_step=001.obj"):
        return [0., 0., 0., 0., 0., 0., 0., 0., 0.]
    cell = sf.loadCellFromFile(1, resetids=resetids)
    initialTissueSurfaceArea = sf.getSurfaceArea(cell)
    #######################################################################
    # Starting the Calculation
    #######################################################################
    laststep = 1
    plotargs = {
        "markersize": 10,
        "capsize": 10,
        "elinewidth": 3,
        "markeredgewidth": 2
    }
    #######################################################################
    orthoradialStressArray = []
    radialStressArray = []
    radialGrowthArray = []
    orthoradialGrowthArray = []
    tissueSurfaceAreaArray = []
    primordiaAreaArray = []
    heightArray = []
    meanstressEigenvalue1Array = []
    meanstressEigenvalue2Array = []

    meangrowthEigenvalue1Array = []
    meangrowthEigenvalue2Array = []
    meanstressdiffarray = []
    areadiffarray = []
    if not startarea:  #no startarea given
        startarea = int(initialTissueSurfaceArea)
    for steparea in range(startarea, endarea, int(areastep)):
        step, tissueSurfaceArea = getTimeStep(steparea,
                                              endStep,
                                              laststep,
                                              stepsize=5,
                                              resetids=resetids)
        ########################################################################
        step2, tissueSurfaceArea2 = getTimeStep(steparea + areastep,
                                                endStep,
                                                step,
                                                stepsize=5,
                                                resetids=resetids)
        ########################################################################
        if not os.path.isfile(
                "qdObject_step=%03d.obj" % step):  #check if file exists
            break
        cell = sf.loadCellFromFile(step, resetids=resetids)
        cell2 = sf.loadCellFromFile(step2, resetids=resetids)
        ################################################
        cell.calculateStressStrain()
        ################################################
        primordialface = sf.getFace(cell, targetid)
        ################################################
        cell.setRadialOrthoradialVector(primordialface)
        cell.setRadialOrthoradialStress()
        ################################################
        sf.calculateDilation(cell, cell2)
        ########################################################################
        #  Starting the Calculation of mean growth and mean stress on boundary
        ########################################################################
        # mean stress
        ########################################################################
        faceList = sf.getPrimordiaBoundaryFaceList(cell, targetid, large=large)
        primordiafacelist = sf.getPrimordiaFaces(cell, targetid, large=False)
        primordiaarea = 0.
        for face in primordiafacelist:
            primordiaarea += face.getAreaOfFace()
        ######################################################
        #radialDict, orthoradialDict = getRadialOrthoradialDict(cell,targetid,large = large)
        ######################################################
        stressEigenvalue1Array = []
        stressEigenvalue2Array = []
        growthEigenvalue1Array = []
        growthEigenvalue2Array = []
        stressdiffarray = []
        growthdiffarray = []
        dTissueSurfaceArea = tissueSurfaceArea2 - tissueSurfaceArea
        height = getPrimordiaHeight(cell, targetid)
        height2 = getPrimordiaHeight(cell2, targetid)
        dhdA = (height2 - height) / dTissueSurfaceArea
        for face in faceList:
            radstress, orthstress, stresseigenvalue1, stresseigenvalue2 = getRadialOrthoradialStress(
                face)
            radGrowth, orthGrowth, growtheigenvalue1, growtheigenvalue2 = getRadialOrthoradialGrowth(
                face)
            stressEigenvalue1Array.append(stresseigenvalue1)
            stressEigenvalue2Array.append(stresseigenvalue2)
            growthEigenvalue1Array.append(growtheigenvalue1)
            growthEigenvalue2Array.append(growtheigenvalue2)
            stressdiffarray.append(stresseigenvalue2 - stresseigenvalue1)
            growthdiffarray.append(growtheigenvalue2 - growtheigenvalue1)
        #######################################################
        # plotting
        #######################################################
        meanstresseigen1 = np.mean(stressEigenvalue1Array)
        meanstresseigen2 = np.mean(stressEigenvalue2Array)
        meangrowtheigenvalue1 = np.mean(growthEigenvalue1Array)
        meangrowtheigenvalue2 = np.mean(growthEigenvalue2Array)

        sigma2 = max(meanstresseigen1, meanstresseigen2)
        sigma1 = min(meanstresseigen1, meanstresseigen2)
        g2 = max(meangrowtheigenvalue1, meangrowtheigenvalue2)
        g1 = min(meangrowtheigenvalue1, meangrowtheigenvalue2)
        #######################################################
        stressscatter.scatter(sigma2 - sigma1,
                              dhdA,
                              c=color,
                              marker='o',
                              alpha=0.7,
                              zorder=maxeta - eta)
        growthscatter.scatter(g2 - g1,
                              dhdA,
                              c=color,
                              marker='o',
                              alpha=0.7,
                              zorder=maxeta - eta)
        #######################################################
        stressscatter1.scatter(np.mean(stressdiffarray),
                               dhdA,
                               c=color,
                               marker='o',
                               alpha=0.7,
                               zorder=maxeta - eta)
        growthscatter1.scatter(np.mean(growthdiffarray),
                               dhdA,
                               c=color,
                               marker='o',
                               alpha=0.7,
                               zorder=maxeta - eta)
        #######################################################
        anisotropyplot.scatter(np.mean(stressdiffarray),
                               dhdA,
                               c=color,
                               marker='o',
                               alpha=0.7,
                               zorder=maxeta - eta)
        meanstressdiffarray.append(np.mean(stressdiffarray))
        areadiffarray.append(dhdA)
        ########################################################################
        laststep = step
        ########################################################################
        print tissueSurfaceArea, tissueSurfaceArea2, dTissueSurfaceArea, step, step2
    ########################################################################
    if cloudCondition:
        points = np.vstack((meanstressdiffarray, areadiffarray)).T
        hull_pts = ConvexHull(points)
        hull_pts = points[hull_pts.vertices]
        hull_pts = np.vstack((hull_pts, hull_pts[0])).T
        interpolatex, interpolatey = interpolatedata(hull_pts)
        anisotropyplot.plot(interpolatex, interpolatey, c=color, ls='--', lw=2)
    ########################################################################
    return [meanstressdiffarray, areadiffarray]