Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring up-to-date #74

Merged
merged 8 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
|____________________________________:_______________________/____________:_____/


.. image:: https://travis-ci.com/smtg-bham/ThermoParser.svg?branch=master
.. image:: https://app.travis-ci.com/SMTG-bham/ThermoParser.svg?branch=master
:alt: The travis-ci badge
:target: https://travis-ci.com/smtg-bham/ThermoParser
:target: https://app.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
Expand All @@ -46,7 +46,7 @@ ThermoParser can easily be installed with git and pip:

.. code-block:: bash

git clone https://github.com/smtg-bham/ThermoParser.git
git clone https://github.com/SMTG-bham/ThermoParser.git
cd ThermoParser
pip install .

Expand All @@ -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-bham/ThermoParser.git``
5. ``git clone https://github.com/SMTG-bham/ThermoParser.git``
6. ``cd ThermoParser``
7. ``pip install --user -e .``

Expand Down
6 changes: 5 additions & 1 deletion examples/heatmaps/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ using an axes template with multiple sets of axes, the ``custom``
argument must be used in ``add_legend`` to enable manual manipulation
of the handles and labels. ``add_ztdiff`` and its power factor
equivalent, ``add_pfdiff``, also make sure the colour scale is centred
on zero (i.e. where both are equal).
on zero (i.e. where both are equal).

