Skip to content

Commit

Permalink
Merge pull request #84 from pllim/mosaicauto
Browse files Browse the repository at this point in the history
Added new MosaicAuto local plugin etc
  • Loading branch information
pllim committed Feb 3, 2016
2 parents cd16e7e + 18741e1 commit ffba2b4
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 28 deletions.
23 changes: 23 additions & 0 deletions docs/source/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ available, in addition to the ones that already come with Ginga. Some are
customizable via plugin configuration files, which are available in the
`stginga/examples/configs <https://github.com/spacetelescope/stginga/tree/master/stginga/examples/configs>`_ directory.

.. _stginga-local-plugins:

Local Plugins
-------------

These plugins work together to display the same object across multiple images:

.. toctree::
Expand All @@ -25,3 +30,21 @@ These plugins behave like a regular Ginga plugin:
plugins_manual/badpixcorr
plugins_manual/dqinspect
plugins_manual/snrcalc

These plugins are for very specific analysis needs. Therefore, they are
distributed but not loaded by default into the Ginga viewer. To load them,
one way is to use the ``--plugins`` option along with ``stginga`` command
(see :ref:`stginga-run`):

.. toctree::
:maxdepth: 2

plugins_manual/mosaicauto


.. _stginga-global-plugins:

Global Plugins
--------------

There is currently none to be distributed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions docs/source/plugins_manual/mosaicauto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _local-plugin-mosaicauto:

MosaicAuto
==========

.. image:: images/mosaicauto_screenshot.png
:width: 800px
:alt: MosaicAuto plugin

.. warning:: This can be very memory intensive.

This local plugin is used to automatically create a mosaic of all currently
loaded images in the channel. The position of an image on the mosaic is
determined by its WCS without distortion correction. This is meant as a
quick-look tool, not an
`AstroDrizzle <http://ssb.stsci.edu/doc/stsci_python_x/drizzlepac.doc/html/index.html>`_
replacement. Currently, such a mosaic can only be created once per Ginga
session. Once the mosaic is successfully created, user can select the desired
image name(s) to highlight associated footprint(s) on the mosaic. User can also
save an image list of the selected image(s).

It is customizable using ``~/.ginga/plugin_Mosaic.cfg``, which is the same file
used for Ginga's core ``Mosaic`` plugin. Here, only the critical parameters or
the ones with values that are different from Ginga's default are listed::

#
# Mosaic plugin preferences file
#
# Place this in file under ~/.ginga with the name "plugin_Mosaic.cfg"

# default FOV for new mosaics
fov_deg = 0.1

# Try to match backgrounds
match_bg = True

# Number of threads to devote to opening images
# NOTE: This depends on how many cores your machine has!
num_threads = 12

# Maximum delta from center of image (in deg) beyond which new images
# are assumed to start a new mosaic. Set to None if you never want this
# behavior
max_center_deg_delta = None

# Allow mosaic images to create thumbnail entries
make_thumbs = True

# MosaicAuto only -- Control how footprints are highlighted.
# Line width must be a number from 1-20.
footprintscolor = 'red'
footprintlinewidth = 5
27 changes: 27 additions & 0 deletions stginga/examples/configs/plugin_Mosaic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Mosaic plugin preferences file
#
# Place this in file under ~/.ginga with the name "plugin_Mosaic.cfg"

# default FOV for new mosaics
fov_deg = 0.1

# Try to match backgrounds
match_bg = True

# Number of threads to devote to opening images
# NOTE: This depends on how many cores your machine has!
num_threads = 12

# Maximum delta from center of image (in deg) beyond which new images
# are assumed to start a new mosaic. Set to None if you never want this
# behavior
max_center_deg_delta = None

# Allow mosaic images to create thumbnail entries
make_thumbs = True

