From 1c31fcb59a1cbf72a8ec5852a485edf6deec8a38 Mon Sep 17 00:00:00 2001 From: Kieran B Spooner Date: Thu, 21 Sep 2023 14:04:12 +0100 Subject: [PATCH 1/2] fixes to cli and tests --- tests/test_data/test_load.py | 4 +++- tp/cli/cli.py | 4 ++-- tp/data/load.py | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_data/test_load.py b/tests/test_data/test_load.py index 1a3746e..7771320 100644 --- a/tests/test_data/test_load.py +++ b/tests/test_data/test_load.py @@ -132,6 +132,8 @@ def test_spin(self): f['ir_kpoints'] = [[1, 2, 3]] f['scattering_rates_up'][0,0,1,0,0] = 1 f['scattering_rates_down'][0,0,1,0,0] = 3 + f['energies_up'] = np.zeros((1, 2, 2, 3, 1)) + f['energies_down'] = np.zeros((1, 2, 2, 3, 1)) data = load.amset_mesh('test.hdf5', 'scattering_rates', spin='avg') for q2 in ['scattering_rates', 'temperature', 'doping', 'meta']: @@ -378,4 +380,4 @@ def test_default(self, mock_load, mock_poscar): data2 = load.phonopy_dos('mock') mock_load.assert_called_once() - mock_poscar.assert_called_once() \ No newline at end of file + mock_poscar.assert_called_once() diff --git a/tp/cli/cli.py b/tp/cli/cli.py index a550ae8..b87d9d6 100644 --- a/tp/cli/cli.py +++ b/tp/cli/cli.py @@ -159,7 +159,7 @@ def get(): show_default=True) @click.option('-s', '--scattering', help='Scattering mechanism.', - type=click.Choice(['ADP', 'IMP', 'PIE', 'POP', 'total'], + type=click.Choice(['ADP', 'IMP', 'PIE', 'POP', 'Total'], case_sensitive=False), default='total', show_default=True) @@ -272,7 +272,7 @@ def get_amset(amset_file, quantity, dtype, doping, direction, temperature, spin, @get.command('occupation') @inputs_function('amset_mesh_file', nargs=1) @doping_type_option -@doping_option +@doping_function() @temperature_option @click.option('--spin', help='Spin direction.', diff --git a/tp/data/load.py b/tp/data/load.py index 829ee6a..755eabc 100644 --- a/tp/data/load.py +++ b/tp/data/load.py @@ -326,6 +326,8 @@ def resolve_spin(data, q, spin): spin2 = 'up' elif 'energies_down' in f: spin2 = 'down' + else: + spin2 = spin data = {'meta': {'doping_type': doping, 'electronic_source': 'amset', From 62959bf5dee29581608a42b16a805f83f763ea82 Mon Sep 17 00:00:00 2001 From: "Kieran B. Spooner" Date: Fri, 23 Feb 2024 12:43:50 +0000 Subject: [PATCH 2/2] update from JOSS review 1 simplified data retrieval in the examples possibly fixed line endings for unix machines? fixed broken links on the github docs. Will update the website one the main branch updated the docstrings for the CLI options Thanks to @epottesmith :bow: This update is based on https://github.com/openjournals/joss-reviews/issues/6340#issuecomment-1939521565 --- README.rst | 24 +- citation.cff | 2 +- examples/01-python-foundations/README.rst | 12 +- .../02-individual-customisation/README.rst | 4 +- .../tutorial-02.py | 2 +- examples/03-compound-axes/README.rst | 2 +- examples/04-layered-plots/README.rst | 2 +- examples/04-layered-plots/tutorial-04.py | 110 ++--- examples/05-helper-functions/tutorial-05.py | 114 ++--- examples/06-package-customisation/README.rst | 2 +- examples/README.rst | 18 +- examples/avg-rates/README.rst | 2 +- examples/avg-rates/plot-avg-rates.py | 2 +- examples/cumkappa/README.rst | 2 +- examples/cumkappa/get-data.sh | 10 - examples/cumkappa/plot-cumkappa.py | 2 +- examples/{heatmaps => }/get-data.sh | 36 +- examples/heatmaps/plot-zt.py | 2 +- examples/heatmaps/plot-ztdiff.py | 2 +- examples/projected-phonons/get-data.sh | 10 - .../plot-projected-phonons.py | 2 +- examples/projected-phonons/plot-wideband.py | 2 +- examples/waterfall/get-data.sh | 10 - examples/waterfall/plot-density.py | 2 +- examples/waterfall/plot-waterfall.py | 2 +- setup.py | 8 +- tp/axes/README.rst | 2 +- tp/cli/options.py | 430 ++++++++++++++++-- tp/data/README.rst | 2 +- tp/plot/README.rst | 2 +- 30 files changed, 567 insertions(+), 255 deletions(-) delete mode 100755 examples/cumkappa/get-data.sh rename examples/{heatmaps => }/get-data.sh (78%) delete mode 100755 examples/projected-phonons/get-data.sh delete mode 100755 examples/waterfall/get-data.sh diff --git a/README.rst b/README.rst index b4c1185..f89c980 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ .. image:: figures/tp-logo-header.png :alt: The ThermoParser logo, which looks like "TP" - :target: https://smtg-ucl.github.io/ThermoParser/ + :target: https://smtg-bham.github.io/ThermoParser/ :align: center .. code-block:: @@ -17,9 +17,9 @@ |____________________________________:_______________________/____________:_____/ -.. image:: https://app.travis-ci.com/SMTG-UCL/ThermoParser.svg?branch=master +.. image:: https://travis-ci.com/smtg-bham/ThermoParser.svg?branch=master :alt: The travis-ci badge - :target: https://app.travis-ci.com/SMTG-UCL/ThermoParser + :target: https://travis-ci.com/smtg-bham/ThermoParser ThermoParser is a toolkit used to simplify the analysis of data produced by specialist materials science codes, centred around @@ -35,9 +35,9 @@ Click on the image to go to the `gallery`_! .. image:: figures/wideband.png :alt: A phonon dispersion where widened bands show phonon scattering - :target: https://smtg-ucl.github.io/ThermoParser/gallery.html + :target: https://smtg-bham.github.io/ThermoParser/gallery.html -.. _gallery: https://smtg-ucl.github.io/ThermoParser/gallery.html +.. _gallery: https://smtg-bham.github.io/ThermoParser/gallery.html Installation ------------ @@ -46,7 +46,7 @@ ThermoParser can easily be installed with git and pip: .. code-block:: bash - git clone https://github.com/SMTG-UCL/ThermoParser.git + git clone https://github.com/smtg-bham/ThermoParser.git cd ThermoParser pip install . @@ -66,7 +66,7 @@ longer process is required: 2. ``python3 -m pip install cython numpy`` 3. ``brew info hdf5`` to retrieve the path to your hdf5 install 4. ``HDF5_DIR=YOUR_HDF5_PATH --no-build-isolation h5py`` -5. ``git clone https://github.com/SMTG-UCL/ThermoParser.git`` +5. ``git clone https://github.com/smtg-bham/ThermoParser.git`` 6. ``cd ThermoParser`` 7. ``pip install --user -e .`` @@ -107,8 +107,8 @@ The best way to get a feel for ThermoParser is to see it in action: Take a look at our `examples`_ and `tutorials`_. Currently supported codes are: -.. _examples: https://github.com/smtg-ucl/ThermoParser/tree/master/examples -.. _tutorials: https://smtg-ucl.github.io/ThermoParser/tutorials.html +.. _examples: https://github.com/smtg-bham/ThermoParser/tree/master/examples +.. _tutorials: https://smtg-bham.github.io/ThermoParser/tutorials.html * Phononic properties: @@ -156,10 +156,10 @@ appropriate `examples`_, further `documentation`_ and `tests`_ are greatly appreciated. Documentation uses the `sphinx`_ package, and can be built from the ``docs`` directory with ``sphinx-build -b html src/ .``. -.. _issue tracker: https://github.com/smtg-ucl/ThermoParser/issues +.. _issue tracker: https://github.com/smtg-bham/ThermoParser/issues .. _fork and pull: https://guides.github.com/activities/forking -.. _documentation: https://smtg-ucl.github.io/ThermoParser/ -.. _tests: https://github.com/smtg-ucl/ThermoParser/tree/master/tests +.. _documentation: https://smtg-bham.github.io/ThermoParser/ +.. _tests: https://github.com/smtg-bham/ThermoParser/tree/master/tests Testing ------- diff --git a/citation.cff b/citation.cff index c3bce4c..fcd7711 100644 --- a/citation.cff +++ b/citation.cff @@ -16,4 +16,4 @@ authors: title: "ThermoParser: Streamlined Analysis of Thermoelectric Properties" version: 3.0.0 date-released: 2023-08-16 -url: "https://github.com/SMTG-UCL/ThermoParser" +url: "https://github.com/smtg-bham/ThermoParser" diff --git a/examples/01-python-foundations/README.rst b/examples/01-python-foundations/README.rst index 983b18a..99e33d2 100644 --- a/examples/01-python-foundations/README.rst +++ b/examples/01-python-foundations/README.rst @@ -88,10 +88,10 @@ ThermoParser has extensive docs. Docstrings are available throughout the code itself, if you are using IPython or Jupyter and you can access them by typing the command name followed by two question marks, and IDEs normally have options too. If you are on the master branch, -they can also be found `here `_. +they can also be found `here `_. -.. _Tutorial-03: https://smtg-ucl.github.io/ThermoParser/tutorial-03.html -.. _Tutorial-05: https://smtg-ucl.github.io/ThermoParser/tutorial-05.html -.. _Axes: https://smtg-ucl.github.io/ThermoParser/tp.axes.html -.. _Load: https://smtg-ucl.github.io/ThermoParser/tp.data.html#module-tp.data.load -.. _Plot: https://smtg-ucl.github.io/ThermoParser/tp.plot.html \ No newline at end of file +.. _Tutorial-03: https://smtg-bham.github.io/ThermoParser/tutorial-03.html +.. _Tutorial-05: https://smtg-bham.github.io/ThermoParser/tutorial-05.html +.. _Axes: https://smtg-bham.github.io/ThermoParser/tp.axes.html +.. _Load: https://smtg-bham.github.io/ThermoParser/tp.data.html#module-tp.data.load +.. _Plot: https://smtg-bham.github.io/ThermoParser/tp.plot.html \ No newline at end of file diff --git a/examples/02-individual-customisation/README.rst b/examples/02-individual-customisation/README.rst index ae56367..e8847be 100644 --- a/examples/02-individual-customisation/README.rst +++ b/examples/02-individual-customisation/README.rst @@ -77,5 +77,5 @@ midpoint you specify, and ``uniform`` calculates the midpoint position based on the relative compositions of the colours, which is used for heatmaps. -.. _Tutorial-01: https://smtg-ucl.github.io/ThermoParser/tutorial-01.html -.. _colourmap generators: https://smtg-ucl.github.io/ThermoParser/tp.plot.html#module-tp.plot.colour \ No newline at end of file +.. _Tutorial-01: https://smtg-bham.github.io/ThermoParser/tutorial-01.html +.. _colourmap generators: https://smtg-bham.github.io/ThermoParser/tp.plot.html#module-tp.plot.colour \ No newline at end of file diff --git a/examples/02-individual-customisation/tutorial-02.py b/examples/02-individual-customisation/tutorial-02.py index 9048ed8..9cee34d 100644 --- a/examples/02-individual-customisation/tutorial-02.py +++ b/examples/02-individual-customisation/tutorial-02.py @@ -13,7 +13,7 @@ # You can ignore down to line 20! from os import path if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # Stop ignoring! # Axes diff --git a/examples/03-compound-axes/README.rst b/examples/03-compound-axes/README.rst index 409cc97..cf0e91f 100644 --- a/examples/03-compound-axes/README.rst +++ b/examples/03-compound-axes/README.rst @@ -65,4 +65,4 @@ and ``labels`` arguments, so in order to specify your own, you must set ``tp.axes.legend.consolidate`` may also be useful for non-ThermoParser endaevors, as will be discussed in `Tutorial-05`_. -.. _Tutorial-05: https://smtg-ucl.github.io/ThermoParser/tutorial-05.html \ No newline at end of file +.. _Tutorial-05: https://smtg-bham.github.io/ThermoParser/tutorial-05.html \ No newline at end of file diff --git a/examples/04-layered-plots/README.rst b/examples/04-layered-plots/README.rst index 1d62a66..9a7e3be 100644 --- a/examples/04-layered-plots/README.rst +++ b/examples/04-layered-plots/README.rst @@ -70,4 +70,4 @@ which removes the ticks and tick labels and the y axis label, while all the default labels can be accessed with ``settings.labels``. These will be covered more in `Tutorial-05`_. -.. _Tutorial-05: https://smtg-ucl.github.io/ThermoParser/tutorial-05.html +.. _Tutorial-05: https://smtg-bham.github.io/ThermoParser/tutorial-05.html diff --git a/examples/04-layered-plots/tutorial-04.py b/examples/04-layered-plots/tutorial-04.py index 927024f..26ed48d 100644 --- a/examples/04-layered-plots/tutorial-04.py +++ b/examples/04-layered-plots/tutorial-04.py @@ -1,55 +1,55 @@ -#!/usr/bin/env python3 - -import tp - -scs = '222 333 444 555'.split() -pfiles = ['../data/basno3/band-{}.yaml'.format(s) for s in scs] -kfile = '../data/basno3/kappa-m363636.hdf5' -dfile = '../data/basno3/projected_dos.dat' -poscar = '../data/basno3/POSCAR' - -direction = 'avg' -temperature = 300 -waterfall = 'mean_free_path' -quantities = ['waterfall', waterfall] - -colour = 'winter_r' -colours = {'Ba': '#ffcf06', - 'Sn': '#59c605', - 'O': '#00b1f7'} -cmap = 'viridis' - -# You can ignore down to line 23! -from os import path -if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') -# Stop ignoring! - -# Axes -fig, ax, add_legend = tp.axes.small.two_h() - -# Load -dispersions = [tp.data.load.phonopy_dispersion(f) for f in pfiles] -kappa = tp.data.load.phono3py(kfile, quantities=quantities) -dos = tp.data.load.phonopy_dos(dfile, poscar=poscar) - -# Plot -tp.plot.phonons.add_multi(ax[0], dispersions, colour=colour, label=scs) -tp.plot.frequency.format_waterfall(ax[1], kappa, waterfall, direction=direction, - temperature=temperature, invert=True) -tp.plot.frequency.add_dos(ax[1], dos, colour=colours, scale=True, main=False, - alpha=0.6, line=False, invert=True) -tp.plot.frequency.add_waterfall(ax[1], kappa, waterfall, colour=cmap, - direction=direction, temperature=temperature, - invert=True) - -# Formatting - -tp.plot.utilities.set_locators(ax[1], x='log', y='linear') -axlabels = tp.settings.labels() -ax[1].set_xlabel(axlabels['mean_free_path']) -ax[1].set_ylabel(axlabels['frequency']) -add_legend() - -# Save -fig.savefig('tutorial-04.png') +#!/usr/bin/env python3 + +import tp + +scs = '222 333 444 555'.split() +pfiles = ['../data/basno3/band-{}.yaml'.format(s) for s in scs] +kfile = '../data/basno3/kappa-m363636.hdf5' +dfile = '../data/basno3/projected_dos.dat' +poscar = '../data/basno3/POSCAR' + +direction = 'avg' +temperature = 300 +waterfall = 'mean_free_path' +quantities = ['waterfall', waterfall] + +colour = 'winter_r' +colours = {'Ba': '#ffcf06', + 'Sn': '#59c605', + 'O': '#00b1f7'} +cmap = 'viridis' + +# You can ignore down to line 23! +from os import path +if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): + raise Exception('File not found, please use get-data.sh in the folder above.') +# Stop ignoring! + +# Axes +fig, ax, add_legend = tp.axes.small.two_h() + +# Load +dispersions = [tp.data.load.phonopy_dispersion(f) for f in pfiles] +kappa = tp.data.load.phono3py(kfile, quantities=quantities) +dos = tp.data.load.phonopy_dos(dfile, poscar=poscar) + +# Plot +tp.plot.phonons.add_multi(ax[0], dispersions, colour=colour, label=scs) +tp.plot.frequency.format_waterfall(ax[1], kappa, waterfall, direction=direction, + temperature=temperature, invert=True) +tp.plot.frequency.add_dos(ax[1], dos, colour=colours, scale=True, main=False, + alpha=0.6, line=False, invert=True) +tp.plot.frequency.add_waterfall(ax[1], kappa, waterfall, colour=cmap, + direction=direction, temperature=temperature, + invert=True) + +# Formatting + +tp.plot.utilities.set_locators(ax[1], x='log', y='linear') +axlabels = tp.settings.labels() +ax[1].set_xlabel(axlabels['mean_free_path']) +ax[1].set_ylabel(axlabels['frequency']) +add_legend() + +# Save +fig.savefig('tutorial-04.png') diff --git a/examples/05-helper-functions/tutorial-05.py b/examples/05-helper-functions/tutorial-05.py index cfd56be..dbf1d09 100644 --- a/examples/05-helper-functions/tutorial-05.py +++ b/examples/05-helper-functions/tutorial-05.py @@ -1,57 +1,57 @@ -#!/usr/bin/env python3 - -import tp -from matplotlib.gridspec import GridSpec -import matplotlib.pyplot as plt - -afile = '../data/basno3/transport_75x75x75.json' -kfile = '../data/basno3/kappa-m363636.hdf5' - -doping = [-1e18, -1e19, -1e20, -1e21] -direction = 'avg' -quantities = ['conductivity', 'seebeck'] -scale = ['log', 'linear', 'linear'] - -from os import path -if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') - -# Axes -plt.style.use('tp') -fig = plt.figure(figsize=(27/2.54, 8.3/2.54)) -grid = GridSpec(1, 14) -ax = [fig.add_subplot(grid[0, :4]), - fig.add_subplot(grid[0, 5:9]), - fig.add_subplot(grid[0, 10:])] -plt.subplots_adjust(left=0.06, right=0.98, - bottom=0.12, top=0.95) - -# Load -adata = tp.data.load.amset(afile) -kdata = tp.data.load.phono3py(kfile) - -# Plot -for i, q in enumerate(quantities): - for d in doping: - data = tp.data.utilities.resolve(adata, q, direction=direction, doping=d) - ax[i].plot(data['temperature'], data[q], - label="{:.2e}".format(data['meta']['doping'])) - -q = 'lattice_thermal_conductivity' -data = tp.data.utilities.resolve(kdata, q, direction=direction) -ax[2].plot(data['temperature'], data[q]) - -# Formatting -axlabels = tp.settings.labels() -for i, q in enumerate([*quantities, q]): - ax[i].set_xlabel(axlabels['temperature']) - ax[i].set_ylabel(axlabels[q]) - tp.plot.utilities.set_locators(ax[i], x='linear', y=scale[i]) - -handles, labels = tp.axes.legend.consolidate(ax) -ax[2].legend(loc='best', title=axlabels['doping'], handles=handles, - labels=labels) -tp.axes.legend.alphabetise(ax, preset='roman', suffix=')', x=-0.12) - -# Save -fig.savefig('tutorial-05.png') +#!/usr/bin/env python3 + +import tp +from matplotlib.gridspec import GridSpec +import matplotlib.pyplot as plt + +afile = '../data/basno3/transport_75x75x75.json' +kfile = '../data/basno3/kappa-m363636.hdf5' + +doping = [-1e18, -1e19, -1e20, -1e21] +direction = 'avg' +quantities = ['conductivity', 'seebeck'] +scale = ['log', 'linear', 'linear'] + +from os import path +if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): + raise Exception('File not found, please use get-data.sh in the folder above.') + +# Axes +plt.style.use('tp') +fig = plt.figure(figsize=(27/2.54, 8.3/2.54)) +grid = GridSpec(1, 14) +ax = [fig.add_subplot(grid[0, :4]), + fig.add_subplot(grid[0, 5:9]), + fig.add_subplot(grid[0, 10:])] +plt.subplots_adjust(left=0.06, right=0.98, + bottom=0.12, top=0.95) + +# Load +adata = tp.data.load.amset(afile) +kdata = tp.data.load.phono3py(kfile) + +# Plot +for i, q in enumerate(quantities): + for d in doping: + data = tp.data.utilities.resolve(adata, q, direction=direction, doping=d) + ax[i].plot(data['temperature'], data[q], + label="{:.2e}".format(data['meta']['doping'])) + +q = 'lattice_thermal_conductivity' +data = tp.data.utilities.resolve(kdata, q, direction=direction) +ax[2].plot(data['temperature'], data[q]) + +# Formatting +axlabels = tp.settings.labels() +for i, q in enumerate([*quantities, q]): + ax[i].set_xlabel(axlabels['temperature']) + ax[i].set_ylabel(axlabels[q]) + tp.plot.utilities.set_locators(ax[i], x='linear', y=scale[i]) + +handles, labels = tp.axes.legend.consolidate(ax) +ax[2].legend(loc='best', title=axlabels['doping'], handles=handles, + labels=labels) +tp.axes.legend.alphabetise(ax, preset='roman', suffix=')', x=-0.12) + +# Save +fig.savefig('tutorial-05.png') diff --git a/examples/06-package-customisation/README.rst b/examples/06-package-customisation/README.rst index 5697a9a..3048d30 100644 --- a/examples/06-package-customisation/README.rst +++ b/examples/06-package-customisation/README.rst @@ -33,7 +33,7 @@ dictionaries like the locators. The aliases are listed as: If you add unit conversions, remember to update the units and labels too! An example has been provided for converting from -S m\ :sup:`-1` to S cm\ :sup:`-1` `here `_. +S m\ :sup:`-1` to S cm\ :sup:`-1` `here `_. There are six labels dictionaries. ``long_``, ``medium_`` and ``short_labels`` contain the actual labels of those lengths, while ``labels``, ``inverted_labels`` and ``large_labels`` point to which of diff --git a/examples/README.rst b/examples/README.rst index eabc654..6d52cb5 100644 --- a/examples/README.rst +++ b/examples/README.rst @@ -15,60 +15,60 @@ cumkappa .. image:: cumkappa/cumkappa.png :alt: Cumulative lattice thermal conductivity against frequency and mean free path. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/cumkappa + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/cumkappa kappa-target ------------ .. image:: kappa-target/kappa-target.png :alt: Lattice thermal conductivity required to reach a given ZT against carrier concentration and temperature. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/kappa-target + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/kappa-target phonons ------- .. image:: phonons/phonons.png :alt: Phonon dispersion and density of states. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/phonons + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/phonons multiphon --------- .. image:: phonons/multiphon.png :alt: Phonon dispersions for different supercell sizes. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/phonons + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/phonons wideband -------- .. image:: projected-phonons/wideband.png :alt: Phonon dispersion with broadened bands. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/projected-phonons + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/projected-phonons projected-phonons ----------------- .. image:: projected-phonons/prophon.png :alt: Phonon dispersion with phonon lifetime projected. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/projected-phonons + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/projected-phonons waterfall --------- .. image:: waterfall/waterfall.png :alt: Waterfall plot of mean free path against frequency with lattice thermal conductivity projected. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/waterfall + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/waterfall density ------- .. image:: waterfall/density.png :alt: Scatter-density plot of mean free path against frequency. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/waterfall + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/waterfall ztmap ----- .. image:: ztmap/ztmap.png :alt: ZT against carrier concentration and temperature. - :target: https://github.com/SMTG-UCL/ThermoParser/tree/master/examples/ztmap + :target: https://github.com/smtg-bham/ThermoParser/tree/master/examples/ztmap diff --git a/examples/avg-rates/README.rst b/examples/avg-rates/README.rst index edcd980..14e05c8 100644 --- a/examples/avg-rates/README.rst +++ b/examples/avg-rates/README.rst @@ -34,7 +34,7 @@ graph matplotlib's normal ``plot`` function is used, and the axes, labels, ticks and legend are all sorted out by tp functions (lines 21, 34-38. 39/40 and 42 respectively, see also `Tutorial-05`_). -.. _Tutorial-05: https://smtg-ucl.github.io/ThermoParser/tutorial-05.html +.. _Tutorial-05: https://smtg-bham.github.io/ThermoParser/tutorial-05.html This graph can instead show weighted mean free paths, by adding the ``--mfp`` tag at the command line or changing ``q`` to equal diff --git a/examples/avg-rates/plot-avg-rates.py b/examples/avg-rates/plot-avg-rates.py index f11959e..39d5c30 100644 --- a/examples/avg-rates/plot-avg-rates.py +++ b/examples/avg-rates/plot-avg-rates.py @@ -14,7 +14,7 @@ # Example only shenanegans from os import path if not path.isfile(f) or path.getsize(f) < 1024*1024*10: - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # End of example only shenanegans # Axes diff --git a/examples/cumkappa/README.rst b/examples/cumkappa/README.rst index 49bfc5a..763e3a2 100644 --- a/examples/cumkappa/README.rst +++ b/examples/cumkappa/README.rst @@ -15,7 +15,7 @@ to add markers has been included, e.g. here you can see nanostructuring to 100 nanometers may reduce the lattice thermal conductivity by around 40 %. -.. _density of states: https://github.com/SMTG-UCL/ThermoParser/blob/master/examples/dos/ +.. _density of states: https://github.com/smtg-bham/ThermoParser/blob/master/examples/dos/ The right plot can be plotted at the command line with: diff --git a/examples/cumkappa/get-data.sh b/examples/cumkappa/get-data.sh deleted file mode 100755 index 0cc7839..0000000 --- a/examples/cumkappa/get-data.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -f='../data/zno/kappa-m404021.hdf5' -repo='https://zenodo.org/record/4428179/files/kappa-m404021.hdf5?download=1' - -if [[ ! -f $f ]]; then - wget $repo -O $f -else - echo Already downloaded! -fi diff --git a/examples/cumkappa/plot-cumkappa.py b/examples/cumkappa/plot-cumkappa.py index 798e87c..9d837c2 100755 --- a/examples/cumkappa/plot-cumkappa.py +++ b/examples/cumkappa/plot-cumkappa.py @@ -11,7 +11,7 @@ # You can ignore this section from os import path if not path.isfile(kappafile) or (path.getsize(kappafile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # End ignore dosfile = '../data/zno/projected_dos.dat' diff --git a/examples/heatmaps/get-data.sh b/examples/get-data.sh similarity index 78% rename from examples/heatmaps/get-data.sh rename to examples/get-data.sh index fc30d74..7347dd6 100644 --- a/examples/heatmaps/get-data.sh +++ b/examples/get-data.sh @@ -1,18 +1,18 @@ -#!/bin/bash - -f1='../data/basno3/kappa-m363636.hdf5' -f2='../data/zno/kappa-m404021.hdf5' -repo1='https://zenodo.org/record/4428179/files/kappa-m363636.hdf5?download=1' -repo2='https://zenodo.org/record/4428179/files/kappa-m404021.hdf5?download=1' - -if [[ ! -f $f1 ]]; then - wget $repo1 -O $f1 -else - echo Already downloaded! -fi - -if [[ ! -f $f2 ]]; then - wget $repo2 -O $f2 -else - echo Already downloaded! -fi +#!/bin/bash + +f1='data/basno3/kappa-m363636.hdf5' +f2='data/zno/kappa-m404021.hdf5' +repo1='https://zenodo.org/record/4428179/files/kappa-m363636.hdf5?download=1' +repo2='https://zenodo.org/record/4428179/files/kappa-m404021.hdf5?download=1' + +if [[ ! -f $f1 ]]; then + wget $repo1 -O $f1 +else + echo Already downloaded! +fi + +if [[ ! -f $f2 ]]; then + wget $repo2 -O $f2 +else + echo Already downloaded! +fi diff --git a/examples/heatmaps/plot-zt.py b/examples/heatmaps/plot-zt.py index 194da80..271b391 100644 --- a/examples/heatmaps/plot-zt.py +++ b/examples/heatmaps/plot-zt.py @@ -6,7 +6,7 @@ bfile = '../data/zno/boltztrap.hdf5' kfile = '../data/zno/kappa-m404021.hdf5' if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') direction = 'x' colour = '#800080' diff --git a/examples/heatmaps/plot-ztdiff.py b/examples/heatmaps/plot-ztdiff.py index da35a80..393d3a2 100644 --- a/examples/heatmaps/plot-ztdiff.py +++ b/examples/heatmaps/plot-ztdiff.py @@ -10,7 +10,7 @@ label = ['ZnO', 'BaSnO$_3$'] for f in kfiles: if not path.isfile(f) or (path.getsize(f) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # Axes fig, ax, add_legend = tp.axes.small.one_colourbar() diff --git a/examples/projected-phonons/get-data.sh b/examples/projected-phonons/get-data.sh deleted file mode 100755 index 0cc7839..0000000 --- a/examples/projected-phonons/get-data.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -f='../data/zno/kappa-m404021.hdf5' -repo='https://zenodo.org/record/4428179/files/kappa-m404021.hdf5?download=1' - -if [[ ! -f $f ]]; then - wget $repo -O $f -else - echo Already downloaded! -fi diff --git a/examples/projected-phonons/plot-projected-phonons.py b/examples/projected-phonons/plot-projected-phonons.py index 0479371..7d5d47a 100755 --- a/examples/projected-phonons/plot-projected-phonons.py +++ b/examples/projected-phonons/plot-projected-phonons.py @@ -7,7 +7,7 @@ kfile = '../data/zno/kappa-m404021.hdf5' poscar = '../data/zno/POSCAR' if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') projected = 'lifetime' quantities = ['frequency', projected, 'dispersion'] diff --git a/examples/projected-phonons/plot-wideband.py b/examples/projected-phonons/plot-wideband.py index d1cb870..28c0358 100644 --- a/examples/projected-phonons/plot-wideband.py +++ b/examples/projected-phonons/plot-wideband.py @@ -8,7 +8,7 @@ poscar = '../data/zno/POSCAR' temperature = 300 if not path.isfile(kappafile) or (path.getsize(kappafile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') colour = ['#000000', '#ff0000'] diff --git a/examples/waterfall/get-data.sh b/examples/waterfall/get-data.sh deleted file mode 100755 index f43d44a..0000000 --- a/examples/waterfall/get-data.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -f='../data/basno3/kappa-m363636.hdf5' -repo='https://zenodo.org/record/4428179/files/kappa-m363636.hdf5?download=1' - -if [[ ! -f $f ]]; then - wget $repo -O $f -else - echo Already downloaded! -fi diff --git a/examples/waterfall/plot-density.py b/examples/waterfall/plot-density.py index ba23282..0e32f83 100644 --- a/examples/waterfall/plot-density.py +++ b/examples/waterfall/plot-density.py @@ -6,7 +6,7 @@ # from os import path if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # direction = 'avg' diff --git a/examples/waterfall/plot-waterfall.py b/examples/waterfall/plot-waterfall.py index 3fba17b..b0cf0b3 100755 --- a/examples/waterfall/plot-waterfall.py +++ b/examples/waterfall/plot-waterfall.py @@ -9,7 +9,7 @@ # from os import path if not path.isfile(kfile) or (path.getsize(kfile) < 1024*1024*100): - raise Exception('File not found, please use get-data.sh') + raise Exception('File not found, please use get-data.sh in the folder above.') # direction = 'avg' diff --git a/setup.py b/setup.py index d57b611..ecd0329 100644 --- a/setup.py +++ b/setup.py @@ -2,11 +2,11 @@ __name__ = 'ThermoParser' __author__ = 'Kieran B. Spooner' -__copyright__ = 'Copyright Scanlon Materials Theory Group (2023)' +__copyright__ = 'Copyright Scanlon Materials Theory Group (2024)' __version__ = '3.0.0' __maintainer__ = 'Kieran B. Spooner' -__email__ = 'kieran.spooner.14@ucl.ac.uk' -__date__ = 'August 16th 2023' +__email__ = 'k.b.spooner@bham.ac.uk' +__date__ = 'February 23rd 2024' import os import setuptools @@ -45,7 +45,7 @@ def __init__(self, *args, **kwargs): description='streamlined analysis of thermoelectric properties', long_description=long_description, long_description_content_type='text/x-rst', - url='https://smtg-ucl.github.io/ThermoParser/', + url='https://smtg-bham.github.io/ThermoParser/', packages=setuptools.find_packages(), classifiers=[ 'Development Status :: 4 - Beta', diff --git a/tp/axes/README.rst b/tp/axes/README.rst index 56e2dda..54cf650 100644 --- a/tp/axes/README.rst +++ b/tp/axes/README.rst @@ -1,6 +1,6 @@ Please see the `examples`_. -.. _examples: https://github.com/smtg-ucl/ThermoParser/tree/master/examples +.. _examples: https://github.com/smtg-bham/ThermoParser/tree/master/examples Pre-sized axes for plotting convenience. Many users may want to ignore this module. diff --git a/tp/cli/options.py b/tp/cli/options.py index e8ef126..eaeac6c 100644 --- a/tp/cli/options.py +++ b/tp/cli/options.py @@ -3,43 +3,69 @@ Functions --------- - direction_function - - doping_type_option - - doping_function - - dos_function - - input_argument - - inputs_function - - interpolate_options - - kpoints_options - - legend_options - - line_options - - fill_options - - plot_io_function - - temperature_option - - verbose_option - + direction_function: + function for picking the --direction (-d). + doping_type_option: + function for picking the doping --type (-t). + doping_function: + function for picking the doping --concentration (-n). + dos_function: + function for setting DoS formatting. + inputs_function: + function for picking the input file(s) argument. + interpolate_options: + function for setting interpolation options. + kpoints_options: + function for handling KPOINTS files. + legend_options: + function for formatting legends. + line_options: + function for formatting line plots. + fill_options: + function for formatting fillable line plots. + plot_io_function: + function for formatting plot outputs. + temperature_option: + function for picking the --temperature (-t). + verbose_option: + function for increasing the verbosity. axes_limit_function + function for setting the axis limits. """ import click def direction_function(multiple=False): + """Function to create direction options. + + Arguments + --------- + + multiple : bool, optional + whether to allow multiple directions. Default: False. + + Returns + ------- + decorator + direction option decorator. + """ + default = ['avg'] if multiple else 'avg' def direction_option(f): - """Option for anisotropic data.""" + """Option for anisotropic data. + + Options + ------- + + --direction, -d : str or array-like, optional + direction. Default: avg. + + Returns + ------- + + decorator + direction option decorator. + """ f = click.option('-d', '--direction', help='Direction(s) for anisotropic data.', @@ -56,9 +82,22 @@ def direction_option(f): return direction_option def doping_type_option(f): - """Option for doping type.""" + """Option for doping type. + + Options + ------- + + --type : str, optional + doping type. Default: n. + + Returns + ------- - f = click.option('-t', '--type', 'dtype', + decorator + doping type option decorator. + """ + + f = click.option('--type', 'dtype', help='Type of doping.', type=click.Choice(['n', 'p']), default='n', @@ -67,9 +106,36 @@ def doping_type_option(f): return f def doping_function(multiple=False): + """Function to create doping options. + + Arguments + --------- + + multiple : bool, optional + whether to allow multiple concentrations. Default: False. + + Returns + ------- + decorator + carrier concentration option decorator. + """ + default = [1e19] if multiple else 1e19 def doping_option(f): - """Option for doping concentration.""" + """Option for doping concentration. + + Options + ------- + + --concentration, -n : int or float or array-like, optional + carrier concentration. Default: 1e19. + + Returns + ------- + + decorator + carrier concentration option decorator. + """ f = click.option('-n', '--concentration', 'doping', help='Doping concentration(s) (will be rounded).', @@ -82,10 +148,53 @@ def doping_option(f): return doping_option def dos_function(dosargs=['-c', '--colour']): + """Function for creating DoS options. + + Arguments + --------- + + dosargs : array-like, optional + names for the colour argument. Default: ['-c', '--colour']. + + Returns + ------- + decorator + DoS options decorator. + """ + if isinstance(dosargs, str): dosargs = [dosargs] def dos_options(f): - """Options for DoS plots.""" + """Options for DoS plots. + + Options + ------- + + --poscar, -p : str, optional + POSCAR path. Ignored if atoms specified. Default: POSCAR. + --atoms : str, optional + atoms in POSCAR order. Overrides poscar. Default: None. + --sigma : float, optional + standard deviation for gaussian broadening. + Recommended: 0.2. Default: None. + --projected/--notprojected : bool, optional + plot atom-projected DoS. Default: --projected. + --colour : str or array-like, optional + colours in atom order followed by total or colourmap. + Default: tab10. + --total, -t/--nototal : bool, optional + plot the total DoS. Default: --nototal. + --total_label : str, optional + total label for the legend. Default: total. + --total_colour : str, optional + total line colour. Overrides --colour. + + Returns + ------- + + decorator + DoS options decorator. + """ f = click.option('-p', '--poscar', help='POSCAR path. Ignored if --atoms specified.', @@ -132,8 +241,38 @@ def dos_options(f): return dos_options def inputs_function(name='filenames', nargs=-1): + """Function for creating input arguments. + + Arguments + --------- + + name : str, optional + filename argument. Default: 'filenames'. + nargs : int, optional + number of input files allowed. Default: -1. + + Returns + ------- + decorator + input argument decorator. + """ + def inputs_argument(f): - """Option for input files.""" + """Option for input files. + + Options + ------- + + name : str or array-like + input files. + + Returns + ------- + + decorator + input argument decorator. + """ + f = click.argument(name, type=click.Path(exists=True, file_okay=True, dir_okay=False), @@ -143,7 +282,22 @@ def inputs_argument(f): return inputs_argument def interpolate_options(f): - """Options for interpolation.""" + """Options for interpolation. + + Options + ------- + + --interpolate, -i : int, optional + number of points to interpolate. Default: 200. + --kind : str, optional + interpolation kind. Default: linear. + + Returns + ------- + + decorator + interpolation options decorator. + """ f = click.option('-i', '--interpolate', help='Number of points to interpolate to on each axis.', @@ -158,7 +312,24 @@ def interpolate_options(f): return f def kpoints_options(f): - """Group of options for handling KPOINTS files.""" + """Group of options for handling KPOINTS files. + + Options + ------- + + --kpoints, -k, --ibzkbt, -i : str, optional + KPOINTS/IBZKPT file. Overrides --mesh. + --mesh, -m : 3x int, optional + k-point mesh. Overridden by --kpoints. + --poscar, -p : str, optional + POSCAR. Required for --mesh. + + Returns + ------- + + decorator + kpoints options decorator. + """ f = click.option('-k', '--kpoints', '-i', '--ibzkpt', help='KPOINTS/IBZKPT file. Overrides --mesh.', @@ -169,7 +340,7 @@ def kpoints_options(f): nargs=3, type=int)(f) f = click.option('-p', '--poscar', - help='POSCAR path.', + help='POSCAR path. Required for --mesh.', type=click.Path(file_okay=True, dir_okay=False), default='POSCAR', show_default=True)(f) @@ -177,8 +348,43 @@ def kpoints_options(f): return f def legend_function(toggle=True, label=True): + """Function for creating legend options. + + Arguments + --------- + + toggle : bool, optional + include option to remove legend. Default: True. + label : bool, optional + include option to set labels manually. Default: True. + + Returns + ------- + decorator + legend options decorator. + """ + def legend_options(f): - """Group of options for plot legends.""" + """Group of options for plot legends. + + Options + ------- + + --label, -l : str, optional + legend label(s). + --legend_title : str, optional + legend title. + --legend/--nolegend : bool, optional + show legend. Default: --legend. + --location : str or int, optional + legend location. + + Returns + ------- + + decorator + legend options decorator. + """ if label: f = click.option('-l', '--label', @@ -203,7 +409,22 @@ def legend_options(f): return legend_options def line_options(f): - """Group of options for line plots""" + """Group of options for line plots + + Options + ------- + + --linestyle : str, optional + linestyle(s). Default: solid. + --marker : str, optional + marker(s). Default: None. + + Returns + ------- + + decorator + line options decorator. + """ f = click.option('--linestyle', help='linestyle(s).', @@ -220,7 +441,25 @@ def line_options(f): return f def fill_options(f): - """Group of options for fillable line plots""" + """Group of options for fillable line plots + + Options + ------- + + --fill, -f/--nofill : bool, optional + fill under line. Default: --fill. + --fillalpha : str, optional + fill opacity (0-1). Only works for #RRGGBB colours. + Default: 0.2. + --line/--noline : bool, optional + show line. Default: --line. + + Returns + ------- + + decorator + fill options decorator. + """ f = click.option('-f', '--fill/--nofill', help='Fill under line. [default: fill]', @@ -240,8 +479,46 @@ def fill_options(f): return f def plot_io_function(name): + """Function for creating plot I/O options. + + Arguments + --------- + + name : str + output filename. + + Returns + ------- + decorator + plot I/O options decorator. + """ + def plot_io_options(f): - """Group of options for plot file I/O.""" + """Group of options for plot file I/O. + + Options + ------- + + --style, -s : str, optional + style sheet to overlay. Later ones override earlier + ones. + --large/--small : str, optional + axes size. Default: small. + --save/--nosave : bool, optional + write to file. Default: --save. + --show/--noshow : bool, optional + show plot. Default: --noshow. + --extension : str, optional + output extensions(s). Default: pdf. + --output : str, optional. + output filenames, sans extension. + + Returns + ------- + + decorator + plot I/O options decorator. + """ f = click.option('-s', '--style', help='Style sheet to overlay. Later ones override ' @@ -277,7 +554,20 @@ def plot_io_options(f): return plot_io_options def temperature_option(f): - """Option for temperature selection.""" + """Option for temperature selection. + + Options + ------- + + --temperature, -t : str, optional + temperature. Default: 300. + + Returns + ------- + + decorator + temperature option decorator. + """ f = click.option('-t', '--temperature', help='Temperature (by default in K).', @@ -288,7 +578,20 @@ def temperature_option(f): return f def verbose_option(f): - """Option for verbose output.""" + """Option for output verbosity. + + Options + ------- + + --verbose/--notverbose : bool, optional + output plot conditions. Default: --verbose. + + Returns + ------- + + decorator + verbosity option decorator. + """ f = click.option('--verbose/--notverbose', help='Output plot conditions. [default: verbose]', @@ -298,8 +601,47 @@ def verbose_option(f): return f def axes_limit_function(multiple=False, c=False): + """Function for creating axes limit options. + + Arguments + --------- + + multiple : bool, optional + allow multiple limits. Default: False. + c : bool, optional + include colour limits. Default: False. + + Returns + ------- + decorator + axes limit options decorator. + """ + def axes_limit_options(f): - """Options for axes limits.""" + """Options for axes limits. + + Options + ------- + + --xmin : float, optional + override minimum x. + --xmax : float, optional + override maximum x. + --ymin : float, optional + override minimum y. + --ymax : float, optional + override maximum y. + --cmin : float, optional + override minimum colour. + --cmax : float, optional + override maximum colour. + + Returns + ------- + + decorator + axes limits options decorator. + """ f = click.option('--xmin', help='Override minimum x.', diff --git a/tp/data/README.rst b/tp/data/README.rst index 543a620..dd01be8 100644 --- a/tp/data/README.rst +++ b/tp/data/README.rst @@ -54,7 +54,7 @@ units. .. _AMSET: .. _Phono3py: .. _Phonopy: -.. _sumo: +.. _sumo: ---------- ``run.py`` diff --git a/tp/plot/README.rst b/tp/plot/README.rst index 1e0742f..99e24fc 100644 --- a/tp/plot/README.rst +++ b/tp/plot/README.rst @@ -1,6 +1,6 @@ Please see the `examples`_. -.. _examples: https://github.com/smtg-ucl/ThermoParser/tree/master/examples +.. _examples: https://github.com/smtg-bham/ThermoParser/tree/master/examples All plotting functions can read in defaults from ``~/.config/tprc.yaml`` to enable consistent customisation. A template ``tprc.yaml`` is