Skip to content

Commit

Permalink
Merge pull request #19 from jason-neal/develop
Browse files Browse the repository at this point in the history
Update master after generation of docs.
  • Loading branch information
jason-neal committed Apr 26, 2017
2 parents 89108ab + e5d9694 commit f812550
Show file tree
Hide file tree
Showing 18 changed files with 734 additions and 212 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docs/.build/

#sync
.sync/

Expand Down
17 changes: 17 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Read the Docs Configuration File

# Build PDF aswell as HTML and JSON
formats:
- pdf

# Requirements file
requirements_file:
requirements.txt

python:
version: 3.5
setup_py_install: true
# From extras_require in setup.py
extra_requirements:
- tests
- docs
21 changes: 6 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ python:
- "2.7"
- "3.4"
- "3.5"
#- "3.5-dev" # 3.5 development branch
#- "nightly" # currently points to 3.6-dev
# command to install dependencies
- "3.6"

#install: "pip install -r requirements.txt"
# command to install dependencies
# Setup anaconda
before_install:
# http://conda.pydata.org/docs/travis.html
Expand All @@ -24,27 +22,20 @@ before_install:
- conda update -q conda
- conda info -a
install:
#- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib #nose atlas dateutil pandas statsmodels
# Coverage packages are on my binstar channel
#- conda install --yes -c dan_blanchard python-coveralls nose-cov
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy astropy
- source activate test-environment
- pip install pyastronomy
- python setup.py install


- pip install pytest-cov python-coveralls
- pip install pytest-cov python-coveralls codeclimate-test-reporter
- pip install -r requirements.txt
# install:
# - pip install numpy
# - pip install tox
# - pip install matplotlib
# - pip install hypothesis

# command to run tests
script:
# - py.test -cov coveralls --cov-report term-missing
# - py.test --cov=spectrum_overload spectrum_overload/ --cov-report term-missing
- py.test --cov=spectrum_overload --cov-report term-missing
- pytest --cov=spectrum_overload --cov-report term-missing --durations 5

