Skip to content

Commit

Permalink
Merge pull request #156 from sosey/release-prep
Browse files Browse the repository at this point in the history
Prepping to release 0.8.1
  • Loading branch information
sosey committed Dec 14, 2018
2 parents 4526223 + f587d30 commit b66a483
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 95 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version 0.8.1dev (unreleased)
-----------------------------
** THIS WILL BE THE LAST VERSION THAT SUPPORT Python 2.7 **

- travis and appveyor testing updates
- radial profile plot centering fixed to more correctly calculate the fractional center offsets
- cumulative radial profile flux calculation should now be correct
Expand All @@ -15,6 +17,7 @@ version 0.8.1dev (unreleased)
- new options added to the aperture phot parameter set that allow users to plot the used apertures
- ZScaleInterval added from astropy.virtualization to set the color range on the data for aperture photometry plot
- replaced the sigma to fwhm lambda with the astropy constant for conversion
- added cursor move recognition using the arrow keys during the imexam loop, however, depending how the user has their windowing focus set, the DS9 window may loose focus, forcing them to move the cursor manually back to the window. Cursor moves are only implemented for DS9, not Ginga.

version 0.8.0 (released)
------------------------
Expand Down
109 changes: 73 additions & 36 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,59 @@ Try turning off the resume state:
defaults write org.python.python ApplePersistenceIgnoreState NO


If you are having display issues, some build problems may exist with the dependency packages which deal with backend graphics, try setting your matplotlib backend to Qt4Agg. You can set this in your .matplotlib/matplotlibrc file. You may also want to switch your matplotlib backend to Qt if you have a mac with the default MacOS backend specified. If you don't already have matplotlibrc file in your home directory, you can download one from their documentation: http://matplotlib.org/_static/matplotlibrc

Contributing
============
Please open a new issue or new pull request for bugs, feedback, or new features
you would like to see. If there is an issue you would like to work on, please
leave a comment and we will be happy to assist. New contributions and
contributors are very welcome!

New to github or open source projects? If you are unsure about where to start
or haven't used github before, please feel free to contact `@sosey`.
Want more information about how to make a contribution? Take a look at
the astropy `contributing`_ and `developer`_ documentation.

Feedback and feature requests? Is there something missing you would like
to see? Please open an issue or send an email to `@sosey`. imexam follows the `Astropy Code of Conduct`_ and strives to provide a
welcoming community to all of our users and contributors.


License
=======
imexam is licensed under a 3-clause BSD style license (see the
``licenses/LICENSE.rst`` file).

.. _AstroPy: http://www.astropy.org/
.. _contributing: http://docs.astropy.org/en/stable/index.html#contributing
.. _developer: http://docs.astropy.org/en/stable/index.html#developer-documentation
.. _Astropy Code of Conduct: http://www.astropy.org/about.html#codeofconduct



Quick Instructions
==================
If you are having display issues, and you are using TkAgg, try setting your matplotlib backend to Qt4Agg or Qt5Agg. You can set this in your .matplotlib/matplotlibrc file. You may also want to switch your matplotlib backend to Qt if you have a mac with the default MacOS backend specified. If you don't already have matplotlibrc file in your home directory, you can download one from their documentation: http://matplotlib.org/_static/matplotlibrc


::

inside ~/.matplotlib/matplotlibrc:
inside ~/.matplotlib/matplotlibrc:
backend: Qt4Agg



Using the Ginga HTML5 Viewer
----------------------------

If you have installed Ginga, you can use the HTML5 viewer for image display with either a python terminal, jupyter console, qtconsole or Jypyter notebook session. If you are using a Windows machine you should install ginga to use as the viewer with this package. Make sure that you have installed the latest version, or you can download the development code here: https://github.com/ejeschke/ginga. There's also a new ginga plugin for imexam which is in the ginga repository in the experimental directory. This will load the imexam plotting and analysis library into the ginga gui framework.
If you have installed Ginga, you can use the HTML5 viewer for image display with either a jupyter console, qtconsole or Jupyter notebook session. If you are using a Windows machine you should install ginga to use as the viewer with this package. Make sure that you have installed the latest version, or you can download the development code here: https://github.com/ejeschke/ginga.

