Skip to content

Commit

Permalink
Merge 845eb73 into 09e9270
Browse files Browse the repository at this point in the history
  • Loading branch information
sosey committed Mar 29, 2020
2 parents 09e9270 + 845eb73 commit 381c138
Show file tree
Hide file tree
Showing 30 changed files with 1,238 additions and 16,497 deletions.
181 changes: 65 additions & 116 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
language: c

# Cache can be cleared from the travis settings menu, see docs currently at
# https://docs.travis-ci.com/user/caching#Clearing-Caches
cache:
- ccache
language: python


os:
- linux
os: linux
services: xvfb

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

# Cache can be cleared from the travis settings menu, see docs currently at
# https://docs.travis-ci.com/user/caching#Clearing-Caches
cache:
- ccache

# The apt packages below are needed for sphinx builds, which can no longer
# be installed with sudo apt-get.
addons:
apt:
packages:
- graphviz
- texlive-latex-extra
- dvipng

env:
global:
# SET DEFAULTS TO AVOID REPEATING IN MOST CASES
- SETUP_XVFB=True
- PYTHON_VERSION=3.6
- NUMPY_VERSION=stable
- ASTROPY_VERSION=stable
- CONDA_DEPENDENCIES='Cython matplotlib scipy ipython'
- PIP_DEPENDENCIES='photutils pytest-astropy pytest-cov'
- MAIN_CMD='python setup.py'
- SETUP_CMD='test'
- CONDA_CHANNELS='astropy-ci-extras astropy'
- SETUP_XVFB=True
- EVENT_TYPE='push pull_request'
# https://docs.travis-ci.com/user/environment-variables/
- CONDA_DEPENDENCIES='scipy matplotlib pyqt ginga ipython Cython setuptools_scm pip pytest'

# PEP8 errors/warnings:
# E101 - mix of tabs and spaces
Expand All @@ -51,122 +37,85 @@ env:
# E722 - do not use bare except
# E901 - SyntaxError or IndentationError
# E902 - IOError
- FLAKE8_OPT="--select=E101,W191,W291,W292,W293,W391,E111,E112,E113,E502,E722,E901,E902"
- FLAKE8_OPT="--select=E101,W191,W291,W292,W293,E111,E112,E113,E502,E722,E901,E902"
jobs:
NUMPY=1.15
NUMPY=1.16
NUMPY=1.17
NUMPY=1.18
ASTROPY=4.0
ASTROPY=3.2.3

before_install:
# Install the latest version of Miniconda
- uname -a
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3.sh
- chmod +x miniconda3.sh
- ./miniconda3.sh -b
- export PATH=/home/travis/miniconda3/bin:$PATH
- conda config --add channels conda-forge
- conda config --add channels astropy
- python --version
# travis clones submodules by default
# - git submodule update --init --recursive

matrix:
# make sure that egg_info works without dependencies
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.7 SETUP_CMD='egg_info'
install:
- conda create --yes -n test python=$PYTHON numpy=$NUMPY
- source activate test
- conda install -y astropy=$ASTROPY
- conda install -y $CONDA_DEPENDENCIES
- pip install pytest-pep8
- pip install pytest-cov
- pip install coveralls
- pip install sphinx-automodapi
- pip install photutils
- pip install flake8
- pip install sphinx-astropy
- pip install graphviz
- python setup.py build_ext --inplace

script: python setup.py test

matrix:
jobs:

# Don't wait for allowed failures
fast_finish: true

include:
# Try MacOS X
- os: osx
env: SETUP_CMD='test'
CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES
PIP_DEPENDENCIES=$PIP_DEPENDENCIES


- os: linux
# Check for sphinx doc build warnings - we do this first because
- python: 3.5
env: SETUP_CMD='build_sphinx -w' CONDA_DEPENDENCIES='Cython ipython scipy matplotlib ginga'

# Try Astropy development and LTS versions
- python: 3.5
env: ASTROPY_VERSION=lts
- python: 3.5
env: ASTROPY_VERSION=development
- python: 3.6
env: ASTROPY_VERSION=development
- python: 3.7
env: ASTROPY_VERSION=development

# Try with optional dependencies disabled
- python: 3.5
env: PIP_DEPENDENCIES=''
- python: 3.6
env: PIP_DEPENDENCIES=''
- python: 3.7
env: PIP_DEPENDENCIES=''
- name: "Test documentation build"
env: NUMPY=1.17 PYTHON=3.7
script: python setup.py build_sphinx

# Try older numpy versions
- python: 3.6
env: NUMPY_VERSION=1.14
env: NUMPY=1.15 ASTROPY=3.2.3
- python: 3.6
env: NUMPY_VERSION=1.15
env: NUMPY=1.16 ASTROPY=4.0
- python: 3.6
env: NUMPY_VERSION=1.16
- python: 3.7
env: NUMPY_VERSION=1.14
env: NUMPY=1.17 ASTROPY=4.0
- python: 3.7
env: NUMPY_VERSION=1.15
env: NUMPY=1.18 ASTROPY=4.0
- python: 3.7
env: NUMPY_VERSION=1.16
env: NUMPY=1.17 ASTROPY=4.0
- python: 3.8
env: NUMPY=1.17 ASTROPY=4.0
- python: 3.8
env: NUMPY=1.18 ASTROPY=4.0


