romerogroup / pyprocar

A Python library for electronic structure pre/post-processing
GNU General Public License v3.0
169 stars 74 forks source link

How to generate dat file from output for further plotting #153

Open danasad80 opened 1 month ago

danasad80 commented 1 month ago

Dear All,

I am new to using PYPROCAR. I have two questions which will be really helpful for me:

1) Is there a possibility to change format of the plotting, for example, a 'stacked_species' comes with filled areas by default. Is there any way of getting normal curve without filled areas

2) Can I get the output of pyprocar in '.dat' format for further plotting (e.g. gnuplot) and analysis.

Thanks! Danial Asad

lllangWV commented 1 month ago

Hey Daniel.

  1. Is there a possibility to change format of the plotting, for example, a 'stacked_species' comes with filled areas by default. Is there any way of getting normal curve without filled areas.

You can use mode=overlay_species, to get the curves without the filled areas.

  1. Can I get the output of pyprocar in '.dat' format for further plotting (e.g. gnuplot) and analysis.

Currently, there isn't. Though you dosplot does return matplotlib.axes object, so you could extract the curves from there

I could add an option to save all the curves in a json file.

A possible implementation would look like this

pyprocar.dosplot(
                    code='vasp',
                    mode='stack_species',
                    orbitals = [4,5,6,7,8],
                    spins=[0,1],
                    clim=[0,1],
                    orientation='horizontal',
                    fermi=5.3017,
                    dirname=data_dir,
                    export_data='{path to file}.json'
)

Then the json would look like this:

{
"energies":  values
"dos_total_spin-0":  values
"dos_total_spin-1":  values
"Sr-d_spin-0-projected": values
"O-d_spin-0-projected": values
"V-d_spin-0-projected": values
}

Something like this. If you have any suggestions on how the format let me know!

Best,

Logan Lang

danasad80 commented 1 month ago

Hi Logan,

Thanks for your kind reply. I think it will be really nice if one can also get the data in traditiional '.dat' format to be plotted in gnuplot etc. But JSON solution should also work!

cheer, Daniel Asad.

lllangWV commented 1 month ago

Hey Daniel,

I have been quite busy, I will get to this tomorrow afternoon. It shouldn't take me long to do this.

Logan Lang

lllangWV commented 1 month ago

Hey Daniel,

I have added an option to export the data into a csv,json,dat,txt file.

Here what the .dat file looks like. It has a header column, then the data. The column names should be self described.

energies dosTotalSpin-0 dosTotalSpin-1 spinChannel-0_orbitals-4:5:6:7:8_atoms-2:3:4_spinProjection-0:1 spinChannel-0_orbitals-4:5:6:7:8_atoms-0_spinProjection-0:1 spinChannel-0_orbitals-4:5:6:7:8_atoms-1_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-2:3:4_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-0_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-1_spinProjection-0:1
-36.5055 0.0 -0.0 0.0 0.0 0.0 -0.0 -0.0 -0.0
-36.497699999999995 0.0 -0.0 0.0 0.0 0.0 -0.0 -0.0 -0.0

Here is how to do this:

pyprocar.dosplot(
                    code='vasp',
                    mode='stack_species',
                    orbitals = [4,5,6,7,8],
                    spins=[0,1],
                    clim=[0,1],
                    # orientation='horizontal',
                    orientation='vertical',
                    fermi=5.3017,
                    grid=True,
                    dirname=data_dir,
                    export_data_file=os.path.join(curent_dir,'data.dat'),
                    # export_data_file=os.path.join(curent_dir,'data.csv'),
                    # export_data_file=os.path.join(curent_dir,'data.json'),
                    # export_data_file=os.path.join(curent_dir,'data.txt'),
                    )

I have pushed my changes to the main branch. I am not going to immediately update pypi or conda, as there are other issues I am working on. So if you want to use the most updated changes clone the repository and install that version

git clone git@github.com:romerogroup/pyprocar.git
cd pyprocar
pip install -e .

Tell me if there is anything else you would like.

Logan Lang

danasad80 commented 1 month ago

Hi Logan,

I am really thankful for your timely support. I am sure other users of pyprocar will also benefit from this.

Best regards

Danial,

On Fri, 19 Jul 2024, 02:33 Logan Lang, @.***> wrote:

Hey Daniel,

I have added an option to export the data into a csv,json,dat,txt file.

Here what the .dat file looks like. It has a header column, then the data. The column names should be self described.

energies dosTotalSpin-0 dosTotalSpin-1 spinChannel-0_orbitals-4:5:6:7:8_atoms-2:3:4_spinProjection-0:1 spinChannel-0_orbitals-4:5:6:7:8_atoms-0_spinProjection-0:1 spinChannel-0_orbitals-4:5:6:7:8_atoms-1_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-2:3:4_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-0_spinProjection-0:1 spinChannel-1_orbitals-4:5:6:7:8_atoms-1_spinProjection-0:1 -36.5055 0.0 -0.0 0.0 0.0 0.0 -0.0 -0.0 -0.0 -36.497699999999995 0.0 -0.0 0.0 0.0 0.0 -0.0 -0.0 -0.0

Here is how to do this:

pyprocar.dosplot( code='vasp', mode='stack_species', orbitals = [4,5,6,7,8], spins=[0,1], clim=[0,1],

orientation='horizontal',

                orientation='vertical',
                fermi=5.3017,
                grid=True,
                dirname=data_dir,
                export_data_file=os.path.join(curent_dir,'data.dat'),
                # export_data_file=os.path.join(curent_dir,'data.csv'),
                # export_data_file=os.path.join(curent_dir,'data.json'),
                # export_data_file=os.path.join(curent_dir,'data.txt'),
                )

I have pushed my changes to the main branch. I am not going to immediately update pypi or conda, as there are other issues I am working on. So if you want to use the most updated changes clone the repository and install that version

git clone @.***:romerogroup/pyprocar.gitcd pyprocar pip install -e .

Tell me if there is anything else you would like.

Logan Lang

— Reply to this email directly, view it on GitHub https://github.com/romerogroup/pyprocar/issues/153#issuecomment-2237137391, or unsubscribe https://github.com/notifications/unsubscribe-auth/BD2325NR6RGEZMD52B4I4MDZM737TAVCNFSM6AAAAABKWBZD4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXGEZTOMZZGE . You are receiving this because you authored the thread.Message ID: @.***>