# MosaicAuto only -- Control how footprints are highlighted.
# Line width must be a number from 1-20.
#footprintscolor = 'red'
#footprintlinewidth = 5
5 changes: 1 addition & 4 deletions stginga/plugins/BackgroundSub.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ def build_gui(self, container):
self.tw = tw

fr = Widgets.Expander('Instructions')
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
fr.set_widget(tw)
vbox.add_widget(fr, stretch=0)

fr = Widgets.Frame('Background Selection')
Expand Down
9 changes: 3 additions & 6 deletions stginga/plugins/BadPixCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ def build_gui(self, container):
self.tw = tw

fr = Widgets.Expander('Instructions')
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
fr.set_widget(tw)
vbox.add_widget(fr, stretch=0)

fr = Widgets.Frame('Correction Type')
Expand Down Expand Up @@ -209,8 +206,8 @@ def redo(self):
# If EXTNAME does not exist, just assume user knows best.
if extname not in (self._sci_extname, self._no_keyword):
self.logger.debug(
'Bad pixel correction not possible for {0} extension in '
'{1}'.format(extname, image.get('name')))
'Bad pixel correction for science data not possible for {0} '
'extension in {1}'.format(extname, image.get('name')))
return True

# Nothing to do
Expand Down
25 changes: 11 additions & 14 deletions stginga/plugins/DQInspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ def __init__(self, fv, fitsimage):
canvas.setSurface(self.fitsimage)
self.canvas = canvas

# TODO: Need to test this when we have a plugin that modifies DQ.
# Overrides redo() issued by image.set_data() by recalculating.
fv.add_callback(
'add-image-info', lambda *args: self.redo(ignore_image_cache=True))

fv.add_callback('remove-image', lambda *args: self.redo())
'remove-image', lambda *args: self.redo(ignore_image_cache=False))

self.gui_up = False

Expand All @@ -137,10 +133,7 @@ def build_gui(self, container):
self.tw = tw

fr = Widgets.Expander('Instructions')
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
fr.set_widget(tw)
vbox.add_widget(fr, stretch=0)

fr = Widgets.Frame('Single Pixel')
Expand Down Expand Up @@ -214,7 +207,7 @@ def build_gui(self, container):
self.gui_up = True

# Populate fields based on active image
self.redo()
self.redo(ignore_image_cache=False)

def instructions(self):
self.tw.set_text("""It is important that you have all the possible DQ definition files defined in your plugin configuration file if you do not want to use default values! Otherwise, results might be inaccurate. The DQ definition file is select by {0} keyword in the image header.
Expand Down Expand Up @@ -320,7 +313,11 @@ def _load_dqparser(self, instrument):

return dqp

def redo(self, ignore_image_cache=False):
# TODO: Setting default to True is a hit on overall performance because
# cache is pretty much useless now. But it is necessary for this plugin
# to pick up changes to DQ buffer from another plugin. Need to think about
# a better way to utilize the cache while still picking up the changes.
def redo(self, ignore_image_cache=True):
"""This updates DQ flags from canvas selection.
Parameters
Expand Down Expand Up @@ -589,7 +586,7 @@ def draw_cb(self, canvas, tag):
self.ycen = y

self.pxdqtag = canvas.add(self.dc.CompoundObject(obj, obj_lbl))
return self.redo()
return self.redo(ignore_image_cache=False)

def set_xcen(self):
try:
Expand All @@ -611,7 +608,7 @@ def set_xcen(self):
c_obj.move_to(self.xcen, c_obj.y)

self.fitsimage.redraw(whence=3)
return self.redo()
return self.redo(ignore_image_cache=False)

def set_ycen(self):
try:
Expand All @@ -636,7 +633,7 @@ def set_ycen(self):
c_obj.y = self.ycen + self._text_label_offset

self.fitsimage.redraw(whence=3)
return self.redo()
return self.redo(ignore_image_cache=False)

def close(self):
self._reset_imdq_on_error()
Expand Down

0 comments on commit ffba2b4

Please sign in to comment.