# Do coverage tests
- python: 3.5
env: SETUP_CMD='test --cov'
- name: "Test coverage status"
python: 3.7
env: ASTROPY=4.0 NUMPY=1.17
script: python setup.py test --cov


# Do a pep8 test
- python: 3.5
env: MAIN_CMD="flake8 imexam --count $FLAKE8_OPT" SETUP_CMD=''

allow_failures:
- python: 3.7
env: NUMPY_VERSION=prerelease
- python: 3.8
env: NUMPY_VERSION=prerelease


before_install:
- uname -a
- python --version
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ( sudo Xvfb :99 -ac -screen 0 1024x768x8; sleep 3; echo ok )& fi

# We now use the ci-helpers package to set up our testing environment.
# This is done by using Miniconda and then using conda and pip to install
# dependencies. Which dependencies are installed using conda and pip is
# determined by the CONDA_DEPDENDENCIES and PIP_DEPENDENCIES variables,
# which should be space-delimited lists of package names. See the README
# in https://github.com/astropy/ci-helpers for information about the full
# list of environment variables that can be used to customize your
# environment. In some cases, ci-helpers may not offer enough flexibility
# in how to install a package, in which case you can have additional
# commands in the install: section below.


install:
- git clone git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- pip install pytest-pep8
- pip install pytest
- pip install pytest-cov
- pip install coveralls

# As described above, using ci-helpers, you should be able to set up an
# environment with dependencies installed using conda and pip, but in some
# cases this may not provide enough flexibility in how to install a
# specific dependency (and it will not be able to install non-Python
# dependencies). Therefore, you can also include commands below (as
# well as at the start of the install section or in the before_install
# section if they are needed before setting up conda) to install any
# other dependencies.


script:
# - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ( xvfb-run -a $MAIN_CMD $SETUP_CMD ) fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ( $MAIN_CMD $SETUP_CMD ) fi
- name: "Test pep8 requirements"
env: PYTHON=3.7 ASTROPY=4.0 NUMPY=1.17
script: flake8 imexam --count $FLAKE8_OPT


after_success:
- if [[ $SETUP_CMD == 'test --coverage' ]]; then coveralls --rcfile='imexam/tests/coveragerc'; fi
- coveralls --rcfile='imexam/tests/coveragerc'
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
version 0.8.2a (unreleased)
---------------------------
- renamed xpa extension for compatibility
- added option for center of mass to aperature photometry centering
- update aper_phot to return tuple of photometry information without plotting
- updated example jupyter notebooks to be compatible with current functionality
- changed the ext_build process a little and added a flag to skip remaking the c code
- remove leftover iraf variable names
- removed support for the grab function under Darwin
- add deleted import of xpa back to utils (#192)
- adapt for change to photutils API for aperture areas (#193)
- fix ginga display of HDUList
- add check for ds9 in alias as well as well as path
Expand Down
2 changes: 1 addition & 1 deletion cextern/xpa
Submodule xpa updated 19 files
+14 −49 Makefile.in
+19 −9 client.c
+6 −0 conf.h.in
+430 −463 config.guess
+329 −115 config.sub
+2 −5 configure
+1 −5 configure.ac
+1 −1 ctest.c
+37 −3 dns.c
+3 −3 doc/pod/xpamb.pod
+3 −3 doc/xpamb.html
+3 −1 find.c
+24 −15 man/man1/xpamb.1
+43 −2 tcp.c
+3 −0 word.c
+3 −1 xalloc.c
+6 −3 xlaunch.c
+12 −4 xpa.c
+4 −1 xpap.h
12 changes: 10 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@
import sphinx
import sphinx.environment
from docutils.utils import get_source_line
from pkg_resources import get_distribution
# from pkg_resources import get_distribution
from distutils.version import LooseVersion

try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))

try:
import imexam
release = imexam.__version__
except ImportError:
from pkg_resources import get_distribution
release = get_distribution(setup_cfg['package_name']).version

release = get_distribution('imexam').version
# for example take major/minor
version = '.'.join(release.split('.')[:4])

Expand Down
8 changes: 4 additions & 4 deletions docs/imexam/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Software Dependencies
* XPA: https://github.com/ericmandel/xpa
* Ginga (image display - optional )

astropy >= 1.0
astropy >= 3.0

python >= 2.7
python >= 3.5

numpy >= 1.7.0
numpy >= 1.12.0

photutils > 0.2
photutils
This must be installed to enable the photometry options for imexam() but
it is not required

Expand Down
28 changes: 15 additions & 13 deletions docs/imexam/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ The ``imexam`` library can be used standalone, without a viewer, to create the p

