From: Thomas H. <th...@gm...> - 2016-09-07 19:07:11
|
Hi Kanika, Code between the lines. When you try to access information from a ParticleList, you must read it first from disk. You were trying to read the wrong type - PickPosition - instead of ParticleList Replace PickPosition with ParticleList Hope it helps solving your problem, Thomas > On Sep 7, 2016, at 12:00 PM, Kanika Khanna <kk...@uc...> wrote: > > Hello all, > > I have been trying to get coordinates of X,Y,Z from particle list using the function 'PickPosition' from ipytom as follows: > ipytom > from pytom.basic.structures import PickPosition from pytom.basic.structures import ParticleList > pl=PickPosition() > pl.fromXMLFile(pl.xml’) for i,p in enumerate(pl): p.getPickPosition() or pl[i].getPickPosition() > But I run into the following error: > UnboundLocalError Traceback (most recent call last) > <ipython-input-5-71b11edb47f3> in <module>() > ----> 1 pl.fromXMLFile ('pl.xml') > > /usr/local/pytom/basic/structures.py in fromXMLFile(self, filename) > 72 lines = readStringFile(filename) > 73 > ---> 74 self.fromStr(lines) > 75 > 76 def toXMLFile(self,filename): > > /usr/local/pytom/basic/structures.py in fromStr(self, string) > 45 root = etree.fromstring(string) > 46 > ---> 47 self.fromXML(root) > 48 > 49 def __str__(self): > > /usr/local/pytom/basic/structures.py in fromXML(self, xmlObj) > 3674 TypeError('PickPosition: You must provide a valid PickPosition XML object.') > 3675 > -> 3676 self._x = float(shift_element.get('X')) > 3677 self._y = float(shift_element.get('Y')) > 3678 self._z = float(shift_element.get('Z')) > > UnboundLocalError: local variable 'shift_element' referenced before assignment > > > Am I doing it right? How can I get the X,Y,Z coordinates of particles in a matrix from particle file? > > Thanks! > ------------------------------------------------------------------------------ > _______________________________________________ > Pytom-mail mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pytom-mail |