QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: ramkrishna on January 17, 2013, 12:36

Title: data extraction from pylab
Post by: ramkrishna on January 17, 2013, 12:36
Dear Sir,
       Is it possible to extract data from pylab and print to a .dat (or .txt) file having two columns (like x and y)?

Regards
Ramkrishna
Title: Re: data extraction from pylab
Post by: Anders Blom on January 17, 2013, 12:52
The question is a bit undefined. There is no data in pylab... Can you be a bit more specific?
Title: Re: data extraction from pylab
Post by: ramkrishna on January 17, 2013, 13:25
Dear Sir,
http://quantumwise.com/documents/manuals/latest/ReferenceManual/index.html/ref.densityofstates.html in this reference manual, I have got a script "si_dos_plot.py". Using this script, I want to plot the PDOS (by using the projection_list command), both in Gaussian and tetrahedron spectrum but when I run this program then the results are shown in pylab plot. Now, it is very difficult for me to modify this figure, so I want to save the data in two columns (for both Gaussian and tetrahedron spectrum in different file)  so that I can plot these in other plotting tools for better resolution.

Regards
Ramkrishna
Title: Re: data extraction from pylab
Post by: Anders Blom on January 17, 2013, 13:47
Sure, this is very simple. If we base it on the reference manual example, you would add to the script

Code: python
for e,d in zip(energies.inUnitsOf(eV), dos_t.inUnitsOf(eV**-1), dos_g.inUnitsOf(eV**-1)):
    print e,d_t,d_g

Pipe the output to a file and you have a data file with 3 columns, energy, dos (tetrahedron) and dos (Gaussian).
Title: Re: data extraction from pylab
Post by: ramkrishna on January 17, 2013, 18:34
Dear Sir,
        Thank you. It is working.

Regards
Ramkrishna