diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0a9f4a2..720b92f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,8 +7,11 @@ Versioning `__. The changelog format is inspired by `Unreleased `__ ------------------------------------------------------------------------- + - Updated setup.py to add a [vasp] extra; this handles Pymatgen installation which can be tricky on older Python versions. +- Update citation information, add to README +- Use a default base stylesheet to make more compatible PDF files `[0.6.1] `__ - 2018-11-19 ----------------------------------------------------------------------------------- diff --git a/MANIFEST.in b/MANIFEST.in index 105d526..1ae1161 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ include README.rst CHANGELOG.rst LICENSE CITATION.cff include test/test*.py -recursive-include galore/data cross_sections.json cross_sections_ups.json cross_sections_haxpes.json scofield_data.db +recursive-include galore/data cross_sections.json cross_sections_ups.json cross_sections_haxpes.json scofield_data.db galore_base.mplstyle include test/DOSCAR.1 test/test_xy_data.csv test/json_test.json recursive-include test/CaF2 ir_lda_700.txt raman_lda_500.dat recursive-include test/CdTe CdTe.gpw diff --git a/galore/__init__.py b/galore/__init__.py index affbc90..b459ccd 100644 --- a/galore/__init__.py +++ b/galore/__init__.py @@ -21,18 +21,23 @@ from __future__ import print_function -import os.path -from itertools import repeat from collections import OrderedDict +from itertools import repeat import logging - from math import sqrt, log +import os.path +from os.path import pardir +from os.path import join as path_join +from pkg_resources import resource_filename + import numpy as np from scipy.interpolate import interp1d import galore.formats from galore.cross_sections import get_cross_sections, cross_sections_info +base_style = resource_filename(__name__, + path_join('data', 'galore_base.mplstyle')) def auto_limits(data_1d, padding=0.05): """Return limiting values outside data range diff --git a/galore/cli/galore.py b/galore/cli/galore.py index 1f59c9d..f52a529 100755 --- a/galore/cli/galore.py +++ b/galore/cli/galore.py @@ -19,7 +19,7 @@ # If not, see . # # # ############################################################################### -import os + import argparse from collections import OrderedDict from json import load as json_load @@ -39,7 +39,6 @@ except ImportError: has_matplotlib = False - def main(): logging.basicConfig(filename='galore.log', level=logging.INFO) console = logging.StreamHandler() @@ -86,9 +85,13 @@ def pdos_from_files(return_plt=False, **kwargs): # For plotting and writing, "None" means "write to screen" # while False means "do nothing" if kwargs['plot'] or kwargs['plot'] is None: + import matplotlib.pyplot + style_list = [galore.base_style] + if 'style' in kwargs and kwargs['style'] is not None: - import matplotlib.pyplot - matplotlib.pyplot.style.use(kwargs['style']) + style_list += kwargs['style'] + matplotlib.pyplot.style.use(style_list) + plt = galore.plot.plot_pdos(pdos_plotting_data, **kwargs) # flipx is included in kwargs @@ -155,9 +158,12 @@ def simple_dos_from_files(return_plt=False, **kwargs): if not has_matplotlib: print("Can't plot, no Matplotlib") else: + import matplotlib.pyplot + style_list = [galore.base_style] if 'style' in kwargs and kwargs['style'] is not None: - import matplotlib.pyplot - matplotlib.pyplot.style.use(kwargs['style']) + style_list += kwargs['style'] + matplotlib.pyplot.style.use(style_list) + plt = galore.plot.plot_tdos(x_values, broadened_data, **kwargs) if kwargs['ylabel'] is not None: plt.ylabel(kwargs['ylabel']) diff --git a/galore/cli/galore_plot_cs.py b/galore/cli/galore_plot_cs.py index 4e2cca1..21ee4f3 100755 --- a/galore/cli/galore_plot_cs.py +++ b/galore/cli/galore_plot_cs.py @@ -25,7 +25,6 @@ import logging import numpy as np from matplotlib import pyplot as plt -plt.style.use('seaborn-colorblind') from galore.cross_sections import get_cross_sections_scofield @@ -67,8 +66,10 @@ def run(elements, emin=1, emax=10, megabarn=False, size=None, output=None, energies = np.linspace(emin, emax, 200) cross_sections = get_cross_sections_scofield(energies, elements) + style_list = [galore.base_style] if style is not None: - plt.style.use(style) + style_list += style + plt.style.use(style_list) if size is None: fig = plt.figure() diff --git a/galore/data/galore_base.mplstyle b/galore/data/galore_base.mplstyle new file mode 100644 index 0000000..7a4159e --- /dev/null +++ b/galore/data/galore_base.mplstyle @@ -0,0 +1 @@ +pdf.fonttype = 42 # Use truetype; makes PDF files easier to modify