Skip to content

Commit

Permalink
Merge branch 'package_prep'
Browse files Browse the repository at this point in the history
  • Loading branch information
merrygoat committed Dec 23, 2019
2 parents 8d66757 + 2611003 commit 342638d
Show file tree
Hide file tree
Showing 26 changed files with 439 additions and 164 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,5 @@ __pycache__/
/example_data/adc_041_7Nb
/tutorial notebooks/working_copy.ipynb
/tutorial notebooks/experiment.dump

/docs/html
13 changes: 13 additions & 0 deletions README.md
@@ -0,0 +1,13 @@
Installation
-------------

To install as a Python module, type

`python -m pip install .`

from the root directory.
For developers, you should install in linked .egg mode using

`python -m pip install . develop`

If you are using a Python virtual environment, you should activate this first before using the above commands.
20 changes: 20 additions & 0 deletions docs/Makefile
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
26 changes: 26 additions & 0 deletions docs/README.md
@@ -0,0 +1,26 @@
Docs README
-------------

The documentation for xrdfit is generated using the Sphinx Python package and built and hosted at Read The Docs.

Documentation is written in reStructuredText format and compiled by the Sphinx package into a HTML source. At compilation time Sphinx also scrapes docstrings from the Python scripts and adds these to the documentation.


Requrements to compile documentation
======================================