Some users may find adding contours with the ``contours`` argument or making
the colour scale discrete with the ``discrete`` argument more legible or
informative.
63 changes: 40 additions & 23 deletions tp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,16 +956,17 @@ def avg_rates(mesh_h5, mfp, total, x, crt, exclude, doping, direction,
elif ymax is not None:
ax.set_ylim(top=ymax)

if ymin is not None:
if ymax is not None:
for a in ax:
a.set_ylim(ymin, ymax)
else:
else:
if ymin is not None:
if ymax is not None:
for a in ax:
a.set_ylim(ymin, ymax)
else:
for a in ax:
a.set_ylim(bottom=ymin)
elif ymax is not None:
for a in ax:
a.set_ylim(bottom=ymin)
elif ymax is not None:
for a in ax:
a.set_ylim(top=ymax)
a.set_ylim(top=ymax)

if save:
for ext in extension:
Expand Down Expand Up @@ -1434,12 +1435,14 @@ def kappa(kfile, efile, component, direction, tmin, tmax, dtype, doping,
help='Colour for values below --cmin.',
default='grey',
show_default=True)
@heatmap_options

@axes_limit_function(c=True)
@plot_io_function('tp-kappa-target')

def kappa_target(transport_file, zt, direction, interpolate, kind, colour,
negativecolour, xmin, xmax, ymin, ymax, cmin, cmax, style,
negativecolour, discrete, levels, contours, contourcolours,
xmin, xmax, ymin, ymax, cmin, cmax, style,
large, save, show, extension, output):
"""Plots lattice thermal conductivity to reach a target ZT.

Expand All @@ -1466,6 +1469,9 @@ def kappa_target(transport_file, zt, direction, interpolate, kind, colour,
xinterp=interpolate,
yinterp=interpolate,
kind=kind, colour=colour,
discrete=discrete, levels=levels,
contours=contours,
contourcolours=contourcolours,
negativecolour=negativecolour,
xmin=xmin, xmax=xmax, ymin=ymin,
ymax=ymax, cmin=cmin, cmax=cmax)
Expand Down Expand Up @@ -2219,11 +2225,13 @@ def wideband(band_yaml, kappa_hdf5, temperature, poscar, colour, smoothing, styl
multiple=True,
default=['viridis'],
show_default=True)
@heatmap_options

@axes_limit_function(c=True)
@plot_io_function('tp-ztmap')

def ztmap(transport_file, pf, kappa, direction, dtype, interpolate, kind, colour,
def ztmap(transport_file, pf, kappa, direction, dtype, interpolate, kind,
colour, discrete, levels, contours, contourcolours,
xmin, xmax, ymin, ymax, cmin, cmax, style, large, save, show,
extension, output):
"""Plots ZT or PF against temperature and carrier concentration."""
Expand All @@ -2242,7 +2250,9 @@ def ztmap(transport_file, pf, kappa, direction, dtype, interpolate, kind, colour
if pf:
tp.plot.heatmap.add_pfmap(ax, edata, direction=direction,
xinterp=interpolate, yinterp=interpolate,
kind=kind, colour=colour, xmin=xmin,
kind=kind, colour=colour, discrete=discrete,
levels=levels, contours=contours,
contourcolours=contourcolours, xmin=xmin,
xmax=xmax, ymin=ymin, ymax=ymax, cmin=cmin,
cmax=cmax)
else:
Expand All @@ -2253,7 +2263,9 @@ def ztmap(transport_file, pf, kappa, direction, dtype, interpolate, kind, colour

tp.plot.heatmap.add_ztmap(ax, edata, kdata=kdata, direction=direction,
xinterp=interpolate, yinterp=interpolate,
kind=kind, colour=colour, xmin=xmin,
kind=kind, colour=colour, discrete=discrete,
levels=levels, contours=contours,
contourcolours=contourcolours, xmin=xmin,
xmax=xmax, ymin=ymin, ymax=ymax, cmin=cmin,
cmax=cmax)

Expand Down Expand Up @@ -2292,15 +2304,16 @@ def ztmap(transport_file, pf, kappa, direction, dtype, interpolate, kind, colour
'colour recognised by matplotlib.',
default='white',
show_default=True)
@heatmap_options

@axes_limit_function(c=True)
@legend_function()
@plot_io_function('tp-ztdiff')

def ztdiff(transport_files, pf, kappa, direction, dtype, interpolate, kind,
colour, midcolour, xmin, xmax, ymin, ymax, cmin, cmax, legend,
label, legend_title, location, style, large, save, show, extension,
output):
colour, midcolour, discrete, levels, contours, contourcolours,
xmin, xmax, ymin, ymax, cmin, cmax, legend, label, legend_title,
location, style, large, save, show, extension, output):
"""Plots ZT or PF difference against temperature and carrier concentration.

Requires two input datasets. --kappa and --colour take exactly two values
Expand Down Expand Up @@ -2328,7 +2341,9 @@ def ztdiff(transport_files, pf, kappa, direction, dtype, interpolate, kind,
_, h, l = tp.plot.heatmap.add_pfdiff(ax, *edata, direction=direction,
xinterp=interpolate, yinterp=interpolate, kind=kind,
colour1=colour[0], colour2=colour[1], midcolour=midcolour,
label1=label[0], label2=label[1], xmin=xmin, xmax=xmax,
label1=label[0], label2=label[1], discrete=discrete,
levels=levels, contours=contours,
contourcolours=contourcolours, xmin=xmin, xmax=xmax,
ymin=ymin, ymax=ymax, cmin=cmin, cmax=cmax)
else:
kdata = []
Expand All @@ -2343,12 +2358,14 @@ def ztdiff(transport_files, pf, kappa, direction, dtype, interpolate, kind,
except OSError:
raise Exception(
"--kappa must be valid filepaths or floats.")
_, h, l = tp.plot.heatmap.add_ztdiff(ax, edata[0], edata[1], kdata1=kdata[0],
kdata2=kdata[1], direction=direction, xinterp=interpolate,
yinterp=interpolate, kind=kind, colour1=colour[0],
colour2=colour[1], midcolour=midcolour, label1=label[0],
label2=label[1], xmin=xmin, xmax=xmax, ymin=ymin,
ymax=ymax, cmin=cmin, cmax=cmax)
_, h, l = tp.plot.heatmap.add_ztdiff(ax, edata[0], edata[1],
kdata1=kdata[0], kdata2=kdata[1], direction=direction,
xinterp=interpolate, yinterp=interpolate, kind=kind,
colour1=colour[0], colour2=colour[1], midcolour=midcolour,
label1=label[0], label2=label[1], discrete=discrete,
levels=levels, contours=contours,
contourcolours=contourcolours, xmin=xmin, xmax=xmax,
ymin=ymin, ymax=ymax, cmin=cmin, cmax=cmax)

if legend and label != [None, None]:
if location is None:
Expand Down
25 changes: 25 additions & 0 deletions tp/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ def doping_option(f):
return f
return doping_option

def heatmap_options(f):
"""Options for heatmaps."""

f = click.option('--discrete/--continuous',
help='Discretise colourmap. [default: continuous]',
default=False,
show_default=False)(f)
f = click.option('-l', '--levels',
help='Levels for discrete plots. Lists directly '
'specify the contour levels, while integers '
'specify the maximum-1 number of "nice" '
'levels to plot.',
multiple=True,
default=None)(f)
f = click.option('--contours',
help='Contours to plot.',
multiple=True,
type=float,
default=None)(f)
f = click.option('--contourcolours',
help='contour colours',
multiple=True,
default='black')(f)
return f

def dos_function(dosargs=['-c', '--colour']):
"""Function for creating DoS options.

Expand Down
Loading