You can connect to an already open DS9 window by specifying the title or the XPA_METHOD. The ``XPA_METHOD`` is the address in the File->Information dialog. If users don't specify a title in the ds9 window when they open one up, ds9 will just call the window "ds9", so you can end up with multiple windows with the same name. This works for DS9 because the XPA_METHOD is always unique. The most straightforward way is for users to open the DS9 windows with explicit titles, and then tell imexam to connect to that window::

python> !ds9 -title megan
python> window=imexam.connect('megan')
python> !ds9 -title custom_title
python> window=imexam.connect('custom-title')

However, if there are windows already open with no unique titles, the best way is to connect using the method. The ``list_active_ds9`` function can be used to return a dictionary which contains the information for all the windows, but it's keys are the unique XPA_METHOD strings.::

In [3]: !ds9&
In [4]: imexam.list_active_ds9()
DS9 ds9 gs c0a80106:61894 sosey
Out[4]: {'c0a80106:61894': ('ds9', 'sosey', 'DS9', 'gs')}
DS9 ds9 gs c0a80106:61894 username
Out[4]: {'c0a80106:61894': ('ds9', 'username', 'DS9', 'gs')}

Using this dictionary, you can also you can return the list of windows you can connect to without too much thinking, making it easy to encorporate into your own scripts as well:::


In [1]: import imexam

In [2]: windows=imexam.list_active_ds9()
DS9 ds9 gs c0a80106:61915 sosey
DS9 ds9 gs c0a80106:61915 username

In [3]: list(windows)
Out[3]: ['c0a80106:61915']

In [4]: !ds9&

In [5]: windows=imexam.list_active_ds9()
DS9 ds9 gs c0a80106:61915 sosey
DS9 ds9 gs c0a80106:61923 sosey
DS9 ds9 gs c0a80106:61915 username
DS9 ds9 gs c0a80106:61923 username

In [6]: list(windows)
Out[6]: ['c0a80106:61915', 'c0a80106:61923']
Expand All @@ -48,12 +48,12 @@ Using this dictionary, you can also you can return the list of windows you can c
But you can also use it as below to cycle through connecting to a set of windows:::

In [8]: windows=imexam.list_active_ds9()
DS9 ds9 gs c0a80106:61915 sosey
DS9 ds9 gs c0a80106:61923 sosey
DS9 ds9 gs c0a80106:61915 username
DS9 ds9 gs c0a80106:61923 username

In [9]: ds=imexam.connect(windows.popitem()[0]) #connect to first window, remove as possible window
In [10]: windows
Out[11]: {'c0a80106:61923': ('ds9', 'sosey', 'DS9', 'gs')}
Out[11]: {'c0a80106:61923': ('ds9','username', 'DS9', 'gs')}

In [12]: w2=imexam.connect(windows.popitem()[0])

Expand Down Expand Up @@ -96,20 +96,22 @@ These are some tips on installing the package, or tracking down problems you mig
conda install imexam -c http://ssb.stsci.edu/astroconda


If you want to build the documentation locally, clone the git repository and then issue the document build command from the imexam directory:

# python setup.py build_sphinx

If you want to have access to the photometry features of the ``imexam()`` analysis, download and install ``photutils`` - another of the astropy associated packages. The full list of astropy packages can be found here: https://github.com/astropy. If ``photutils`` is not installed, ``imexam`` should issue a nice statement saying that the photometry options are not available upon import, and any time an analysis key is pressed during the ``imexam()`` function loop which requires ``photutils`` to render a result.


Usage
-----

``imexam`` displays plots using matplotlib, if you find that no windows are popping up after installation it's probably the backend that was loaded. One quick way to get things started is to load ipython and use the %matplotlib magic, this will make sure the proper display backend loads when matplotlib is imported::
``imexam`` displays plots using matplotlib, if you find that no windows are popping up after installation it's probably the backend that was loaded. One quick way to get things started is to load ipython::

>ipython
>%matplotlib
>import imexam

Matplotlib magic should also be used inside the Jupyter notebook or proper interaction with the plots. Before importing ``imexam`` into the notebook, specify the ``notebook`` backend if you wish to save your plots into the notebook itself. Otherwise you can use the standard ipython magics.
Matplotlib magic can also be used inside the Jupyter notebook for interaction with the plots. If one of the standard backends is used the plots should be saved into the cell from which the command was issued. The notebook backend (nbagg) will require you to close the plotting window from inside the cell.


``imexam`` is a class based library. The user creates an object which is tied to a specific image viewing window, such as a DS9 window. In order to interact with multiple windows the user must create multiple objects. Each object stores all the relevent information about the window and data with which it is associated.
Expand Down
6 changes: 3 additions & 3 deletions docs/imexam/example1.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

=========
Example 1
=========
===========
Basic Usage
===========

.. note:: More examples in the form of Jupyter notebooks can be downloaded from the git repository and are contained in the "example_notebooks" directory.

Expand Down

0 comments on commit 381c138

Please sign in to comment.