Ejemplo n.º 1
0
    def readApshDocFile(self, docfile, picklefile):
        ### eventually add this as apSpider.alignment.readAPSHDocFile()
        apDisplay.printMsg("processing alignment doc file " + docfile)
        if not os.path.isfile(docfile):
            apDisplay.printError("Doc file, " + docfile + " does not exist")
        docf = open(docfile, "r")
        partlist = []
        for line in docf:
            data = line.strip().split()
            if data[0] == ";":
                continue
            if len(data) < 15:
                continue
            """
			2 psi,
			3 theta,
			4 phi,
			5 refNum,
			6 particleNum,
			7 sumRotation,
			8 sumXshift,
			9 sumYshift,
			10 #refs,
			11 anglechange,
			12 cross-correlation,
			13 currentRotation,
			14 currentXshift,
			15 currentYshift,
			16 currentMirror
			"""
            partdict = {
                'psi': float(data[2]),
                'theta': float(data[3]),
                'phi': float(data[4]),
                'template': int(abs(float(data[5]))),
                'num': int(float(data[6])),
                'rot': alignment.wrap360(float(data[7])),
                'xshift': float(data[8]),
                'yshift': float(data[9]),
                'mirror': alignment.checkMirror(float(data[16])),
                'score': float(data[12]),
            }
            partlist.append(partdict)
        docf.close()
        picklef = open(picklefile, "w")
        cPickle.dump(partlist, picklef)
        picklef.close()
        return partlist
 def readApshDocFile(self, docfile, picklefile):
         ### eventually add this as apSpider.alignment.readAPSHDocFile()
         apDisplay.printMsg("processing alignment doc file "+docfile)
         if not os.path.isfile(docfile):
                 apDisplay.printError("Doc file, "+docfile+" does not exist")
         docf = open(docfile, "r")
         partlist = []
         for line in docf:
                 data = line.strip().split()
                 if data[0] == ";":
                         continue
                 if len(data) < 15:
                         continue
                 """
                 2 psi,
                 3 theta,
                 4 phi,
                 5 refNum,
                 6 particleNum,
                 7 sumRotation,
                 8 sumXshift,
                 9 sumYshift,
                 10 #refs,
                 11 anglechange,
                 12 cross-correlation,
                 13 currentRotation,
                 14 currentXshift,
                 15 currentYshift,
                 16 currentMirror
                 """
                 partdict = {
                         'psi': float(data[2]),
                         'theta': float(data[3]),
                         'phi': float(data[4]),
                         'template': int(abs( float(data[5]) )),
                         'num': int(float(data[6])),
                         'rot': alignment.wrap360(float(data[7])),
                         'xshift': float(data[8]),
                         'yshift': float(data[9]),
                         'mirror': alignment.checkMirror( float(data[16]) ),
                         'score': float(data[12]),
                         }
                 partlist.append(partdict)
         docf.close()
         picklef = open(picklefile, "w")
         cPickle.dump(partlist, picklef)
         picklef.close()
         return partlist
 def readRefBasedDocFile(self, docfile, picklefile):
     apDisplay.printMsg("processing alignment doc file " + docfile)
     if not os.path.isfile(docfile):
         apDisplay.printError("Doc file, " + docfile + " does not exist")
     docf = open(docfile, "r")
     partlist = []
     angs = []
     shifts = []
     for line in docf:
         data = line.strip().split()
         if data[0][0] == ";":
             continue
         if len(data) < 6:
             continue
         templatenum = float(data[1])
         angle = alignment.wrap360(float(data[2]))
         partdict = {
             'num': int(data[0]),
             'template': int(abs(templatenum)),
             'mirror': bool(data[5]),
             'score': float(data[6]),
             'rot': angle,
             'xshift': float(data[3]),
             'yshift': float(data[4]),
         }
         angs.append(angle)
         shift = math.hypot(float(data[3]), float(data[4]))
         shifts.append(shift)
         partlist.append(partdict)
     docf.close()
     shifts = numpy.array(shifts, dtype=numpy.float32)
     angs = numpy.array(angs, dtype=numpy.float32)
     apDisplay.printMsg("Angles = %.3f +/- %.3f" %
                        (angs.mean(), angs.std()))
     apDisplay.printMsg("Shifts = %.3f +/- %.3f" %
                        (shifts.mean(), shifts.std()))
     picklef = open(picklefile, "w")
     cPickle.dump(partlist, picklef)
     picklef.close()
     return partlist
	def readRefBasedDocFile(self, docfile, picklefile):
		apDisplay.printMsg("processing alignment doc file "+docfile)
		if not os.path.isfile(docfile):
			apDisplay.printError("Doc file, "+docfile+" does not exist")
		docf = open(docfile, "r")
		partlist = []
		angs = []
		shifts = []
		for line in docf:
			data = line.strip().split()
			if data[0][0] == ";":
				continue
			if len(data) < 6:
				continue
			templatenum = float(data[1])
			angle = alignment.wrap360(float(data[2]))
			partdict = {
				'num': int(data[0]),
				'template': int(abs(templatenum)),
				'mirror': bool(data[5]),
				'score': float(data[6]),
				'rot': angle,
				'xshift': float(data[3]),
				'yshift': float(data[4]),
			}
			angs.append(angle)
			shift = math.hypot(float(data[3]), float(data[4]))
			shifts.append(shift)
			partlist.append(partdict)
		docf.close()
		shifts = numpy.array(shifts, dtype=numpy.float32)
		angs = numpy.array(angs, dtype=numpy.float32)
		apDisplay.printMsg("Angles = %.3f +/- %.3f"%(angs.mean(), angs.std()))
		apDisplay.printMsg("Shifts = %.3f +/- %.3f"%(shifts.mean(), shifts.std()))
		picklef = open(picklefile, "w")
		cPickle.dump(partlist, picklef)
		picklef.close()
		return partlist