diff --git a/examples/01-python-foundations/README.rst b/examples/01-python-foundations/README.rst index 9c41184..8679ae5 100644 --- a/examples/01-python-foundations/README.rst +++ b/examples/01-python-foundations/README.rst @@ -34,7 +34,7 @@ Every function returns three things: 2. axes: Where the data goes, used in step 3. 3. add_legend: Adds a legend. We don't use it here, so we've thrown it away by assigning it to ``_``. Giving it any name and not using it - has the same effect. Legends will be discussed in example 03. + has the same effect. Legends will be discussed in ``03-compound-axes``. This command can easily be replaced with ``matplotlib.pyplot`` commands such as ``figure`` and ``subfigs``. @@ -50,7 +50,7 @@ file to read from, and return a dictionary of the data. While you can load your own data, ThermoPlotter takes several steps to ensure consistent format and units between codes and also with some old versions of these codes; and with the plotting functions. It also -consistently applies cutom unit conversions and provides metadata +consistently applies custom unit conversions and provides metadata including array shapes, units and data sources, so care should be taken if this step is done manually. @@ -66,7 +66,7 @@ customisation option, including all the ``kwargs`` from the underlying This stage can be replaced with ordinary ``matplotlib`` functions such as ``ax.plot``, which can be assisted by a number of ancillary -ThermoPlotter functions discussed later. +ThermoPlotter functions discussed in ``05-helper-functions``. ---- Save diff --git a/examples/02-individual-customisation/README.rst b/examples/02-individual-customisation/README.rst index 58914f1..392cbdf 100644 --- a/examples/02-individual-customisation/README.rst +++ b/examples/02-individual-customisation/README.rst @@ -1,7 +1,7 @@ .. image:: wideband.png :alt: Finite bandwidth phonon dispersion of ZnO. -In most cases, plotting scripts will be more complex than example 01. +In most cases, plotting scripts will be more complex than ``01-python-foundations``. Many functions require more inputs, and most users will want to customise plots with colours and stuff. diff --git a/examples/03-compound-axes/README.rst b/examples/03-compound-axes/README.rst index d0c1ebc..84f1762 100644 --- a/examples/03-compound-axes/README.rst +++ b/examples/03-compound-axes/README.rst @@ -55,4 +55,4 @@ into one legend, with duplicates removed, which uses up the ``handles`` and ``labels`` arguments, so in order to specify your own, you must set ``custom=True`` (not necessary for single-axes figures). ``tp.axes.legend.consolidate`` may also be useful for non-ThermoPlotter -endaevors, as will be discussed in example 05 +endaevors, as will be discussed in ``05-helper-functions``. diff --git a/examples/04-layered-plots/README.rst b/examples/04-layered-plots/README.rst index 048aa47..a0a4839 100644 --- a/examples/04-layered-plots/README.rst +++ b/examples/04-layered-plots/README.rst @@ -15,7 +15,7 @@ Axes Here we use ``two_h``. h stands for horizontal, and there is a corresponding vertical set of axes, ``two_v``. They also come with -colourbars, by adding ``_colourbars`` to their names. +space for colourbars, by adding ``_colourbars`` to their names. ---- Load @@ -61,4 +61,4 @@ reversed with some helper functions: ``set_locators`` sets the axis scales and tick locators for each axis, and also has a DoS argument, 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 example 05. +be covered more in ``05-helper-functions``. diff --git a/examples/05-helper-functions/README.rst b/examples/05-helper-functions/README.rst index f2b567e..c4625b1 100644 --- a/examples/05-helper-functions/README.rst +++ b/examples/05-helper-functions/README.rst @@ -52,9 +52,10 @@ Locators, Ticks and Labels There are several functions to aid in formatting axes. ``tp.settings.labels``, and its variations ``large_``, ``long_``, ``medium_`` and ``short_labels`` return a dictionary of axes labels -(more on these in example 06). ``tp.plot.utilities.set_locators`` sets -the locators, if you provide a set of axes and set ``x`` and ``y`` to -either ``'linear'`` or ``'log'`` as appropriate. +(more on these in ``06-package-customisation``). +``tp.plot.utilities.set_locators`` sets the locators, if you provide a +set of axes and set ``x`` and ``y`` to either ``'linear'`` or ``'log'`` +as appropriate. ------- Legends diff --git a/examples/05-helper-functions/plot-transport.py b/examples/05-helper-functions/plot-transport.py index f0561f3..5bc5d84 100644 --- a/examples/05-helper-functions/plot-transport.py +++ b/examples/05-helper-functions/plot-transport.py @@ -54,4 +54,4 @@ tp.axes.legend.alphabetise(ax, preset='roman', suffix=')', x=-0.12) # Save -fig.savefig('transport.pdf') +fig.savefig('transport.png') diff --git a/examples/05-helper-functions/transport.pdf b/examples/05-helper-functions/transport.pdf deleted file mode 100644 index 97e2c1c..0000000 Binary files a/examples/05-helper-functions/transport.pdf and /dev/null differ diff --git a/examples/05-helper-functions/transport.png b/examples/05-helper-functions/transport.png new file mode 100644 index 0000000..05a7e26 Binary files /dev/null and b/examples/05-helper-functions/transport.png differ diff --git a/examples/06-package-customisation/README.rst b/examples/06-package-customisation/README.rst index 6131c66..a15623c 100644 --- a/examples/06-package-customisation/README.rst +++ b/examples/06-package-customisation/README.rst @@ -29,17 +29,18 @@ dictionaries like the locators. The aliases are listed as: alias: xxx_name If you add unit conversions, remember to update the units and labels -too! 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 those you' would liek to default to for small, inverted and large -axes, respectively. For example, if you prefer to put a inverted DoSs -in a separate axes rather than a DoS axes, you may want to set -``inverted_labels: long``. Finally, there are the default ``kwargs`` -for each function, which are passed to the matplotlib plotting -function, such as ``plt.plot``. These override defaults set in the -ThermoPlotter plotting function, but are overridden by arguments -specified by the user. +too! An example has been provided for converting from +S m-1 to S cm-1. 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 those you would like to default +to for small, inverted and large axes, respectively. For example, if +you prefer to put a inverted DoSs in a separate axes rather than a DoS +axes, you may want to set ``inverted_labels: long``. Finally, there are +the default ``kwargs`` for each function, which are passed to the +matplotlib plotting function, such as ``plt.plot``. These override +defaults set in the ThermoPlotter plotting function, but are overridden +by arguments specified by the user. ----------------------- Extending ThermoPlotter diff --git a/examples/06-package-customisation/tprc.yaml b/examples/06-package-customisation/tprc.yaml new file mode 100644 index 0000000..70d4622 --- /dev/null +++ b/examples/06-package-customisation/tprc.yaml @@ -0,0 +1,77 @@ +# This is a counterpart to the ThermoPlotter/tp/settings.py module for +# saving cutom values. If you want to edit ThermoPlotter, save a copy of +# this file as ``~/.config/tprc.yaml``, and edit it there. Only that +# file will be checked and any changes made in the ThermoPlotter +# directory will be overwritten on upgrading. + +# style sheet names or lists of names +style: null # default style sheet +large_style: null # large style sheet + +# Locator settings +locator: + # Unlike other parts of this file, rather than whole arguments, this + # should give integers to pass to MaxNLocator and AutoMinorLocator, + # respectively. + major: null + minor: null + +# The to_xxx, conversions, units and long_, medium_ and short_labels +# functions should contain dictionaries, e.g. +# to_xxx: +# energies: 'energy' +# and if you change a conversion, remember to change the units and +# labels as well and vice versa! + +# aliases for quantities +to_tp: null +to_amset: null +to_boltztrap: null +to_phono3py: null + +# unit conversions from the tp standards (see settings.py for reference) +conversions: + conductivity: 1.e-2 + +# updated units +units: + conductivity: 'S cm-1' + +# updated axis labels` +long_labels: + conductivity: 'Conductivity (S cm$\mathregular{^{-1}}$)' +medium_labels: + conductivity: 'Conductivity (S cm$\mathregular{^{-1}}$)' +short_labels: + conductivity: '$\mathregular{\sigma\ (S\ cm^{-1}}$)' + +# The following should contain either long, medium or short, to point to +# the dictionaries of long_, medium_ or short_labels. +labels: null # for paper-style (small) axes +inverted_labels: null # for dos-style axes +large_labels: null # for presentation-style (large) axes + +# The following are default kwargs for each plot type. These will +# override those specified in the module, but will be overridden by +# those specified when the function is called. +# Frequency: +dos_kwargs: null +frequency_cum_kappa_kwargs: null +waterfall_kwargs: null +projected_waterfall_kwargs: null +density_kwargs: null +# Heatmap: +heatmap_kwargs: null +ztmap_kwargs: null +kappa_target_kwargs: null +# MFP: +mfp_cum_kappa_kwargs: null +marker_kwargs: null +# Phonons: +dispersion_kwargs: null +multi_kwargs: null +alt_dispersion_kwargs: null +projected_dispersion_kwargs: null +alt_projected_dispersion_kwargs: null +wideband_kwargs: null +xmarkkwargs: null diff --git a/examples/cumkappa/README.rst b/examples/cumkappa/README.rst index 62b14e1..4b5ce37 100644 --- a/examples/cumkappa/README.rst +++ b/examples/cumkappa/README.rst @@ -11,7 +11,7 @@ to add markers has been included, e.g. here you can see nanostructuring to 10 nanometers may reduce the lattice thermal conductivity by nearly 50 %. -This also demonstrates use of the add_legend function supplied with +This also demonstrates use of the ``add_legend`` function supplied with ``tp.axes`` functions, which combines the legends of all plots and places itself in one of several pre-programmed position, which you can select with the ``location`` argument. Numbers will place the legend diff --git a/examples/kappa-target/README.rst b/examples/kappa-target/README.rst index 3f15a0d..6b1f0d1 100644 --- a/examples/kappa-target/README.rst +++ b/examples/kappa-target/README.rst @@ -11,7 +11,7 @@ This is also available as a command-line script, ``tp plot kappa-target``. This also demonstrates the ``tp.plot.heatmap.add_heatmap`` function which ``add_ztmap`` wraps around, which enhances pcolourmesh in ways such as automatic rescaling of axes to represent all data, automatic -extension of colourbars if applicable and custom colourmaps These +extension of colourbars if applicable and custom colourmaps. These colourmaps are generated dynamically with the input of a single ``#RRGGBB`` colour code. In this case, the ``tp.plot.colour.uniform`` colourmap generator has been used, which calculates a uniform colourmap diff --git a/examples/phonons/README.rst b/examples/phonons/README.rst index e9a3f47..ddf0091 100644 --- a/examples/phonons/README.rst +++ b/examples/phonons/README.rst @@ -5,8 +5,8 @@ This shows a phonon dispersion and density of states (DoS). All plot- types in ``tp.plot.frequency`` have an invert argument to plot them side-on by a phonon dispersion, which also shortens their x-axis labels and removes their y-axis labels and tick labels. Currently the axes of -the two plots have to be aligned manually, but this is simple (see -script). +the two plots have to be aligned manually, but this is simple +(``plot-phonons.py`` line 24). .. image:: multiphon.png :alt: Phonon dispersions for different supercell sizes. diff --git a/tp/calculate.py b/tp/calculate.py index 6e0593c..2331899 100644 --- a/tp/calculate.py +++ b/tp/calculate.py @@ -554,7 +554,7 @@ def to_tp(name, value): conversions = tp.settings.conversions() if name in conversions and conversions[name] is not None: - value = np.divide(value, conversions[name]) + value = np.divide(value, float(conversions[name])) return value @@ -578,7 +578,7 @@ def from_tp(name, value): conversions = tp.settings.conversions() if name in conversions and conversions[name] is not None: - value = np.multiply(value, conversions[name]) + value = np.multiply(value, float(conversions[name])) return value diff --git a/tp/data/load.py b/tp/data/load.py index 5cf3332..612de6f 100644 --- a/tp/data/load.py +++ b/tp/data/load.py @@ -151,7 +151,7 @@ def amset(filename, quantities=['seebeck', 'conductivity', for c in aconversions: if c in data2: - data2[c] = np.multiply(data2[c], aconversions[c]) + data2[c] = np.multiply(data2[c], float(aconversions[c])) if 'power_factor' in quantities: data2 = tp.calculate.power_factor_fromdict(data2) @@ -360,11 +360,11 @@ def resolve_spin(data, q, spin): for c in aconversions: if c in data: - data[c] = np.multiply(data[c], aconversions[c]) + data[c] = np.multiply(data[c], float(aconversions[c])) for c in conversions: if c in data: - data[c] = np.multiply(data[c], conversions[c]) + data[c] = np.multiply(data[c], float(conversions[c])) return data @@ -445,11 +445,11 @@ def boltztrap(filename, quantities=['temperature', 'doping', 'seebeck', for c in bconversions: if c in data: - data[c] = np.multiply(data[c], bconversions[c]) + data[c] = np.multiply(data[c], float(bconversions[c])) for c in conversions: if c in data: - data[c] = np.multiply(data[c], conversions[c]) + data[c] = np.multiply(data[c], float(conversions[c])) return data @@ -581,7 +581,7 @@ def phono3py(filename, quantities=['kappa', 'temperature']): for c in pconversions: if c in data: - data[c] = np.multiply(data[c], pconversions[c]) + data[c] = np.multiply(data[c], float(pconversions[c])) if 'lifetime' in quantities or 'mean_free_path' in quantities: data['lifetime'] = tp.calculate.lifetime(data['gamma'], use_tprc=False) @@ -596,7 +596,7 @@ def phono3py(filename, quantities=['kappa', 'temperature']): for c in conversions: if c in data: - data[c] = np.multiply(data[c], conversions[c]) + data[c] = np.multiply(data[c], float(conversions[c])) return data @@ -666,11 +666,11 @@ def phonopy_dispersion(filename, xdata=None): for c in pconversions: if c in data2: - data2[c] = np.multiply(data2[c], pconversions[c]) + data2[c] = np.multiply(data2[c], float(pconversions[c])) for c in conversions: if c in data2: - data2[c] = np.multiply(data2[c], conversions[c]) + data2[c] = np.multiply(data2[c], float(conversions[c])) return data2 @@ -748,11 +748,11 @@ def phonopy_dos(filename, poscar='POSCAR', atoms=None): for c in pconversions: if c in data2: - data2[c] = np.multiply(data2[c], pconversions[c]) + data2[c] = np.multiply(data2[c], float(pconversions[c])) for c in conversions: if c in data2: - data2[c] = np.multiply(data2[c], conversions[c]) + data2[c] = np.multiply(data2[c], float(conversions[c])) return data2