Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #284 from nmearl/master
Browse files Browse the repository at this point in the history
Bug squashing and polish
  • Loading branch information
nmearl authored Apr 5, 2017
2 parents 178eb5f + 4610e5f commit 93d505c
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ os:
- osx

# Setting sudo to false opts in to Travis-CI container-based builds.
sudo: false
sudo: true

# The apt packages below are needed for sphinx builds. A full list of packages
# that can be included can be found here:
Expand Down Expand Up @@ -95,4 +95,4 @@ after_success:
# If coveralls.io is set up for this package, uncomment the line
# below and replace "packagename" with the name of your package.
# The coveragerc file may be customized as needed for your package.
# - if [[ $SETUP_CMD == 'test --coverage' ]]; then coveralls --rcfile='packagename/tests/coveragerc'; fi
# - if [[ $SETUP_CMD == 'test --coverage' ]]; then coveralls --rcfile='packagename/tests/coveragerc'; fi
Binary file added docs/source/_static/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/viewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '0.3'
# The full version, including alpha/beta/rc tags.
release = '0.1.0a1'
release = '0.3.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 4 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ emission and absorption lines in addition to regions of flat continuua).
SpecViz incorporates various methods for fitting such models to data. For more
details, see :ref:`doc_model_fitting`.

Furthermore, SpecViz allows for overplotting or simple combining of spectra.
Furthermore, SpecViz allows for overplotting or combining of spectra.

SpecViz will soon include the ability to
- Measure the average of multiple spectra, splice a spectrum, and apply Fourier filters.
- Measure the average of multiple spectra, detrending, and apply Fourier filters.
- Interactively renormalize data from spectral templates.
- Overplot spectral line lists.
- And more...

Demo
----

.. image:: https://i.vimeocdn.com/video/571749719_640.jpg
.. image:: _static/demo.png
:target: https://stsci.box.com/s/6ynrfshzrix3yaxvd3c8bcs4hzltpadz


Expand All @@ -45,6 +45,7 @@ Installation and Setup
:maxdepth: 2

installation
launching


Using SpecViz
Expand Down
108 changes: 36 additions & 72 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,13 @@ any terminal::
$ specviz


PyQt5 version (optional)
^^^^^^^^^^^^^^^^^^^^^^^^
Uninstalling
^^^^^^^^^^^^

While the PyQt4 version of SpecViz is currently the default distributed, it
is recommended that you upgrade to using the PyQt5 version if you know that
you do not have any system conflicts. Note that this is entirely optional,
but encouraged due to the fact that `Qt4 development and support has ended
<http://blog.qt.io/blog/2015/05/26/qt-4-8-7-released/>`_. ::
To uninstall via Anaconda, simply type the following at a command line::

$ conda install --channel https://conda.anaconda.org/spyder-ide pyqt5
$ conda install --channel https://conda.anaconda.org/nmearl specviz
$ conda uninstall specviz

SpecViz can then be launched via the command line::

$ specviz

Install via source
------------------
Expand All @@ -60,70 +52,58 @@ handled automatically by the setup functions, with the exception of PyQt/PySide.
* Numpy
* Scipy
* PyQtGraph
* qtpy


Installing PyQt/PySide
^^^^^^^^^^^^^^^^^^^^^^

The easiest way to install PyQt/PySide is through some package manager.
Please keep in mind that PyQt5 is the recommended PyQt implementation as
`Qt4 development and support has ended <http://blog.qt.io/blog/2015/05/26/qt-4-8-7-released/>`_.

Below are instructions for installing using *either* `Homebrew <http://brew
.sh/>`_ *or* `Anaconda <https://www.continuum.io/downloads>`__.
Installing
^^^^^^^^^^