There is also a ginga plugin for imexam which is in the ginga repository in the experimental directory. This will load the imexam plotting and analysis library into the ginga gui framework.

Starting a connection to a Ginga HTML5 canvas backend for browser and Jupyter viewing:

::

a=imexam.connect(viewer='ginga')
a = imexam.connect(viewer='ginga')

You can optionally provide a port number to which the viewer is connected as well:

Expand All @@ -105,10 +139,39 @@ You can optionally provide a port number to which the viewer is connected as wel
a=imexam.connect(viewer='ginga', port=9856)


Using imexam with DS9
---------------------
From a python terminal: using either the TkAGG or QT4Agg/QT5Agg backends:


::

import imexam
a = imexam.connect()
a.imexam()

From an ipython terminal: using either the TkAgg or QT4Agg/QT5Agg backends.

::

import imexam
a = imexam.connect()

If you are using TkAGG as the backend, from an ipython terminal, you may need to ctrl-D, then select n, to closeout the plotting window. This should not happen if you are running TkAgg and running from a regular python terminal. Looking into the closeout issue with TkAgg now.

From jupyter console/qtconsole: startup with the matplotlib magics to use the backend you specified for display:

::

In [1]: %matplotlib
import imexam
a = imexam.connect()

If you are using the Qt4Agg/Qt5Agg backend with ginga, the plots will display in the console window


Launching multiple DS9 windows
------------------------------

You can launch multiple ds9 windows either from this package or the command line. DS9 can be used to view images and arrays from any of the python terminals, consoles or the Jupyter notebook.

If you launch ds9 from outside the imexam package, you need supply the name of the window to imexam, this can be done in one of 2 ways:
Expand Down Expand Up @@ -156,7 +219,10 @@ Connecting to a DS9 window which was started from the system prompt:
Examples can be found in the package documentation, online documentation, and imexam.display_help() will pull up the installed package documentation in a web browser. You can also download the examply Jupyter notebooks available in the example_notebooks directory above.


You can also just load the plotting library and NOT connect to any viewer:
You can also just load the plotting library for use without a viewer:
---------------------------------------------------------------------
This is useful when you want to make batch plots or return information from scripts.
You can also save the lotting data returned and use it futher, or design your own plot.

::

Expand All @@ -172,32 +238,3 @@ You can also just load the plotting library and NOT connect to any viewer:

plots.set_data(data)
plots.plot_line(35,45)

Contributing
------------

Please open a new issue or new pull request for bugs, feedback, or new features
you would like to see. If there is an issue you would like to work on, please
leave a comment and we will be happy to assist. New contributions and
contributors are very welcome!

New to github or open source projects? If you are unsure about where to start
or haven't used github before, please feel free to contact `@sosey`.
Want more information about how to make a contribution? Take a look at
the astropy `contributing`_ and `developer`_ documentation.

Feedback and feature requests? Is there something missing you would like
to see? Please open an issue or send an email to `@sosey`. imexam follows the `Astropy Code of Conduct`_ and strives to provide a
welcoming community to all of our users and contributors.


License
-------

imexam is licensed under a 3-clause BSD style license (see the
``licenses/LICENSE.rst`` file).

.. _AstroPy: http://www.astropy.org/
.. _contributing: http://docs.astropy.org/en/stable/index.html#contributing
.. _developer: http://docs.astropy.org/en/stable/index.html#developer-documentation
.. _Astropy Code of Conduct: http://www.astropy.org/about.html#codeofconduct
3 changes: 2 additions & 1 deletion docs/imexam/current_capability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ but not yet fully implemented should return an error to that affect.


**load_fits**\ (fname="", extver=1, extname=None):
Load a fits image into the current frame
Load a fits image into the current frame.
fname can be a filename or a fits HDU


