Oct-23-2018, 02:18 AM
Would anyone tell me how to open a dx file in Python? I got stuck here. Thanks a bunch.
how to open dx file in Python
|
Oct-23-2018, 02:18 AM
Would anyone tell me how to open a dx file in Python? I got stuck here. Thanks a bunch.
Oct-23-2018, 07:53 AM
There are some docs/howtos/wiki you can find easily, like : https://griddataformats.readthedocs....ts/OpenDX.html
Oct-23-2018, 08:02 AM
Would you please send the full link again?Thanks. :)
Oct-23-2018, 10:27 AM
https://griddataformats.readthedocs.io/
And the link in the other post is https://griddataformats.readthedocs.io/e...penDX.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Oct-23-2018, 11:10 AM
That's great. Thanks a lot.
I did use "from gridData import Grid". but got error mesg saying: "No module named 'gridData'". What else should I do to import Grid? Thanks again.
Oct-23-2018, 11:20 AM
You need to install it first
https://github.com/MDAnalysis/GridDataFormats From what I see it is available via pip from PyPI
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Oct-24-2018, 02:33 AM
Sorry to bother you again. I got ParseError as following:
g = Grid("ray.dx") --------------------------------------------------------------------------- DXParseError Traceback (most recent call last) <ipython-input-2-0a1918c382cd> in <module>() ----> 1 g = Grid("ray.dx") ~/anaconda3/lib/python3.7/site-packages/gridData/core.py in __init__(self, grid, edges, origin, delta, metadata, interpolation_spline_order) 115 116 if type(grid) is str: --> 117 self.load(grid) 118 elif not (grid is None or edges is None): 119 # set up from histogramdd-type data ~/anaconda3/lib/python3.7/site-packages/gridData/core.py in load(self, filename, file_format) 300 """ 301 loader = self._get_loader(filename, file_format=file_format) --> 302 loader(filename) 303 304 def _load_python(self, filename): ~/anaconda3/lib/python3.7/site-packages/gridData/core.py in _load_dx(self, filename) 319 """Initializes Grid from a OpenDX file.""" 320 dx = OpenDX.field(0) --> 321 dx.read(filename) 322 grid, edges = dx.histogramdd() 323 self.__init__(grid=grid, edges=edges, metadata=self.metadata) ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in read(self, file) 486 DXfield = self 487 p = DXParser(file) --> 488 p.parse(DXfield) 489 490 def add(self,component,DXobj): ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in parse(self, DXfield) 672 self.tokens = [] # token buffer 673 with open(self.filename,'r') as self.dxfile: --> 674 self.use_parser('general') # parse the whole file and populate self.objects 675 676 # assemble field from objects ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in use_parser(self, parsername) 930 """Set parsername as the current parser and apply it.""" 931 self.__parser = self.parsers[parsername] --> 932 self.__parser() 933 def set_parser(self,parsername): 934 """Set parsername as the current parser.""" ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in __general(self) 721 raise DXParseError('Unknown level-1 construct at '+str(tok)) 722 --> 723 self.apply_parser() # hand over to new parser 724 # (possibly been set further down the hierarchy!) 725 ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in apply_parser(self) 936 def apply_parser(self): 937 """Apply the current parser to the token stream.""" --> 938 self.__parser() 939 940 def __tokenize(self,string): ~/anaconda3/lib/python3.7/site-packages/gridData/OpenDX.py in __array(self) 895 value = self.__consume().value() 896 else: --> 897 raise DXParseError('array: '+str(tok)+' not recognized.') 898 899 def __field(self): DXParseError: array: <token BARESTRING,shape> not recognized.
Oct-24-2018, 04:50 AM
are you sure this is OpenDX file?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
aha, openDX can be installed using "sudo apt-get install dx". so simple. I found it somewhere.
Yes, it is openDX file. I think the format is different tho. Anyway, the window pops up. Thanks, buran. Really appreciate your help. And shivkumar123 also. |
|