PyQt5
"""""
Clone the SpecViz repository somewhere on your system, and install locally using
``pip``. If you are using an Anaconda virtual environment, please be sure to
activate it first before installing: ``$ source activate <environment_name>``.

Homebrew
`Install using Homebrew for Qt5 <http://brewformulas.org/Pyqt5>`_.
::

Anaconda
Installing PyQt5 with Anaconda will require installing from the Spyder-IDE
channel as it is not currently a core package (but they're working on it).
::
$ git clone https://github.com/spacetelescope/specviz.git
$ cd specviz
$ git checkout tags/v0.3.0
$ pip install -r requirements.txt

$ conda install --channel https://anaconda.org/m-labs/pyqt5 pyqt5
This uses the ``pip`` installation system, so please note that

1. You need to have ``pip`` installed (included in most Python installations).
2. You do **not** need to run ``python setup.py install``.
3. You do **not** need to install the dependencies by hand (except for PyQt).

PyQt4
"""""
Likewise, the ``pip`` command will use your default Python to install.
You can specify by using ``pip2`` or ``pip3``, if you're not using a virtual
environment.

Homebrew
`Install using Homebrew for Qt4 <http://brewformulas.org/Pyqt4>`_.

Anaconda
Install using Anaconda::
PyQt/PySide bindings
^^^^^^^^^^^^^^^^^^^^

$ conda install pyqt
SpecViz requires PyQt. Currently, only python environments with 3.5 or higher
installed can use ``pip`` to install PyQt5, in which case simply type::

$ pip install pyqt5

Installing
^^^^^^^^^^
to install it on your system.

Clone the SpecViz repository somewhere on your system, and install locally using
``pip``. If you are using an Anaconda virtual environment, please be sure to
activate it first before installing: ``$ source activate <environment_name>``.
In any other case, PyQt can be installed via anaconda::

::
$ conda install pyqt

$ git clone https://github.com/spacetelescope/specviz.git
$ cd specviz
$ git checkout tags/v0.1.2rc3
$ pip install -r requirements.txt
SpecViz works with with PyQt4 and PySide, but it is recommended that users use
PyQt5 if available.

.. note::

This uses the ``pip`` installation system, so please note that
Uninstalling
^^^^^^^^^^^^

1. You need to have ``pip`` installed (included in most Python
installations).
2. You do **not** need to run ``python setup.py install``.
3. You do **not** need to install the dependencies by hand (except for PyQt).
To uninstall via ``pip``, simply type the following at a command line::

Likewise, the ``pip`` command will use your default Python to install.
You can specify by using ``pip2`` or ``pip3``, if you're not using a virtual
environment.
$ pip uninstall specviz


Known Issues
Expand Down Expand Up @@ -154,19 +134,3 @@ This issue can be solved with the following command::

$ conda uninstall pyqt5 qt5


.. _doc_launching:

Launching SpecViz
=================

Once you've installed SpecViz, you can launch it via the command line::

$ specviz


If you only wish to inspect a single FITS or ASCII file using the default
:ref:`doc_custom_loaders` file formatting, you can also pass in the filename
as a command line argument, as follows::

$ specviz filename
20 changes: 20 additions & 0 deletions docs/source/launching.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. _doc_launching:

Launching SpecViz
=================

Once you've installed SpecViz, you can launch it via the command line::

$ specviz


If you only wish to inspect a single FITS or ASCII file using the default
:ref:`doc_custom_loaders` file formatting, you can also pass in the filename
as a command line argument, as follows::

$ specviz filename


You may also include the name of a custom loader as second optional argument::

$ specviz filename --format="my-custom-format"
68 changes: 36 additions & 32 deletions docs/source/model_fitting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ SLSQP `~astropy.modeling.fitting.SLSQPLSQFitter`

To use a model:

#. Select the layer you wish to operate on from the LAYERS window in the upper left.
#. Create and position a region of interest (ROI) as described in the :ref:`doc_viewer` section of
the documentation.”
#. Select the layer you wish to operate on from the "Layer List" window in the
bottom left. For example, you can choose the layer containing your emission
or absorption line.
#. Create and position a region of interest (ROI) as described in the
:ref:`doc_viewer` section of the documentation.
#. Select the desired model from the ``Add Model`` drop-down box and click
``Select`` to add it to ``Current Models``.
#. If desired, repeat the above step to add additional models.
#. A new model layer will be created under ``Layers`` (left panel) and it is
attached to the selected data layer.
#. A new model layer will be created under your data layer in the "Layer List"
window.

To edit model parameters or enter a better first estimate of the model parameters:
To edit model parameters or enter a better first estimate of the model
parameters:

#. Select the model layer under ``Layers`` (left panel) that contains the desired
model.
#. Select the model layer in the "Layer List" window that contains the
desired model.
#. If desired, double-click on the model name to rename it. When you see a
blinking cursor, enter its new name and press "Enter".
#. Expand the model listing under ``Current Models`` on the right of the viewer.
Expand Down Expand Up @@ -135,7 +138,7 @@ accessed, and varied, by the fitter. Thus, the spline parameters are not fitted,
they are just a convenient mechanism that enables user access to the parameter's
values.

The documentation for the spline model can be seen here:
The documentation for the spline model can be found here:

http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.interpolate.UnivariateSpline.html

Expand All @@ -152,44 +155,45 @@ value.
Model arithmetic is a work in progress.


Saving and Exporting Models to File
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Saving and exporting models to a file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Selecting a model layer under "Layers" will enable the
:ref:`Save <doc_model_save>` (the "floppy disk" icon) and
:ref:`doc_model_export` (the "out the door" icon) buttons under
"Current Models" on the right of the viewer. Saving a model to a file will
enable SpecViz to read back that model into a new model layer. Exporting a model
"Current Models" on the right of the viewer. When a model is saved as a file on
disk, it can later be read into SpecViz as described below. Exporting a model
to a file wil create a Python script in a ``.py`` file. This file can be
directly imported by Python in a command-line session.

Click on either button to get a file dialog window. Type in a file name.
If this file name does not end with the correct suffix, the suffix will
automatically be appended. Click "Save", or just the Return/Enter key.
The correct suffix for saved and exported files are ``.yaml`` and ``.py``,
respectively.
Click on either button to get a file dialog window. Provide a name for the model
file, if this file name does not end with the
correct suffix, the suffix will automatically be appended. Click "Save", or
just press the Return/Enter key. The correct suffix for saved and exported files are
``.yaml`` and ``.py``, respectively.


.. _doc_model_save:

Save and Load
Save and load
^^^^^^^^^^^^^

Saving the model to a file works in the same way as :ref:`doc_model_export`.
The difference is that a saved model can be later read back into SpecViz via
the "Load" button (the "folder" icon), also under "Current Models".
the "Load" button (the "folder" icon), also under "Current Models", whereas the
exported model cannot.

For the "Load" button to be enabled, a data (spectrum) layer (not a model layer)
must be selected under "Layers" listing. The selected ``.yaml`` model file will
generate a model that will be attached to a new model layer associated under the
selected data layer.
must be selected in the "Layer List" window. The selected ``.yaml`` model file
will generate a model that will be attached to a new model layer associated
with the selected data layer.

The file is writen using the YAML format. Being a plain text file with a
The file is writen in the YAML format. Being a plain text file with a
self-explanatory structure, it can be edited at will by the user, e.g., to add
bounds, fixed flags, and ties to the model parameters. Note that these extra,
user-defined attributes, won't be accessible from SpecViz's user interface.
They will however, be accessible by the fitter when a fit is run on the
model. They will also be written ou correctly, either when saving or exporting
They will however, be used by the fitter when a fit is run on the
model. They will also be written out correctly, either when saving or exporting
the model.

.. note::
Expand All @@ -205,8 +209,8 @@ Export

This will save the model in the currently selected model layer to a file
that can be directly imported by Python. The file is just a plain text
file with the model expressed recorded as a Python expression. The model
is associated to a variable named ``'model1'``.
file with the model given as a Python expression. The model
is associated a variable named ``'model1'``.

The following example uses the ``'test3.py'`` file name, and a model comprised
of a constant and a gaussian:
Expand All @@ -228,11 +232,11 @@ of a constant and a gaussian:
-------------- ------------- ------------- -------------
0.297160787184 2.25396100263 15117.1710847 948.493577186
The file can be edited at will by the user, e.g., to add bounds, fixed flags,
The file can be edited by the user, e.g., to add bounds, fixed flags,
and ties to the model parameters.

.. note::
.. warning::

Security issues importing model this way into Python and usage of advanced
features like bounds and fixed flags are work in progress.
Security issues with importing model this way into Python and usage of
advanced features like bounds and fixed flags are work in progress.

Loading

0 comments on commit 93d505c

Please sign in to comment.