**load_mef_as_cube**\ (filename=None):
Expand Down
2 changes: 1 addition & 1 deletion docs/imexam/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ If you are having display issues, some build problems may exist with the depende

backend: Qt4Agg

The package works with the Qt5Agg and notebook backends, but on occasion I've seen the matplotlib window take two cycles to update, especially inside the Jupyter notebook with inline plots, meaning you may have to hit the exam key twice for the plot to appear. This issue still needs to be worked out, if you're running into it try using the Qt4Agg backend or plotting outside the notebook and saving the figures through the imexam grab or save calls.
The package works with the Qt5Agg and notebook backends, but on occasion I've seen the matplotlib window take two cycles to update, especially inside the Jupyter notebook with inline plots, meaning you may have to hit the exam key twice for the plot to appear. This issue still needs to be worked out, if you're running into it try using the Qt4Agg backend or plotting outside the notebook and saving the figures through the imexam grab or save calls. More information about the backends for matplotlib can be found here: https://matplotlib.org/users/shell.html


If you get an error about not finding the file "import" when you use the grab() function to save a copy of the DS9 window.
Expand Down
4 changes: 2 additions & 2 deletions docs/imexam/example5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ These are the functions you now have access to:

plots.aper_phot plots.contour_plot plots.histogram_plot plots.plot_line plots.set_colplot_pars plots.set_surface_pars
plots.aperphot_def_pars plots.curve_of_growth_def_pars plots.imexam_option_funcs plots.plot_name plots.set_column_fit_pars plots.show_xy_coords
plots.aperphot_pars plots.curve_of_growth_pars plots.line_fit plots.print_options plots.set_contour_pars plots.showplt
plots.aperphot_pars plots.curve_of_growth_pars plots.line_fit plots.print_options plots.set_contour_pars plots.set_plot_name
plots.colplot_def_pars plots.curve_of_growth_plot plots.line_fit_def_pars plots.register plots.set_data plots.sleep_time
plots.colplot_pars plots.do_option plots.line_fit_pars plots.report_stat plots.set_histogram_pars plots.surface_def_pars
plots.column_fit plots.gauss_center plots.lineplot_def_pars plots.report_stat_def_pars plots.set_line_fit_pars plots.surface_pars
plots.column_fit_def_pars plots.get_options plots.lineplot_pars plots.report_stat_pars plots.set_lineplot_pars plots.surface_plot
plots.column_fit_pars plots.get_plot_name plots.new_plot_window plots.reset_defpars plots.set_option_funcs plots.unlearn_all
plots.contour_def_pars plots.histogram_def_pars plots.option_descrip plots.save_figure plots.set_plot_name
plots.contour_def_pars plots.histogram_def_pars plots.option_descrip plots.save_figure
plots.contour_pars plots.histogram_pars plots.plot_column plots.set_aperphot_pars plots.set_radial_pars


Expand Down
2 changes: 1 addition & 1 deletion imexam/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ def test(package=None, test_path=None, args=None, plugins=None,
"importing from source, this is expected.")
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
del e
except:
except Exception:
raise orig_error
40 changes: 29 additions & 11 deletions imexam/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,40 @@ def _run_imexam(self):
self._check_frame()
if self.window.iscube():
self._check_slice()

# This loop now recognizes the arrow keys
# for moving the cursor in the window, it calls
# the windows cursor function. However, depending
# on how the use has their windowing focus setup
# they might loose focus on the DS9 window and have to
# move the cursor to gain focus again, is there a way
# around this? Cursor is not implemented in the ginga
# interface.
try:
x, y, current_key = self.readcursor()
self._check_frame()
if self.window.iscube():
self._check_slice()
if current_key not in keys and 'q' not in current_key:
print("Invalid key")
self.exam._close_plots()
if current_key in ["Left", "Right", "Up", "Down"]:
if current_key == "Left":
x, y = x - 1, y
if current_key == "Right":
x, y = x + 1, y
if current_key == "Down":
x, y = x, y - 1
if current_key == "Up":
x, y = x, y + 1
self.cursor(x=x, y=y)
else:
if 'q' in current_key:
current_key = None
if current_key not in keys and 'q' not in current_key:
self.exam._close_plots()
else:
self.exam.do_option(
x, y, current_key)

