-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Corrections of docstrings and some clean up. * Add Differential import to main __init__.py To solve this issue when building docs. AttributeError: module 'spectrum_overload' has no attribute 'Differential' * Update doc strings in classes. * Add paths to module in doc conf. * Change default theme. * Update index.rst * Add documentation about installation. * Quickstart doc. * Document available classes. Using autodoc. * Tidy spacing in docs. * rearrange order of requirements. * Add numpy to setup_requires. To resolve issue with pyastronomy. * Remove pyastronomy from requirements.txt * Update requirements regarding pyastronomy. * Edits to quickstart. * Add docs extra_requirements to setup.py * Run requirements.txt in setup.py. * Add pyastronomy to travis.yml So that tests will run before pyastronomy fixed. * Adjust comment of setup.cfg - unimportant * Fix setup.py error. missing comma for docs: dependencies. * Try empty install requires. * Add readthedocs YAML config file. * try pyastronomy in doc requirements. * Add docs/.build to gitignore. Ignores build files for docs. * Add editable installation to docs. * Note about classes not building. And how to build manually. * Re-add index and search to home page.
- Loading branch information
1 parent
a715e39
commit e179dd3
Showing
15 changed files
with
306 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
docs/.build/ | ||
|
||
#sync | ||
.sync/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
||
# Requirements file | ||
requirements_file: | ||
requirements.txt | ||
|
||
python: | ||
version: 3.5 | ||
setup_py_install: true | ||
# From extras_require in setup.py | ||
extra_requirements: | ||
- tests | ||
- docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
.. _install: | ||
|
||
============================================= | ||
Installation | ||
============================================= | ||
Spectrum_overload is currently available from ``github``. | ||
|
||
Navigate to where you want to put files. | ||
Then Download: | ||
|
||
with ``git``:: | ||
|
||
$ git clone https://github.com/jason-neal/spectrum_overload.git | ||
|
||
To install, run:: | ||
|
||
$ cd spectrum_overload | ||
$ python setup.py install | ||
|
||
# Or: | ||
|
||
$ cd spectrum_overload | ||
$ pip install . | ||
|
||
# Or, for an editable installation: | ||
|
||
$ cd spectrum_overload | ||
$ pip install -e . | ||
|
||
The plan is to have it available via ``pypi`` someday in the future.:: | ||
|
||
# Bug me about this. | ||
$ pip install spectrum-overload | ||
|
||
That day is not today... | ||
|
||
If you have any issues with installation of spectrum_overload please open an `issue`_ so it can be resolved. | ||
|
||
.. _issue: https://github.com/jason-neal/spectrum_overload/issues | ||
|
||
|
||
Requirements | ||
============ | ||
The main requirements are | ||
|
||
- `numpy <https://www.numpy.org/>`_ | ||
- `astropy <https://www.astropy.org/>`_ | ||
- `scipy <https://www.scipy.org/>`_ | ||
- `pyastronomy <http://www.hs.uni-hamburg.de/DE/Ins/Per/Czesla/PyA/PyA/index.html>`_ | ||
|
||
If you are needing to use this package you probably have these installed already... | ||
|
||
Unfortunately `pyastronomy <http://www.hs.uni-hamburg.de/DE/Ins/Per/Czesla/PyA/PyA/index.html>`_ cannot be added to the ``requirements.txt`` alongside ``numpy`` due to `issue #22 <https://github.com/sczesla/PyAstronomy/issues/22>`_ with the setup dependency of ``numpy`` in ``pyastronomy``. | ||
If you do not have it installed already then run:: | ||
|
||
$ pip install pyastronomy | ||
|
||
Other requirements are needed for running the `pytest <https://docs.pytest.org/en/latest/>`_ test suite. | ||
If you want to try run the tests, run:: | ||
|
||
$ python setup.py test | ||
|
||
after normal installation. | ||
|
||
These other dependencies that you may need are | ||
|
||
- pytest-runner | ||
- hypothesis | ||
- pytest | ||
- pytest-cov | ||
- python-coveralls | ||
- coverage | ||
|
||
|
||
Editable Installation | ||
===================== | ||
If you want to modify spectrum_overload you can instead install it like:: | ||
|
||
$ python setup.py develop | ||
|
||
.. or pip install -e . when available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.. _quickstart: | ||
|
||
================== | ||
Quickstart Guide | ||
================== | ||
First install spectrum_overload via the :ref:`installation guide <install>`. | ||
|
||
Import the Spectrum class into your code. | ||
|
||
:: | ||
|
||
from spectrum_overload.Spectrum import Spectrum | ||
|
||
Then to create a spectrum object, and exponentially scale it by 2 use: | ||
|
||
:: | ||
|
||
s = Spectrum(flux=f, xaxis=x) | ||
|
||
# exponential scaling | ||
s = s ** 2 | ||
|
||
where ``f`` and ``x`` are 1D lists or numpy arrays. | ||
|
||
.. note:: | ||
|
||
Flux is the first kwarg. Be careful not to switch the order of flux and xaxis when not specifying the kwarg names. | ||
|
||
By default the spectrum is "calibrated". If the xaxis is only the pixel values of your spectra you can pass | ||
|
||
:: | ||
|
||
s = Spectrum(flux=f, xaxis=pxls, calibrated=False) | ||
|
||
or if no xaxis is given it will be set by | ||
|
||
:: | ||
|
||
xaxis = np.arange(len(flux)) | ||
|
||
You can calibrate the spectra with a polynomial using the ``calibrate_with`` method which uses ``np.polyval``:: | ||
|
||
s.calibrate_with([p0, p1, p2 ...]) | ||
|
||
|
||
.. _overloaded_operators: | ||
|
||
Overloaded Operators | ||
==================== | ||
The main purpose of this package is overloading the operators ``+``, ``-``, ``*``, ``/``, ``**`` to work with spectrum objects. e.g:: | ||
|
||
# Given two spectra | ||
s1 = Spectrum(...) | ||
s2 = Spectrum(...) | ||
|
||
# You can easily do the following operations. | ||
add = s1 + s2 | ||
subtract = s1 - s2 | ||
multiply = s1 * s2 | ||
divide = s1 / s2 | ||
power = s1 ** a # where a is a number | ||
|
||
|
||
This is to make easier to do some basic manipulation of spectra, average spectra, take the difference, normalization, | ||
exponential scaling etc... | ||
|
||
.. note :: | ||
Its probably best to interpolate the spectra to the same xaxis yourself before hand. | ||
If the spectra do not have the same wavelength axis then it is automatically spline interpolated | ||
to match the first spectrum or to another defined new xaxis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
pyastronomy | ||
numpy | ||
astropy | ||
scipy | ||
#pyastronomy | ||
hypothesis | ||
pytest | ||
pytest-cov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# setup.py configuration file? | ||
# http://doc.pytest.org/en/latest/goodpractices.html | ||
# Should now beable to call python setup.py test and test will run pytest | ||
# Should now be able to call python setup.py test and test will run pytest | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
[tool:pytest] | ||
addopts = --verbose | ||
addopts = --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.