after_success:
- coveralls
- codeclimate-test-reporter
77 changes: 64 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,84 @@
# spectrum_overload [![Build Status](https://travis-ci.org/jason-neal/spectrum_overload.svg)](https://travis-ci.org/jason-neal/spectrum_overload) [![Coverage Status](https://coveralls.io/repos/github/jason-neal/spectrum_overload/badge.svg?branch=develop)](https://coveralls.io/github/jason-neal/spectrum_overload?branch=develop)
Learn to use Classes by creating a Spectrum class to use in my Phd work.
# spectrum_overload
| Branch | Docs | Build | Coverage | Code Climate | Code Issues |
| :----: | :---: | :-----: | :----: | :----------: | :---------: |
| master | [![Documentation Status](https://readthedocs.org/projects/spectrum-overload/badge/?version=latest)](http://spectrum-overload.readthedocs.io/en/latest/?badge=latest) | [![Build Status](https://travis-ci.org/jason-neal/spectrum_overload.svg?branch=master)](https://travis-ci.org/jason-neal/spectrum_overload) | [![Coverage Status](https://coveralls.io/repos/github/jason-neal/spectrum_overload/badge.svg?branch=master)](https://coveralls.io/github/jason-neal/spectrum_overload?branch=master) [![Test Coverage](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/coverage.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload/coverage) | [![Code Climate](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/gpa.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload)[![Issue Count](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/issue_count.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload) | [![Code Issues](https://www.quantifiedcode.com/api/v1/project/6e918445f6f344c1af9c32f50718082e/snapshot/origin:master:HEAD/badge.svg)](https://www.quantifiedcode.com/app/project/6e918445f6f344c1af9c32f50718082e?branch=origin/master) |
| develop | [![Documentation Status](https://readthedocs.org/projects/spectrum-overload/badge/?version=develop)](http://spectrum-overload.readthedocs.io/en/latest/?badge=develop) | [![Build Status](https://travis-ci.org/jason-neal/spectrum_overload.svg?branch=develop)](https://travis-ci.org/jason-neal/spectrum_overload) | [![Coverage Status](https://coveralls.io/repos/github/jason-neal/spectrum_overload/badge.svg?branch=develop)](https://coveralls.io/github/jason-neal/spectrum_overload?branch=develop) [![Test Coverage](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/coverage.svg?branch=develop)](https://codeclimate.com/github/jason-neal/spectrum_overload/coverage?branch=develop) | [![Code Climate](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/gpa.svg?branch=develop)](https://codeclimate.com/github/jason-neal/spectrum_overload?branch=develop)[![Issue Count](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/issue_count.svg?branch=develop)](https://codeclimate.com/github/jason-neal/spectrum_overload?branch=develop) | [![Code Issues](https://www.quantifiedcode.com/api/v1/project/6e918445f6f344c1af9c32f50718082e/snapshot/origin:develop:HEAD/badge.svg)](https://www.quantifiedcode.com/app/project/6e918445f6f344c1af9c32f50718082e?branch=origin/develop) |

## Overview
The purpose of this was project was to learn how to use and create Classes, and to create a Spectrum object to use within my Phd work.

Ideas to include:
The main goals of this project are basically complete.

Variables pixel, flux, wavelength
- create a class to contain spectrum
- automatic interpolation
- overloaded operators
especially
- Spectral division (SpectrumA / SpectrumB )
- Spectral subtraction (SpectrumA - SpectrumB)
- Powers/exponents (Spectrum ** x)

Spectral slicing method. (wav_selector)
## Installation
Currently to install and use Spectrum class for your own projects.

Radial velocity shifts
clone the git repository where you want it:

Wavelength calibration method. pixel->wavelength
https://github.com/jason-neal/spectrum_overload.git

Spectral subtraction: SpectrumA - SpectrumB
cd into the downloaded directory:

Spectral division SpectrumA/SpectrumB
cd spectrum_overload

and install using:

python setup.py install

## Other Spectrum Classes:

There are many other spectrum classes around but None (sofar) that overload the operators
## Usage
To use import the class using :

from spectrum_overload import Spectrum
...
my_spectrum = Spectrum.Spectrum(flux, xaxis)

or :

from spectrum_overload.Spectrum import Spectrum as spec
...
my_spectrum = spec(flux, xaxis)

or how ever else you would like to import it.

A tutorial is provided [here](Notebooks/Tutorial.ipynb) to show an example of how to use this class.


## Contributions
Contributions are very welcome.

I would really appreciate user feedback or suggested improvements if you have any.

Feel free to submit issues or create pull requests.



## Other Spectrum Classes

There are many other spectrum classes around but I didn't see any that overload the operators. (I could be blind).

One of these may better suit your needs

I will list them here as I find them
- https://github.com/crawfordsm/specreduce
- https://github.com/crawfordsm/pyspectrograph/tree/master/PySpectrograph/Spectra
- http://pyspeckit.bitbucket.org/html/sphinx/spectrum.html#pyspeckit.spectrum.classes.Spectrum
- https://github.com/cokelaer/spectrum
-https://github.com/astropy/specutils
- https://github.com/astropy/specutils

Wow A lot. I probably should not reinvent the wheel too much then...

It turns out that astropy/specutils is very similar to what I have created but its direction is uncertain at the moment and they do not use overloaded operators and will not implement in the foreseeable future.

## TO DO
Some tasks still to do:

- Improve Documentation
- Generate Calibration solution (outside spectrum class)?
- Push a version to pypi
49 changes: 49 additions & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. _classes
=================
Available Classes
=================
Currently there are two classes available.
- :ref:`Spectrum <spectrumclass>`
- :ref:`DifferentialSpectrum <diffclass>`


.. _spectrumclass:

.. note::
Unfortunately the auto-documentation for these classes does not build properly yet due to the ``Pyastronomy`` install dependency `issue. <https://github.com/sczesla/PyAstronomy/issues/22>`_
I hope to see it here soon.

If you need you can try and build this documentation yourself from the root `spectrum_overload` directory::

pip install -e .[docs] # editable installation, install docs dependencies.
cd docs
make html

This page will be docs/.build/classes.html

Spectrum
=========

A class to contain a spectrum. The operators have been overloaded so that you can easily manipulate spectra.

.. autoclass:: spectrum_overload.Spectrum.Spectrum
:members:
:undoc-members:
:show-inheritance:


.. _diffclass:

Differential Spectrum
=====================
Compute the difference between two :ref:`Spectrum <spectrumclass>` objects.

This is in an introductory state and need more work.

Would be useful add an s-profile function from `Ferluga et al. 1997 <http://aas.aanda.org/articles/aas/ps/1997/01/dst6676.ps.gz>`_. The subtraction of two gaussian lines with a RV offset.

.. autoclass:: spectrum_overload.Differential.DifferentialSpectrum
:members:
:undoc-members:
:show-inheritance:
85 changes: 54 additions & 31 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Spectrum documentation build configuration file, created by
# Licensed under the MIT Licence

# spectrum_overload documentation build configuration file, created by
# sphinx-quickstart on Sun Sep 11 23:45:23 2016.
#
# This file is execfile()d with the current directory set to its
Expand All @@ -13,9 +14,24 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

try:
import sphinx_rtd_theme
except ImportError:
sphinx_rtd_theme = None


base_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")

about = {}
with open(os.path.join(base_dir, "spectrum_overload", "__about__.py")) as f:
exec(f.read(), about)


sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "spectrum_overload"))
# 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.
Expand All @@ -37,6 +53,7 @@
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon'
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -54,18 +71,18 @@
master_doc = 'index'

# General information about the project.
project = 'Spectrum'
copyright = '2016, Jason Neal'
author = 'Jason Neal'
project = 'spectrum_overload'
copyright = about["__copyright__"]
author = about["__author__"]

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
version = about["__version__"]
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = about["__version__"]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -117,7 +134,13 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
#html_theme = 'alabaster'
if sphinx_rtd_theme:
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
else:
# html_theme = "default"
html_theme = "sphinxdoc"

# 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
Expand All @@ -129,7 +152,7 @@

# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#html_title = 'Spectrum v0.1'
#html_title = 'spectrum_overload v0.1'

# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
Expand All @@ -138,9 +161,9 @@
# of the sidebar.
#html_logo = None

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# The name of an image file (relative to this directory) to use as a favicon
# of the docs. This file should be a Windows icon file (.ico) being 16x16 or
# 32x32 pixels large.
#html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down Expand Up @@ -211,31 +234,31 @@
#html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'Spectrumdoc'
htmlhelp_basename = 'spectrum_overloaddoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',

# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Latex figure (float) alignment
#'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Spectrum.tex', 'Spectrum Documentation',
'Jason Neal', 'manual'),
]
(master_doc, 'spectrum_overload.tex', 'spectrum_overload Documentation',
author, 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand Down Expand Up @@ -263,9 +286,9 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'spectrum', 'Spectrum Documentation',
(master_doc, 'spectrum_overload', 'spectrum_overload Documentation',
[author], 1)
]
]

# If true, show URL addresses after external links.
#man_show_urls = False
Expand All @@ -277,10 +300,10 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Spectrum', 'Spectrum Documentation',
author, 'Spectrum', 'One line description of project.',
(master_doc, 'spectrum_overload', 'spectrum_overload Documentation',
author, 'spectrum_overload', 'One line description of project.',
'Miscellaneous'),
]
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
Expand Down
Loading

0 comments on commit f812550

Please sign in to comment.