if 'q' in current_key:
current_key = None
self.exam._close_plots()
else:
self._check_frame()
if self.window.iscube():
self._check_slice()
self.exam.do_option(
x, y, current_key)
except KeyError:
print(
"Invalid key, use\n: {0}".format(
Expand Down
65 changes: 42 additions & 23 deletions imexam/ginga_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,12 @@ def embed(self, width=600, height=650):

return self.ginga_view.embed(width, height)

def load_fits(self, fname="", extver=None):
def load_fits(self, fname=None, extver=None):
"""Load fits image to current frame.
Parameters
----------
fname: string, optional
fname: string, FITS HDU
The name of the file to be loaded. You can specify the full
extension in the name, such as
filename_flt.fits[sci,1] or filename_flt.fits[1]
Expand All @@ -582,38 +582,57 @@ def load_fits(self, fname="", extver=None):
number, not the version number associated with a name
"""
if fname is None:
raise ValueError("No filename provided")
raise ValueError("No filename or HDU provided")

try:
shortname, extn, extv = util.verify_filename(fname)
image = AstroImage(logger=self.logger)
if isinstance(fname, (fits.hdu.image.PrimaryHDU, fits.hdu.image.ImageHDU)):
# Simple fits, data + header
shortname = fname
extn = None
if extver is None:
extv = None
extver = 0

elif isinstance(fname, fits.hdu.hdulist.HDUList):
shortname = fname
extn = None
extv = extver

elif isinstance(fname, str):
shortname, extn, extv = util.verify_filename(fname)
if extn is not None:
raise ValueError("Extension name given, must specify "
"the absolute extension you want")
# prefer specified over filename
raise ValueError("Extension name given, must "
"specify the absolute extension you want")
# prefer the keyword value over the extension in the name
if extver is None:
extver = extv

if (extv is None and extver is None):
mef_file, nextend, first_image = util.check_valid(shortname)
# if mef_file:
# extver = 1 # MEF fits
# else:
# extver = 0 # simple fits
extver = first_image # really ext number for first IMAGE
else:
raise TypeError("Expected FITS data as input")

with fits.open(shortname) as filedata:
hdu = filedata[extver]
image.load_hdu(hdu)
# safety for a valid imexam file
if ((extv is None) and (extver is None)):
mef_file, nextend, first_image = util.check_valid(shortname)
extver = first_image # the extension of the first IMAGE

image = AstroImage(logger=self.logger)

try:
if isinstance(fname, str):
with fits.open(shortname) as filedata:
hdu = filedata[extver]
image.load_hdu(hdu)
else:
if extver:
hdu = shortname[extver]
else:
hdu = shortname
image.load_hdu(hdu)
self._set_frameinfo(fname=shortname, hdu=hdu, image=image)
self.ginga_view.set_image(image)
except Exception as e:
self.logger.error("Exception opening file: {0}".format(repr(e)))
self.logger.error("Exception loading image: {0}".format(repr(e)))
raise Exception(repr(e))

self._set_frameinfo(fname=shortname, hdu=hdu, image=image)
self.ginga_view.set_image(image)

def panto_image(self, x, y):
"""Change to x,y physical image coordinates.
Expand Down
2 changes: 1 addition & 1 deletion imexam/imexam_defpars.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"floor": [None, "Minimum value to be contoured"],
"ceiling": [None, "Maximum value to be contoured"],
"ncontours": [8, "Number of contours to be drawn"],
"linestyle": ["--", "matplotlib linestyle"],
"linestyles": ["--", "matplotlib linestyle"],
"label": [True, "Label major contours with their values? [bool]"],
"cmap": ["viridis", "Colormap (matplotlib style) for image"],
}
Expand Down

0 comments on commit b66a483

Please sign in to comment.