Install: Sphinx (http://www.sphinx-doc.org/en/master/) - (conda install sphinx/pip install sphinx)


Compiling documentation
=========================

To recompile the documentation after a change, from the docs folder use the commands::

sphinx-build -b html ./source ./html

If the structure of the Python scripts is significantly changed, api-doc can autogenerate the API documentation with the command::

sphinx-apidoc -o ./source ../xrdfit

The HTML output should not be committed to the repository, this is just a local preview version. Each time the repository is pushed to GitHub the docs are rebuilt from source at: https://xrdfit.readthedocs.io/en/latest/
1 change: 1 addition & 0 deletions docs/index.html
@@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; url=./html/index.html" />
69 changes: 69 additions & 0 deletions docs/source/conf.py
@@ -0,0 +1,69 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'xrdfit'
copyright = '2019, Peter Crowther'
author = 'Peter Crowther'

# The full version, including alpha/beta/rc tags
release = '0.1'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# The master toctree document.
master_doc = 'index'

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {"body_max_width": "100%"}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
20 changes: 20 additions & 0 deletions docs/source/index.rst
@@ -0,0 +1,20 @@
.. xrdfit documentation master file, created by
sphinx-quickstart on Mon Dec 16 15:47:29 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to xrdfit's documentation!
==================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions docs/source/modules.rst
@@ -0,0 +1,7 @@
xrdfit
======

.. toctree::
:maxdepth: 4

xrdfit
46 changes: 46 additions & 0 deletions docs/source/xrdfit.rst
@@ -0,0 +1,46 @@
xrdfit package
==============

Submodules
----------

xrdfit.fit\_analysis module
---------------------------

.. automodule:: xrdfit.fit_analysis
:members:
:undoc-members:
:show-inheritance:

xrdfit.plotting module
----------------------

.. automodule:: xrdfit.plotting
:members:
:undoc-members:
:show-inheritance:

xrdfit.pv\_fit module
---------------------

.. automodule:: xrdfit.pv_fit
:members:
:undoc-members:
:show-inheritance:

xrdfit.spectrum\_fitting module
-------------------------------

.. automodule:: xrdfit.spectrum_fitting
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: xrdfit
:members:
:undoc-members:
:show-inheritance:
12 changes: 12 additions & 0 deletions paper/paper.bib
@@ -0,0 +1,12 @@
% Encoding: UTF-8
@Misc{Newville2014,
author = {Newville, Matthew and Stensitzki, Till and Allen, Daniel B. and Ingargiola, Antonino},
title = {LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python},
year = {2014},
doi = {10.5281/ZENODO.11813},
keywords = {python, non-linear least-squares optimization, curve-fitting},
publisher = {Zenodo},
}

@Comment{jabref-meta: databaseType:bibtex;}
45 changes: 45 additions & 0 deletions paper/paper.md
@@ -0,0 +1,45 @@
---
title: 'xrdfit: A Python package for fitting SXRD diffraction spectra'
tags:
- Python
- physics
- crystallography
- material structure
authors:
- name: Peter Crowther
orcid: 0000-0002-5430-6924
affiliation: 1
- name: Christopher Daniel
orcid: 0000-0002-5574-6833
affiliation: 1
affiliations:
- name: Univeristy of Manchester
index: 1
date: 16 December 2019
bibliography: paper.bib

---

# Summary

100 words on xrd and material structure

``xrdfit`` is an Python package for fitting the peaks found in shallow x-ray
diffraction spectra. It is designed to be an easy to use tool for quick analysis of
spectra. Features are included for automating fitting over many spectra to enable
tracking of peaks as they shift through the experiment. Some basic Materials anlysis
algorithms are added which allow converstion of the peak positions to material properties
like strain. ``xrdfit`` uses the Python package ``lmfit`` for the underlying fitting [@Newville2014].

``xrdfit`` is designed to be used by experimental researchers who need to
process SXRD spectra but do not have a detailed knowledge of programming or
fitting. It has been used for the analysis of data presented in [insert paper here].
We hope that its public release will allow other researchers to benefit from
fast data fitting, reducing the effort required to do basic analysis of their
experimental data.

# Acknowledgements

We acknowledge funding from

# References
10 changes: 10 additions & 0 deletions readthedocs.yaml
@@ -0,0 +1,10 @@
# This file provides configuration for building the documentation at: https://xrdfit.readthedocs.io/en/latest/index.html

version: 2

python:
version: 3.6
install:
- requirements: requirements.txt
- method: setuptools
path: .
7 changes: 7 additions & 0 deletions requirements.txt
@@ -0,0 +1,7 @@
numpy
matplotlib
pandas
dill
tqdm
scipy
lmfit
18 changes: 18 additions & 0 deletions setup.py
@@ -0,0 +1,18 @@
from setuptools import setup, find_packages

setup(
name='xrdfit',
version='0.1',
description='Automated fitting of XRD peaks using Pseudo-Voight fits',
author='Peter Crowther',
packages=find_packages(),
install_requires=['numpy',
'matplotlib',
'pandas',
'dill',
'tqdm',
'scipy',
'lmfit'
],
extras_require={"documentation_compilation": "sphinx"}
)
14 changes: 5 additions & 9 deletions tests/Tests.ipynb
Expand Up @@ -26,13 +26,9 @@
"\n",
"%autoreload 2\n",
"\n",
"import sys\n",
"sys.path.append('./..')\n",
"\n",
"from glob import glob\n",
"\n",
"import spectrum_fitting\n",
"from spectrum_fitting import PeakParams"
"from xrdfit.spectrum_fitting import PeakParams, FitSpectrum"
]
},
{
Expand Down Expand Up @@ -68,7 +64,7 @@
"outputs": [],
"source": [
"for file_path in test_files:\n",
" spectral_data = spectrum_fitting.FitSpectrum(file_path, 90, verbose=False)\n",
" spectral_data = FitSpectrum(file_path, 90, verbose=False)\n",
" spectral_data.plot(1, show_points=True)"
]
},
Expand All @@ -86,7 +82,7 @@
"outputs": [],
"source": [
"for file_path in test_files:\n",
" spectral_data = spectrum_fitting.FitSpectrum(file_path, 90, verbose=False)\n",
" spectral_data = FitSpectrum(file_path, 90, verbose=False)\n",
" peak_params = spectral_data.detect_peaks(1)\n",
" spectral_data.plot_peak_params(peak_params, 1, show_points=True)"
]
Expand All @@ -105,7 +101,7 @@
"outputs": [],
"source": [
"for file_path in test_files:\n",
" spectral_data = spectrum_fitting.FitSpectrum(file_path, 90, verbose=False)\n",
" spectral_data = FitSpectrum(file_path, 90, verbose=False)\n",
" peak_params = spectral_data.detect_peaks(1)\n",
" spectral_data.fit_peaks(peak_params, 1)\n",
"\n",
Expand All @@ -128,7 +124,7 @@
"metadata": {},
"outputs": [],
"source": [
"spectral_data = spectrum_fitting.FitSpectrum(\"../tests/full_spectrum.txt\", 90, verbose=False)\n",
"spectral_data = FitSpectrum(\"../tests/full_spectrum.txt\", 90, verbose=False)\n",
"peak_params = spectral_data.detect_peaks(1)\n",
"spectral_data.plot_peak_params(peak_params, 1, show_points=True)\n",
"spectral_data.fit_peaks(peak_params, 1)\n",
Expand Down

0 comments on commit 342638d

Please sign in to comment.